Command to view Partitions and Offsets of Kafka Topics
Kafka comes with many tools, one of them is kafka-consumer-groups that help to list all consumer groups, describe a consumer group, reset consumer group offsets, and delete consumer group information. We will use this tool to view partitions and offsets of Kafka topics.
Go to Kafka folder and run the following command. Replace test-group-id with your consumer group id:
Ubuntu/Linux/Mac
$ ./bin/kafka-consumer-groups.sh --bootstrap-server localhost:9092 --group test-group-id --describe
Windows
> .\bin\windows\kafka-consumer-groups.bat --bootstrap-server localhost:9092 --group test-group-id --describe
The output of the above command will be something like this:
GROUP | TOPIC | PARTITION | CURRENT-OFFSET | LOG-END-OFFSET | LAG | CONSUMER-ID |
test-group-id | my-topic-name | 0 | 85 | 97 | 12 | - |
test-group-id | my-topic-name | 1 | 77 | 124 | 47 | - |
test-group-id | my-topic-name | 2 | 74 | 104 | 30 | - |
test-group-id | my-topic-name | 3 | 78 | 121 | 43 | - |
test-group-id | my-topic-name | 4 | 43 | 122 | 79 | - |