# Automate rollover for daily indices using ILM

**URL:** <https://discuss.elastic.co/t/automate-rollover-for-daily-indices-using-ilm/249233>\
**Category:** Elasticsearch\
**Tags:** ilm-index-lifecycle-management\
**Created:** [September 20, 2020, 4:30am UTC](https://discuss.elastic.co/t/automate-rollover-for-daily-indices-using-ilm/249233 "2020-09-20T04:30:12Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Akshay\_Pawar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/akshay_pawar/32/45475_2.png) [@Akshay\_Pawar](https://discuss.elastic.co/u/Akshay_Pawar)\
**Post date:** [September 20, 2020, 4:30am UTC](https://discuss.elastic.co/t/automate-rollover-for-daily-indices-using-ilm/249233/1 "2020-09-20T04:30:12Z")

</div>

Hello, I am looking into automating rollover using Index lifecycle management for daily indices.

I am looking for the pattern as follows so that I would be seamlessly able to search across all three indices

```auto
    rollover-test-2020.09.18 (pre-create template with this alias) 
        -rollover-test-2020.09.18-000001 (pre-create index)
        -rollover-test-2020.09.18-000002
        -rollover-test-2020.09.18-000003

    rollover-test-2020.09.19 (pre-create template with this alias)
        -rollover-test-2020.09.19-000001 (pre-create index)
        -rollover-test-2020.09.19-000002
        -rollover-test-2020.09.19-000003

```

As rollover API requires an alias, I have to pre-create indices so that I can use the `"is_write_index"` and `"alias"` setting for the original index. Also, I figured that I will have to pre-create template for every daily index so that it holds the `rollover_alias` (`rollover-test-2020-09-19` in above case) settings and when ILM rolls over the index, the new index can apply the rollover alias from the template.

Is there any better solution for this where in I don't have to create template for every daily index?

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [September 20, 2020, 9:23pm UTC](https://discuss.elastic.co/t/automate-rollover-for-daily-indices-using-ilm/249233/2 "2020-09-20T21:23:40Z")

</div>

Welcome to our community! 😃

If you are using ILM, then there's no need create daily indices like that. It's supposed to handle that for you.

---

<div class="post-metadata">

**Author:** ![Akshay\_Pawar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/akshay_pawar/32/45475_2.png) [@Akshay\_Pawar](https://discuss.elastic.co/u/Akshay_Pawar)\
**Post date:** [September 20, 2020, 9:38pm UTC](https://discuss.elastic.co/t/automate-rollover-for-daily-indices-using-ilm/249233/3 "2020-09-20T21:38:04Z")

</div>

@warkolm, I am creating daily indices because its an requirement.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [September 20, 2020, 9:42pm UTC](https://discuss.elastic.co/t/automate-rollover-for-daily-indices-using-ilm/249233/4 "2020-09-20T21:42:24Z")

</div>

Ok, but you can tell ILM to do that directly by using a `max_age` of `24h`.

ILM is not intended to me used in the way you are looking at.

---

<div class="post-metadata">

**Author:** ![Akshay\_Pawar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/akshay_pawar/32/45475_2.png) [@Akshay\_Pawar](https://discuss.elastic.co/u/Akshay_Pawar)\
**Post date:** [September 20, 2020, 10:01pm UTC](https://discuss.elastic.co/t/automate-rollover-for-daily-indices-using-ilm/249233/5 "2020-09-20T22:01:33Z")

</div>

The reason I am planning to use automated rollover for daily indices is to rollover the index when the index reaches ~25GB.  
Eg:  
When `rollover-test-2020.09.18-000001` reaches ~25GB, rollover so that a new index will be created `rollover-test-2020.09.18-000002` and shards would be distributed.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [September 20, 2020, 10:12pm UTC](https://discuss.elastic.co/t/automate-rollover-for-daily-indices-using-ilm/249233/6 "2020-09-20T22:12:57Z")

</div>

Yep I get that. The intent with ILM is that you also define the `max_age` to be `24h`, thereby also getting the daily rollover.

With your other approach, there's no way in ILM do do that. You'd need to do the setup each day, as you are effectively deploying a new policy each day.

---

<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:** [October 18, 2020, 10:13pm UTC](https://discuss.elastic.co/t/automate-rollover-for-daily-indices-using-ilm/249233/7 "2020-10-18T22:13:09Z")

</div>

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