Is there any way I can view the message content sent to kafka for a given topic? Say some thing like view last 5 messages for this topic, if that it possible.
8 Answers
I work for a company with hundreds of developers who obviously need to check Kafka messages on a regular basis. Employees come and go and therefore we want to avoid the setup (dedicated SASL credentials, certificates, ACLs, ...) for each new employee.
Our platform teams operate a deployment of Kowl (https://github.com/cloudhut/kowl) so that everyone can access it without going through the usual setup. We also use it when developing locally using a docker-compose file.
On server where your admin run kafka find kafka-console-consumer.sh by command find . -name kafka-console-consumer.sh
then go to that directory and run for read message from your topic
./kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test --from-beginning --max-messages 10
note that in topic may be many messages in that case I use --max-messages key
You can try Kafka Magic - it's free and you can write complex queries in JavaScript referencing message properties and metadata. Works with Avro serialization too
Old version includes kafka-simple-consumer-shell.sh
(https://kafka.apache.org/downloads#1.1.1) which is convenient since we do not need cltr+c
to exit.
For example
kafka-simple-consumer-shell.sh --broker-list $BROKERIP:$BROKERPORT --topic $TOPIC1 --property print.key=true --property key.separator=":" --no-wait-at-logend