# ISM policy for deletion after a certain period of time

**URL:** <https://forum.opensearch.org/t/ism-policy-for-deletion-after-a-certain-period-of-time/9381>\
**Category:** Open Source Elasticsearch and Kibana\
**Tags:** discuss\
**Created:** [April 25, 2022, 10:30am UTC](https://forum.opensearch.org/t/ism-policy-for-deletion-after-a-certain-period-of-time/9381 "2022-04-25T10:30:16Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![priyankasharma](https://avatars.discourse-cdn.com/v4/letter/p/7c8e57/32.png) [@priyankasharma](https://forum.opensearch.org/u/priyankasharma)\
**Post date:** [April 25, 2022, 10:30am UTC](https://forum.opensearch.org/t/ism-policy-for-deletion-after-a-certain-period-of-time/9381/1 "2022-04-25T10:30:16Z")

</div>

I just want to delete the indexes directly after its min age but i don’t want index to go into hot or warm stage.

A nd also right now i have created a policy it will take more then the defined min age time to delete.

{  
“policy\_id”: “delete\_after\_2\_days”,  
“description”: “Policy that deletes indicies older than 20sec.”,  
“last\_updated\_time”: 1650533329086,  
“schema\_version”: 1,  
“error\_notification”: null,  
“default\_state”: “close”,  
“states”: [  
{  
“name”: “close”,  
“actions”: [  
{  
“close”: {}  
}  
],  
“transitions”: [  
{  
“state\_name”: “delete”,  
“conditions”: {  
“min\_index\_age”: “10s”  
}  
}  
]  
},  
{  
“name”: “delete”,  
“actions”: [  
{  
“delete”: {}  
}  
],  
“transitions”:   
}  
],  
“ism\_template”: [  
{  
“index\_patterns”: [  
“yset-index-\*”  
],  
“priority”: 0,  
“last\_updated\_time”: 1650450452750  
}  
]  
}

---

<div class="post-metadata">

**Author:** ![priyankasharma](https://avatars.discourse-cdn.com/v4/letter/p/7c8e57/32.png) [@priyankasharma](https://forum.opensearch.org/u/priyankasharma)\
**Post date:** [April 28, 2022, 6:04am UTC](https://forum.opensearch.org/t/ism-policy-for-deletion-after-a-certain-period-of-time/9381/2 "2022-04-28T06:04:04Z")

</div>

Hi Team ,

Can somebody help me here

---

<div class="post-metadata">

**Author:** ![mmamaenko](https://avatars.discourse-cdn.com/v4/letter/m/22d042/32.png) [@mmamaenko](https://forum.opensearch.org/u/mmamaenko)\
**Post date:** [April 28, 2022, 11:55am UTC](https://forum.opensearch.org/t/ism-policy-for-deletion-after-a-certain-period-of-time/9381/3 "2022-04-28T11:55:58Z")

</div>

you set min index age to 10 sec. I am not sure but task to check all policy conditions is not running every 10 sec. put more usable age, 5 min for instance

---

<div class="post-metadata">

**Author:** ![priyankasharma](https://avatars.discourse-cdn.com/v4/letter/p/7c8e57/32.png) [@priyankasharma](https://forum.opensearch.org/u/priyankasharma)\
**Post date:** [April 28, 2022, 12:02pm UTC](https://forum.opensearch.org/t/ism-policy-for-deletion-after-a-certain-period-of-time/9381/4 "2022-04-28T12:02:04Z")

</div>

Thanks for reply ,  
I have already test this with 1day min index age , also 5 min but still it takes more then 5 min to delete .

can you explain me how much time opensearch take to initialize any policy over an index pattern.

can we also the change the job\_interval time in opensearch ?

---

<div class="post-metadata">

**Author:** ![mmamaenko](https://avatars.discourse-cdn.com/v4/letter/m/22d042/32.png) [@mmamaenko](https://forum.opensearch.org/u/mmamaenko)\
**Post date:** [April 28, 2022, 12:21pm UTC](https://forum.opensearch.org/t/ism-policy-for-deletion-after-a-certain-period-of-time/9381/5 "2022-04-28T12:21:22Z")

</div>

> **[Settings](https://opensearch.org/docs/latest/im-plugin/ism/settings/)**
>
> ISM settings

---

<div class="post-metadata">

**Author:** ![priyankasharma](https://avatars.discourse-cdn.com/v4/letter/p/7c8e57/32.png) [@priyankasharma](https://forum.opensearch.org/u/priyankasharma)\
**Post date:** [April 29, 2022, 10:33am UTC](https://forum.opensearch.org/t/ism-policy-for-deletion-after-a-certain-period-of-time/9381/6 "2022-04-29T10:33:52Z")

</div>

Hi ,

I am not able to change the setting of cluster. Can you please check with this

PUT /\_cluster/settings  
{  
“transient”: {  
“opendistro.index\_state\_management.job\_interval” : “5 Minute”  
}  
}

showing “Message”:“Your request: ‘/\_cluster/settings’ payload is not allowed.”}

---

<div class="post-metadata">

**Author:** ![mmamaenko](https://avatars.discourse-cdn.com/v4/letter/m/22d042/32.png) [@mmamaenko](https://forum.opensearch.org/u/mmamaenko)\
**Post date:** [April 29, 2022, 11:33am UTC](https://forum.opensearch.org/t/ism-policy-for-deletion-after-a-certain-period-of-time/9381/7 "2022-04-29T11:33:33Z")

</div>

didn’t work with opensearch, mainly with opendistro. I remember that some of security settings requires to use client certificate:  
curl --cert ./config/admin.pem --key ./config/admin.key -XPUT [http://admin:password@localhost:9200/xxxxx](http://admin:password@localhost:9200/xxxxx)  
You also may change the settings in configuration file itself

---

<div class="post-metadata">

**Author:** ![priyankasharma](https://avatars.discourse-cdn.com/v4/letter/p/7c8e57/32.png) [@priyankasharma](https://forum.opensearch.org/u/priyankasharma)\
**Post date:** [April 30, 2022, 5:42pm UTC](https://forum.opensearch.org/t/ism-policy-for-deletion-after-a-certain-period-of-time/9381/8 "2022-04-30T17:42:25Z")

</div>

Okay Thanks ,  
One last question if i need to delete the previous index after somedays in opensearch when shards got max without taking care of time is it the right approach i am following???

{  
“policy\_id”: “delete\_index\_after\_open\_close\_5mins”,  
“description”: “Policy that deletes indicies older than 20sec.”,  
“last\_updated\_time”: 1650970737786,  
“schema\_version”: 1,  
“error\_notification”: null,  
“default\_state”: “open”,  
“states”: [  
{  
“name”: “open”,  
“actions”: [  
{  
“open”: {}  
}  
],  
“transitions”: [  
{  
“state\_name”: “close”,  
“conditions”: {  
“min\_index\_age”: “5m”  
}  
}  
]  
},  
{  
“name”: “close”,  
“actions”: [  
{  
“close”: {}  
}  
],  
“transitions”: [  
{  
“state\_name”: “delete”,  
“conditions”: {  
“min\_index\_age”: “5m”  
}  
}  
]  
},  
{  
“name”: “delete”,  
“actions”: [  
{  
“delete”: {}  
}  
],  
“transitions”:   
}  
],  
“ism\_template”: [  
{  
“index\_patterns”: [  
“shanky-index-\*”  
],  
“priority”: 0,  
“last\_updated\_time”: 1650970737786  
}  
]  
}

or i need to update something in this policy

---

<div class="post-metadata">

**Author:** ![mmamaenko](https://avatars.discourse-cdn.com/v4/letter/m/22d042/32.png) [@mmamaenko](https://forum.opensearch.org/u/mmamaenko)\
**Post date:** [April 30, 2022, 6:20pm UTC](https://forum.opensearch.org/t/ism-policy-for-deletion-after-a-certain-period-of-time/9381/9 "2022-04-30T18:20:40Z")

</div>

Your policy will delete index after 10 min (5 min in open state and 5 min in close). If you want to delete index based on number of docs or index size - use correspondent condition. Just remember that index will be deleted and new created if you do not use some sort of rollover parameters or index pattern naming

---

<div class="post-metadata">

**Author:** ![priyankasharma](https://avatars.discourse-cdn.com/v4/letter/p/7c8e57/32.png) [@priyankasharma](https://forum.opensearch.org/u/priyankasharma)\
**Post date:** [May 2, 2022, 6:43am UTC](https://forum.opensearch.org/t/ism-policy-for-deletion-after-a-certain-period-of-time/9381/10 "2022-05-02T06:43:00Z")

</div>

As per testing first it will take 30 min to initialized the policy after that it will lookover the min age i.e. 5 min after that it will again take 30 min to go into close stage also same for delete.

also we cannot change this 30min job interval
