# Curator: Delete oldest indices based on ES cluster size

**URL:** <https://discuss.elastic.co/t/curator-delete-oldest-indices-based-on-es-cluster-size/66930>\
**Category:** Elasticsearch\
**Created:** [November 23, 2016, 3:08am UTC](https://discuss.elastic.co/t/curator-delete-oldest-indices-based-on-es-cluster-size/66930 "2016-11-23T03:08:20Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![theuntergeek](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/theuntergeek/32/44961_2.png) [@theuntergeek](https://discuss.elastic.co/u/theuntergeek)\
**Post date:** [November 23, 2016, 4:40am UTC](https://discuss.elastic.co/t/curator-delete-oldest-indices-based-on-es-cluster-size/66930/2 "2016-11-23T04:40:45Z")

</div>

An action file like this should suffice (if all indices match a given prefix):

```auto
---
actions:
  1:
    action: delete_indices
    description: >-
      Delete indices matching the prefix MY_INDEX_PREFIX_HERE in excess of 
      25.5TB of data, starting with the oldest indices, based on index creation_date. 
      An empty index list (from no indices being in excess of the size limit, for 
      example) will not generate an error.
    options:
      ignore_empty_list: True
      timeout_override: 300
      continue_if_exception: False
      disable_action: False
    filters:
    - filtertype: pattern
      kind: prefix
      value: MY_INDEX_PREFIX_HERE
    - filtertype: space
      disk_space: 25500
      use_age: True
      source: creation_date

```

I suggest running Curator with the [`--dry-run`](https://www.elastic.co/guide/en/elasticsearch/client/curator/current/command-line.html) flag to see the output before running it against your production database. This set of filters will first filter by index prefix (this will prevent accidentally deleting your `.kibana` index, for example), and then filter by the amount of disk space consumed, sorted by age (using the index creation\_date as the time stamp), so the oldest indices are deleted first. You could also use `source: name`, if your indices have a date stamp in the index name. The [documentation for the space filtertype](https://www.elastic.co/guide/en/elasticsearch/client/curator/current/filtertype_space.html) should help you select a different means of determining age, if desired.

---

_[View the full topic](https://discuss.elastic.co/t/curator-delete-oldest-indices-based-on-es-cluster-size/66930)._
