How to see the retention for a particular topic in

2019-03-11 17:08发布

问题:

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 retention period for all the topics.

回答1:

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.



回答2:

See config 'log.retention.hours' in Kafka Doc:

The number of hours to keep a log file before deleting it (in hours), tertiary to log.retention.ms property

Default value is 168 hours which is 7 days.