# How to delete the indices older than 30 days

**URL:** <https://discuss.elastic.co/t/how-to-delete-the-indices-older-than-30-days/242182>\
**Category:** Kibana\
**Created:** [July 22, 2020, 12:03pm UTC](https://discuss.elastic.co/t/how-to-delete-the-indices-older-than-30-days/242182 "2020-07-22T12:03:05Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![nikhilesh](https://avatars.discourse-cdn.com/v4/letter/n/46a35a/32.png) [@nikhilesh](https://discuss.elastic.co/u/nikhilesh)\
**Post date:** [July 22, 2020, 12:03pm UTC](https://discuss.elastic.co/t/how-to-delete-the-indices-older-than-30-days/242182/1 "2020-07-22T12:03:06Z")

</div>

Hi Team,

i am using ELK version 7.5, i would like to delete the indices which are older than 30 days.

can i create the index life cycle policy to achieve this?

Also, does this policy deletes the default indices which will be created starting name with dot (.)(.kibana\_task\_manager\_1 (like this)) when installed the ELK setup.

Thanks  
NIkhilesh Gade

---

<div class="post-metadata">

**Author:** ![Bamieh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bamieh/32/38730_2.png) [@Bamieh](https://discuss.elastic.co/u/Bamieh)\
**Post date:** [July 22, 2020, 2:55pm UTC](https://discuss.elastic.co/t/how-to-delete-the-indices-older-than-30-days/242182/2 "2020-07-22T14:55:46Z")

</div>

Hello,

Yes ILM (index lifecycle management) will help you achieve this. In kibana there is a UI to help you create such policies under **Management \> Index Lifecycle Policies**

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/6/f/6f362148b45cffe1653f526b9e8ae9258a3c8a79.png)

You can apply policies to kibana's **.** \* indices although it is not recommended as these are managed by kibana itself.

To delete indices after 30 days, simply enable the "Delete phase" and set it to 30 days

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/5/5/55ff3bc884cbe196863d310da70a41f4c598e415.png)

---

<div class="post-metadata">

**Author:** ![nikhilesh](https://avatars.discourse-cdn.com/v4/letter/n/46a35a/32.png) [@nikhilesh](https://discuss.elastic.co/u/nikhilesh)\
**Post date:** [July 23, 2020, 5:33am UTC](https://discuss.elastic.co/t/how-to-delete-the-indices-older-than-30-days/242182/3 "2020-07-23T05:33:33Z")

</div>

Thanks Bamieh for the quick response .

After creating the policy, the requirement is it should not delete the indices that are managed by kibana itself. means by default there are some of the indices which are created automatically with the setup (ex..below) with starting with dot(.)

.triggered\_watches  
.apm-custom-link  
.tasks  
.watches  
.security-7  
.async-search  
.apm-agent-configuration  
.kibana-event-log-7.8.0-000001  
.ml-config  
.kibana\_1

Thanks  
Nikhilesh Gade

---

<div class="post-metadata">

**Author:** ![nikhilesh](https://avatars.discourse-cdn.com/v4/letter/n/46a35a/32.png) [@nikhilesh](https://discuss.elastic.co/u/nikhilesh)\
**Post date:** [July 23, 2020, 5:37am UTC](https://discuss.elastic.co/t/how-to-delete-the-indices-older-than-30-days/242182/4 "2020-07-23T05:37:38Z")

</div>

Does this ILM policy include system indices as well for deletion?

Thanks  
Nikhilesh Gade

---

<div class="post-metadata">

**Author:** ![nikhilesh](https://avatars.discourse-cdn.com/v4/letter/n/46a35a/32.png) [@nikhilesh](https://discuss.elastic.co/u/nikhilesh)\
**Post date:** [July 29, 2020, 11:20am UTC](https://discuss.elastic.co/t/how-to-delete-the-indices-older-than-30-days/242182/5 "2020-07-29T11:20:11Z")

</div>

Any help on this please?

---

<div class="post-metadata">

**Author:** ![Bamieh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bamieh/32/38730_2.png) [@Bamieh](https://discuss.elastic.co/u/Bamieh)\
**Post date:** [July 29, 2020, 2:25pm UTC](https://discuss.elastic.co/t/how-to-delete-the-indices-older-than-30-days/242182/6 "2020-07-29T14:25:46Z")

</div>

I'm not sure I fully understood your last question.

> Does this ILM policy include system indices as well for deletion?

You can attach the policy to any index pattern, even the ones starting with a dot.

After creating the policy, click on **add policy to index template** :

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/a/a/aafab726620798d7d2ccef6f5303f5f9bee1b43b.png)

Then you can specify any index template you're after. The policy can include deletion rules as well.

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/c/d/cdedf12e806800294c71318e4aba7992011ae8d5.png)

You can learn the full details about ILM by following the docs: [Getting started with index lifecycle management | Elasticsearch Guide [7.5] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/7.5/getting-started-index-lifecycle-management.html)

---

<div class="post-metadata">

**Author:** ![nikhilesh](https://avatars.discourse-cdn.com/v4/letter/n/46a35a/32.png) [@nikhilesh](https://discuss.elastic.co/u/nikhilesh)\
**Post date:** [July 29, 2020, 2:28pm UTC](https://discuss.elastic.co/t/how-to-delete-the-indices-older-than-30-days/242182/7 "2020-07-29T14:28:16Z")

</div>

Thanks Bamieh for your help. i will check that.

---

<div class="post-metadata">

**Author:** ![nikhilesh](https://avatars.discourse-cdn.com/v4/letter/n/46a35a/32.png) [@nikhilesh](https://discuss.elastic.co/u/nikhilesh)\
**Post date:** [July 31, 2020, 4:55pm UTC](https://discuss.elastic.co/t/how-to-delete-the-indices-older-than-30-days/242182/8 "2020-07-31T16:55:49Z")

</div>

Hi Bameih,

I have attached the index template and updated a policy to delete the index older than 25 days. but still i can see the index exists.

at what time the policy executes?if i created the policy now , will it applicable to delete the indexes older than 25 days.?

Thanks  
Nikhilesh Gade

---

<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:** [July 31, 2020, 5:40pm UTC](https://discuss.elastic.co/t/how-to-delete-the-indices-older-than-30-days/242182/9 "2020-07-31T17:40:03Z")

</div>

Nikhilesh  
you have to create a policy (ILM) and then link your index to this ILM policy  
and it will act only on that indexes.

for example my index name is mysystem\_logs-2020-01, mysystem\_logs-2020-02 .....  
and my ILM is link to that index. then it will only delete that index. nothing else

---

<div class="post-metadata">

**Author:** ![nikhilesh](https://avatars.discourse-cdn.com/v4/letter/n/46a35a/32.png) [@nikhilesh](https://discuss.elastic.co/u/nikhilesh)\
**Post date:** [August 2, 2020, 12:01pm UTC](https://discuss.elastic.co/t/how-to-delete-the-indices-older-than-30-days/242182/10 "2020-08-02T12:01:49Z")

</div>

yeah, i did same. but could see indexes still exists.

I did not enabled roll over, i gave the delete phase(PFB).

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/4/a/4ac64cf4b87404e130cd59a1300b44145be584f0.png)

Here i could see my indices still exists, after applied the policy.

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/f/b/fb291c97c9d0198eff717334d8dbc6f3280d2709.png)

---

<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 3, 2020, 10:00pm UTC](https://discuss.elastic.co/t/how-to-delete-the-indices-older-than-30-days/242182/11 "2020-08-03T22:00:15Z")

</div>

when you go to ILM tab on you should see something like this

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/c/7/c70a9e89be37904d66690787ec34c314ffab57ec.png)

This tells me I have 13 index which has this policy assign.

now if you go to your index management select and you will be able to assign this ILM policy to that index

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/6/9/6926e5b91c8030f54c8c9de03e8e689145c2b0d9.png)

---

<div class="post-metadata">

**Author:** ![nikhilesh](https://avatars.discourse-cdn.com/v4/letter/n/46a35a/32.png) [@nikhilesh](https://discuss.elastic.co/u/nikhilesh)\
**Post date:** [August 4, 2020, 4:54pm UTC](https://discuss.elastic.co/t/how-to-delete-the-indices-older-than-30-days/242182/12 "2020-08-04T16:54:52Z")

</div>

Thanks sachin:) for your help

---

<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 1, 2020, 4:54pm UTC](https://discuss.elastic.co/t/how-to-delete-the-indices-older-than-30-days/242182/13 "2020-09-01T16:54:55Z")

</div>

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