Kafka consumers


The Lenses-CLI allows you to handle consumer group offsets. The command used for this purpose is offsets, with subcommands update-multiple-partitions or update-single-partition. Certain mandatory flags such as --group and --topic are required, indicating the consumer group ID and topic name respectively. To affect all topics use the --all-topics flag. The table below shows some additional flags used for modifying consumers offsets.

FlagDescription
-g, --groupSet the Consumer Group ID
-t, --topicSet the topic name
--all-topicsSelect implicitly all the topics
--topicsThe topic to reset offsets for
--partitionSet the partition ID
--to-earliestReset partition offset to earliest offset
--to-latestReset partition offset to latest offset
--to-offsetReset the partition offset to the provided value

Update a single topic’s partition offset to the specified value 

lenses-cli consumers \
    offsets \
    update-single-partition \
    --group [GROUP_NAME] \
    --topic [TOPIC_NAME] \
    --partition [PARTITION_ID] \
    --to-offset [OFFSET_ID]

Update to the earliest offset available 

lenses-cli consumers \
    offsets \
    update-single-partition \
    --group [GROUP_NAME] \
    --topic [TOPIC_NAME] \
    --partition [PARTITION_ID] \
    --to-earliest

Update to the latest offset available 

lenses-cli consumers \
    offsets \
    update-single-partition \
    --group [GROUP_NAME] \
    --topic [TOPIC_NAME] \
    --partition [PARTITION_ID] \
    --to-latest

Update given topics for all their partition offsets to the specified datetime 

# The datime parameter needs to be in ISO 8601 format
lenses-cli consumers \
    offsets \
    update-multiple-partitions \
    --group [GROUP_NAME] \
    --topic [TOPIC_NAME] \
    --to-datetime [DATETIME]

Reset given topics for all their partitions offsets to the earliest offset possible 

lenses-cli consumers \
    offsets \
    update-multiple-partitions \
    --group [GROUP_NAME] \
    --topic [TOPIC_NAME] \
    --to-earliest

Reset given topics for all their partitions offsets to the latest offset possible 

lenses-cli consumers \
    offsets \
    update-multiple-partitions \
    --group [GROUP_NAME] \
    --topic [TOPIC_NAME] \
    --to-latest

Reset offsets for all topics of this consumer group 

lenses-cli consumers \
    offsets \
    update-multiple-partitions \
    --group [GROUP_NAME] \
    --all-topics \
    --to-latest
--
Last modified: July 3, 2024