Prometheus支持很多IP自动发现方式,根据IP刷新可以很好地刷新普罗监控的监控IP,并且不需要重启普罗,其中核心的配置就是file_sd_configs
# Patterns for files from which target groups are extracted.
files:
[ - <filename_pattern> ... ]
# Refresh interval to re-read the files.
[ refresh_interval: <duration> | default = 5m ]
我们修改Prometheus的配置如下:
global:
scrape_interval: 15s
evaluation_interval: 15s
scrape_timeout: 10s
scrape_configs:
- job_name: "prometheus"
static_configs:
- targets: ["localhost:9090"]
- job_name: "zookeeper"
file_sd_configs:
- files:
- "/opt/sh/prometheus/zookeeper.json"
refresh_interval: 10s
然后动态修改zookeeper.json
[
{
"targets": [
"10.0.0.53:8080"
]
}
]
image.png
随后可以很快生效
网友评论