美文网首页
prometheus根据文件做服务IP动态刷新

prometheus根据文件做服务IP动态刷新

作者: ShootHzj | 来源:发表于2020-12-18 15:54 被阅读0次

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

随后可以很快生效

相关文章

网友评论

      本文标题:prometheus根据文件做服务IP动态刷新

      本文链接:https://www.haomeiwen.com/subject/ulxfnktx.html