简体   繁体   English

Kafka 消费者通过 JMX 滞后

[英]Kafka consumer lag through JMX

I'm trying to monitor the lag of a consumer group in Kafka 0.10.我正在尝试监控 Kafka 0.10 中消费者群体的滞后。

Our consumers are keeping track of their offsets in Kafka rather than ZooKeper.我们的消费者在 Kafka 而不是 ZooKeeper 中跟踪他们的偏移量。 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.但是,我的经纪人已经使用Prometheus JMX 导出器来收集大量统计信息。 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 .我已将 JConsole 连接到代理,但看不到 JMX 中报告的数据与kafka-consumer-groups.sh报告的数据相同。

Is there anyway to get this information from Kafka with JMX without needing any additional tools?没有办法在不需要任何额外工具的情况下使用 JMX 从 Kafka 获取这些信息?

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.您可以检索所有{topic}-{partition}.records-lag的指标kafka.consumer:type=consumer-fetch-manager-metrics,client-id={client-id}的属性{topic}-{partition}.records-lag That should be equivalent to the output of consumer-groups.sh那应该相当于consumer-groups.sh的输出

To expose JMX metrics from consumer simply add 要向使用者公开JMX指标,只需添加

-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. 参数到基于Java的消费者应用程序中,然后可以使用jconsole工具和localhost:9090 url访问它。 There you can find kafka.consumer:type=consumer-fetch-manager-metrics bean. 在这里可以找到kafka.consumer:type = consumer-fetch-manager-metrics bean。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM