# Curator - delete all indices based on "alias" name (prefix+timestring)

**URL:** <https://discuss.elastic.co/t/curator-delete-all-indices-based-on-alias-name-prefix-timestring/99588>\
**Category:** Elasticsearch\
**Created:** [September 6, 2017, 1:21pm UTC](https://discuss.elastic.co/t/curator-delete-all-indices-based-on-alias-name-prefix-timestring/99588 "2017-09-06T13:21:01Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![olc-olivier](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/olc-olivier/32/21845_2.png) [@olc-olivier](https://discuss.elastic.co/u/olc-olivier)\
**Post date:** [September 6, 2017, 1:21pm UTC](https://discuss.elastic.co/t/curator-delete-all-indices-based-on-alias-name-prefix-timestring/99588/1 "2017-09-06T13:21:01Z")

</div>

Hi,

I would like delete all indices older than xxx days based on alias name (prefix+timestring) and not index name.

Is it possible ?

action: delete\_indices \>\>\> action: delete\_indices\_from\_alias

ex:

alias \> log-20170506  
indexes \> log-A1  
indexes \> log-B2  
indexes \> log-D1

name log-  
timestring: '%Y%m%d'  
unit: days  
unit\_count: xxx

Thx for help.

Best Regards

---

<div class="post-metadata">

**Author:** ![thn](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thn/32/8061_2.png) [@thn](https://discuss.elastic.co/u/thn)\
**Post date:** [September 6, 2017, 1:31pm UTC](https://discuss.elastic.co/t/curator-delete-all-indices-based-on-alias-name-prefix-timestring/99588/2 "2017-09-06T13:31:48Z")

</div>

You may find the info at the link below  
[https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html)

---

<div class="post-metadata">

**Author:** ![olc-olivier](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/olc-olivier/32/21845_2.png) [@olc-olivier](https://discuss.elastic.co/u/olc-olivier)\
**Post date:** [September 6, 2017, 3:00pm UTC](https://discuss.elastic.co/t/curator-delete-all-indices-based-on-alias-name-prefix-timestring/99588/3 "2017-09-06T15:00:19Z")

</div>

I m not sure this page could be help me.

Because I would like use curator actions. It is for cron task to automatic delete old indexes.

Like this but regex on alias name doesn't work. Or How use timestring on Alias name.

actions:  
1:  
action: alias  
description: \>-  
Alias indices  
options:  
name: log-?????????  
warn\_if\_no\_indices: True  
ignore\_empty\_list: True  
timeout\_override:  
continue\_if\_exception: False  
disable\_action: False  
remove:  
filters:  
- filtertype: pattern  
kind: regex  
value: 'log.\*'  
- filtertype: age  
source: name  
direction: older  
timestring: '%Y%m%d'  
unit: days  
unit\_count: 1  
exclude:

---

<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:** [September 6, 2017, 3:06pm UTC](https://discuss.elastic.co/t/curator-delete-all-indices-based-on-alias-name-prefix-timestring/99588/4 "2017-09-06T15:06:41Z")

</div>

Try [Curator's alias filter](https://www.elastic.co/guide/en/elasticsearch/client/curator/current/filtertype_alias.html). It will keep only indices associated with a named alias. However, it currently requires fully named aliases. You can't specify `alias-%Y.%m.%d` to select _aliases_ older than `unit_count` `unit`s.

---

<div class="post-metadata">

**Author:** ![olc-olivier](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/olc-olivier/32/21845_2.png) [@olc-olivier](https://discuss.elastic.co/u/olc-olivier)\
**Post date:** [September 6, 2017, 3:32pm UTC](https://discuss.elastic.co/t/curator-delete-all-indices-based-on-alias-name-prefix-timestring/99588/5 "2017-09-06T15:32:22Z")

</div>

I can not provide fully named aliases. Because it is exactly what I want to do.  
Get indices from alias-%Y.%m.%d...

Same thing that "delete\_indices" but from alias and not index name.

So, for now, I will use the elasticsearch java api with a custom program.

Waiting a new curator version with this function ^^.

Thx a lot.

---

<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:** [September 6, 2017, 4:10pm UTC](https://discuss.elastic.co/t/curator-delete-all-indices-based-on-alias-name-prefix-timestring/99588/6 "2017-09-06T16:10:01Z")

</div>

> [@olc-olivier](#):
>
> Waiting a new curator version with this function

It won't happen without a feature request at [GitHub - elastic/curator: Curator: Tending your Elasticsearch indices](https://github.com/elastic/curator)

Please go and add that feature there.

---

<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:** [October 4, 2017, 4:10pm UTC](https://discuss.elastic.co/t/curator-delete-all-indices-based-on-alias-name-prefix-timestring/99588/7 "2017-10-04T16:10:08Z")

</div>

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