The Kafka Topic Size Tool is a command-line utility that provides information about the size of topics in a Kafka cluster. It utilizes the Kafka command-line tools kafka-topics
and kafka-log-dirs
to retrieve and analyze the size information.
You can install the Kafka Topic Size Tool from PyPI using pip
:
pip install ksize
ksize -b <bootstrap-server> [-c <config>] (-t <topic> | -a) [-o <output>]
-b
,--bootstrap-server
: The Kafka cluster to connect to (e.g.,localhost:9092
).-c
,--config
: The path to the Kafka config file.-t
,--topic
: The topic or list of topics to get the size for.-a
,--all
: Get the size for all topics.-o
,--output
: Send output to a file.
- Get the size of a specific topic:
ksize -b localhost:9092 -c /path/to/config/file.conf -t my_topic -o output.txt
- Get the size of all topics:
ksize -b localhost:9092 -c /path/to/config/file.conf -a -o output.txt
- Either
--topic
or--all
is required. - Make sure you have the Kafka command-line tools (
kafka-topics
andkafka-log-dirs
) installed and available in your system's PATH. - The tool calculates the size of topics in megabytes (MB).
- If an error occurs during the process, it will be displayed in the console output.
This tool is provided under the MIT License. Feel free to use, modify, and distribute it according to the terms of the license.