Nacos监控中心篇(一)Prometheus+Grafana的配置

配置

暴露metrics数据

搭建Nacos集群后,我们要在集群的每个节点中的配置文件application.properties中,暴露metric数据。

实际上,就是把注释取消即可。

访问10.128.198.200:8845/nacos/actuator/prometheus,看是否能访问到metrics数据,我这里直接演示下访问效果

搭建prometheus采集Nacos metrics数据 

下载你想安装的prometheus版本,地址为:https://prometheus.io/download/

我这里选择的版本是

 修改配置文件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-cluster"    
    scrape_interval: 60s
    metrics_path: '/nacos/actuator/prometheus'
    static_configs:
      - targets: ["10.128.198.200:8845","10.128.198.200:8846","10.128.198.200:8848"]
        labels:
            instance: nacos cluster

启动prometheus服务

prometheus.exe --config.file=prometheus.yml

检测是否配置成功

访问这个地址

http://10.128.198.200:9090/targets

看到如下,配置成功

或者

http://10.128.198.200:9090/graph

可以看到prometheus的采集数据,在搜索栏搜索nacos_monitor可以搜索到Nacos数据说明采集数据成功!

此时,说明可以收集到Nacos的metric数据了,但是这个数据我需要有个大盘展示

搭建grafana图形化展示metrics数据

和prometheus在同一台机器上安装grafana

参考文档:Install on Windows | Grafana documentationhttp://docs.grafana.org/installation/windows/

访问grafana(用谷歌浏览器):

账号密码都是admin

http://10.128.198.200:3000/loginhttp://10.128.198.200:3000/login

 配置prometheus数据源 

 

URL填写prometheus的地址,http method选择get方法,然后点"Save & Test"

配置一个Nacos的数据源头

现在你添加了两个数据源了,点击save保存

 

 

 导入Nacos grafana监控模版 

 

  这里你需要从Nacosgrafana监控模版,官网指定模版、详见Nacos官网。用于监控nacos各项指标。注:prometheus在Gr-Java文档类资源-CSDN下载下载MySQL_Overview.json,然后通过上面页面的Upload .json File按钮上传上去,导入即可。

 会跳到这个界面

点击右上角的设置按钮

 ​​​​​​​

 跳转主页,显示结果,成功

 遇见的问题

Nacos grafana显示为空_StarJava_的博客-CSDN博客_nacos订阅者列表为空Nacos grafana显示为空在搭建 Shoulder-Platform 时,根据 Nacos 官方教程对 Nacos 监控时,未正确显示数据,仪表盘为空。检查后发现是以下两个原因导致的:数据源不正确- [nacos 官方给的监控模板](https://github.com/nacos-group/nacos-template)中的数据源名称为 `prometheus` ,而 `Grafana` 默认的 Prometheus 数据源名称为 `Prometheus`(P大写),由于不匹配,导致不会https://blog.csdn.net/qq_35425070/article/details/108114911

Nacos监控分为三个模块:

  • nacos monitor展示核心监控项 
  • nacos detail展示指标的变化曲线
  • nacos alert为告警项 

Nacos metrics含义

jvm metrics

指标含义
system_cpu_usageCPU使用率
system_load_average_1mload
jvm_memory_used_bytes内存使用字节,包含各种内存区
jvm_memory_max_bytes内存最大字节,包含各种内存区
jvm_gc_pause_seconds_countgc次数,包含各种gc
jvm_gc_pause_seconds_sumgc耗时,包含各种gc
jvm_threads_daemon线程数

Nacos 监控指标

指标含义
http_server_requests_seconds_counthttp请求次数,包括多种(url,方法,code)
http_server_requests_seconds_sumhttp请求总耗时,包括多种(url,方法,code)
nacos_timer_seconds_sumNacos config水平通知耗时
nacos_timer_seconds_countNacos 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)

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Prometheus是一种开源的监控系统,可以监控多种应用程序和服务的运行状态。而Nacos是一个服务注册和配置中心,也支持监控系统。在Nacos 0.8.0版本中,它完善了监控系统,支持通过暴露metrics数据接入第三方监控系统,包括Prometheus。因此,你可以使用Prometheus监控Nacos的运行状态。 要实现这个监控过程,首先需要安装Prometheus并关联Nacos。你可以使用brew命令来安装Prometheus,在安装完成后,需要修改Prometheus配置文件prometheus.yml来采集Nacos的metrics数据。接下来,启动Prometheus。除了启动Prometheus之外,你还可以通过验证Nacos来确保Nacos的安装和配置是否成功。 接下来,你需要安装Grafana并关联Prometheus。同样,你可以使用brew命令来安装Grafana,并且需要进行相应的配置。在配置完成后,你可以通过启动和停止命令来配合配置Grafana。 总结起来,要实现Prometheus监控Nacos的过程大致如下: 1. 安装Prometheus并修改配置文件prometheus.yml以采集Nacos的metrics数据。 2. 启动Prometheus并验证Nacos的安装和配置是否成功。 3. 安装Grafana配置Prometheus的关联。 4. 启动和停止命令来配置Grafana。 需要注意的是,以上是一个大致的步骤,具体的安装和配置过程可能因环境和版本而有所不同。你可以参考Nacos的官方文档和PrometheusGrafana的官方文档来获取更详细和准确的步骤和操作指南。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *3* [监控 —— Prometheus Grafana监控Nacos (MAC)](https://blog.csdn.net/Cy_LightBule/article/details/119330374)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* [prometheus监控Nacos](https://blog.csdn.net/WEDUEST/article/details/131644230)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值