How to list Kafka consumer group using python

How to list Kafka consumer group using python



I want to get Kafka consumer group list with python but I couldn't.



I use to zookeeper python client( kazoo) but consumer group list empty because this method for old consumer and we are not using old consumer.



How can I get consumer group list with python code?


./kafka-consumer-groups.sh -bootstrap-server localhost:9092 -list




2 Answers
2



You can easily list consumer groups with kafka-python.



Just send a ListGroupsRequest to any of the brokers in your cluster.


ListGroupsRequest



For example:


from kafka import BrokerConnection
from kafka.protocol.admin import *
import socket

bc = BrokerConnection('localhost', 9092, socket.AF_INET)
bc.connect_blocking()

list_groups_request = ListGroupsRequest_v1()

future = bc.send(list_groups_request)
while not future.is_done:
for resp, f in bc.recv():
f.success(resp)

for group in future.value.groups:
print(group)





Thank you for your answer.
– BigData
Sep 12 at 20:30



KIP-222 was recently introduced to enable Java clients to retrieve all consumer groups. Maybe it needs more time to have librdkafka or python client support this. See details in this issue.





There's other Python libraries than the Confluent librd based ones, though
– cricket_007
Aug 30 at 13:51



Required, but never shown



Required, but never shown






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

Edmonton

Crossroads (UK TV series)