栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

Prometheus(七)配置服务发现

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Prometheus(七)配置服务发现

什么是服务发现
https://editor.csdn.net/md/?articleId=120808227
https://zhuanlan.zhihu.com/p/34332329

JSON格式文件的服务发现:
[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秒
YAML格式文件的服务发现
[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

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/333554.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号