创建目录
cd /home/dev/kafka
mkdir kafka-agent kafka-service
kafka-agent目录下
下载jmx_export
# 下载链接
wget https://repo1.maven.org/maven2/io/prometheus/jmx/jmx_prometheus_javaagent/0.17.0/jmx_prometheus_javaagent-0.17.0.jar
jmxremote.password
见上级目录下
kafka_broker.yml
见上级目录下,也可直接下载:
https://github.com/xxd763795151/kafka-exporter/blob/main/kafka_broker.yml
kafka-service目录下
kafka-server-start.sh
见上级目录
更新目录权限
chown -R 1001:root kafka-agent
chown -R 1001:root kafka-service
chmod -R 777 kafka-service
chmod 400 ./kafka-agent/jmxremote.password
停止kafka服务
docker exec -it kafka-kafka-1 /bin/bash
cd /opt/bitnami/kafka/bin
sh kafka-server-stop.sh
docker-compose down
更新docker-compose
备份并重命名原有的
docker-compose.yaml
文件
cp docker-compose.yaml docker-compose_20220829.yaml
echo > docker-compose.yaml
cat docker-compose.yaml
启动服务
docker-compose up -d
docker-compose ps
# 查看日志
docker-compose logs kafka
对接prometheus
登录
k8s master01
节点
cd /root/admin-workspace/prometheus/kafka
cat serviceMonitorKafka.yaml
kubectl apply -f serviceMonitorKafka.yaml
对接Grafana
cat kafka-grafana-newest.json
注意:变量的设置~
截图如下:
消息积压
在kafka的broker端无法直接获取消息积压等指标信息,这些数据在消费端上,我们也不太可能去连接所有的消费端获取监控信息。
启动kafka-exporter服务
详见上级目录kafka-squeeze
说明。
对接prometheus
登录
k8s master01
节点
cd /root/admin-workspace/prometheus/kafka
cat serviceMonitorKafka-squeeze.yaml
kubectl apply -f serviceMonitorKafka-squeeze.yaml
对接Grafana
参考文档
- https://www.confluent.io/blog/monitor-kafka-clusters-with-prometheus-grafana-and-confluent/
- https://blog.51cto.com/u_15360362/3809143
- http://dbaselife.com/project-3/doc-995/