I’ve been using kafka lately and this is a short post on a couple of the commands that I have used to get information from it when I am debugging.
One thing to note, kafka was running inside a docker container on my machine, so I needed to log into that container in order to run the commands, that is, I couldn’t run these commands from my host and expect any results (maybe I will learn how to later).
If you want to do that on your machine then use the following command to create a docker container for kafka, and one for zookeeper.
curl -sSL https://raw.githubusercontent.com/bitnami/containers/main/bitnami/kafka/docker-compose.yml > docker-compose.yml
docker-compose up -d
This means that you will find the commands (in the container) in
/opt/bitnami/kafka/bin/
The first thing that anyone needs to know is what topics have been created on the kafka instance.
$ kafka-topics.sh --list --bootstrap-server localhost:9092
Will provide that list.
The next thing that people want is to see all the messages that have been received by a given topic.
$ kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic your_topic_name --from-beginning
Which gives a list of the messages that that topic knows about.