I would like to update the TTL of a specific Kafka topic to 10 days.
How can I do that?
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.
Default retention period for Segments is 7 days. Here are the parameters (in decreasing order of priority) that you can set in your Kafka broker properties file: Size Based Retention: In this policy, we configure the maximum size of a Log data structure for a Topic partition.
Kafka Topic Retention For time based retention, the message log retention is based on either hours, minutes or milliseconds. In terms of priority to be actioned by the cluster milliseconds will win, always. You can set all three but the lowest unit size will be used. retention.ms takes priority over retention.
You previously asked about that and I already replied here : Update TTL for a particular topic in kafka using Java
Unless you are asking to do that using Kafka tools? (And not in Java) In this case there is the kafka-topics.sh command line tool, allowing you to do that using the --alter option.
bin/kafka-topics.sh --alter --zookeeper localhost:2181 --topic test --config retention.ms=10000
Because altering using kafka-topics script could be removed in next release, you should use the kafka-configs script:
bin/kafka-configs.sh --zookeeper localhost:2181 --alter --entity-type topics --entity-name test --add-config retention.ms=5000
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