Nacos监控
概述
Nacos 0.8.0
版本完善了监控系统,支持通过暴露metrics
数据接入第三方监控系统监控Nacos
运行状态,目前支持prometheus
、elastic search
和influxdb
,下面结合prometheus和grafana如何监控Nacos,官网grafana监控页面。
搭建Nacos并暴露metrics数据
- 搭建
Nacos
环境
- 配置
application.properties
文件,暴露metrics
数据,如果仅暴露prometheus
只配置prometheus
即可,所有的都需要暴露,直接配置*
management.endpoints.web.exposure.include=prometheus
- 访问http://ip:8848/nacos/actuator/prometheus,看能否访问当metrics数据,获取到数据即正常。
![prometheus监控Nacos_第1张图片](http://img.e-com-net.com/image/info8/5001e4f5eeaa435cacc8c440f4b16cf4.jpg)
Prometheus采集Nacos metrics数据
- 安装prometheus。
- 修改配置文件prometheus.yml采集Nacos metrics数据
# 静态文件配置
- job_name: 'NACOS监控'
metrics_path: '/nacos/actuator/prometheus'
static_configs:
- targets: ['{ip1}:8848','{ip2}:8848','{ip3}:8848']
# 动态文件发现机制
- job_name: 'NACOS监控'
metrics_path: '/nacos/actuator/prometheus'
file_sd_configs:
- files:
- './nacos_config/*.json' #文件路径
refresh_interval: 15s #刷新时间
- 访问
prometheus
地址http://127.0.0.1:9090/graph,可以看到nacos相关的数据说明采集数据成功。或者可以查看http://127.0.0.1:9090/targets,查看Endpoint
的状态。
![prometheus监控Nacos_第2张图片](http://img.e-com-net.com/image/info8/d9a29dd20aa04462abd1d8bf7c479d2b.jpg)
![prometheus监控Nacos_第3张图片](http://img.e-com-net.com/image/info8/3562d8d14dc24a4aa4ab96d7ad5ce74b.jpg)
grafana图形化展示
- 搭建grafana环境
- 导入nacos面板信息。
面板地址:https://grafana.com/grafana/dashboards/13221
ID :13221
![prometheus监控Nacos_第4张图片](http://img.e-com-net.com/image/info8/9587b432aa13443cba2b234f4445abd9.jpg)
![prometheus监控Nacos_第5张图片](http://img.e-com-net.com/image/info8/e1afb956e3c3438cb246bb7a97f44c4f.jpg)
Nacos监控分为三个模块
![prometheus监控Nacos_第6张图片](http://img.e-com-net.com/image/info8/385f8af456a3444386959c3e5321967d.jpg)
![prometheus监控Nacos_第7张图片](http://img.e-com-net.com/image/info8/a40173972a8d461ebb6400fdbda20452.jpg)
![prometheus监控Nacos_第8张图片](http://img.e-com-net.com/image/info8/0d96c4c480fe42b7872fc795ae72220b.jpg)
指标含义(官方)
jvm metrics
指标 |
含义 |
system_cpu_usage |
CPU使用率 |
system_load_average_1m |
load |
jvm_memory_used_bytes |
内存使用字节,包含各种内存区 |
jvm_memory_max_bytes |
内存最大字节,包含各种内存区 |
jvm_gc_pause_seconds_count |
gc次数,包含各种gc |
jvm_gc_pause_seconds_sum |
gc耗时,包含各种gc |
jvm_threads_daemon |
线程数 |
Nacos 监控指标
指标 |
含义 |
http_server_requests_seconds_count |
http请求次数,包括多种(url,方法,code) |
http_server_requests_seconds_sum |
http请求总耗时,包括多种(url,方法,code) |
nacos_timer_seconds_sum |
Nacos config水平通知耗时 |
nacos_timer_seconds_count |
Nacos config水平通知次数 |
nacos_monitor{name=‘longPolling’} |
Nacos config长连接数 |
nacos_monitor{name=‘configCount’} |
Nacos config配置个数 |
nacos_monitor{name=‘dumpTask’} |
Nacos config配置落盘任务堆积数 |
nacos_monitor{name=‘notifyTask’} |
Nacos config配置水平通知任务堆积数 |
nacos_monitor{name=‘getConfig’} |
Nacos config读配置统计数 |
nacos_monitor{name=‘publish’} |
Nacos config写配置统计数 |
nacos_monitor{name=‘ipCount’} |
Nacos naming ip个数 |
nacos_monitor{name=‘domCount’} |
Nacos naming域名个数(1.x 版本) |
nacos_monitor{name=‘serviceCount’} |
Nacos naming域名个数(2.x 版本) |
nacos_monitor{name=‘failedPush’} |
Nacos naming推送失败数 |
nacos_monitor{name=‘avgPushCost’} |
Nacos naming平均推送耗时 |
nacos_monitor{name=‘leaderStatus’} |
Nacos naming角色状态 |
nacos_monitor{name=‘maxPushCost’} |
Nacos naming最大推送耗时 |
nacos_monitor{name=‘mysqlhealthCheck’} |
Nacos naming mysql健康检查次数 |
nacos_monitor{name=‘httpHealthCheck’} |
Nacos naming http健康检查次数 |
nacos_monitor{name=‘tcpHealthCheck’} |
Nacos naming tcp健康检查次数 |
nacos 异常指标
指标 |
含义 |
nacos_exception_total{name=‘db’} |
数据库异常 |
nacos_exception_total{name=‘configNotify’} |
Nacos config水平通知失败 |
nacos_exception_total{name=‘unhealth’} |
Nacos config server之间健康检查异常 |
nacos_exception_total{name=‘disk’} |
Nacos naming写磁盘异常 |
nacos_exception_total{name=‘leaderSendBeatFailed’} |
Nacos naming leader发送心跳异常 |
nacos_exception_total{name=‘illegalArgument’} |
请求参数不合法 |
nacos_exception_total{name=‘nacos’} |
Nacos请求响应内部错误异常(读写失败,没权限,参数错误) |
client metrics
指标 |
含义 |
nacos_monitor{name=‘subServiceCount’} |
订阅的服务数 |
nacos_monitor{name=‘pubServiceCount’} |
发布的服务数 |
nacos_monitor{name=‘configListenSize’} |
监听的配置数 |
nacos_client_request_seconds_count |
请求的次数,包括多种(url,方法,code) |
nacos_client_request_seconds_sum |
请求的总耗时,包括多种(url,方法,code) |
自定义修改面板
面板样式
![prometheus监控Nacos_第9张图片](http://img.e-com-net.com/image/info8/21fdae3cef2948918c0f6522b1d1bf06.jpg)
参考资料
- Nacos 监控手册