正常安装普罗米修斯之后,静态配置不对方便后续添加,官方也提供了许多自动发现服务,这里采用了其中一种。
在prometheus.yml同级目录下,创建一个node文件夹,用来存放后续想拉取的node配置信息。
yml配置里采用通配符,指定node目录的*yml
node节点配套规范如下:
1.文件名称node开头 .yml结尾
如:node_serviceFind.yml
2.文本内容规范
严格示例:
- targets:
- "192.168.56.234:9098"
labels:
appName: locahost
完整的prometheus.yml参考
# my global config
global:
scrape_interval: 3s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
# scrape_timeout is set to the global default (10s).
# Alertmanager configuration
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"
# 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_name: "prometheus"
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
# static_configs:
# - targets: ["localhost:9099"]
- job_name: "nodeTest"
file_sd_configs:
- files: ['node/node*.yml']
refresh_interval: 5m