# Apply ILM to existing index

**URL:** <https://discuss.elastic.co/t/apply-ilm-to-existing-index/334022>\
**Category:** Kibana\
**Tags:** ilm-index-lifecycle-management\
**Created:** [May 22, 2023, 2:01pm UTC](https://discuss.elastic.co/t/apply-ilm-to-existing-index/334022 "2023-05-22T14:01:56Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![ppic](https://avatars.discourse-cdn.com/v4/letter/p/3da27b/32.png) [@ppic](https://discuss.elastic.co/u/ppic)\
**Post date:** [May 22, 2023, 2:01pm UTC](https://discuss.elastic.co/t/apply-ilm-to-existing-index/334022/1 "2023-05-22T14:01:56Z")

</div>

Hello,

I use Elastic 7.17.  
I have created an ILM and applied it to the existing indexes through the Kibana UI (section Index Management).  
Each day, an index is automaticaly created but has no ILM associated.  
How can I make all these newly created indexes have the ILM automaticaly associated ?  
Is it possible through the UI, or do I have to run a command in the console ?  
Thank you for your advice.

---

<div class="post-metadata">

**Author:** ![Rios](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rios/32/95745_2.png) [@Rios](https://discuss.elastic.co/u/Rios)\
**Post date:** [May 22, 2023, 3:23pm UTC](https://discuss.elastic.co/t/apply-ilm-to-existing-index/334022/2 "2023-05-22T15:23:23Z")

</div>

You can do in Kibana. Check [video](https://www.youtube.com/watch?v=TPO6WzRp6Vo)

---

<div class="post-metadata">

**Author:** ![ppic](https://avatars.discourse-cdn.com/v4/letter/p/3da27b/32.png) [@ppic](https://discuss.elastic.co/u/ppic)\
**Post date:** [May 23, 2023, 5:24pm UTC](https://discuss.elastic.co/t/apply-ilm-to-existing-index/334022/3 "2023-05-23T17:24:06Z")

</div>

Hi Rios,

I didn't find an answer in this video.  
My problem is about the new indexes automaticaly created. They have no ILM.  
I guess the ILM have to be applied something that concerns all the indexes, past and future, like the index pattern.

---

<div class="post-metadata">

**Author:** ![leandrojmp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leandrojmp/32/107231_2.png) [@leandrojmp](https://discuss.elastic.co/u/leandrojmp)\
**Post date:** [May 23, 2023, 5:31pm UTC](https://discuss.elastic.co/t/apply-ilm-to-existing-index/334022/4 "2023-05-23T17:31:10Z")

</div>

> [@ppic](#):
>
> I guess the ILM have to be applied something that concerns all the indexes, past and future, like the index pattern.

You need to apply it to the template of your indices, if you do not have a template you will need to create one.

Take a look at the documentation about [index templates](https://www.elastic.co/guide/en/elasticsearch/reference/current/index-templates.html)

---

<div class="post-metadata">

**Author:** ![ppic](https://avatars.discourse-cdn.com/v4/letter/p/3da27b/32.png) [@ppic](https://discuss.elastic.co/u/ppic)\
**Post date:** [May 23, 2023, 5:50pm UTC](https://discuss.elastic.co/t/apply-ilm-to-existing-index/334022/5 "2023-05-23T17:50:15Z")

</div>

Hello,

I have an index template.  
In the doc, I see nothing about ILM.  
In Kibana, I checked the several pages of : Stack Management / Index Management / Templates / Edit template 'my\_template'  
and didn't find any reference to ILM.  
Where is it ?

---

<div class="post-metadata">

**Author:** ![leandrojmp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leandrojmp/32/107231_2.png) [@leandrojmp](https://discuss.elastic.co/u/leandrojmp)\
**Post date:** [May 23, 2023, 6:03pm UTC](https://discuss.elastic.co/t/apply-ilm-to-existing-index/334022/6 "2023-05-23T18:03:29Z")

</div>

The Lifecycle policy is a setting, you can add this setting in your index template.

You just need to add the setting `index.lifecycle.name` with the name of your lifecycle policy in the settings part of your template.

Something like this:

```auto
{
    "template": {
        "settings" : {
            "index" : {
              "lifecycle": {
                  "name": "policy-name"
              }
            }
        }
    }
}

```

Check this [example](https://www.elastic.co/guide/en/elasticsearch/reference/current/getting-started-index-lifecycle-management.html#ilm-gs-alias-apply-policy) in the documentation.

---

<div class="post-metadata">

**Author:** ![ppic](https://avatars.discourse-cdn.com/v4/letter/p/3da27b/32.png) [@ppic](https://discuss.elastic.co/u/ppic)\
**Post date:** [May 24, 2023, 9:02am UTC](https://discuss.elastic.co/t/apply-ilm-to-existing-index/334022/7 "2023-05-24T09:02:57Z")

</div>

Hi,

From this example, in the console I ran the command :

```auto
PUT _index_template/timeseries_template
{
  "index_patterns": ["the_index_pattern-*"],                 
  "template": {
    "settings": {
      "index.lifecycle.name": "the_policy"
    }
  }
}

```

The response was :

```auto
#! index template [timeseries_template] has index patterns [the_index_pattern-*] matching patterns from existing older templates [opentelemetry-lab-jaeger-service,opentelemetry-lab-jaeger-span,opentelemetry-dev-jaeger-span,otel-uat-data-jaeger-service,otel-dev-data-jaeger-service,xapi-dev-data-jaeger-service,xapi-uat-data-jaeger-service,opentelemetry-dev-jaeger-service,xapi-dev-data-jaeger-span,xapi-uat-data-jaeger-span,otel-dev-data-jaeger-span,otel-uat-data-jaeger-span] with patterns (opentelemetry-lab-jaeger-service => [*opentelemetry-lab-jaeger-service-*],opentelemetry-lab-jaeger-span => [*opentelemetry-lab-jaeger-span-*],opentelemetry-dev-jaeger-span => [*opentelemetry-dev-jaeger-span-*],otel-uat-data-jaeger-service => [*otel-uat-data-jaeger-service-*],otel-dev-data-jaeger-service => [*otel-dev-data-jaeger-service-*],xapi-dev-data-jaeger-service => [*xapi-dev-data-jaeger-service-*],xapi-uat-data-jaeger-service => [*xapi-uat-data-jaeger-service-*],opentelemetry-dev-jaeger-service => [*opentelemetry-dev-jaeger-service-*],xapi-dev-data-jaeger-span => [*xapi-dev-data-jaeger-span-*],xapi-uat-data-jaeger-span => [*xapi-uat-data-jaeger-span-*],otel-dev-data-jaeger-span => [*otel-dev-data-jaeger-span-*],otel-uat-data-jaeger-span => [*otel-uat-data-jaeger-span-*]); this template [timeseries_template] will take precedence during new index creation
{
  "acknowledged" : true
}

```

I don't understand the line #!.....  
but I see it is aknowledged.  
The last automatically created indexes still have `ilm.managed:false`, but I guess this command will be applied to future indexes.  
I will see tomorrow and tell you.

---

<div class="post-metadata">

**Author:** ![ppic](https://avatars.discourse-cdn.com/v4/letter/p/3da27b/32.png) [@ppic](https://discuss.elastic.co/u/ppic)\
**Post date:** [May 25, 2023, 8:22am UTC](https://discuss.elastic.co/t/apply-ilm-to-existing-index/334022/8 "2023-05-25T08:22:10Z")

</div>

This was not the solution.  
Despite this PUT command, the index automaticaly created today has no associated ILM.  
Another idea ?

---

<div class="post-metadata">

**Author:** ![ppic](https://avatars.discourse-cdn.com/v4/letter/p/3da27b/32.png) [@ppic](https://discuss.elastic.co/u/ppic)\
**Post date:** [June 5, 2023, 8:05am UTC](https://discuss.elastic.co/t/apply-ilm-to-existing-index/334022/9 "2023-06-05T08:05:55Z")

</div>

Hello,

The solution was not far.  
As I am not familiar with these query, I made some mistakes.

The full operating mode that worked for me is :

- 

> GET \_index\_template/my\_template\_name

you get a json output with the characteristics of my\_template\_name

- in the json output, in section `"template" : { "settings" : { "index" : { `  
(same level as: "codec", "best\_compression", "mapping", "number\_of\_shards" … )  
insert the line : `"lifecycle" : { "name" : "the_policy_name" }, `

- 

> PUT \_index\_template/my\_template\_name  
> { .... modified json .... }

and the newly created index have the ILM.

best rgds.

---

<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:** [July 3, 2023, 8:06am UTC](https://discuss.elastic.co/t/apply-ilm-to-existing-index/334022/10 "2023-07-03T08:06:25Z")

</div>

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