I want to see the retention period set for a particular topic. Is there any command? I tried with
bin/kafka-topics.sh --zookeeper hostname:2181 --alter --config retention.ms=172800000 --topic <topic_name>
for deleting 2 days old data. But I want to see how many days are set in the retention period for all the topics.
log.retention.hours The most common configuration for how long Kafka will retain messages is by time. The default is specified in the configuration file using the log. retention. hours parameter, and it is set to 168 hours, the equivalent of one week.
If the log retention is set to five days, then the published message is available for consumption five days after it is published. After that time, the message will be de discarded to free up space. The performance of Kafka is not affected by the data size of messages, so retaining lots of data is not a problem.
The Kafka cluster retains all published messages—whether or not they have been consumed—for a configurable period of time. For example if the log retention is set to two days, then for the two days after a message is published it is available for consumption, after which it will be discarded to free up space.
If you have altered a topic and want to view the topic configuration the following command will be helpful
kafka-topics.sh --zookeeper localhost:2181 --describe --topics-with-overrides
This will describe only the topics along with configurations that have configurations set that differ from the cluster defaults.
If you want to view the configurations for all topic Either you can view these properties log.retention.hours
or log.retention.ms
in server.properties
in kafka config directory.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With