# How to rollover to same index

**URL:** <https://discuss.elastic.co/t/how-to-rollover-to-same-index/239940>\
**Category:** Elasticsearch\
**Tags:** ilm-index-lifecycle-management\
**Created:** [July 6, 2020, 1:41am UTC](https://discuss.elastic.co/t/how-to-rollover-to-same-index/239940 "2020-07-06T01:41:36Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Prash7](https://avatars.discourse-cdn.com/v4/letter/p/51bf81/32.png) [@Prash7](https://discuss.elastic.co/u/Prash7)\
**Post date:** [July 6, 2020, 1:41am UTC](https://discuss.elastic.co/t/how-to-rollover-to-same-index/239940/1 "2020-07-06T01:41:36Z")

</div>

Hello Team,

I am trying to configure an ILM for a time series logs. Since they are logs, i am trying to impose a hot phase of 2d, and then essentially move them into the warm phase, where (i can proceed to mark them as read only, as they won't be written to, but will be queried, and **shrink** the indices.)

Below is the policy i had configured

```auto
PUT _ilm/policy/time_logs_data_policy
{
  "policy": {
    "phases": {
      "hot": {
        "actions": {
          "rollover": {
            "max_age": "2d"
          }
        }
      },
     "warm": {
        "actions": {
          "readonly" : { },
          "shrink" : {
            "number_of_shards": 20
          }
        }
      },
      "delete": {
        "min_age": "50d",
        "actions": {
          "delete": {}
        }
      }
    }
  }
}
PUT _template/index_template
{
  "index_patterns": ["time_logs_*"],
  "settings": {
    "index.lifecycle.name": "time_logs_data_policy"
  }
}

```

My indices would be created as such - `time_logs_2020_07_04`,` time_logs_2020_07_05` etc.

I see this exception with the configured ILM policy.

```auto
"""
java.lang.IllegalArgumentException: setting [index.lifecycle.rollover_alias] for index [time_logs_2020_06_24] is empty or not defined
	at org.elasticsearch.xpack.core.indexlifecycle.WaitForRolloverReadyStep.evaluateCondition(WaitForRolloverReadyStep.java:50)
	at org.elasticsearch.xpack.indexlifecycle.IndexLifecycleRunner.runPeriodicStep(IndexLifecycleRunner.java:133)
	at org.elasticsearch.xpack.indexlifecycle.IndexLifecycleService.triggerPolicies(IndexLifecycleService.java:270)
	at org.elasticsearch.xpack.indexlifecycle.IndexLifecycleService.triggered(IndexLifecycleService.java:213)
	at org.elasticsearch.xpack.core.scheduler.SchedulerEngine.notifyListeners(SchedulerEngine.java:168)
	at org.elasticsearch.xpack.core.scheduler.SchedulerEngine$ActiveSchedule.run(SchedulerEngine.java:196)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)

```

Now, i technically do not want to rollover to a new index, but essentially mark the index read only, and shrink it after 2d in hot phase. I see examples for actually rolling over to a new index.

eg. once `time_logs_2020_07_02` is 2 days old, ready to be rolled over (on average, each index has 40 shards), i want to shrink it to 20 shards, and still maintain the same index name.

Could anyone help in figuring out, how do i maintain the same index, but still have ILM rollover policies declared ?

---

<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:** [July 6, 2020, 10:54pm UTC](https://discuss.elastic.co/t/how-to-rollover-to-same-index/239940/2 "2020-07-06T22:54:24Z")

</div>

> [@Prash7](#):
>
> i technically do not want to rollover to a new index

This is not how ILM was designed, so it won't work like that sorry. It needs a write alias attached to it that you then write to, otherwise you will need to create a policy for each of these individual indices, which defeats the purpose.

> [@Prash7](#):
>
> on average, each index has 40 shards

Why so many?

---

<div class="post-metadata">

**Author:** ![Prash7](https://avatars.discourse-cdn.com/v4/letter/p/51bf81/32.png) [@Prash7](https://discuss.elastic.co/u/Prash7)\
**Post date:** [July 13, 2020, 12:22am UTC](https://discuss.elastic.co/t/how-to-rollover-to-same-index/239940/3 "2020-07-13T00:22:43Z")

</div>

Thank you @warkolm for helping me out.  
I understand. How would i set a write alias attached to it, so that, it can be still used to read effectively from it ?

eg. i have index for a day, `time_logs_2020_07_01`, after 2 days, i can rename this into something else, `time_logs_2020_07_01-1` with the help of ILM i however, still need to mark the newly created index as read-only, and proceed to shrink it, since it won't be written to anymore, but will be queried from. Then i need to add the old index ( `time_logs_2020_07_01`) as alias to newly created read-only index. I then need to delete the old one.

I searched online, but i wasn't able to figure out this ILM policy out.

We are working with a index per day, and that's why there are so many shards. (it includes 20 primary + 20 replicas) If this is not ideal, what should i be looking into? What are the effects of this ?

---

<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:** [July 13, 2020, 12:25am UTC](https://discuss.elastic.co/t/how-to-rollover-to-same-index/239940/4 "2020-07-13T00:25:04Z")

</div>

Have you looked at [ILM: Manage the index lifecycle | Elasticsearch Guide [8.11] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/index-lifecycle-management.html), it should explain what's needed.

> [@Prash7](#):
>
> We are working with a index per day, and that's why there are so many shards. (it includes 20 primary + 20 replicas) If this is not ideal, what should i be looking into? What are the effects of this ?

How big are your indices?

---

<div class="post-metadata">

**Author:** ![Prash7](https://avatars.discourse-cdn.com/v4/letter/p/51bf81/32.png) [@Prash7](https://discuss.elastic.co/u/Prash7)\
**Post date:** [July 13, 2020, 12:35am UTC](https://discuss.elastic.co/t/how-to-rollover-to-same-index/239940/5 "2020-07-13T00:35:34Z")

</div>

I did, and that's how i wrote the initial policy, which then did not work as intended.  
I am looking to shrink the already created indices, after 2 days. I think i should revisit, maybe i missed something. Thank you 🙂 @warkolm

Also, each index is around ~500-600gb.

---

<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:** [August 10, 2020, 12:35am UTC](https://discuss.elastic.co/t/how-to-rollover-to-same-index/239940/6 "2020-08-10T00:35:46Z")

</div>

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