2

I like to know how to get the retention period for Kafka topics. Our Kafka Cluster's default retention is seven days i.e. log.retention.hours=168 But for some topics it is configured with custom retention period like 3 days.

Kafka version is 0.10.0.1 and I tried below command it is not giving retention period details.

/bin/kafka-topics.sh -zookeeper localhost:2181 --describe --topic <topic-name>

displayed below output without retention details. 
--------------------------------------------------
Topic:<topic-name> PartitionCount:50       ReplicationFactor:2     Configs:
Topic: <topic-name>       Partition: 0    Leader: 7       Replicas: 7,22  Isr: 7,22

Thanks in advance!

Bala
  • 45
  • 1
  • 9
  • 1
    Possible duplicate of [How to see the retention for a particular topic in kafka](https://stackoverflow.com/questions/41135820/how-to-see-the-retention-for-a-particular-topic-in-kafka) – Ankit Deshpande Oct 21 '19 at 18:52

1 Answers1

4

If your retention period has been changed then it will appear in Configs. From the output, I can see that you haven't set retention.ms configuration and hence the default retention period will apply.

If you haven't changed any configuration, it should be 7 days (168 hours).

Below is a sample output for changed retention.

Topic:<topic_name> PartitionCount:12 ReplicationFactor:3 Configs:retention.ms=18000000

Piyush Patel
  • 1,646
  • 1
  • 14
  • 26
  • 2
    using the command ```bin/kafka-topics.sh -zookeeper localhost:2181 --describe --topics-with-overrides``` we can also get the list of topics with with non-default retention. – Bala Oct 21 '19 at 20:38
  • Yes it gives topics whose configuration has been changed. – Piyush Patel Oct 21 '19 at 20:41