Setting up a new policy

edit

This functionality is in beta and is subject to change. The design and code is less mature than official GA features and is being provided as-is with no warranties. Beta features are not subject to the support SLA of official GA features.

There are many new features introduced by ILM, but we will only focus on a few that are needed for our example. For starters, we will use the Put Policy API to define our first policy. Lifecycle policies are defined in JSON and include specific phases and actions.

PUT _ilm/policy/datastream_policy   
{
  "policy": {                       
    "phases": {
      "hot": {                      
        "actions": {
          "rollover": {             
            "max_size": "50GB",
            "max_age": "30d"
          }
        }
      },
      "delete": {
        "min_age": "90d",           
        "actions": {
          "delete": {}              
        }
      }
    }
  }
}

call to the put lifecycle API endpoint to create a new policy named "datastream_policy"

policy definition sub-object

the hot phase defined in the "phases" section. Optional min_age field not defined — defaults to 0ms

rollover action definition

delete phase begins after 90 days

delete action definition

Here we created the policy called datastream_policy which rolls over the index being written to after it reaches 50 gigabytes, or it is 30 days old. The rollover will occur when either of these conditions is true. The index will be deleted 90 days after it is rolled over.