Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kafka consumer list

I need to find out a way to ask Kafka for a list of topics. I know I can do that using the kafka-topics.sh script included in the bin\ directory. Once I have this list, I need all the consumers per topic. I could not find a script in that directory, nor a class in the kafka-consumer-api library that allows me to do it.

The reason behind this is that I need to figure out the difference between the topic's offset and the consumers' offsets.

Is there a way to achieve this? Or do I need to implement this functionality in each of my consumers?

like image 973
Tavo Avatar asked Sep 21 '15 14:09

Tavo


People also ask

How do you list consumers in Kafka?

Get the list of consumer groups for a topic. Use kafka-consumer-groups.sh to list all consumer groups. Note that the below command will list all the consumer groups for all topics managed by the cluster.

How can I see the consumer group of Kafka topic?

Step1: Open the Windows command prompt. Step2: Use the '-group' command as: 'kafka-console-consumer -bootstrap-server localhost:9092 -topic -group <group_name>' . Give some name to the group. Press enter.

Who are the consumers of Kafka?

Kafka consumers are typically part of a consumer group . When multiple consumers are subscribed to a topic and belong to the same consumer group, each consumer in the group will receive messages from a different subset of the partitions in the topic.

How do you check Kafka consumer is running?

6 Answers. Show activity on this post. You can use consumer. assignment() , it will return set of partitions and verify whether all of the partitions are assigned which are available for that topic.


2 Answers

Use kafka-consumer-groups.sh

For example

bin/kafka-consumer-groups.sh  --list --bootstrap-server localhost:9092  bin/kafka-consumer-groups.sh --describe --group mygroup --bootstrap-server localhost:9092 
like image 169
Basanth Roy Avatar answered Sep 22 '22 23:09

Basanth Roy


you can use this for 0.9.0.0. version kafka

./kafka-consumer-groups.sh --list --zookeeper hostname:potnumber 

to view the groups you have created. This will display all the consumer group names.

 ./kafka-consumer-groups.sh --describe --zookeeper hostname:potnumber  --describe  --group consumer_group_name 

To view the details

GROUP, TOPIC, PARTITION, CURRENT OFFSET, LOG END OFFSET, LAG, OWNER 
like image 31
jack AKA karthik Avatar answered Sep 21 '22 23:09

jack AKA karthik