配置zookeeper_exporter监控zookeeper

1 安装zookeeper_exporter监控

目前promethus中没有开发有现成的zookeeper插件,所以选择github中验证的zookeeper插件

l exporter下载地址:https://github.com/carlpett/zookeeper_exporter/releases/download/v1.0.2/zookeeper_exporter

  • 下载后上传至/usr/local/prometheus目录下,没有可以自己建任意目录(注意下面配置到该目录即可)
  • 赋予执行权限

chmod 755 zookeeper_exporter
image.png

  • 查看帮助:./zookeeper_exporter -h

配置zookeeper_exporter监控zookeeper_第1张图片

2 启动zookeeper_exporter监控

  • 配置:vim /lib/systemd/system/prometheus-zookeeper.service
[Unit]
Description= prometheus-zookeeper
After=network.target

[Service]
Type=simple
ExecStart= /usr/local/prometheus/zookeeper_exporter/zookeeper_exporter -zookeeper yourIP:2181 -bind-addr :9143

Restart=on-failure

[Install]
WantedBy=multi-user.target
  • 将 zookeeper_exporter 服务设为开机自启并启动

systemctl daemon-reload

systemctl enable prometheus-zookeeper.service

systemctl start prometheus-zookeeper.service

3 配置zookeeper_exporter

· 安装好zookeeper _exporter 后,我们需要在 Prometheus 中对其进行集成
· 修改 Prometheus 的配置文件 (prometheus.yml),添加 redis 服务 (在 scrape_configs 属性下添加)
cd /usr/local/prometheus/prometheus-2.15.2.linux-amd64
vim prometheus.yml

scrape_configs:

 # The job name is added as a label `job=` 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: 'zookeeper'

 static_configs:

 - targets: ['YourIP:9143']

 labels:

 instance: zookeeper

:wq

· 重启 prometheus 服务

systemctl restart prometheus.service

· 查看 Prometheus 服务 (默认端口为: 9090)

如上所示,当 State 状态显示为 UP 时,则说明 zookeeper_exporter 服务已经集成进来了

你可能感兴趣的:(zookeeper)