一、安装配置kafka_exporter
下载kafka_exporter
powershell
wget http://*.*.*.45:10000/prometheus/kafka_exporter-1.4.2.linux-amd64.tar.gz
tar -zxcf kafka_exporter-1.4.2.linux-amd64.tar.gz
启动kafka_exporter
powershell
./kafka_exporter --kafka.server=*.*.*.77:8423 --kafka.server=*.*.*.78:8423 --kafka.server=*.*.*.79:8423 --kafka.server=*.*.*.80:8423 --kafka.server=*.*.*.81:8423 &
Error Init Kafka Client: kafka: client has run out of available brokers to talk to (Is your cluster reachable?)
报错原因:kafka_exporter版本太低 !!!
防火墙开放端口(未启动防火墙不需要)
powershell
firewall-cmd --add-port=9092/tcp --permanent # 开放 9092 端口
firewall-cmd --reload # 重新加载
firewall-cmd --list-ports # 查看所有开放端口
或
firewall-cmd --add-port=9092/tcp --permanent && firewall-cmd --reload && firewall-cmd --list-ports
kafka_exporter启动脚本
powershell
#!/bin/bash
nohup /data/gxpt/kafka_exporter/kafka_exporter-2.0 --kafka.server=*.*.*.77:8423 --kafka.server=*.*.*.78:8423 --kafka.server=*.*.*.79:8423 --kafka.server=*.*.*.80:8423 --kafka.server=*.*.*.81:8423 --sasl.enabled --sasl.username=user --sasl.password=md5(pwd) --sasl.mechanism=scram-sha512 --log.enable-sarama --web.listen-address=:19091 > /dev/null 2>&1 &
其中,kafka监控账号:user/pwd【md5(pwd)】 监听端口号:--web.listen-address=:19091 kafka_exporter
二、安装配置prometheus
在prometheus.yml配置文件添加以下配置
yaml
scrape_configs:
- job_name: "kafka"
static_configs:
- targets: ['localhost:19091']
使用sudo权限,后台执行Prometheus启动命令,并启用lifecycle功能,指定监听端口为9090
powershell
sudo nohup ./prometheus --web.enable-lifecycle --web.listen-address=:9090 &
三、安装配置grafana
下载grafana
powershell
wget https://dl.grafana.com/enterprise/release/grafana-enterprise-10.2.3-1.x86_64.rpm
安装grafana
powershell
yum install grafana-enterprise-10.2.3-1.x86_64.rpm
或
powershell
sudo yum install -y https://dl.grafana.com/enterprise/release/grafana-enterprise-10.2.3-1.x86_64.rpm
启动grafana,默认端口3000
powershell
systemctl start grafana-server.service
登录grafana
http://localhost:3000/dashboards amdin/admin
下载kafka监控模板
https://grafana.com/grafana/dashboards/7589-kafka-exporter-overview/
配置普米数据源,导入模板即可显示监控信息;