Loading

Apply an index lifecycle policy to an existing Elasticsearch index

Stack

While index templates are typically used to automatically apply index lifecycle management (ILM) policies to new indices, you might need to apply a policy to an existing index. This page explains how to manually assign an ILM policy to an index through Kibana or using the Elasticsearch API, ensuring your existing data is managed according to lifecycle rules. This is useful if you want to:

  • Configure the indices to move through different data tiers as they age.
  • Perform lifecycle actions such as downsampling or shrinking.
  • Delete the indices when they reach a certain age.
Warning

Consider the following before manually applying a policy to an index:

  • If an index is currently managed by an ILM policy you must first remove that policy before applying a new one. To remove or make changes to an ILM policy currently applied to one or more indices, or to switch indices to use a different policy, refer to Update or switch an Elasticsearch index lifecycle policy.
  • Do not manually apply a policy that uses the rollover action. Policies that use rollover must be applied by the index template. Otherwise, the policy is not carried forward when the rollover action creates a new index. For an approach to migrating existing indices that supports rollover, refer to Migrate to ILM.

You can do this procedure in Kibana or using the Elasticsearch API.

To apply a lifecycle policy to an existing index:

  1. Go to the Index Management page using the navigation menu or the global search field.

  2. In the Indices tab, search for and select an index. Enable Include hidden indices to see the full list of indices.

  3. From the Manage index dropdown menu select Add lifecycle policy.

  4. Choose a lifecycle policy and confirm your changes.

Use the update settings API to apply a lifecycle policy to an index.

				PUT my-index/_settings
					{
  "index": {
    "lifecycle": {
      "name": "my_ilm_policy"
    }
  }
}
		

You can apply the same policy to multiple indices by using wildcards in the index name when you call the API.

				PUT my-indices*/_settings
					{
  "index": {
    "lifecycle": {
      "name": "my_ilm_policy"
    }
  }
}
		
Warning

Be careful not to inadvertently match indices that you don’t want to modify.

Once the policy is applied, ILM starts managing the index immediately.