Create Lifecycle Policy APIedit

Creates or updates lifecycle policy.

Requestedit

PUT _ilm/policy/<policy_id>

Descriptionedit

Creates a lifecycle policy. If the specified policy exists, the policy is replaced and the policy version is incremented.

Note

Only the latest version of the policy is stored, you cannot revert to previous versions.

Path Parametersedit

policy (required)
(string) Identifier for the policy.

Request Parametersedit

timeout
(time units) Specifies the period of time to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. Defaults to 30s. For more information about time units, see Time unitsedit.
master_timeout
(time units) Specifies the period of time to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and returns an error. Defaults to 30s. For more information about time units, see Time unitsedit.

Authorizationedit

You must have the cluster manage privilege to use this API. For more information, see Security Privileges.

Examplesedit

The following example creates a new policy named my_policy:

PUT _ilm/policy/my_policy
{
  "policy": {
    "phases": {
      "warm": {
        "min_age": "10d",
        "actions": {
          "forcemerge": {
            "max_num_segments": 1
          }
        }
      },
      "delete": {
        "min_age": "30d",
        "actions": {
          "delete": {}
        }
      }
    }
  }
}

If the request succeeds, you receive the following result:

{
  "acknowledged": true
}