LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

kcat

generic non-JVM producer and consumer for Apache Kafka

TLDR

Consume messages from topic
$ kcat -b [localhost:9092] -t [topic] -C
copy
Produce message to topic
$ echo "[message]" | kcat -b [localhost:9092] -t [topic] -P
copy
List metadata
$ kcat -b [localhost:9092] -L
copy
Consume with custom format
$ kcat -b [localhost:9092] -t [topic] -C -f '%k: %s\n'
copy
Consume from beginning
$ kcat -b [localhost:9092] -t [topic] -C -o beginning
copy
Query watermarks
$ kcat -b [localhost:9092] -t [topic] -Q
copy

SYNOPSIS

kcat [options] mode

DESCRIPTION

kcat (formerly kafkacat) is a generic non-JVM producer and consumer for Apache Kafka. Written in C using librdkafka, it provides a lightweight CLI for interacting with Kafka clusters. It supports producing, consuming, listing metadata, querying offsets, and working with Avro/JSON payloads via Schema Registry.

PARAMETERS

-b brokers

Comma-separated Kafka broker list (host[:port]).
-t topic
Topic to produce to or consume from.
-p partition
Partition to produce to or consume from.
-C
Consumer mode.
-P
Producer mode.
-L
Metadata list mode.
-Q
Query offsets by timestamp.
-G group
High-level consumer group (requires broker >= 0.9.0).
-o offset
Starting offset (beginning, end, stored, or numeric; negative counts from end).
-e
Exit after consuming the last message.
-q
Quiet mode, no informational output.
-f format
Output format string (e.g. `%t %p %o %k %s\n`).
-J
Output messages in a JSON envelope.
-K sep
Key delimiter for produce/consume.
-D sep
Message delimiter (default newline).
-X prop=val
Set a librdkafka configuration property.
-F file
Read librdkafka config from file.

INSTALL

sudo apt install kcat
copy
sudo dnf install kcat
copy
sudo apk add kcat
copy
brew install kcat
copy
nix profile install nixpkgs#kcat
copy

HISTORY

Originally named kafkacat, the tool was renamed to kcat in 2021 to align with upstream branding. Both names may still be present depending on the distribution's packaging.

SEE ALSO

Copied to clipboard
Kai