一、nacos集群暴露metrics数据
部署好nacos集群后,配置application.properties文件,暴露metrics数据
management.endpoints.web.exposure.include=*
多个节点按照上面配置,暴露metrics数据,然后重启nacos,
#如果有nginx,也可以通过nginx ip+port进行访问
localhost:8848/nacos/actuator/prometheus
localhost:8848/nacos/actuator
localhost:8848/nacos/actuator/mappings
这里用了chrome插件JSON-handle
下载你想安装的prometheus版本,地址为download prometheus
tar xvfz prometheus-*.tar.gz
cd prometheus-*
修改配置文件Prometheus.yml采集nacos metrics数据
此处注意空格,否则报错
scrape_configs:
# The job name is added as a label `job=` to any timeseries scraped from this config.
- job_name: 'prometheus'
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
static_configs:
- targets: ['localhost:9090']
- job_name: 'nacos'
metrics_path: '/nacos/actuator/prometheus'
static_configs:
- targets: ['210.310.5.143:8848','110.330.5.182:8848','110.340.5.183:8848']
启动prometheus服务
./prometheus --config.file="prometheus.yml"
prometheus.exe --config.file=prometheus.yml
通过访问http://localhost:9090/graph可以看到prometheus的采集数据,在搜索栏搜索nacos_monitor可以搜索到Nacos数据说明采集数据成功
和prometheus在同一台机器上安装grafana,使用 yum 安装grafana
sudo yum install https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-5.2.4-1.x86_64.rpm
sudo service grafana-server start
下载链接
windows运行
访问grafana: http://localhost:3000
导入Nacos grafana监控模版 下载很慢提供gitee链接
参考1,参考2, 参考3,参考4