0

I want to get a Kafka consumer group list by topic in kafka-python but I couldn't. How can I get consumer group list that is associated with topic in python code:

from kafka import BrokerConnection
from kafka.protocol.admin import *
import socket
list_groups_request = ListGroupsRequest_v1()
future = bc.send(list_groups_request)
alfonso
  • 884
  • 17
  • 31
  • 1
    https://stackoverflow.com/questions/52080471/how-to-list-kafka-consumer-group-using-python/52088863 .. .You would have to describe all groups, then filter them for the topic name. – OneCricketeer Oct 24 '19 at 21:03
  • @cricket_007 I have tried describe the Topic in Command line but its listing empty topic a,but it was linked with the topic . Tried in 2 approaches. 1. Used the stack overflow link provided by you 2. Used in this way Import Kafka admin_client = Kafka.KafkaAdminClient() print(admin_client.list_consumer_groups()) For the above line, output is like [‘test-consumer-group’, ‘consumer’] Now tried to describe it in the following way. >>> admin_client.describe_consumer_groups(['test-consumer-group']) [(0, 'test-consumer-group', 'Empty', 'consumer', '', [])] – Andrews Ashwin Oct 25 '19 at 20:24
  • The `list_consumer_group_offsets` method will return TopicPartitions for a given group https://kafka-python.readthedocs.io/en/master/apidoc/KafkaAdminClient.html#kafka.KafkaAdminClient.list_consumer_group_offsets – OneCricketeer Oct 25 '19 at 21:36

0 Answers0