How to assign ISM policy to existing indices

Hi Team,

I have indices by name proapps-* and have created a below policy to it. Can someone please guide how to attach the policy to existing indices already created?

{
    "policy_id": "ProApps-Policy",
    "description": "hot warm delete workflow",
    "last_updated_time": 1633492037659,
    "schema_version": 1,
    "error_notification": null,
    "default_state": "hot",
    "states": [
        {
            "name": "hot",
            "actions": [
                {
                    "rollover": {
                        "min_index_age": "1d"
                    }
                }
            ],
            "transitions": [
                {
                    "state_name": "warm"
                }
            ]
        },
        {
            "name": "warm",
            "actions": [
                {
                    "replica_count": {
                        "number_of_replicas": 2
                    }
                }
            ],
            "transitions": [
                {
                    "state_name": "delete",
                    "conditions": {
                        "min_index_age": "90d"
                    }
                }
            ]
        },
        {
            "name": "delete",
            "actions": [
                {
                    "notification": {
                        "destination": {
                            "chime": {
                                "url": "<URL>"
                            }
                        },
                        "message_template": {
                            "source": "The index {{ctx.index}} is being deleted",
                            "lang": "mustache"
                        }
                    }
                },
                {
                    "delete": {}
                }
            ],
            "transitions": []
        }
    ],
    "ism_template": null
}
1 Like

Policies can be added to indices in two ways:

  • Rest API
  • using index pattern inside policy - “ism_template” field

We have add policy API which can be used to add existing policies to indices that don’t currently have any policy attached to them

We have update managed index policy API to change policy of currently managed index


The ism_template inside policy can be used to hold index pattern and when a new index created with matching pattern policy will get added to the index

1 Like

Hi, sorry to resurrect the thread but I’m having an issue assigning policies to existing indices.
The documentation here states:

enter any ISM template patterns to automatically apply this policy to existing and future indexes

but when I create an policy with an index pattern, the policy is not assigned to any existing indices. And I don’t see anything in the logs that can give me a clue to what’s happening.

Hi @fgento,

The documentation is incorrect, ism_templates only apply to future created indices.
To add the policy to existing indices you have to use the Add Policy API.

We’ll fix the documentation, thanks for pointing it out.

1 Like

Thanks, I was going crazy looking for anything I might’ve misconfigured.