# Deleting indexes with ILM Policy and Index Template

**URL:** <https://discuss.elastic.co/t/deleting-indexes-with-ilm-policy-and-index-template/246776>\
**Category:** Elasticsearch\
**Tags:** ilm-index-lifecycle-management\
**Created:** [August 28, 2020, 1:50pm UTC](https://discuss.elastic.co/t/deleting-indexes-with-ilm-policy-and-index-template/246776 "2020-08-28T13:50:16Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![RahejaGaurav](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rahejagaurav/32/74698_2.png) [@RahejaGaurav](https://discuss.elastic.co/u/RahejaGaurav)\
**Post date:** [August 28, 2020, 1:50pm UTC](https://discuss.elastic.co/t/deleting-indexes-with-ilm-policy-and-index-template/246776/1 "2020-08-28T13:50:16Z")

</div>

Elasticsearch: 7.6.2, Kibana: Kibana:7.6.2  
As given in the [Tutorial: Automate rollover with ILM](https://www.elastic.co/guide/en/elasticsearch/reference/master/getting-started-index-lifecycle-management.html). I tried to create an ILM Policy and a simple Index template with two index pattern as given below

> url: /\_ilm/policy/efk\_policy  
> method: PUT  
> payload: {"policy": {"phases": {"delete": {"min\_age": "1h", "actions": {"delete": {}}}}}})

and template

> url: /\_template/efk\_policy\_template  
> method: PUT  
> payload: {"index\_patterns": ["services\*", "pipelines\*"], "settings": {"index.lifecycle.name": policy\_name}}

Which Gives Me following

Service Index Which has no policy being attached

 ![Screenshot from 2020-08-28 18-30-49](https://us1.discourse-cdn.com/elastic/original/3X/c/2/c2c6fee2b8471a274fb5e520a04ee95ad2f721a6.png)

Template

 ![Screenshot from 2020-08-28 18-31-12](https://us1.discourse-cdn.com/elastic/original/3X/7/b/7b36b437c24d7d00f652ff3f0286e5d67c065384.png)

And There was no Index attached to policy also

 ![Screenshot from 2020-08-28 18-31-56](https://us1.discourse-cdn.com/elastic/original/3X/5/6/5612ddf5a0a93dec2d6e28af2203f525e03db90c.png)

But Same when i did with Kibana add API /kibana/api/index\_lifecycle\_management/index/add , it was working fine. Am I missing something?

---

<div class="post-metadata">

**Author:** ![elasticforme](https://avatars.discourse-cdn.com/v4/letter/e/f05b48/32.png) [@elasticforme](https://discuss.elastic.co/u/elasticforme)\
**Post date:** [August 28, 2020, 3:06pm UTC](https://discuss.elastic.co/t/deleting-indexes-with-ilm-policy-and-index-template/246776/2 "2020-08-28T15:06:55Z")

</div>

I think if index is already created then you have to go assign this ILM to that index.  
go to setting, index management, check box index services and manage index drop down last one is add index lifecyle policy

---

<div class="post-metadata">

**Author:** ![RahejaGaurav](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rahejagaurav/32/74698_2.png) [@RahejaGaurav](https://discuss.elastic.co/u/RahejaGaurav)\
**Post date:** [August 28, 2020, 5:00pm UTC](https://discuss.elastic.co/t/deleting-indexes-with-ilm-policy-and-index-template/246776/3 "2020-08-28T17:00:46Z")

</div>

The issue with that approach, if all logs get deleted on particular index, that index is removed from that policy. For eg. If my pipeline index has logs that is generated very rarely consider it once a week , then when ilm policy delete that Index, it also get detached from that policy, i was wondering when the same Index will be populated again after another week, will that Index have that policy being attached there.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [August 31, 2020, 4:46am UTC](https://discuss.elastic.co/t/deleting-indexes-with-ilm-policy-and-index-template/246776/4 "2020-08-31T04:46:19Z")

</div>

If the index pattern matches what is defined in the policy, then it'll inherit it.

---

<div class="post-metadata">

**Author:** ![RahejaGaurav](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rahejagaurav/32/74698_2.png) [@RahejaGaurav](https://discuss.elastic.co/u/RahejaGaurav)\
**Post date:** [September 1, 2020, 9:44am UTC](https://discuss.elastic.co/t/deleting-indexes-with-ilm-policy-and-index-template/246776/5 "2020-09-01T09:44:58Z")

</div>

The index pattern i think matches already as **services** can match with **services** \* as shown in the image but i cant see any action on the indexes, also shown in the image. does there is delay while indexes being updated by the policy?

---

<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:** [September 29, 2020, 9:44am UTC](https://discuss.elastic.co/t/deleting-indexes-with-ilm-policy-and-index-template/246776/6 "2020-09-29T09:44:59Z")

</div>

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