下载以及安装kafka_exporter
#1、下载kafka_exporter
~# wget https://github.com/danielqsj/kafka_exporter/releases/download/v1.2.0/kafka_exporter-1.2.0.linux-amd64.tar.gz
#2、解压,重命名
~# tar xf kafka_exporter-1.2.0.linux-amd64.tar.gz
~# mv kafka_exporter-1.2.0.linux-amd64 ../
~# mv kafka_exporter-1.2.0.linux-amd64/ kafka_exporter
#3、把kafka_exporter配置成系统项
~# vim /etc/systemd/system/kafka_exporter.service
[Unit]
Description=kafka_exporter
Documentation=https://prometheus.io/
After=network.target
[Service]
Type=simple
ExecStart=/usr/local/kafka_exporter/kafka_exporter --kafka.server=172.31.152.181:9092
Restart=on-failure
[Install]
WantedBy=multi-user.target
#注释:--kafka.server=kafkaIP地址:9092
#4、加载开机自启动和启动服务
~# systemctl enable kafka_exporter.service
~# systemctl restart kafka_exporter.service
~# ss -lntp|grep 9308
LISTEN 0 16384 [::]:9308 [::]:* users:(("kafka_exporter",pid=11744,fd=5))
#5、配置prometheus文件
~# vi prometheus.yml
- job_name: 'Kafka'
static_configs:
- targets: ['172.31.152.181:9308']
- targets: ['172.31.152.182:9308']
- targets: ['172.31.152.183:9308']
#在配置文件最后一行进行配置
#6、重启prometheus
~# systemctl restart prometheus
配置grafana:
最后效果图: