apache-kafka kafka console tools kafka-consumer-groups


Example

This tool allows you to list, describe, or delete consumer groups. Have a look at this article for more information about consumer groups.

if you still use the old consumer implementation, replace --bootstrap-server with --zookeeper.

List consumer groups:

kafka-consumer-groups  --bootstrap-server localhost:9092 --list
octopus

Describe a consumer-group:

kafka-consumer-groups  --bootstrap-server localhost:9092 --describe --group octopus
GROUP          TOPIC           PARTITION  CURRENT-OFFSET  LOG-END-OFFSET  LAG       OWNER
octopus        test-topic      0          15              15              0         octopus-1/127.0.0.1
octopus        test-topic      1          14              15              1         octopus-2_/127.0.0.1

Remarks: in the output above,

  • current-offset is the last committed offset of the consumer instance,
  • log-end-offset is the highest offset of the partition (hence, summing this column gives you the total number of messages for the topic)
  • lag is the difference between the current consumer offset and the highest offset, hence how far behind the consumer is,
  • owner is the client.id of the consumer (if not specified, a default one is displayed).

Delete a consumer-group:

deletion is only available when the group metadata is stored in zookeeper (old consumer api). With the new consumer API, the broker handles everything including metadata deletion: the group is deleted automatically when the last committed offset for the group expires.

kafka-consumer-groups --bootstrap-server localhost:9092 --delete --group octopus