How to add deletion phase in policy (POST does not seem to work)

I am trying to add a deletion phase in an existing policy. The policy works fine, creating new indices every day.
However, I cannot add a deletion phase. Since this is not possible from the UI, I tried with a POST :

But this does not seem to work... Why are the PUT and POST rejected - is it not possible to update it, only to create a new one that includes the delete phase?

Here is the policy:

{
  "myindexpolicy" : {
    "version" : 1,
    "modified_date" : "2023-02-17T12:05:04.639Z",
    "policy" : {
      "phases" : {
        "hot" : {
          "min_age" : "0ms",
          "actions" : {
            "set_priority" : {
              "priority" : 100
            },
            "rollover" : {
              "max_primary_shard_size" : "1gb",
              "max_age" : "1d"
            }
          }
        }
      }
    },
    "in_use_by" : {
      "indices" : [
        "myindexalias-000008",
        "myindexalias-000009",
        "myindexalias-000015",
        "myindexalias-000004",
        "myindexalias-000016",
        "myindexalias-000005",
        "myindexalias-000006",
        "myindexalias-000017",
        "myindexalias-000007",
        "myindexalias-000011",
        "myindexalias-000012",
        "myindexalias-000013",
        "myindexalias-000002",
        "myindexalias-000003",
        "myindexalias-000014",
        "myindexalias-000010"
      ],
      "data_streams" : [ ],
      "composable_templates" : [
        "mts_template"
      ]
    }
  }
}

And here is the POST (also tried PUT)

POST /_ilm/policy/myindexpolicy/_update
{
  "policy": {
    "phases": {
      "delete": {
        "min_age": "30d",
        "actions": {
          "delete": {}
        }
      }
    }
  }
}

Here is the error message:

{
  "error" : {
    "root_cause" : [
      {
        "type" : "x_content_parse_exception",
        "reason" : "[2:3] [UpdateRequest] unknown field [policy]"
      }
    ],
    "type" : "x_content_parse_exception",
    "reason" : "[2:3] [UpdateRequest] unknown field [policy]"
  },
  "status" : 400
}

PUT gives

 "error" : "Incorrect HTTP method for uri [/_ilm/policy/myindexpolicy/_update?pretty=true] and method [PUT], allowed: [POST]",
  "status" : 405

@Mark_S

There is no _update directive for ILM API for create, create and update are the same although it will version the ILM Polocy

You simply PUT a complete new policy, there is no partial update, there is no POST with _update

You should be... it is easy to miss but you need to select the little Trashcan symbol on the right hand side

1 Like

@stephenb : Thank you!

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