ILM policy is notworking

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

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:

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.

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?

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

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

You need to apply on index settings.

ILM policy will be applied to new created indices.

I applied....and it says

{
  "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:

{
  "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:

"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:

{
  "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"
        }
      }
    }
  }
}

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:

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