jmx_prometheus方式监控zk指标
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了jmx_prometheus方式监控zk指标相关的知识,希望对你有一定的参考价值。
一、下载jmx_prometheus_javaagent和zookeeper.yaml
#下载jmx程序包
cd /usr/local/src/
wget https://raw.githubusercontent.com/prometheus/jmx_exporter/master/example_configs/zookeeper.yaml
wget https://repo1.maven.org/maven2/io/prometheus/jmx/jmx_prometheus_javaagent/0.6/jmx_prometheus_javaagent-0.6.jar
#移动到zookeeper程序目录
mkdir /usr/local/zookeeper/prometheus/
mv zookeeper.yaml /usr/local/zookeeper/prometheus/
mv jmx_prometheus_javaagent-0.6.jar /usr/local/zookeeper/prometheus/
二、配置jmx_prometheus
cat > /usr/local/zookeeper/conf/java.env <<\\EOF
export JMX_DIR="/usr/local/zookeeper/prometheus"
export SERVER_JVMFLAGS="-javaagent:$JMX_DIR/jmx_prometheus_javaagent-0.6.jar=9505:$JMX_DIR/zookeeper.yaml $SERVER_JVMFLAGS"
EOF
三、然后重启zookeeper
#服务停止
/usr/local/zookeeper/bin/zkServer.sh stop
#服务启动
/usr/local/zookeeper/bin/zkServer.sh start /usr/local/zookeeper/conf/zoo.cfg
#查看指标了
curl localhost:9505/metrics
四、修改prometheus配置
cat > /home/prometheus/prometheus.yml <<\\EOF
scrape_configs:
# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
- job_name: zookeeper
static_configs:
- targets: [192.168.56.11:9505]
labels:
instance: 192.168.56.11_9505
EOF
#重启prometheus
docker restart prometheus
五、grafna导入视图
https://grafana.com/grafana/dashboards/9236
#注意使用在使用rate或者irate的时候,范围需要大于注意上报的最小时间间隔
rate(process_cpu_seconds_totaljob="zookeeper"[5m])
以上是关于jmx_prometheus方式监控zk指标的主要内容,如果未能解决你的问题,请参考以下文章