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 监控实图


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

被折叠的 条评论
为什么被折叠?



