Bala
Bala

Reputation: 45

How to check the retention period for a topic in Kafka?

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!

Upvotes: 2

Views: 8214

Answers (1)

Piyush Patel
Piyush Patel

Reputation: 1751

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

Upvotes: 4

Related Questions