promethues 配置文件动态管理
promethues.yaml 动态加载配置文件
static_configs
静态配置
static_configs 参数
1
2
3
4
5
6
7
8
9
10
11
12
13
14# 服务端监控_状态码404
- job_name: http_404_status
metrics_path: /probe
params:
module: [http_404]
static_configs:
- targets: ['http://172.16.6.2:8800']
labels:
host: 172.16.6.2
instance: wl-02-pro:admin:8800
- targets: ['http://172.16.2.2:8299']
labels:
host: 172.16.2.2
instance: wl-base:base:8299
file_sd_configs
动态加载
file_sd_configs 参数
1
2
3
4
5
6
7
8
9# 服务端监控_状态码404
- job_name: http_404_status
metrics_path: /probe
params:
module: [http_404]
file_sd_configs:
- files:
- ./targets.json
refresh_interval: 5m
curl刷新配置文件
curl -X POST http://172.16.8.32:9090/-/reload
调用curl方法,前提Prometheus启动 加入 –web.enable-lifecycle
示例:
1
docker run -itd -p 9090:9090 --name prometheus -v /data/prometheus_config:/etc/prometheus -v /data/prometheus_rules:/prometheus_rules prom/prometheus --config.file="/etc/prometheus/prometheus.yml" --web.enable-lifecycle
json 文件示例如下
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
[
{
"targets": [
"172.16.6.3:8294",
"172.16.6.9:8294"
],
"labels": {
"host": "172.16.6.3",
"instance": "logis01:logistics:8294"
}
},
{
"targets": [
"172.16.6.3:8294",
"172.16.6.9:8294"
],
"labels": {
"host": "172.16.6.3",
"instance": "wl-ucenter:logistics:8294"
}
}
]
本博客所有文章除特别声明外,均采用 CC BY-SA 4.0 协议 ,转载请注明出处!