# ILM delete all indices in X days

**URL:** <https://discuss.elastic.co/t/ilm-delete-all-indices-in-x-days/267127>\
**Category:** Elasticsearch\
**Tags:** ilm-index-lifecycle-management\
**Created:** [March 12, 2021, 10:37pm UTC](https://discuss.elastic.co/t/ilm-delete-all-indices-in-x-days/267127 "2021-03-12T22:37:17Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![d4nnyx](https://avatars.discourse-cdn.com/v4/letter/d/e99b99/32.png) [@d4nnyx](https://discuss.elastic.co/u/d4nnyx)\
**Post date:** [March 12, 2021, 10:37pm UTC](https://discuss.elastic.co/t/ilm-delete-all-indices-in-x-days/267127/1 "2021-03-12T22:37:17Z")

</div>

Hello,

I need some help with understanding ILM configuration.

Here is my configuration for ILM

```auto
PUT _ilm/policy/example
{
  "policy": {
    "phases": {
      "hot": {
        "min_age": "0ms",
        "actions": {
          "rollover": {
            "max_size": "40gb",
            "max_age": "7d"
          }
        }
      },
      "warm": {
        "actions": {
          "forcemerge": {
            "max_num_segments": 1
          },
          "migrate": {
            "enabled": false
          },
          "shrink": {
            "number_of_shards": 1
          }
        }
      },
      "delete": {
        "min_age": "14d",
        "actions": {
          "delete": {
            "delete_searchable_snapshot": true
          }
        }
      }
    }
  }
}

```

I want to keep all indices max 14 days. Problem is that time for deleting is counted from rollover, which can be processed in 1-7 days. So there are some indices which can be deleted after 14 days (1st day rollover, then 14 days to delete phase), but there are many which can be deleted after 21 days (rollover after 7 days + 14 days to phase age).

Curator was the first idea which came to my mind, I could omit the delete phase and use curator to delete index older than 14 days.

My second idea is that I have a wrong settings on ILM, but I cannot figure how to do it. Is there a posibility to achive what I just described?

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [March 12, 2021, 10:40pm UTC](https://discuss.elastic.co/t/ilm-delete-all-indices-in-x-days/267127/2 "2021-03-12T22:40:36Z")

</div>

Your retention period is very short compared to the max period each index covers. If you are keeping 14 days of data I would rollover after a day or two.

---

<div class="post-metadata">

**Author:** ![d4nnyx](https://avatars.discourse-cdn.com/v4/letter/d/e99b99/32.png) [@d4nnyx](https://discuss.elastic.co/u/d4nnyx)\
**Post date:** [March 12, 2021, 10:46pm UTC](https://discuss.elastic.co/t/ilm-delete-all-indices-in-x-days/267127/3 "2021-03-12T22:46:40Z")

</div>

That has its purpose. There are some indices, which grows slowly and some which grows very quickly. If I had 1 day rollover, there will be many small indices (hundreds of kb size), which is not good for ES as i read in the docs. 7 days rollover means 7 times less these small indices. Sounds reasonable to you?

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [March 12, 2021, 10:48pm UTC](https://discuss.elastic.co/t/ilm-delete-all-indices-in-x-days/267127/4 "2021-03-12T22:48:48Z")

</div>

It does, but that is also what limits the accuracy of deletion.

---

<div class="post-metadata">

**Author:** ![andreidan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andreidan/32/78167_2.png) [@andreidan](https://discuss.elastic.co/u/andreidan)\
**Post date:** [March 18, 2021, 1:35pm UTC](https://discuss.elastic.co/t/ilm-delete-all-indices-in-x-days/267127/5 "2021-03-18T13:35:25Z")

</div>

Thanks for using Elasticsearch and ILM.

Phase transition timings can be calculated based on the index creation time (instead of rollover time) if the origination date is configured for the managed indices (as described [here](https://www.elastic.co/blog/control-ilm-phase-transition-timings-using-origination-date) )

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [April 15, 2021, 1:35pm UTC](https://discuss.elastic.co/t/ilm-delete-all-indices-in-x-days/267127/6 "2021-04-15T13:35:47Z")

</div>

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