Reputation: 237
I know we can get the list of consumer groups and then pass any one of he consumer group to a particular topic to determine the consumers offset.
Step 1: Use the following command to get list of consumer groups
kafka-consumer-groups --zookeeper <Server-URL> --list
From the list of consumers obtained, pick a consumer group Step 2: Get that particular consumer offset for a particular topic
kafka-consumer-offset-checker --zookeeper <Server-URL> --topic <topic-name> --group <group-name>
Same thing for bootstrap server.
But in a single step i need a command to get list of consumers for a particular topic.
Upvotes: 6
Views: 11797
Reputation: 1006
A way to extract this for all consumer is retrieve from the __consumer_offsets
topic the list of topics/consumers.
I did a script to do so, it's quite slow to get the list but does the job
https://gist.github.com/padilo/6a5101f9e005c975956208cb19ba9f67
Upvotes: 3
Reputation: 919
As far as I know there is no direct command to do that:
One workaround for this could be to list all consumer groups
~ $ $KAFKA_DIR/bin/kafka-consumer-groups.sh -bootstrap-server localhost:9092 -list
consumer-group-1
consumer-group-2
consumer-group-3
Then describe the consumer group using the below command which will show the topic.
~ $ $KAFKA_DIR/bin/kafka-consumer-groups.sh --describe --bootstrap-server 0.0.0.0:9092 --group consumer-group-1
TOPIC PARTITION CURRENT-OFFSET LOG-END-OFFSET LAG CONSUMER-ID HOST CLIENT-ID
topic-1 0 - 0 - consumer-1-9bf71d08-bcf8-4eb1-adb8-91589fd034b3 /11.2.9.159 consumer-1
Upvotes: 4