ZK监控方法以及核心指标

news/2024/10/23 5:49:44/

文章目录

  • 1. 监控指标采集
    • 1.1 zk版本高于3.6.0监控指标采集
    • 1.2 zk版本低于3.6.0监控指标采集
    • 1.3 配置promethues采集和大盘
  • 2. 核心告警指标
  • 3. 参考文章

探讨zk的监控数据采集方式以及需要关注的核心指标,便于日常生产进行监控和巡检。

1. 监控指标采集

  1. 3.6.0 版本后,原生支持开放指标接口供Prometheus采集。
  2. 如果低于3.6.0 版本,只能使用zookeeper-exporter进行采集

1.1 zk版本高于3.6.0监控指标采集

详细的可以参考 ZooKeeper Monitor Guide

具体操作如下
1, 调整zoo.cfg配置,增加配置

metricsProvider.className=org.apache.zookeeper.metrics.prometheus.PrometheusMetricsProvider
metricsProvider.httpPort=7000
metricsProvider.exportJvmInfo=true

在这里插入图片描述
指标的暴露接口是7000,完成配置并重启zk后可以获取对应的指标。

 curl localhost:7000/metrics

在这里插入图片描述

1.2 zk版本低于3.6.0监控指标采集

可以通过 zookeeper-exporter 下载zookeeper-exporter的安装包,并进行配置。

进程启动配置

./zookeeper-exporter -listen 0.0.0.0:7000  -zk-hosts Master:2181,Slave1:2181,Slave2:2181

更多使用方法可以参考 文档

指标的暴露接口是7000,完成配置并重启zk后可以获取对应的指标。

 curl localhost:7000/metrics

1.3 配置promethues采集和大盘

完成指标采集后,可以通过prometheus配置监控、告警和大盘。

配置prometheus的指标采集任务

  - job_name: zkstatic_configs:- targets: ['172.19.0.2:7000','172.19.0.3:7000','172.19.0.4:7000']

完成prometheus监控指标后,就可以配置grafana大盘,grafana的dashboard官网可以下载很多优秀的大盘进行借鉴,本文不再追溯。

2. 核心告警指标

在 ZooKeeper Monitor Guide中记录了zk的关键指标进行配置告警,可以参考。

groups:
- name: zk-alert-examplerules:- alert: ZooKeeper server is downexpr:  up == 0for: 1mlabels:severity: criticalannotations:summary: "Instance {{ $labels.instance }} ZooKeeper server is down"description: "{{ $labels.instance }} of job {{$labels.job}} ZooKeeper server is down: [{{ $value }}]."- alert: create too many znodesexpr: znode_count > 1000000for: 1mlabels:severity: warningannotations:summary: "Instance {{ $labels.instance }} create too many znodes"description: "{{ $labels.instance }} of job {{$labels.job}} create too many znodes: [{{ $value }}]."- alert: create too many connectionsexpr: num_alive_connections > 50 # suppose we use the default maxClientCnxns: 60for: 1mlabels:severity: warningannotations:summary: "Instance {{ $labels.instance }} create too many connections"description: "{{ $labels.instance }} of job {{$labels.job}} create too many connections: [{{ $value }}]."- alert: znode total occupied memory is too bigexpr: approximate_data_size /1024 /1024 > 1 * 1024 # more than 1024 MB(1 GB)for: 1mlabels:severity: warningannotations:summary: "Instance {{ $labels.instance }} znode total occupied memory is too big"description: "{{ $labels.instance }} of job {{$labels.job}} znode total occupied memory is too big: [{{ $value }}] MB."- alert: set too many watchexpr: watch_count > 10000for: 1mlabels:severity: warningannotations:summary: "Instance {{ $labels.instance }} set too many watch"description: "{{ $labels.instance }} of job {{$labels.job}} set too many watch: [{{ $value }}]."- alert: a leader election happensexpr: increase(election_time_count[5m]) > 0for: 1mlabels:severity: warningannotations:summary: "Instance {{ $labels.instance }} a leader election happens"description: "{{ $labels.instance }} of job {{$labels.job}} a leader election happens: [{{ $value }}]."- alert: open too many filesexpr: open_file_descriptor_count > 300for: 1mlabels:severity: warningannotations:summary: "Instance {{ $labels.instance }} open too many files"description: "{{ $labels.instance }} of job {{$labels.job}} open too many files: [{{ $value }}]."- alert: fsync time is too longexpr: rate(fsynctime_sum[1m]) > 100for: 1mlabels:severity: warningannotations:summary: "Instance {{ $labels.instance }} fsync time is too long"description: "{{ $labels.instance }} of job {{$labels.job}} fsync time is too long: [{{ $value }}]."- alert: take snapshot time is too longexpr: rate(snapshottime_sum[5m]) > 100for: 1mlabels:severity: warningannotations:summary: "Instance {{ $labels.instance }} take snapshot time is too long"description: "{{ $labels.instance }} of job {{$labels.job}} take snapshot time is too long: [{{ $value }}]."- alert: avg latency is too highexpr: avg_latency > 100for: 1mlabels:severity: warningannotations:summary: "Instance {{ $labels.instance }} avg latency is too high"description: "{{ $labels.instance }} of job {{$labels.job}} avg latency is too high: [{{ $value }}]."- alert: JvmMemoryFillingUpexpr: jvm_memory_bytes_used / jvm_memory_bytes_max{area="heap"} > 0.8for: 5mlabels:severity: warningannotations:summary: "JVM memory filling up (instance {{ $labels.instance }})"description: "JVM memory is filling up (> 80%)\n labels: {{ $labels }}  value = {{ $value }}\n"

3. 参考文章

  • ZooKeeper Monitor Guide

http://www.ppmy.cn/news/1332972.html

相关文章

SpringBoot整理-依赖注入

Spring Boot, 继承自 Spring 框架,提供了强大的依赖注入(Dependency Injection, DI)功能。这是一种编程技术,允许软件组件动态地接收它们的依赖项,而无需自己创建或查找它们。在 Spring Boot 中,这通常通过注解(Annotations)实现,使得应用的配置和依赖管理更加简洁和直…

寒假刷题第15天

PTA甲级 1101 Quick Sort 求partition的位置&#xff0c;partition位置一定是排好的序列与原序列相等的位置&#xff0c;并且对应原数组的位置左右两边左边小右边大 #include<iostream> #include<algorithm> #include<vector>using namespace std;const in…

为什么选择Lua语言开发游戏?探索其高效与灵活之秘

在当今的游戏开发领域&#xff0c;有多种编程语言可以选择&#xff0c;每种语言都有其独特的优势和适用场景。而在这些语言中&#xff0c;Lua语言因其高效性和灵活性而备受游戏开发者的青睐。那么&#xff0c;为什么选择Lua语言开发游戏呢&#xff1f;本文将深入探索其背后的原…

Java转成m3u8,hls格式

Java转成m3u8,hls格式 需求分析 大致思路 循环文件夹下面所有文件判断当前文件是否是视频文件&#xff0c;如果是视频文件先转为ts文件 因为听别人说先转成ts之后再切片会快很多 转成ts文件&#xff0c;并为这些文件单独生成一个目录&#xff0c;如果目录不存在则新建一个目…

Linux 挂载读取、卸载 ntfs格式硬盘

windows常用的ntfs硬盘分区格式&#xff0c;在linux通常不能直接读取&#xff0c;不过挂载也是非常容易 一、挂载ntfs分区 1.安装 apt-get install ntfs-3g2.查看现在接上的硬盘 fdisk -l可以找到类似如下的&#xff0c;会显示microsoft basic data 3.创建挂载的目录 创…

Spring5学习笔记

Spring5 框架概述IOC(Inversion Of Control)IOC基本过程:IOC接口(BeanFactory)IOC接口实现类IOC操作Bean管理一、什么是Bean管理?二、什么是DI?三、Bean管理的两种实现方式1.基于XML配置文件方式实现基于XML方式创建对象基于XML方式注入属性常规属性注入特殊属性值的注入…

家用洗地机什么品牌比较好?洗地机口碑榜

近年来&#xff0c;家庭清洁产品备受瞩目&#xff0c;人们寻求省力的清洁解决方案&#xff0c;在清洁产品上面的购买真的是煞费苦心。各大厂商们也不负众望&#xff0c;推出了洗地机&#xff0c;这一产品在市场上受到了广泛欢迎。洗地机作为新时代的产物&#xff0c;集吸尘、拖…

基于OpenLayers实战地理信息系统教程

第1讲-概述.rar 第2讲-庞杂的GIS体系概览 01.rar 第3讲-项目快速实战(-).rar 第4讲-项目快速实战(二) 01.rar 第5讲-项目快速实战(三).rar 第6讲-项目快速实战(四).rar 第7讲-项目快速实战(五).rar 第8讲-项目快速实战(六).rar 第9讲-项目快速实战(七).rar 第10讲-项目…