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