We are Borg
We are Borg

Reputation: 5313

ElasticSearch, AWS: Delete index data older than 4 days via ILM giving error

I am trying to add an ILM policy in AWS based ElasticSearch(7.9) to delete data older than 4 days, I am getting the following error :

Error log :

[illegal_argument_exception] State name is null

Policy :

{
    "policy": {
        "description": "Delete older than 4 days",
        "default_state": "hot",
        "states": [
            {
                "transitions": [
                    {
                        "state_name": "delete",
                        "conditions": {
                            "min_index_age": "4d"
                        }
                    }
                ]
            }
        ]
    }
}

What am I doing wrong?

Upvotes: 1

Views: 864

Answers (1)

YLR
YLR

Reputation: 1540

You must have a field 'name' for each "States". So in you case this looks like this :

{
    "policy": {
        "description": "Delete older than 4 days",
        "default_state": "hot",
        "states": [
            {
                "name": "hot",
                "actions": [],
                "transitions": [
                    {
                        "state_name": "delete",
                        "conditions": {
                            "min_index_age": "4d"
                        }
                    }
                ]
            },
            {
                "name": "delete",
                "actions": [
                   {
                     "delete":{}
                   }
                ],
                "transitions": []
            }
        ]
    }
}

As you can see, I've name this state "hot" cause it's your default state so I guess this default state must be describe in your policy. And for your information, this transition, made nothing (actions fields is empty). So I've written a second state call "detele" that will currently delete index.

Upvotes: 2

Related Questions