# ILM policy not working as expected

**URL:** <https://discuss.elastic.co/t/ilm-policy-not-working-as-expected/233504>\
**Category:** Elasticsearch\
**Created:** [May 20, 2020, 9:58am UTC](https://discuss.elastic.co/t/ilm-policy-not-working-as-expected/233504 "2020-05-20T09:58:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![reddy1262](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/reddy1262/32/68722_2.png) [@reddy1262](https://discuss.elastic.co/u/reddy1262)\
**Post date:** [May 20, 2020, 9:58am UTC](https://discuss.elastic.co/t/ilm-policy-not-working-as-expected/233504/1 "2020-05-20T09:58:59Z")

</div>

Hi Team,

We have implemented ILM policies to cleanup indexes automatically after 14 days. But I see some old indexes still present with less documents count and Storage size whose min age is passed more than 14 days. Below are ilm policy and delete template.

Its deleting the index as i see another index with latest date, but i see indexes remain there with less documents count and Storage size for old dates (which need to be deleted by that time as per ILM policy). Please check and let us know did we missed anything here.

PUT \_ilm/policy/infra\_delete\_policy  
{  
"policy": {  
"phases": {  
"hot": {  
"actions": {}  
},  
"delete": {  
"min\_age": “14d",  
"actions": {  
"delete": {}  
}  
}  
}  
}  
}

1. Applying a policy to index template

PUT \_template/infra\_delete\_template  
{  
"index\_patterns": ["infra-\*"],  
"settings": {  
"number\_of\_shards": 1,  
"number\_of\_replicas": 1,  
"index.lifecycle.name": "infra\_delete\_policy"  
}  
}

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [May 22, 2020, 4:33am UTC](https://discuss.elastic.co/t/ilm-policy-not-working-as-expected/233504/2 "2020-05-22T04:33:00Z")

</div>

If you are not using rollover, the index a document is sent to is often determined by the timestamp. If you have old data coming in, belonging to indices that have already been deleted, these would get recreated with the new data.

---

<div class="post-metadata">

**Author:** ![reddy1262](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/reddy1262/32/68722_2.png) [@reddy1262](https://discuss.elastic.co/u/reddy1262)\
**Post date:** [May 25, 2020, 5:47am UTC](https://discuss.elastic.co/t/ilm-policy-not-working-as-expected/233504/3 "2020-05-25T05:47:20Z")

</div>

[quote="reddy1262, post:1, topic:233504"]  
PUT \_template/infra\_delete\_template  
{  
"index\_patterns": ["infra-\*"],  
"settings": {  
"number\_of\_shards": 1,  
"number\_of\_replicas": 1,  
"index.lifecycle.name": "infra\_delete\_policy"  
"index.lifecycle.rollover\_alias": "infra-alias"  
}  
}

Thanks Chris, does above syntax will work for rollover ? or can you explain me how rollover need to be added for all existing delete templates

---

<div class="post-metadata">

**Author:** ![reddy1262](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/reddy1262/32/68722_2.png) [@reddy1262](https://discuss.elastic.co/u/reddy1262)\
**Post date:** [May 29, 2020, 10:08am UTC](https://discuss.elastic.co/t/ilm-policy-not-working-as-expected/233504/4 "2020-05-29T10:08:26Z")

</div>

@Christian_Dahlqvist could you please confirm on above syntax

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [June 26, 2020, 10:12am UTC](https://discuss.elastic.co/t/ilm-policy-not-working-as-expected/233504/5 "2020-06-26T10:12:12Z")

</div>

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