# Indices deleting using curator (different retention period for different index)

**URL:** <https://discuss.elastic.co/t/indices-deleting-using-curator-different-retention-period-for-different-index/77792>\
**Category:** Elasticsearch\
**Created:** [March 8, 2017, 9:52am UTC](https://discuss.elastic.co/t/indices-deleting-using-curator-different-retention-period-for-different-index/77792 "2017-03-08T09:52:07Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![macymin](https://avatars.discourse-cdn.com/v4/letter/m/8e7dd6/32.png) [@macymin](https://discuss.elastic.co/u/macymin)\
**Post date:** [March 8, 2017, 9:52am UTC](https://discuss.elastic.co/t/indices-deleting-using-curator-different-retention-period-for-different-index/77792/1 "2017-03-08T09:52:07Z")

</div>

hi All,  
I have a question regarding deleting indices.

say i have many index data below, i want to purge A-YYYY.MM.DD when \> 14 days, but for rest of the indexes B, C ...Z purge when \> 7 days. How can I do that?  
A-YYYY.MM.DD  
B-YYYY.MM.DD  
C-YYYY.MM.DD  
...  
Z-YYYY.MM.DD

---

<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:** [March 15, 2017, 4:36pm UTC](https://discuss.elastic.co/t/indices-deleting-using-curator-different-retention-period-for-different-index/77792/2 "2017-03-15T16:36:11Z")

</div>

By using multiple actions, each with different prefix filters and age filters:

```auto
---
actions:
  1:
    action: delete_indices
    ...
    filters:
    - filtertype: pattern
      kind: prefix
      value: A-
    - filtertype: pattern
      kind: timestring
      value: %Y.%m.%d
    - filtertype: age
      source: creation_date
      direction: older
      unit: days
      unit_count: 14
  2:
    action: delete_indices
    ...
    filters:
    - filtertype: pattern
      kind: regex
      value: '^B-|^C-|^D-'
    - filtertype: pattern
      kind: timestring
      value: %Y.%m.%d
    - filtertype: age
      source: creation_date
      direction: older
      unit: days
      unit_count: 7

```

This is a _hypothetical_ action file with two actions. The first would delete indices that start with `A-` and contain a `YEAR`.`MONTH`.`DAY` timestring, after they were determined to be older than 14 days (based on the index creation date). The second would delete _any_ indices _starting_ with `B-`, `C-`, or `D-`, that also contain a `YEAR`.`MONTH`.`DAY` timestring, after they were determined to be older than 7 days (based on the index creation date). No other configuration data is included here, so test thoroughly with the `--dry-run` flag before actually running something against your production data.

---

<div class="post-metadata">

**Author:** ![macymin](https://avatars.discourse-cdn.com/v4/letter/m/8e7dd6/32.png) [@macymin](https://discuss.elastic.co/u/macymin)\
**Post date:** [March 30, 2017, 2:37am UTC](https://discuss.elastic.co/t/indices-deleting-using-curator-different-retention-period-for-different-index/77792/3 "2017-03-30T02:37:09Z")

</div>

hi Thanks for your reply.  
so the idea is we dont want to setup based on eachindex like "value: '^B-|^C-|^D-'" because everytime we have to add in if having a new index.

so probably i can put the 2nd action as below, does it work?  
2:  
action: delete\_indices  
...  
filters:  
- filtertype: pattern  
kind: regex  
value: A-  
**exclude: True**  
- filtertype: pattern  
kind: timestring  
value: %Y.%m.%d  
- filtertype: age  
source: creation\_date  
direction: older  
unit: days  
unit\_count: 7

---

<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:** [March 30, 2017, 12:59pm UTC](https://discuss.elastic.co/t/indices-deleting-using-curator-different-retention-period-for-different-index/77792/4 "2017-03-30T12:59:12Z")

</div>

This will _partly_ work the way you expect, in that it will get all indices _except_ the ones that start with `A-`. However, what if there are other indices in your system? Do you use Kibana? There will be `.kibana`-type indices that would still be seen by this, as they do not start with `A-`.

You might still need additional filters to achieve exactly what you want, but you are on the right track. Use the `--dry-run` flag and check your logs to see for sure before committing to a course of action in production.

---

<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:** [April 27, 2017, 12:59pm UTC](https://discuss.elastic.co/t/indices-deleting-using-curator-different-retention-period-for-different-index/77792/5 "2017-04-27T12:59:12Z")

</div>

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