Skip to content

Instantly share code, notes, and snippets.

@rmoff rmoff/kafkacat.adoc
Last active Jan 17, 2020

Embed
What would you like to do?
Show last three messages from a Kafka topic with kafkacat
kafkacat -b localhost:9092 \
         -t _kafka-connect-group-01-status \
         -C \
         -o-3 \
         -c3 \
         -f 'Topic %t / Partition %p / Offset: %o / Timestamp: %T\nHeaders: %h\nKey (%K bytes): %k\nPayload (%S bytes): %s\n--\n'

Where:

-b

Broker address

-t

Topic name

-C

Run as a consumer (-P for producer)

-o-3

From offset (-o) three from the end (-3).

-c3

Consume three messages and exit (omit this to continue displaying new messages)

-f

Optional format string to display rich information about the message and its metadata.

Useful when starting to poke around topic structures :)

asciicast
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.