Loading

Manually apply a lifecycle policy to an index

Stack

When you create a new Elasticsearch index, it automatically picks up settings, mappings, and aliases from any matching index template and its component templates. If the template specifies a lifecycle policy, that policy is applied to the new index as soon as it's created so that the index will be managed by ILM. This process is described in detail in Configure a lifecycle policy.

You can also apply a lifecycle policy manually to existing indices that are not yet managed, as described on this page. 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 a 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 Stack Management > Index Management. In the Indices tab, search for and select an index. Enable Include hidden indices to see the full list of indices.

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

  3. 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.