什么是服务发现
https://editor.csdn.net/md/?articleId=120808227
https://zhuanlan.zhihu.com/p/34332329
[root@localhost ~] cd /usr/local/prometheus/ [root@localhost prometheus] mkdir targets [root@localhost prometheus] vi targets/dev_node.json
[
{
"targets": [ "192.168.1.5:9090","127.0.0.1:9090" ],
"labels": {
"env": "dev_webgame"
}
}
]
集成prometheus
[root@localhost prometheus] vi prometheus.yml
- job_name: 'node_service_discovery'
file_sd_configs:
- files:
- targets/*.json
refresh_interval: 60m
[root@localhost prometheus] systemctl restart prometheus
由于配置的两个地址不存在,所以显示DOWN
配置文件说明:
file_sd_configs,指定prometheus基于文件的服务发现配置使用的选项
- files,自定义的和prometheus程序同级目录的targets目录,要被自动加载的所有.json格式的文件。当然也可以单独指定某一个JSON格式的文件。
refresh_interval: 60m,自定义刷新间隔时间为60秒
[root@localhost prometheus] vi targets/dev_node.yaml
- targets: - "192.168.1.30:9100"
[root@localhost prometheus] vi prometheus.yml
- job_name: 'node_service_discovery'
file_sd_configs:
- files:
- targets/*.json
refresh_interval: 60m
- files:
- targets/*.yaml
refresh_interval: 60m
[root@localhost prometheus] systemctl restart prometheus



