# Purpose of "Data Retention" in index template

**URL:** <https://discuss.elastic.co/t/purpose-of-data-retention-in-index-template/371552>\
**Category:** Elasticsearch\
**Created:** [December 5, 2024, 4:23pm UTC](https://discuss.elastic.co/t/purpose-of-data-retention-in-index-template/371552 "2024-12-05T16:23:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stephen\_IAnson](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephen_ianson/32/137582_2.png) [@Stephen\_IAnson](https://discuss.elastic.co/u/Stephen_IAnson)\
**Post date:** [December 5, 2024, 4:23pm UTC](https://discuss.elastic.co/t/purpose-of-data-retention-in-index-template/371552/1 "2024-12-05T16:23:36Z")

</div>

Hi,

Can someone explain to me what the purpose of the data retention field is in an index template?  
My understanding is that the ILM is responsible for moving data between phases, rollover and optionally deletion. What is the effect of setting e.g. 3 hours data retention on the index template but then setting 1 day on the delete phase in the relevant ILM?

Thanks

---

<div class="post-metadata">

**Author:** ![strawgate](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/strawgate/32/131008_2.png) [@strawgate](https://discuss.elastic.co/u/strawgate)\
**Post date:** [December 5, 2024, 4:31pm UTC](https://discuss.elastic.co/t/purpose-of-data-retention-in-index-template/371552/2 "2024-12-05T16:31:17Z")

</div>

> [@Stephen\_IAnson](#):
>
> data retention field is in an index template

The `template.lifecycle. data_retention` field is how you configure the new Datastream Lifecycle management (DLM), an alternative to ILM that is built right into the datastream settings: [Data stream lifecycle | Elasticsearch Guide [8.16] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/data-stream-lifecycle.html)

You do not have to use it but it can simplify management in many use-cases.

If a datastream is covered under both an ILM policy and there is DLM configured, only one system will work at a time on each underlying index as explained here: [Tutorial: Migrate ILM managed data stream to data stream lifecycle | Elasticsearch Guide [8.16] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/tutorial-migrate-data-stream-from-ilm-to-dsl.html) -- you can use the setting `index.lifecycle.prefer_ilm` to pick the winner if you are applying both.

---

<div class="post-metadata">

**Author:** ![Stephen\_IAnson](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephen_ianson/32/137582_2.png) [@Stephen\_IAnson](https://discuss.elastic.co/u/Stephen_IAnson)\
**Post date:** [December 5, 2024, 5:15pm UTC](https://discuss.elastic.co/t/purpose-of-data-retention-in-index-template/371552/3 "2024-12-05T17:15:02Z")

</div>

great stuff, thx
