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

在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值