master监控主机上的prometheus.yml
# my global config
global: # global模块是全局配置信息,它定义的内容会被 scrape_configs模块中的每一个单独Job单独覆盖
scrape_interval: 15s # 抓取 target的时间间隔 设置为15秒,默认值为1分钟,经验值为10-60秒
evaluation_interval: 15s # Prometheus计算每一条规则配置的时间间隔,设置为15秒
# scrape_timeout is set to the global default (10s).
scrape——timeout: *s # 抓取target的超时时间, 默认为10s
external_labels # 与外部系统通信时添加到任意时间序列或告警所用的外部标签
#告警模块:Prometheus server 发送请求给Altermanager之前也会触发一次relabel操作,
#alert子模块下 也可以配置alert_relabel_configs
# Alertmanager configuration
alerting:
alertmanagers:
- static_configs: # 静态配置Alert manager的地址,也可以依赖服务发现动态识别
- targets: # 可以配置多个IP地址
# - alertmanager:9093
# 加载规则一次,并定期根据全局的“evaluation_interval”计算它们。
# Prometheus 自定义rule主要分为 recording rule 和 altering rule
# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
# - "first_rules.yml"
# - "second_rules.yml"
# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
# Job 名字很重要。Prometheus会及那个该名称作为Label 追加到每条时许中
- job_name: "prometheus"
# metrics_path 默认值是 /metrics
# metrics_path defaults to '/metrics'
# scheme 默认是http
# scheme defaults to 'http'.
static_configs: # 静态方式
- targets: ["localhost:9090"]
- job_name: "node01"
static_configs:
- targets: ["192.168.131.130:9100"]