LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

kafkacat

command-line Kafka producer and consumer

TLDR

Produce messages
$ echo "[message]" | kafkacat -P -b [localhost:9092] -t [topic]
copy
Consume messages
$ kafkacat -C -b [localhost:9092] -t [topic]
copy
Consume from beginning
$ kafkacat -C -b [localhost:9092] -t [topic] -o beginning
copy
List topics
$ kafkacat -L -b [localhost:9092]
copy
Produce from file
$ kafkacat -P -b [localhost:9092] -t [topic] [file.txt]
copy
Consume with format
$ kafkacat -C -b [localhost:9092] -t [topic] -f '[%T] %k: %s\n'
copy
Produce with key using delimiter
$ echo "[key]:[value]" | kafkacat -P -b [localhost:9092] -t [topic] -K ":"
copy
Consume N messages and exit
$ kafkacat -C -b [localhost:9092] -t [topic] -c [10]
copy

SYNOPSIS

kafkacat [options]

DESCRIPTION

kafkacat (also known as kcat) is a command-line Kafka producer and consumer. It's faster and simpler than Kafka's built-in shell scripts, useful for testing and debugging.

PARAMETERS

-P

Producer mode.
-C
Consumer mode.
-L
Metadata list mode.
-b brokers
Broker list.
-t topic
Topic name.
-p partition
Partition number.
-o offset
Offset: beginning, end, stored, or number.
-K delim
Key delimiter.
-f format
Output format string.
-c count
Exit after consuming count messages.
-e
Exit at end of topic.
-G group topic
Consumer group mode (high-level balanced consumer).
-X property=value
Set librdkafka property (e.g., security.protocol=SSL).

FORMAT STRINGS

$ %T  - Timestamp
%k  - Key
%s  - Message (payload)
%p  - Partition
%o  - Offset
%t  - Topic
copy

INSTALL

brew install kafkacat
copy

CAVEATS

Renamed to kcat in newer versions. Requires librdkafka. Not included with Kafka distribution. Some features need specific librdkafka version.

HISTORY

kafkacat was created by Magnus Edenhill, who also created librdkafka. It's been renamed to kcat but kafkacat remains widely used.

SEE ALSO

kcat(1), kafka(1), kafka-topics(1)

Braincup
Open source brain training for math, memory and focus
Braincup mini-games
41 mini-games · Apache-2.0
No ads · No tracking
Play in browser
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid
276 stars
From the maker of Linux Command Library
Copied to clipboard
Braincup
Open source brain training for math, memory and focus. 41 mini-games, from mental arithmetic to Sudoku, N-Back and Solo Chess.
Apache-2.0 licensed · No ads · No tracking · No account
From the maker of Linux Command Library
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid