# Elastic Cloud - More than 100 APM indices - How to automate the deletion?

**URL:** <https://discuss.elastic.co/t/elastic-cloud-more-than-100-apm-indices-how-to-automate-the-deletion/213485>\
**Category:** APM\
**Tags:** server\
**Created:** [January 1, 2020, 10:12am UTC](https://discuss.elastic.co/t/elastic-cloud-more-than-100-apm-indices-how-to-automate-the-deletion/213485 "2020-01-01T10:12:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tzachalon](https://avatars.discourse-cdn.com/v4/letter/t/2acd7d/32.png) [@tzachalon](https://discuss.elastic.co/u/tzachalon)\
**Post date:** [January 1, 2020, 10:12am UTC](https://discuss.elastic.co/t/elastic-cloud-more-than-100-apm-indices-how-to-automate-the-deletion/213485/1 "2020-01-01T10:12:36Z")

</div>

Hi,

We are using elasticsearch cloud and enabled the APM component. Now, after a month or so, we have about 150 indices of APM, called "apm-7.5.1-metric/span/error-000001"  
I understand that I need to configure ILM for those, but I can't understand how does the indices even switch between the lifecycle phases.  
Can I limit the number of APM indices? Where can I find a generic ILM policy so I'll only have max of 10-20 indices of APM?

Thanks  
Tzach  
**Kibana version** :  
7.5.1  
**Elasticsearch version** :  
7.5.1  
**APM Server version** :  
7.5.1

---

<div class="post-metadata">

**Author:** ![bmorelli25](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bmorelli25/32/38738_2.png) [@bmorelli25](https://discuss.elastic.co/u/bmorelli25)\
**Post date:** [January 1, 2020, 5:38pm UTC](https://discuss.elastic.co/t/elastic-cloud-more-than-100-apm-indices-how-to-automate-the-deletion/213485/2 "2020-01-01T17:38:30Z")

</div>

Hi Tzach 👋

I recommend taking a read through the [APM ILM documentation](https://www.elastic.co/guide/en/apm/server/current/ilm.html#custom-ilm-policy) when you have a chance. There's (hopefully) a lot of useful information about how ILM works available there!

The [default ILM policy](https://www.elastic.co/guide/en/apm/server/current/ilm.html#ilm-default) for APM rolls data over (creates a new index) when the index reaches a maximum size of 50gb or a maximum age of 30 days. After 30 days, data will be moved to the warm phase. The default policy does not define a delete phase, so your total number of indices will continue to grow.

Is there a reason why you want to limit the number of APM indices to 10-20? You could accomplish this by increasing the maximum size of each index, which would lead to a smaller total number of indices, but 50gb is generally a good maximum size. If you're more so concerned about the amount of data you're storing, you can define [cold and/or delete phases](https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-policy-definition.html). A cold phase with [frozen indices](https://www.elastic.co/guide/en/elasticsearch/reference/master/frozen-indices.html) keeps data searchable without occupying heap, while a delete phase removes the index completely.

You can amend the default APM ILM policies [in Kibana](https://www.elastic.co/guide/en/kibana/current/managing-index-lifecycle-policies.html). Here's an [example config](https://www.elastic.co/guide/en/apm/server/current/ilm.html#example-ilm-config) that deletes error and span indices after 60 days, and freezes transactions and metrics after 90 days.

---

<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:** [January 22, 2020, 1:38pm UTC](https://discuss.elastic.co/t/elastic-cloud-more-than-100-apm-indices-how-to-automate-the-deletion/213485/3 "2020-01-22T13:38:30Z")

</div>

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