当前位置:   article > 正文

KAFKA监控一条龙:史上最强Kafka看板+监控配置与告警规则

kafka监控一条龙

使用kafka_exporter监控多kafka

kafka_exporter项目地址:https://github.com/danielqsj/kafka_exporter

  • 使用docker-compose部署多个kafka_exporter,每个exporter对接一个kafka。

  • 注意:配置上每个kafka broker的地址,kafka3需要指定版本。

  1. version: '3.1'
  2. services:
  3.   kafka-exporter-opslogs:
  4.     image: bitnami/kafka-exporter:latest
  5.     command:
  6.       - '--kafka.server=10.2.19.43:9092'
  7.       - '--kafka.server=10.2.24.62:9092'
  8.       - '--kafka.server=10.5.98.190:9092'
  9.       - '--kafka.version=3.2.1'
  10.     restart: always
  11.     ports:
  12.       - 9310:9308
  13.   kafka-exporter-prod:
  14.     image: bitnami/kafka-exporter:latest
  15.     command:
  16.       - '--kafka.server=192.168.53.99:9092'
  17.       - '--kafka.server=192.168.53.53:9092'
  18.       - '--kafka.server=192.168.53.96:9092'
  19.     restart: always
  20.     ports:
  21.       - 9311:9308

Promethus配置job接入kafka-exporter

  • 注意:每个kafka-exporter必须增加name标签,看板需要使用这个标签。

  1.   - job_name: 'kafka-exporter'
  2.     metrics_path: /metrics
  3.     scrape_interval: 15s
  4.     scrape_timeout: 10s
  5.     static_configs:
  6.     - targets:
  7.       - 10.0.0.26:9310
  8.       labels:
  9.         name: kafka-opslogs
  10.     - targets:
  11.       - 10.0.0.26:9311
  12.       labels:
  13.         name: kafka-prod

KAFKA Grafana Dashboard

【中文版本】2024.05.16更新,基于Prometheus的kafka_exporter,KAFKA资源展示、问题排查、快速积压分析!
  • 看板的所有Panel支持最新样式,优化展示性能,已兼容Grafana10.X版本.

  • 包括KAFKA整体的资源状态,

  • 生产者与消费者关系

  • 消息积压的明细信息

  • 生产与消费的速率

  • 异常的消费与Topic展示

  • 分区级别的积压与消费明细

截图

  • 全局信息、消费者与Topic、异常与积压分析

图片

  • 分区维度明细

图片

看板下载

  • Grafana看板ID:21078

  • Grafana看板地址:

    https://grafana.com/grafana/dashboards/21078

  • 项目仓库:

    https://github.com/starsliao/Prometheus/tree/master/kafka

Prometheus告警规则

  1. - name: kafka
  2. rules:
  3. - alert: KAFKA_brokers异常
  4. expr: kafka_broker_info != 1
  5. for: 2m
  6. labels:
  7. severity: critical
  8. annotations:
  9. description: "{{ $labels.name }}当前brokers异常:{{ $labels.address }}"
  10. - alert: 电商生产KAFKA消息整体积压
  11. expr: sum(kafka_consumergroup_lag_sum{job="kafka-exporter"}) by (name,consumergroup, topic)>5000
  12. for: 2m
  13. labels:
  14. severity: critical
  15. annotations:
  16. description: "【环境】{{ $labels.name }}\n【消费组】{{ $labels.consumergroup }}\n【topic】{{ $labels.topic }}【积压】:{{ $value | printf \"%.2f\" }}"
  17. - alert: 电商生产KAFKA消息分区积压
  18. expr: (sum(kafka_consumergroup_lag{job="kafka-exporter"}) by (name,consumergroup, topic, partition)>1500) AND ON() (hour()+8)%24 >= 7 <= 21
  19. for: 3m
  20. labels:
  21. severity: critical
  22. annotations:
  23. description: "【环境】{{ $labels.name }}\n【消费组】{{ $labels.consumergroup }}\n【topic】{{$labels.topic}}【分区】{{ $labels.partition }}【积压】:{{ $value | printf \"%.2f\" }}"
  24. - alert: 电商生产KAFKA分区数过多
  25. expr: sum by(name)(kafka_topic_partitions{job="kafka-exporter",topic !~"__.*"})>1500
  26. for: 2m
  27. labels:
  28. severity: critical
  29. annotations:
  30. description: "{{ $labels.name }}当前分区数:{{ $value | printf \"%.2f\" }}"
  31. - alert: 电商生产KAFKA_brokers丢失
  32. expr: kafka_brokers{job="kafka-exporter"} < 3
  33. for: 2m
  34. labels:
  35. severity: critical
  36. annotations:
  37. description: "{{ $labels.name }}当前brokers数:{{ $value | printf \"%.2f\" }}"
  38. - alert: 电商生产KAFKA_TopicsReplicas
  39. expr: sum(kafka_topic_partition_in_sync_replica{job="kafka-exporter"}) by (name,topic) <1
  40. for: 2m
  41. labels:
  42. severity: critical
  43. annotations:
  44. description: "{{ $labels.name }} Kafka topic in-sync partition:{{ $value | printf \"%.2f\" }}"
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Gausst松鼠会/article/detail/678782
推荐阅读
相关标签
  

闽ICP备14008679号