View Consumer Group Info¶
Apache Kafka® provides a kafka-consumer-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 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.