问题描述
我写了一个java程序来消耗来自kafka的消息。我想监视消耗滞后,如何通过java获取它?
I wrote a java program to consume messsage from kafka. I want to monitor the consume lag, how to get it by java?
BTW,我使用:
<groupId>org.apache.kafka</groupId>
<artifactId>kafka_2.11</artifactId>
<version>0.10.1.1</version>
提前致谢。
推荐答案
我个人直接从我的消费者那里查询jmx信息。我只在java中使用JMX bean: kafka.consumer:type = consumer-fetch-manager-metrics,client-id = * / records-lag-max
可用。
I personnaly query directly jmx informations from my consumers. I only consume in java so the JMX beans : kafka.consumer:type=consumer-fetch-manager-metrics,client-id=*/records-lag-max
are available.
如果jolokia在您的类路径中,您可以在 /jolokia/read/kafka.consumer:type=consumer-上使用GET检索值。 fetch-manager-metrics,client-id = * / records-lag-max
并将所有结果收集到一个地方。
If jolokia is in your classpath you can retrieve the value with a GET on /jolokia/read/kafka.consumer:type=consumer-fetch-manager-metrics,client-id=*/records-lag-max
and gather all the results in one place.
有还有,它非常容易配置,但它有点过时(如果不是0.10,则不适用我记得很清楚。)
There is also Burrow which is very easy to configure, but it's a bit outdated (doesn't work for 0.10 if I remember well).
这篇关于如何在java程序中获取kafka消耗滞后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!