How to view kafka message

前端 未结 8 1307
既然无缘
既然无缘 2021-02-01 12:10

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条回答
  • 2021-02-01 12:32

    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
    
    0 讨论(0)
  • 2021-02-01 12:36

    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.

    0 讨论(0)
  • 2021-02-01 12:37

    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

    0 讨论(0)
  • 2021-02-01 12:40

    Use the Kafka consumer provided by Kafka :

    bin/kafka-console-consumer.sh --bootstrap-server BROKERS --topic TOPIC_NAME
    

    It will display the messages as it will receive it. Add --from-beginning if you want to start from the beginning.

    0 讨论(0)
  • 2021-02-01 12:40

    If you doing from windows folder, I mean if you are using the kafka from windows machine

    kafka-console-consumer.bat --bootstrap-server localhost:9092 --<topic-name> test --from-beginning
    
    0 讨论(0)
  • 2021-02-01 12:43

    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

    0 讨论(0)
提交回复
热议问题