Prometheus系列——监控zookeeper
【摘要】 prometheus监控zookeeper
笔者所在公司有使用zookeeper集群,所以,也配置一下对于zookeeper这个集群的监控吧。
一、下载jmx_exporter
#linux下 cd /usr/local/prometheus wget https://repo1.maven.org/maven2/io/prometheus/jmx/jmx_prometheus_javaagent/0.3.1/jmx_prometheus_javaagent-0.3.1.jar
二、编写jmx_exporter配置文件
jmx_exporter官方推荐配置: https://github.com/prometheus/jmx_exporter/blob/master/example_configs/zookeeper.yaml #将文件下载下来放到下面文件中/usr/local/prometheus/jmx-exporter.yaml #cat /usr/local/prometheus/jmx-exporter.yaml rules: # replicated Zookeeper - pattern: "org.apache.ZooKeeperService<name0=ReplicatedServer_id(\\d+)><>(\\w+)" name: "zookeeper_$2" type: GAUGE - pattern: "org.apache.ZooKeeperService<name0=ReplicatedServer_id(\\d+), name1=replica.(\\d+)><>(\\w+)" name: "zookeeper_$3" type: GAUGE labels: replicaId: "$2" - pattern: "org.apache.ZooKeeperService<name0=ReplicatedServer_id(\\d+), name1=replica.(\\d+), name2=(\\w+)><>(Packets\\w+)" name: "zookeeper_$4" type: COUNTER labels: replicaId: "$2" memberType: "$3" - pattern: "org.apache.ZooKeeperService<name0=ReplicatedServer_id(\\d+), name1=replica.(\\d+), name2=(\\w+)><>(\\w+)" name: "zookeeper_$4" type: GAUGE labels: replicaId: "$2" memberType: "$3" - pattern: "org.apache.ZooKeeperService<name0=ReplicatedServer_id(\\d+), name1=replica.(\\d+), name2=(\\w+), name3=(\\w+)><>(\\w+)" name: "zookeeper_$4_$5" type: GAUGE labels: replicaId: "$2" memberType: "$3" # standalone Zookeeper - pattern: "org.apache.ZooKeeperService<name0=StandaloneServer_port(\\d+)><>(\\w+)" type: GAUGE name: "zookeeper_$2" - pattern: "org.apache.ZooKeeperService<name0=StandaloneServer_port(\\d+), name1=InMemoryDataTree><>(\\w+)" type: GAUGE name: "zookeeper_$2"
修改bin/zkServer.sh,在第六十行添加内容
JMX_DIR="/usr/local/prometheus" JVMFLAGS="$JVMFLAGS -javaagent:$JMX_DIR/jmx_prometheus_javaagent-0.3.1.jar=20000:$JMX_DIR/jmx-exporter.yaml"
启动zookeeper
使用命令验证是否配置成功:
curl localhost:20000/metrics
四、添加prometheus关于zookeeper的配置
# vim prometheus.yml - job_name: 'zookeeper' static_configs: - targets: ['192.168.1.200:20000']
重启prometheus,然后在Prometheus页面中的Targets中就能看到新加入的zookeeper,
grafana中可以搜索相应的dashboard,不再赘述。
【版权声明】本文为华为云社区用户原创内容,转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息, 否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)