Apply ILM to existing index


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.

You can do in Kibana. Check video

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.

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


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 ?

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

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

Something like this:

    "template": {
        "settings" : {
            "index" : {
              "lifecycle": {
                  "name": "policy-name"

Check this example in the documentation.


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

PUT _index_template/timeseries_template
  "index_patterns": ["the_index_pattern-*"],                 
  "template": {
    "settings": {
      "": "the_policy"

The response was :

#! 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.

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


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.

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