【Nacos】 监控手册
【Nacos】 监控手册
Metadata
title: 【Nacos】 监控手册
date: 2023-01-04 15:31
tags:
- 行动阶段/完成
- 主题场景/组件
- 笔记空间/KnowladgeSpace/ProgramSpace/ModuleSpace
- 细化主题/Module/Nacos/运维手册
categories:
- Nacos
keywords:
- Nacos
description: 【Nacos】 监控手册
【Nacos】 监控手册
Nacos 0.8.0 版本完善了监控系统,支持通过暴露 metrics 数据接入第三方监控系统监控 Nacos 运行状态,目前支持 prometheus、elastic search 和 influxdb,下面结合 prometheus 和 grafana 如何监控 Nacos。与 elastic search 和 influxdb 结合可自己查找相关资料
搭建 Nacos 集群暴露 metrics 数据
按照部署文档搭建好 Nacos 集群
配置 application.properties 文件,暴露 metrics 数据
management.endpoints.web.exposure.include=*
访问 {ip}:8848/nacos/actuator/prometheus,看是否能访问到 metrics 数据
搭建 prometheus 采集 Nacos metrics 数据
下载你想安装的 prometheus 版本,地址为 download prometheus
linux & mac
解压 prometheus 压缩包
tar xvfz prometheus-*.tar.gz
cd prometheus-*
修改配置文件 prometheus.yml 采集 Nacos metrics 数据
metrics_path: '/nacos/actuator/prometheus'
static_configs:
- targets: ['{ip1}:8848','{ip2}:8848','{ip3}:8848']
启动 prometheus 服务
./prometheus --config.file="prometheus.yml"
windows
下载对应的 windows 版本并解压
修改配置文件 prometheus.yml 采集 Nacos metrics 数据
metrics_path: '/nacos/actuator/prometheus'
static_configs:
- targets: ['{ip1}:8848','{ip2}:8848','{ip3}:8848']
启动 prometheus 服务
prometheus.exe --config.file=prometheus.yml
通过访问 http://{ip}:9090/graph 可以看到 prometheus 的采集数据,在搜索栏搜索 nacos_monitor 可以搜索到 Nacos 数据说明采集数据成功
搭建 grafana 图形化展示 metrics 数据
和 prometheus 在同一台机器上安装 grafana,使用 yum 安装 grafana
mac
brew install grafana
brew services start grafana
linux
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
参考文档:http://docs.grafana.org/installation/windows/
访问 grafana: http://{ip}:3000
配置 prometheus 数据源
导入 Nacos grafana 监控模版
Nacos 监控分为三个模块:
配置 grafana 告警
当 Nacos 运行出现问题时,需要 grafana 告警通知相关负责人。grafana 支持多种告警方式,常用的有邮件,钉钉和 webhook 方式
钉钉告警
钉钉可以通过配置钉钉机器人
配置钉钉通知 url
测试告警项
邮件告警
修改 defaults.ini 配置文件,增加邮件告警
#################################### SMTP / Emailing ##########################
[smtp]
enabled = true
host = smtp.126.com:25
user = xxxxxx
password = xxxxx
;cert_file =
;key_file =
skip_verify = true
from_address = xxxxxx@126.com
[emails]
;welcome_email_on_sign_up = false
配置通知邮箱
Nacos metrics 含义
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) |
Nacos-Sync 监控
随着 Nacos 0.9 版本发布,Nacos-Sync 0.3 版本支持了 metrics 监控,能通过 metrics 数据观察 Nacos-Sync 服务的运行状态,提升了 Nacos-Sync 的在生产环境的监控能力。 整体的监控体系的搭建参考 Nacos 监控手册
grafana 监控 Nacos-Sync
和 Nacos 监控一样,Nacos-Sync 也提供了监控模版,导入监控模版
Nacos-Sync 监控同样也分为三个模块:
Nacos-Sync metrics 含义
Nacos-Sync 的 metrics 分为 jvm 层和应用层
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 | 线程数 |
应用层 metrics
指标 | 含义 |
---|---|
nacosSync_task_size | 同步任务数 |
nacosSync_cluster_size | 集群数 |
nacosSync_add_task_rt | 同步任务执行耗时 |
nacosSync_delete_task_rt | 删除任务耗时 |
nacosSync_dispatcher_task | 从数据库中分发任务 |
nacosSync_sync_task_error | 所有同步执行时的异常 |