# How to delete the setting of retention.ms from topic

**URL:** <https://forum.confluent.io/t/how-to-delete-the-setting-of-retention-ms-from-topic/2695>\
**Category:** Command Line tools\
**Created:** [10 September 2021 10:50 UTC](https://forum.confluent.io/t/how-to-delete-the-setting-of-retention-ms-from-topic/2695 "2021-09-10T10:50:38Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![comverse123](https://avatars.discourse-cdn.com/v4/letter/c/b487fb/32.png) [@comverse123](https://forum.confluent.io/u/comverse123)\
**Post date:** [10 September 2021 10:50 UTC](https://forum.confluent.io/t/how-to-delete-the-setting-of-retention-ms-from-topic/2695/1 "2021-09-10T10:50:38Z")

</div>

by default all topics in our kafka cluster are with retention `hours=24` , ( as defined in kafka server.properties )

we decided to decrease the retention hours only on topic `test` to `64000` ms

so we set the following retention hours - `64000` on topic test

```
kafka-configs.sh --zookeeper zoo_server:2181 --entity-type topics --alter --entity-name test -add-config retention.ms=64000

```

now we want to return the default retention hours on topic test ( to `24` hours ) ,as was before

we don’t sure if the following kafka cli , really return the retention hours to `24` on topic `test`

```
kafka-configs.sh --zookeeper zoo_server:2181 --alter --entity-type topics --entity-name test --delete-config retention.ms

```

as I know the above delete the configuration of the `retention in ms` but I not sure if this is really what above command is doing

please advice if I am wrong?

NOTE: in order to get all data about retention for particular topic in kafka , we can do

```
kafka-topics.sh --zookeeper zoo_server:2181 --describe --topics-with-overrides

```

reference- [How to see the retention for a particular topic in kafka - Stack Overflow](https://stackoverflow.com/questions/41135820/how-to-see-the-retention-for-a-particular-topic-in-kafka)

reference - [apache kafka - Delete topic level config - Stack Overflow](https://stackoverflow.com/questions/56220849/delete-topic-level-config)

additionally:

I can suggest other approach as:

```
kafka-configs.sh --zookeeper zoo_server:2181 --entity-type topics --alter --entity-name test -add-config retention.ms=86400000

```

its configure the 24 hours for test topic , but this is workaround  
but I preferred is to delete the configuration of retention in ms instead of set the retention in ms to `86400000`

---

<div class="post-metadata">

**Author:** ![danicafine](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/danicafine/32/2995_2.png) [@danicafine](https://forum.confluent.io/u/danicafine)\
**Post date:** [13 September 2021 19:14 UTC](https://forum.confluent.io/t/how-to-delete-the-setting-of-retention-ms-from-topic/2695/2 "2021-09-13T19:14:46Z")

</div>

Hello! First off, welcome to the Forum and congrats on your first post. 🙂

You are entirely correct. As per the [documentation](https://kafka.apache.org/documentation/#topicconfigs), you can rest assured that

```auto
> bin/kafka-configs.sh --bootstrap-server localhost:9092 --entity-type topics --entity-name my-topic
  --alter --delete-config retention.ms

```

is, in fact, removing the override that you had set and returning that config to cluster defaults. Hope that gives you peace of mind!

---

<div class="post-metadata">

**Author:** ![comverse123](https://avatars.discourse-cdn.com/v4/letter/c/b487fb/32.png) [@comverse123](https://forum.confluent.io/u/comverse123)\
**Post date:** [14 September 2021 10:17 UTC](https://forum.confluent.io/t/how-to-delete-the-setting-of-retention-ms-from-topic/2695/3 "2021-09-14T10:17:18Z")

</div>

thank you so much  
you answered on my Question

---

<div class="post-metadata">

**Author:** ![comverse123](https://avatars.discourse-cdn.com/v4/letter/c/b487fb/32.png) [@comverse123](https://forum.confluent.io/u/comverse123)\
**Post date:** [14 September 2021 10:18 UTC](https://forum.confluent.io/t/how-to-delete-the-setting-of-retention-ms-from-topic/2695/4 "2021-09-14T10:18:28Z")

</div>

I guess , after we returned the default config , then no need to restart the Kafka broker  
am I right?

---

<div class="post-metadata">

**Author:** ![danicafine](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/danicafine/32/2995_2.png) [@danicafine](https://forum.confluent.io/u/danicafine)\
**Post date:** [14 September 2021 14:56 UTC](https://forum.confluent.io/t/how-to-delete-the-setting-of-retention-ms-from-topic/2695/5 "2021-09-14T14:56:35Z")

</div>

No, I don’t believe so! I don’t recall ever having to do that for a topic config change.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex019/uploads/confluentcommunity/original/1X/c49438c90c9df282e9996fdf6971be890c71b65a.svg) [@system](https://forum.confluent.io/u/system)\
**Post date:** [21 September 2021 14:57 UTC](https://forum.confluent.io/t/how-to-delete-the-setting-of-retention-ms-from-topic/2695/6 "2021-09-21T14:57:16Z")

</div>

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
