如何查看kafka消息

San*_*ndy 27 apache-kafka


有什么方法可以查看发送给kafka的消息内容给定的主题?如果有可能,请说一些关于查看此主题的最后5条消息的内容.

谢谢,Sandeep

vat*_*ada 55

您可以使用控制台使用者来查看在某些主题上生成的消息:

bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test --from-beginning
Run Code Online (Sandbox Code Playgroud)

  • 使用bin/kafka-console-consumer.sh --new-consumer --bootstrap-server localhost:9092 - topic test - from-beginning (2认同)
  • bootstrap-server和zookeeper是kafka版本的问题。 (2认同)

ken*_*tor 8

我在一家拥有数百名开发人员的公司工作,他们显然需要定期检查 Kafka 消息。员工来来去去,因此我们希望避免为每个新员工设置(专用 SASL 凭证、证书、ACL 等)。

我们的平台团队运行 Kowl ( https://github.com/cloudhut/kowl )的部署,以便每个人都可以访问它,而无需通过通常的设置。我们在使用 docker-compose 文件进行本地开发时也会使用它。

Kowl 消息列表


Mik*_*ail 6

在您的管理员运行 kafka 的服务器上通过命令找到kafka-console-consumer.shfind . -name kafka-console-consumer.sh然后转到该目录并运行从您的主题中读取消息

./kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test --from-beginning --max-messages 10

请注意,在这种情况下,主题中可能有很多消息,我使用--max-messages