kafkacat
command-line Kafka producer and consumer
TLDR
Produce messages
$ echo "[message]" | kafkacat -P -b [localhost:9092] -t [topic]
Consume messages$ kafkacat -C -b [localhost:9092] -t [topic]
Consume from beginning$ kafkacat -C -b [localhost:9092] -t [topic] -o beginning
List topics$ kafkacat -L -b [localhost:9092]
Produce from file$ kafkacat -P -b [localhost:9092] -t [topic] [file.txt]
Consume with format$ kafkacat -C -b [localhost:9092] -t [topic] -f '[%T] %k: %s\n'
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.-X property=value
Set librdkafka property.
FORMAT STRINGS
$ %T - Timestamp
%k - Key
%s - Message (payload)
%p - Partition
%o - Offset
%t - Topic
%k - Key
%s - Message (payload)
%p - Partition
%o - Offset
%t - Topic
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
kafka(1), kafka-topics(1)
