一、yum 安装 prometheus
1. 官网下载安装包
https://prometheus.io/download/
2. 解压
$ tar xvfz prometheus-2.32.0-beta.0.linux-amd64.tar.gz -C /home
3. 重命名
mv prometheus-2.32.0-beta.0.linux-amd64/ prometheus-2.32.0
4. 维护配置文件
prometheus.yml 是 Prometheus 的配置文件。配置信息详细介绍可查看官方文档:https://prometheus.io/docs/prometheus/latest/configuration/configuration/
prometheus.yml 部分配置信息如下:
# 全局配置
global:
scrape_interval: 15s # 设置每15s采集数据一次,默认1分钟
evaluation_interval: 15s # 每15秒计算一次规则,默认1分钟
# scrape_timeout:15s # 采集数据超时时间,默认10s。
# 告警配置
alerting:
alertmanagers:
- static_configs:
- targets:
# - alertmanager:9093
# 告警规则,Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
# - "first_rules.yml"
# - "second_rules.yml"
# 在 scrape_config 中每个监控目标是一个job,但job的类型有很多种。可以是最简单的 static_config,即静态地指定每一个目标。
scrape_configs:
# 这是 prometheus 本机的一个监控节点
- job_name: "prometheus"
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
static_configs:
# targets 配置要监控的节点,格式:机器名+端口号。配置完成后,prometheus就可以通过配置文件识别监控的节点,持续开始采集数据
# 可以并列写入多个节点,用逗号隔开
- targets: ["localhost:9090"]
-