# ILM policy is notworking

**URL:** <https://discuss.elastic.co/t/ilm-policy-is-notworking/267891>\
**Category:** Elasticsearch\
**Tags:** ilm-index-lifecycle-management\
**Created:** [March 20, 2021, 6:27pm UTC](https://discuss.elastic.co/t/ilm-policy-is-notworking/267891 "2021-03-20T18:27:20Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Narayan\_Banik](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/narayan_banik/32/84627_2.png) [@Narayan\_Banik](https://discuss.elastic.co/u/Narayan_Banik)\
**Post date:** [March 20, 2021, 6:27pm UTC](https://discuss.elastic.co/t/ilm-policy-is-notworking/267891/1 "2021-03-20T18:27:20Z")

</div>

I'm using ES 7.1... here is my ILM policy:

```auto
GET _ilm/policy/el_metric_policy 
{
  "el_metric_policy" : {
    "version" : 1,
    "modified_date" : "2021-03-20T15:53:20.941Z",
    "policy" : {
      "phases" : {
        "hot" : {
          "min_age" : "0ms",
          "actions" : {
            "rollover" : {
              "max_size" : "10mb",
              "max_age" : "10h"
            },
            "set_priority" : {
              "priority" : 100
            }
          }
        },
        "delete" : {
          "min_age" : "1h",
          "actions" : {
            "delete" : { }
          }
        }
      }
    }
  }
}

```

Here is my template:

```auto
GET _template/el_metric_template
 {
  "el_metric_template" : {
    "order" : 0,
    "index_patterns" : [
      "elasticsearch_metrics*"
    ],
    "settings" : {
      "index" : {
        "lifecycle" : {
          "name" : "el_metric_policy",
          "rollover_alias" : "el_metric"
        },
        "number_of_shards" : "1",
        "number_of_replicas" : "1"
      }
    },
    "mappings" : { },
    "aliases" : { }
  }
}

```

But my indices are still unmanaged.

```auto
GET elasticsearch_metrics-*/_ilm/explain
{
  "indices" : {
    "elasticsearch_metrics-2021.03.18" : {
      "index" : "elasticsearch_metrics-2021.03.18",
      "managed" : false
    },
    "elasticsearch_metrics-2021.03.20" : {
      "index" : "elasticsearch_metrics-2021.03.20",
      "managed" : false
    },
    "elasticsearch_metrics-2021.03.17" : {
      "index" : "elasticsearch_metrics-2021.03.17",
      "managed" : false
    },
    "elasticsearch_metrics-2021.03.19" : {
      "index" : "elasticsearch_metrics-2021.03.19",
      "managed" : false
    }
  }
}

```

What did i do wrong?

---

<div class="post-metadata">

**Author:** ![AClerk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aclerk/32/55297_2.png) [@AClerk](https://discuss.elastic.co/u/AClerk)\
**Post date:** [March 22, 2021, 4:29am UTC](https://discuss.elastic.co/t/ilm-policy-is-notworking/267891/2 "2021-03-22T04:29:34Z")

</div>

Are these new or old indices? Comparing to when the poilcy was created.

---

<div class="post-metadata">

**Author:** ![Narayan\_Banik](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/narayan_banik/32/84627_2.png) [@Narayan\_Banik](https://discuss.elastic.co/u/Narayan_Banik)\
**Post date:** [March 22, 2021, 5:41am UTC](https://discuss.elastic.co/t/ilm-policy-is-notworking/267891/3 "2021-03-22T05:41:59Z")

</div>

Old indices....I want to apply ILM for old indices. Pls help me.

---

<div class="post-metadata">

**Author:** ![AClerk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aclerk/32/55297_2.png) [@AClerk](https://discuss.elastic.co/u/AClerk)\
**Post date:** [March 22, 2021, 5:52am UTC](https://discuss.elastic.co/t/ilm-policy-is-notworking/267891/4 "2021-03-22T05:52:54Z")

</div>

You need to apply on index settings.

> **[Configure a lifecycle policy | Elasticsearch Reference \[7.11\] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/set-up-lifecycle-policy.html#apply-policy-multiple)**

ILM policy will be applied to new created indices.

---

<div class="post-metadata">

**Author:** ![Narayan\_Banik](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/narayan_banik/32/84627_2.png) [@Narayan\_Banik](https://discuss.elastic.co/u/Narayan_Banik)\
**Post date:** [March 22, 2021, 7:02am UTC](https://discuss.elastic.co/t/ilm-policy-is-notworking/267891/5 "2021-03-22T07:02:07Z")

</div>

I applied....and it says

```auto
{
  "indices" : {
    "elasticsearch_metrics-2021.03.21" : {
      "index" : "elasticsearch_metrics-2021.03.21",
      "managed" : true,
      "policy" : "el_metric_policy",
      "lifecycle_date_millis" : 1616334799345,
      "phase" : "hot",
      "phase_time_millis" : 1616336811421,
      "action" : "rollover",
      "action_time_millis" : 1616337275557,
      "step" : "ERROR",
      "step_time_millis" : 1616337874617,
      "failed_step" : "check-rollover-ready",
      "step_info" : {
        "type" : "illegal_argument_exception",
        "reason" : "index [el_metric] is not the write index for alias [elasticsearch_metrics-2021.03.21]",
        "stack_trace" : """
java.lang.IllegalArgumentException: index [el_metric] is not the write index for alias [elasticsearch_metrics-2021.03.21]
	at org.elasticsearch.xpack.core.indexlifecycle.WaitForRolloverReadyStep.evaluateCondition(WaitForRolloverReadyStep.java:100)
	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.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:835)

"""
      },

```

Here is my template:

```auto
{
  "el_metric_template" : {
    "order" : 0,
    "index_patterns" : [
      "elasticsearch_metrics*"
    ],
    "settings" : {
      "index" : {
        "lifecycle" : {
          "name" : "el_metric_policy",
          "rollover_alias" : "el_metric"
        },
        "number_of_shards" : "1",
        "number_of_replicas" : "1"
      }
    },
    "mappings" : { },
    "aliases" : { }
  }
}

```

ILM policy:

```auto
"el_metric_policy" : {
    "version" : 1,
    "modified_date" : "2021-03-21T13:57:07.016Z",
    "policy" : {
      "phases" : {
        "hot" : {
          "min_age" : "0ms",
          "actions" : {
            "rollover" : {
              "max_size" : "5mb"
            },
            "set_priority" : {
              "priority" : 100
            }
          }
        },
        "delete" : {
          "min_age" : "1h",
          "actions" : {
            "delete" : { }
          }
        }
      }
    }
  },

```

My indices:

```auto
{
  "elasticsearch_metrics-2021.03.22" : {
    "settings" : {
      "index" : {
        "lifecycle" : {
          "name" : "el_metric_policy",
          "rollover_alias" : "el_metric"
        },
        "number_of_shards" : "1",
        "provided_name" : "elasticsearch_metrics-2021.03.22",
        "creation_date" : "1616371238057",
        "priority" : "100",
        "number_of_replicas" : "1",
        "uuid" : "p6tOYm0jQjq-Q9elRsq9qg",
        "version" : {
          "created" : "7010099"
        }
      }
    }
  },
  "elasticsearch_metrics-2021.03.21" : {
    "settings" : {
      "index" : {
        "lifecycle" : {
          "name" : "el_metric_policy",
          "rollover_alias" : "el_metric"
        },
        "number_of_shards" : "1",
        "provided_name" : "elasticsearch_metrics-2021.03.21",
        "creation_date" : "1616334799345",
        "priority" : "100",
        "number_of_replicas" : "1",
        "uuid" : "2lxZ7XutRW-2oGGalGHLZQ",
        "version" : {
          "created" : "7010099"
        }
      }
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![AClerk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aclerk/32/55297_2.png) [@AClerk](https://discuss.elastic.co/u/AClerk)\
**Post date:** [March 23, 2021, 12:07am UTC](https://discuss.elastic.co/t/ilm-policy-is-notworking/267891/6 "2021-03-23T00:07:34Z")

</div>

How did you apply the settings?  
Not sure what is going on here, maybe someone from the elastic team can assist?  
Anyhow, try to remove the rollover from your template and test again.

Some discussions:

> [@Index management error: "Index is not the write index for alias"](https://discuss.elastic.co/t/index-management-error-index-is-not-the-write-index-for-alias/180894/2):
>
> Had the same thing happen. If you use the rollover API manually to do the rollover instead of using your ILM policy, each time the policy runs it will throw this error. This happens because the index is not being flagged as complete, when the policy runs it appears to be trying to manage the index but it's not flagged as writable. Add "index.lifecycle.indexing\_complete": "true" to the index in question, then clear the error by retrying the policy. When the policy next runs(default is every 1…

> [@Index \[filebeat-7.4.1-YYYY.MM.DD\] is not the write index for alias \[filebeat-7.4.1\]](https://discuss.elastic.co/t/index-filebeat-7-4-1-yyyy-mm-dd-is-not-the-write-index-for-alias-filebeat-7-4-1/206405):
>
> Hi, After installation on 1 filebeat agent to a new 7.4.1 Elastic cluster, I have the following errors on my filebeat indices: Index lifecycle error illegal\_argument\_exception: index [filebeat-7.4.1-2019.11.04] is not the write index for alias [filebeat-7.4.1] GET filebeat-7.4.1/\_ilm/explain "filebeat-7.4.1-2019.11.04" : { "index" : "filebeat-7.4.1-2019.11.04", "managed" : true, "policy" : "filebeat-7.4.1", "lifecycle\_date\_millis" : 1572822004864, "age" : "1…

> [@Index Lifecycle Error - Not Write Index](https://discuss.elastic.co/t/index-lifecycle-error-not-write-index/207068):
>
> Hello guys, i tried to implement an ilm-policy. Now i always get the following error: illegal\_argument\_exception: source alias [Syslog] does not point to a write index Now, i don't really get how i make this index my write index. Anybody got an idea how to solve this, without loosing data? Greets, Moritz

---

<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 20, 2021, 12:08am UTC](https://discuss.elastic.co/t/ilm-policy-is-notworking/267891/7 "2021-04-20T00:08:03Z")

</div>

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