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
- 查看帮忙:./zookeeper_exporter -h
2 启动zookeeper_exporter监控
- 配置:vim /lib/systemd/system/prometheus-zookeeper.service
[Unit]Description= prometheus-zookeeperAfter=network.target[Service]Type=simpleExecStart= /usr/local/prometheus/zookeeper_exporter/zookeeper_exporter -zookeeper yourIP:2181 -bind-addr :9143Restart=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=<job_name>` 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 服务曾经集成进来了