一、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采集Nacos metrics数据
下载你想安装的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=<job_name>` 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数据说明采集数据成功
三、搭建grafana图形化展示metrics数据
3.1 安装与启动
和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
3.2 配置prometheus数据源
3.3 导入nacos grafana监控模板
导入Nacos grafana监控模版 下载很慢提供gitee链接