How to see the retention for a particular topic in kafka

manoj picture manoj · Dec 14, 2016 · Viewed 39.9k times · Source

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.

Answer

Abhimanyu picture Abhimanyu · Feb 22, 2017

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.