View Consumer Group Info in Kafka

Apache Kafka® is an open-source distributed streaming system used for stream processing, real-time data pipelines, and data integration at scale.

Kafka provides a kafka-groups.sh tool that enables you to check the consumer position and view general consumer group info.

For a complete list of command-line tools that are provided with Kafka, see Kafka Command-Line Interface (CLI) Tools. For client, consumer, and producer tools, see Client, producer, and consumer tools.

Check consumer position

Sometimes it’s useful to see the position of your consumers. The kafka-consumer-groups tool shows the position of all consumers in a consumer group and how far behind the end of the log they are.

The command to run this tool on a consumer group named my-group consuming a topic named my-topic would look like this:

bin/kafka-consumer-groups.sh \  --bootstrap-server localhost:9092 \  --describe --group my-group 

The output would be similar to the following (CONSUMER-IDs truncated for readability):

TOPIC PARTITION CURRENT-OFFSET LOG-END-OFFSET LAG CONSUMER-ID HOST CLIENT-ID my-topic 0 2 4 2 consumer-1-... /127.0.0.1 consumer-1 my-topic 1 2 3 1 consumer-1-... /127.0.0.1 consumer-1 my-topic 2 2 3 1 consumer-2-... /127.0.0.1 consumer-2 

List groups and view offsets

The kafka-consumer-groups tool also enables you to list, describe, or delete consumer groups. The consumer group can be deleted manually, or automatically when the last committed offset for that group expires.

Manual deletion will be successful only if the group does not have any active members.

To list all consumer groups across all topics:

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

The output should be similar to the following:

test-consumer-group 

To filter the list of consumer groups by their protocol type, use the --list and --type flags. You can specify a single type or a comma-separated list of types, such as classic or consumer.

./bin/kafka-consumer-groups.sh \  --bootstrap-server localhost:9092 \  --list \  --type classic,consumer 

The command returns only the consumer groups that match one of the specified types.

To view offsets, use the tool with the describe command, like the following:

./bin/kafka-consumer-groups.sh \  --bootstrap-server localhost:9092 \  --describe \  --group my-group 

The output would be similar to the following (CONSUMER-IDs truncated for readability):

TOPIC PARTITION CURRENT-OFFSET LOG-END-OFFSET LAG CONSUMER-ID HOST CLIENT-ID topic3 0 241019 395308 154289 consumer2-e76e... /127.0.0.1 consumer2 topic2 1 520678 803288 282610 consumer2-e76e... /127.0.0.1 consumer2 topic3 1 241018 398817 157799 consumer2-e76e... /127.0.0.1 consumer2 topic1 0 854144 855809 1665 consumer1-3fc8... /127.0. 

Confluent Tip

To use the kafka-consumer-groups tool with Confluent Cloud, add the --command-config parameter with a value that points to the properties configuration file containing all the required properties for connecting. For more information, see How to Use Kafka Tools With Confluent Cloud.