一、在kafka服務器上安裝kafka_exporter
注:1個kafka集群只需要1個exporter,在集群上的任意1台服務器部署。
1、 下載包地址:https://github.com/danielqsj/kafka_exporter/releases/download/v1.2.0/kafka_exporter-1.2.0.linux-amd64.tar.gz
2、安裝kafka_exporter
# tar zxf kafka_exporter-1.2.0.linux-amd64.tar.gz -C /usr/local/ # cd /usr/local/kafka_exporter-1.2.0.linux-amd64/
3、啟動kafka_exporter
# nohup ./kafka_exporter --kafka.server 172.16.68.169:9092 &
4、瀏覽器輸入http://172.16.68.169:9308/metrics,可看到kafka_exporter抓取的監控指標。
二、編輯prometheus配置文件
# cat prometheus.yml #在文檔末尾添加一下內容,注意格式
- job_name: 'kafka' static_configs: - targets: ['172.16.68.169:9308'] #配置kafka監控
配置文件語法檢測
# ./promtool check config prometheus.yml
Checking prometheus.yml SUCCESS: 2 rule files found Checking rules/kafka.yml SUCCESS: 1 rules found Checking rules/kafka_lag.yml SUCCESS: 1 rules found
重啟prometheus
# systemctl restart prometheus.service
三、打開瀏覽器輸入http://172.16.68.169:9090/
Status--->Targets,可看到kafka監控已經UP了。
四、grafana導入引導盤
-
Grafana儀表盤參考: