Created 09-30-2017 09:04 PM
Hi,
I am trying to write a java program that monitors the kafka consumer and end offset values and send alerts if it does not update for a given period of time. So i was using the consumer.getCommitedOffsets() method in the Kafka consumer API in java. But this does not seem to be the correct consumer offset value or maybe not the consumer offset for this consumer group. Can anyone tell me how to get the value of consumer offsets in kafka for a consumer group and particular topic?
Created 09-30-2017 09:39 PM
Have you tried using consumer.position(TopicPartition partition)? or run the following script from your java program. You can also run the script with zookeeper instead of bootsrap-server.
kafka-consumer-groups.sh --bootstrap-server <broker-host>:9092 --new-consumer --group groupname --describe
Created 10-01-2017 05:42 PM
@mqureshi I tried using the consumer.position(TopicPartition partition) method. But this does not seem to give the correct value either. I know how to get them in the command line. So i am comparing the values in zookeeper to the one in java method. My goal is to get those values in Java.
Created 10-02-2017 02:40 PM
I understand. That's why, I think you need to call kafka-consumer-group.sh script from your java program to get what you are looking for.
Created 10-02-2017 07:31 PM
kafka-consumer-groups.sh calls ConsumerGroupCommand
Please take a look at the following method:
ConsumerGroupCommand#getPartitionOffsets