Kafka is super popular and powerful data streaming platform but I’m surprised by lack of easy cli tool.
To find out version, there is no such thing as kafka --version
you do:
$ find /opt/kafka/libs/ -name kafka_\* | head -1
/opt/kafka/libs/kafka_2.13-2.4.0-test-sources.jar
where 2.13 is scala version and 2.4.0 is kafka version.
One tool that I played with is lovely called kaf, “Modern CLI for Kafka”.
to list topics, you do:
sudo bin/kafka-topics.sh --list --bootstrap-server localhost:9092
whereas with kaf you do:
$ kaf topics
to consume on console you do:
sudo bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test_topic
whereas with kaf you do:
kaf consume test_topic
just be able to omit –bootstrap-server etc makes you type less thus productive ;)
To install
go get github.com/birdayz/kaf/cmd/kaf
set auto-complete for zsh
echo 'source <(kaf completion zsh)' >> ~/.zshrc
for shell
echo 'source <(kaf completion bash)' >> ~/.bashrc
ADD and SELECT cluster ADD config for local
kaf config add-cluster local -b localhost:9092
This will create config file here:
~/.kaf/config
Then you can SELECT to use this config
kaf config select-cluster
Use the arrow keys to navigate: ↓ ↑ → ←
? Select cluster:
▸ local
prod-kafka
dev-kafka
LIST Kafka node
kaf node ls
LIST Kafka topics
kaf topics
Describe a topic
kaf topic describe ${topic}
List groups
kaf groups
Describe a group
You can see offset etc.
kaf group describe ${group}
LIST Kafka send message
echo '{"a": 123}' | kaf produce test_topic
LIST Kafka consume message
kaf consume test_topic --offset oldest|newest
Easy to install, easy to use, less typing and cluster def in yaml config. So why not use this!
Cheers!