下载以及安装kafka_exporter

  1. #1、下载kafka_exporter
  2. ~# wget https://github.com/danielqsj/kafka_exporter/releases/download/v1.2.0/kafka_exporter-1.2.0.linux-amd64.tar.gz
  3. #2、解压,重命名
  4. ~# tar xf kafka_exporter-1.2.0.linux-amd64.tar.gz
  5. ~# mv kafka_exporter-1.2.0.linux-amd64 ../
  6. ~# mv kafka_exporter-1.2.0.linux-amd64/ kafka_exporter
  7. #3、把kafka_exporter配置成系统项
  8. ~# vim /etc/systemd/system/kafka_exporter.service
  9. [Unit]
  10. Description=kafka_exporter
  11. Documentation=https://prometheus.io/
  12. After=network.target
  13. [Service]
  14. Type=simple
  15. ExecStart=/usr/local/kafka_exporter/kafka_exporter --kafka.server=172.31.152.181:9092
  16. Restart=on-failure
  17. [Install]
  18. WantedBy=multi-user.target
  19. #注释:--kafka.server=kafkaIP地址:9092
  20. #4、加载开机自启动和启动服务
  21. ~# systemctl enable kafka_exporter.service
  22. ~# systemctl restart kafka_exporter.service
  23. ~# ss -lntp|grep 9308
  24. LISTEN 0 16384 [::]:9308 [::]:* users:(("kafka_exporter",pid=11744,fd=5))
  25. #5、配置prometheus文件
  26. ~# vi prometheus.yml
  27. - job_name: 'Kafka'
  28. static_configs:
  29. - targets: ['172.31.152.181:9308']
  30. - targets: ['172.31.152.182:9308']
  31. - targets: ['172.31.152.183:9308']
  32. #在配置文件最后一行进行配置
  33. #6、重启prometheus
  34. ~# systemctl restart prometheus

配置grafana:

image.png
image.png
image.png

最后效果图:
image.png