Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to alter the TTL for a particular topic in Kafka

Tags:

apache-kafka

I would like to update the TTL of a specific Kafka topic to 10 days.

How can I do that?

like image 872
Sat Avatar asked Jul 20 '17 14:07

Sat


People also ask

How do you check the retention time of a Kafka topic?

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.

What is the default retention period in Kafka?

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.

What is retention policy in Kafka topic?

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.


1 Answers

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
like image 94
ppatierno Avatar answered Nov 12 '22 23:11

ppatierno