Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to query topic list and messages under topic by kafka

Shulou Source: shulou.com Published: 2022-06-01 16:18:08 10月04日 Update

This article mainly introduces kafka how to query the topic list and topic messages, the article is very detailed, has a certain reference value, interested friends must read it!

When using Kafka, you often come across the need to check whether the topic is created, or to view the data under the topic.

At first, if you want to go directly to the visualization tool to check it, you will find Kafka tool and find that the environment with less linked data is really easier to use, but if there is more data under topic or topic, it will be stuck and cannot be opened.

Simple use of Kafka tool

First, go to the official website to download Kafka tool: https://www.kafkatool.com/

Brainless next step for installation. Create a new link after the installation is complete

Because the data is all byte in Kafka, it is necessary to configure byte to string so that it can be viewed more easily.

In tools-- > settings-- > Topics

Then select the topic you want to view and configure key and message as string in properties

Then go to the partition under topic and click the green query button to view it.

If the amount of data is small, you can use this tool to view it, but if there is too much data, it will be stuck directly.

Use the Kafka command script to view

Since our company's Kafka is deployed in docker, we need to enter the Kafka container first, and then go to the opt/kafka/bin/ directory, where the Kafka script commands are located.

Check the kafka topic list kafka-topics.sh-list-- zookeeper zookeeper address: the port starts from scratch to view the data under kafka topic kafka-console-consumer.sh-- bootstrap-server localhost:9092-- topic topic_name-- from-beginning to view the data under topic by offset kafka-console-consumer.sh-- bootstrap-server localhost:9092-- topic topic_name-- offset latest-- partition address-- offset setting offset latest represents the last, you can set the range If you don't set the end, the default is to query latest (finally) #-when partition sets a partition to use offset query, you must set up a partition to query and clear all messages under Kafka topic kafka-topics.sh-- zookeeper zookeeper address: Port-- delete-- topic topic_name above is all the contents of the article "how to query topic list and messages under topic by kafka". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Tags: Data query message offset content command address tool directory port article script link configuration from scratch representative value company interest interval Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker macOS Huawei MariaDB Microsoft