Apache Kafka 4 cheatsheet
Apache Kafka 4: Consumer groups
5 common Apache Kafka 4 tasks.
List consumer groups
Show all consumer groups in the cluster.
bin/kafka-consumer-groups.sh --bootstrap-server localhost:9092 --list
Check consumer lag
Show each partition's current offset, end offset and lag for a group.
bin/kafka-consumer-groups.sh --bootstrap-server localhost:9092 --describe --group order-readers
Preview an offset reset
Show what resetting to the earliest offset would do, without changing anything. The group must have no active consumers.
bin/kafka-consumer-groups.sh --bootstrap-server localhost:9092 --group order-readers --topic orders --reset-offsets --to-earliest --dry-run
Reset offsets
Move the group back to the earliest offset so it reprocesses messages.
bin/kafka-consumer-groups.sh --bootstrap-server localhost:9092 --group order-readers --topic orders --reset-offsets --to-earliest --execute
Caution: The group will reprocess messages, which can cause duplicate side effects. Preview with --dry-run first.
Delete a consumer group
Delete a group that has no active members.
bin/kafka-consumer-groups.sh --bootstrap-server localhost:9092 --delete --group order-readers
Caution: The group's committed offsets are lost.