Bhaskar
Bhaskar

Reputation: 1

How to get consumer metrics using kafka admin client?

I need to write an API to display consumer metrics in java. I thought of using Kafka admin client. Is there any way we can retrieve consumer metrics information

I checked admin client code. I have Kafka consumer class. I have consumer metrics method, but it is not holding the information.

Upvotes: 0

Views: 1153

Answers (1)

mazaneicha
mazaneicha

Reputation: 9417

Kafka consumer can report a lot of metrics through JMX, you just need to add a few Java properties to your consumer, either in the code or through command-line. For example, for console consumer:

$ KAFKA_JMX_OPTS="-Dcom.sun.management.jmxremote=true -Dcom.sun.management.jmxremote.port=9398 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false"  kafka-console-consumer ...

Upvotes: 1

Related Questions