1.下载(zookeeper_exporter采集器)
https://github.com/carlpett/zookeeper_exporter/releases/download/v1.0.2/zookeeper_exporter
2. 传到liunx上/usr/local/prometheus目录下,没有目录可以自行创建
3.授予权限
chmod 755 zookeeper_exporter
4.查看帮助(如果提示没有权限,则执行 chmod 755 zookeeper_exporter进行授权)
./zookeeper_exporter -h
5.编写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 yourIP:2181 -bind-addr :9143
Restart=on-failure
[Install]
WantedBy=multi-user.target
6.分别执行如下命令
重载配置
systemctl daemon-reload
设置开机启动
systemctl enable prometheus-zookeeper.service
启动zookeeper_exporter
systemctl start prometheus-zookeeper.service
systemctl status prometheus-zookeeper.service
7.查看zookeeper_exporter运行状态(如出现Active: active (running) 已经运行成功)
8.查看采集数据
curl localhost:9143/metrics
9.修改 Prometheus 的配置文件 (prometheus.yml)
crape_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
10.重启Prometheus ,访问http://localhost:9090
如上所示,当 State 状态显示为 UP 时,则说明 zookeeper_exporter 服务已经集成进来了
参考:https://segmentfault.com/a/1190000039725616