Kafka consumer lag through JMX

…衆ロ難τιáo~ 提交于 2019-12-10 10:39:58

问题


I'm trying to monitor the lag of a consumer group in Kafka 0.10.

Our consumers are keeping track of their offsets in Kafka rather than ZooKeper. This means I can get the figures using the following:

bin/kafka-consumer-groups.sh --bootstrap-server <broker> --describe --group <group-name>

This works fine. However, my broker already makes use of the Prometheus JMX exporter for collecting a number of stats. I've connected JConsole to the brokers but can't see the same data being reported in JMX as reported by kafka-consumer-groups.sh.

Is there anyway to get this information from Kafka with JMX without needing any additional tools?


回答1:


You could retrieve the atrributes {topic}-{partition}.records-lag of metric kafka.consumer:type=consumer-fetch-manager-metrics,client-id={client-id} for all partitions. That should be equivalent to the output of consumer-groups.sh




回答2:


To expose JMX metrics from consumer simply add

-Dcom.sun.management.jmxremote.port=9090 
-Dcom.sun.management.jmxremote.authenticate=false  
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.local.only=false

parameters to your java based consumer application, then you can access it using jconsole tool and localhost:9090 url. There you can find kafka.consumer:type=consumer-fetch-manager-metrics bean.



来源:https://stackoverflow.com/questions/46613797/kafka-consumer-lag-through-jmx

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!