1

jmx_prometheus方式监控zk指标

 1 year ago
source link: https://blog.51cto.com/u_14068620/5714568
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

jmx_prometheus方式监控zk指标

精选 原创

微笑涛声 2022-09-27 09:13:49 博主文章分类:Linux系统 ©著作权

文章标签 zookeeper java bash 文章分类 软考 考试认证 yyds干货盘点 阅读数178

一、下载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_total{job="zookeeper"}[5m])  
  • 收藏
  • 评论
  • 分享
  • 举报

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK