pythonapache-kafkaconfluent-kafka-python

Get consumer group state using confluent kafka python


I am doing this way currently to get the groupmetadata for list of consumers

    admin = AdminClient({ 'bootstrap.servers' : config['kafka']['brokers']  })
for group in config['kafka']['groups']:
    metadata = admin.list_groups(group)
    print(metadata[0].state)

Is there a way to achieve the below

metadata = admin.list_groups(config['kafka']['groups']) //list of groups

It throws an error that it expects only one string argument, the next one is an integer.

But when I checked the doc, this, I expect that it would work for selected groups.

What am I missing here? is there a way to achieve this?

Thanks.


Solution

  • The docs say group param is only str, not list(str)

    If you don't provide it, it will return all groups, which you could then choose to filter, based on your config.