How to check the status of Kafka on Linux?

To check the status of Kafka, you can use one of the following methods:

  1. You can use Kafka’s built-in command line tool kafka-topics.sh to view a list of topics and detailed information. To check the status of Kafka, you can run the following command.
./kafka-topics.sh --bootstrap-server <kafka服务器地址:端口> --list

This will list all the topic names in Kafka.

  1. Using JMX tools: Kafka provides a JMX interface for monitoring and managing the state of Kafka. You can use any JMX tool (such as JConsole, VisualVM) to connect to Kafka’s JMX interface and view various metrics and status information of Kafka.

To connect to Kafka’s JMX interface using JMX tools, you need to add the following configuration to Kafka’s startup configuration file, such as kafka-server.properties.

export JMX_PORT=<JMX端口号>

Upon starting Kafka, the JMX interface will listen on the specified port number. You can connect to this port using a JMX tool to view Kafka’s status information.

  1. Utilize Kafka’s built-in Metrics tool which exposes various metrics of Kafka through the Metrics interface, allowing for querying and monitoring of Kafka’s status.

To use the Metrics tool, you can execute the following command:

./kafka-metrics.sh --bootstrap-server <kafka服务器地址:端口>

This will print out various metrics information for Kafka.

Please note that the commands and options in the above methods may vary depending on the version and configuration of Kafka. Adjust the commands and options accordingly based on your specific circumstances.

bannerAds