一、安装配置kafka_exporter
下载kafka_exporter
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
./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版本太低 !!!
防火墙开放端口(未启动防火墙不需要)
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启动脚本
#!/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配置文件添加以下配置
scrape_configs:
- job_name: "kafka"
static_configs:
- targets: ['localhost:19091']
使用sudo权限,后台执行Prometheus启动命令,并启用lifecycle功能,指定监听端口为9090
sudo nohup ./prometheus --web.enable-lifecycle --web.listen-address=:9090 &
三、安装配置grafana
下载grafana
wget https://dl.grafana.com/enterprise/release/grafana-enterprise-10.2.3-1.x86_64.rpm
安装grafana
yum install grafana-enterprise-10.2.3-1.x86_64.rpm
或
sudo yum install -y https://dl.grafana.com/enterprise/release/grafana-enterprise-10.2.3-1.x86_64.rpm
启动grafana,默认端口3000
systemctl start grafana-server.service
登录grafana
http://localhost:3000/dashboards amdin/admin
下载kafka监控模板
https://grafana.com/grafana/dashboards/7589-kafka-exporter-overview/
https://grafana.com/grafana/dashboards/11962-kafka-metrics/文章来源:https://www.toymoban.com/news/detail-811988.html
配置普米数据源,导入模板即可显示监控信息;文章来源地址https://www.toymoban.com/news/detail-811988.html
到了这里,关于基于kafka_exporter&prometheus&grafana的kafka监控实现的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!