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
}

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