prometheus监控nacos

本文介绍了如何将Nacos与Prometheus集成,以监控Nacos的服务指标,并通过修改配置文件暴露metrics数据。接着,展示了在Prometheus中添加Nacos的监控配置,并验证数据获取。最后,详细说明了在Grafana中导入Nacos的官方监控模板时遇到的问题,包括数据源名称匹配和标签正则匹配的调整,以确保监控图表能正常显示数据。
摘要由CSDN通过智能技术生成

1.nacos

官方文档:https://nacos.io/zh-cn/docs/monitor-guide.html

版本:docker 1.4.1

修改配置文件:/home/nacos/conf/application.properties

增加配置,,暴露metrics数据

management.endpoints.web.exposure.include=*

重启nacos

访问{ip}:8848/nacos/actuator/prometheus,看是否能访问到metrics数据

2.prometheus

修改prometheus.yml,增加配置

  - job_name: 'nacos'
    metrics_path: '/nacos/actuator/prometheus'
    static_configs:
    - targets: ['192.168.1.1:8848']
      labels:
        instance: 'nacos'

重启prometheus 生效,并进入prometheus,输入nacos_monitor,有数据产生则ok ,如图

3.grafana 引入nacos官方grafana json模板

官方地址:https://github.com/nacos-group/nacos-template/blob/master/nacos-grafana.json

直接导入会导致无数据,需要调整2处地方。

3.1数据源不正确问题

- [nacos 官方给的监控模板](https://github.com/nacos-group/nacos-template)中的数据源名称为 `prometheus` ,而 `Grafana` 默认的 Prometheus 数据源名称为 `Prometheus`(P大写),由于不匹配,导致不会显示任何数据。

直接调整编辑nacos-grafana.json ,替换为Prometheus

3.2 标签没有正确匹配,调衡Variables,

增加Query

label_values(instance)

增加Regex 正则匹配nacos

(nacos-.*)  

如图

4 监控实图

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值