# Deleting indices with curator 4.0

**URL:** <https://discuss.elastic.co/t/deleting-indices-with-curator-4-0/55729>\
**Category:** Elasticsearch\
**Created:** [July 18, 2016, 7:22am UTC](https://discuss.elastic.co/t/deleting-indices-with-curator-4-0/55729 "2016-07-18T07:22:45Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jpuch](https://avatars.discourse-cdn.com/v4/letter/j/ccd318/32.png) [@Jpuch](https://discuss.elastic.co/u/Jpuch)\
**Post date:** [July 18, 2016, 7:22am UTC](https://discuss.elastic.co/t/deleting-indices-with-curator-4-0/55729/1 "2016-07-18T07:22:45Z")

</div>

Hi there,

I just read this thread [How do I know if curator is cleaning up? (SOLVED)](https://discuss.elastic.co/t/how-do-i-know-if-curator-is-cleaning-up-solved/28887) and same as the last comment, when i use this command line :

> curator delete indices --older-than 5 --time-unit days --timestring %Y.%m.%d

i got this :  
\> root@itsupervision:/# curator delete indices --older-than 7 --time-unit days --timestring %Y.%m.%d

> ```
> Error: no such option: --older-than
> 
> ```

I assume it's because of the new version but what is the equivalent for the 4.0.1 version then ?

Thanks for reading,

Josselin

---

<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:** [July 18, 2016, 1:00pm UTC](https://discuss.elastic.co/t/deleting-indices-with-curator-4-0/55729/2 "2016-07-18T13:00:37Z")

</div>

Curator v4 is a major release update, and it fundamentally changes the usage behavior. It uses YAML configuration files now instead of command-line flags. I recommend you read up on the new version at [https://www.elastic.co/guide/en/elasticsearch/client/curator/current/index.html](https://www.elastic.co/guide/en/elasticsearch/client/curator/current/index.html)

---

<div class="post-metadata">

**Author:** ![Ravi\_Shanker\_Reddy](https://avatars.discourse-cdn.com/v4/letter/r/a5b964/32.png) [@Ravi\_Shanker\_Reddy](https://discuss.elastic.co/u/Ravi_Shanker_Reddy)\
**Post date:** [July 19, 2016, 6:21am UTC](https://discuss.elastic.co/t/deleting-indices-with-curator-4-0/55729/3 "2016-07-19T06:21:52Z")

</div>

Can you please explain this a little bit more. From the link you mentioned I understand that I need two files now.

`Action File Configuration file`

1. In test\_curator.YML  
` 1:  
action: delete\_indices  
description: \>-  
Delete indices older than 45 days (based on index name), for logstash-  
prefixed indices. Ignore the error if the filter does not result in an  
actionable list of indices (ignore\_empty\_list) and exit cleanly.  
options:  
ignore\_empty\_list: True  
timeout\_override:  
continue\_if\_exception: False  
disable\_action: True  
filters:

2. How to create the config file. Whats the extension??

how to mention the file names while running in the curator????

---

<div class="post-metadata">

**Author:** ![Jpuch](https://avatars.discourse-cdn.com/v4/letter/j/ccd318/32.png) [@Jpuch](https://discuss.elastic.co/u/Jpuch)\
**Post date:** [July 19, 2016, 10:41am UTC](https://discuss.elastic.co/t/deleting-indices-with-curator-4-0/55729/4 "2016-07-19T10:41:24Z")

</div>

Hi,

You have to create a curator conf file in the default conf directory (~/.curator/) and it has a .yml extension

* * *

> client:  
> hosts:  
> - 127.0.0.1  
> port: 9200  
> url\_prefix:  
> use\_ssl: False  
> certificate:  
> client\_cert:  
> client\_key:  
> aws\_key:  
> aws\_secret\_key:  
> aws\_region:  
> ssl\_no\_validate: False  
> http\_auth:  
> timeout: 30  
> master\_only: False

> logging:  
> loglevel: INFO  
> logfile:  
> logformat: default

and then you can run curator with

> curator PATH\_ACTION\_FILE

---

<div class="post-metadata">

**Author:** ![Ravi\_Shanker\_Reddy](https://avatars.discourse-cdn.com/v4/letter/r/a5b964/32.png) [@Ravi\_Shanker\_Reddy](https://discuss.elastic.co/u/Ravi_Shanker_Reddy)\
**Post date:** [July 20, 2016, 6:51am UTC](https://discuss.elastic.co/t/deleting-indices-with-curator-4-0/55729/5 "2016-07-20T06:51:03Z")

</div>

> [@Jpuch](#):
>
> in the default conf directory (~/.curator/)

I cant find any directory in the root with that name (Searched with `ls -alrt`).  
As you mentioned I created a file `test_curator_config.yml`. [quote="Jpuch, post:4, topic:55729"]  
curator PATH\_ACTION\_FILE  
[/quote]

Here I am mentioning only action file name & path. Then how the curator understand which file it has to read as configuration file. (I am not mentioned any thing about conf file in action file)

Sorry if these are very silly questions. Very new to ES

---

<div class="post-metadata">

**Author:** ![Jpuch](https://avatars.discourse-cdn.com/v4/letter/j/ccd318/32.png) [@Jpuch](https://discuss.elastic.co/u/Jpuch)\
**Post date:** [July 20, 2016, 7:19am UTC](https://discuss.elastic.co/t/deleting-indices-with-curator-4-0/55729/6 "2016-07-20T07:19:03Z")

</div>

I have to create this directory myself too and put my curator.yml in it with the conf i posted above.

You don't have to mention the name of the conf file in the command line because it's the default directory.

---

<div class="post-metadata">

**Author:** ![Ravi\_Shanker\_Reddy](https://avatars.discourse-cdn.com/v4/letter/r/a5b964/32.png) [@Ravi\_Shanker\_Reddy](https://discuss.elastic.co/u/Ravi_Shanker_Reddy)\
**Post date:** [July 20, 2016, 8:55am UTC](https://discuss.elastic.co/t/deleting-indices-with-curator-4-0/55729/7 "2016-07-20T08:55:47Z")

</div>

Hi Jpuch

`mkdir -p /root/.curator` #Created the directory  
created file `curator.yml` in the directory

`client:  
hosts:

- 172.16.15.153  
port: 9200  
url\_prefix:  
use\_ssl: False  
certificate:  
client\_cert:  
client\_key:  
aws\_key:  
aws\_secret\_key:  
aws\_region:  
ssl\_no\_validate: False  
http\_auth:  
timeout: 30  
master\_only: False  
logging:  
loglevel: INFO  
logfile:  
logformat: default`

And also created action file as `action_file.yml`

`actions: 1: action: delete_indices description: >- options: ignore_empty_list: True timeout_override: continue_if_exception: False disable_action: False filters: - filtertype: pattern kind: prefix value: packetbeat- exclude: - filtertype: age source: name direction: older timestring: '%Y.%m.%d' unit: days unit_count: 3 exclude:`

and run as `curator /root/action_file.yml`

Then its showing an error

`[root@smsc ~]# curator /root/action_file.yml Traceback (most recent call last): File "/usr/local/bin/curator", line 11, in <module> sys.exit(main()) File "/usr/local/lib/python2.7/site-packages/curator/curator.py", line 5, in main cli() File "/usr/local/lib/python2.7/site-packages/click/core.py", line 716, in __call__ return self.main(*args, **kwargs) File "/usr/local/lib/python2.7/site-packages/click/core.py", line 696, in main rv = self.invoke(ctx) File "/usr/local/lib/python2.7/site-packages/click/core.py", line 889, in invoke return ctx.invoke(self.callback,**ctx.params) File "/usr/local/lib/python2.7/site-packages/click/core.py", line 534, in invoke return callback(*args, **kwargs) File "/usr/local/lib/python2.7/site-packages/curator/cli.py", line 135, in cli yaml_log_opts = prune_nones(yaml_config['logging']) File "/usr/local/lib/python2.7/site-packages/curator/utils.py", line 1002, in prune_nones return dict([(k,v) for k, v in mydict.items() if v != None and v != 'None']) AttributeError: 'NoneType' object has no attribute 'items'`

**EDIT** : **Sorry for the reply. I missed the indent in the config file. After indent all working fine**

---

<div class="post-metadata">

**Author:** ![mikesparr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mikesparr/32/4619_2.png) [@mikesparr](https://discuss.elastic.co/u/mikesparr)\
**Post date:** [September 26, 2016, 8:42pm UTC](https://discuss.elastic.co/t/deleting-indices-with-curator-4-0/55729/8 "2016-09-26T20:42:46Z")

</div>

I had similar issue when upgrading to 4.0. One thing you should do is omit all the empty lines on config file or comment them with hash (pound sign). They will load as empty strings.

I just created in my user home directory a config and action file like so:

**curator\_config.yml**  
---  
# Remember, leave a key empty if there is no value. None will be a string,  
# not a Python "NoneType"  
client:  
hosts:  
- search1  
port: 9200  
timeout: 30

```
logging:
  loglevel: INFO

```

**curator\_action.yml**  
---  
# Remember, leave a key empty if there is no value. None will be a string,  
# not a Python "NoneType"  
#  
# Also remember that all examples have 'disable\_action' set to True. If you  
# want to use this action as a template, be sure to set this to False after  
# copying it.  
actions:  
1:  
action: delete\_indices  
description: \>-  
Delete indices older than 5 days (based on index name), for custom-  
prefixed indices. Ignore the error if the filter does not result in an  
actionable list of indices (ignore\_empty\_list) and exit cleanly.  
options:  
ignore\_empty\_list: True  
continue\_if\_exception: False  
disable\_action: False  
filters:  
- filtertype: age  
source: name  
direction: older  
timestring: '%Y.%m.%d'  
unit: days  
unit\_count: 5

Then run curator, passing in the config files' paths and view output as so (I was deleting any indices with timestamp suffices older than 5 days):

```
curator --config ~/curator_config.yml ~/curator_action.yml
2016-09-26 14:33:20,862 INFO Preparing Action ID: 1, "delete_indices"
2016-09-26 14:33:20,870 INFO Trying Action ID: 1, "delete_indices": Delete indices older than 5 days (based on index name), for custom- prefixed indices. Ignore the error if the filter does not result in an actionable list of indices (ignore_empty_list) and exit cleanly.
2016-09-26 14:33:21,592 INFO Deleting selected indices: [u'topbeat-2016.09.17', u'topbeat-2016.09.16', u'topbeat-2016.09.15', u'topbeat-2016.09.14', u'feedbeat-2016.09.20', u'feedbeat-2016.09.21', u'topbeat-2016.09.19', u'topbeat-2016.09.18', u'feedbeat-2016.09.06', u'feedbeat-2016.09.07', u'feedbeat-2016.09.08', u'feedbeat-2016.09.09', u'feedbeat-2016.09.19', u'filebeat-2016.09.20', u'filebeat-2016.09.21', u'packetbeat-2016.09.19', u'packetbeat-2016.09.18', u'packetbeat-2016.09.12', u'packetbeat-2016.09.13', u'packetbeat-2016.09.14', u'packetbeat-2016.09.11', u'packetbeat-2016.09.17', u'packetbeat-2016.09.16', u'packetbeat-2016.09.15', u'packetbeat-2016.09.21', u'packetbeat-2016.09.08', u'packetbeat-2016.09.09', u'feedbeat-2016.09.11', u'feedbeat-2016.09.10', u'feedbeat-2016.09.13', u'feedbeat-2016.09.12', u'feedbeat-2016.09.15', u'feedbeat-2016.09.14', u'feedbeat-2016.09.17', u'feedbeat-2016.09.16', u'feedbeat-2016.09.18', u'filebeat-2016.09.17', u'filebeat-2016.09.16', u'filebeat-2016.09.15', u'filebeat-2016.09.14', u'filebeat-2016.09.19', u'filebeat-2016.09.18', u'packetbeat-2016.09.20', u'topbeat-2016.09.20', u'topbeat-2016.09.21']
2016-09-26 14:33:21,592 INFO ---deleting index feedbeat-2016.09.20
2016-09-26 14:33:21,593 INFO ---deleting index feedbeat-2016.09.21
2016-09-26 14:33:21,593 INFO ---deleting index topbeat-2016.09.19
2016-09-26 14:33:21,593 INFO ---deleting index topbeat-2016.09.18
2016-09-26 14:33:21,593 INFO ---deleting index feedbeat-2016.09.19
2016-09-26 14:33:21,593 INFO ---deleting index filebeat-2016.09.20
2016-09-26 14:33:21,593 INFO ---deleting index filebeat-2016.09.21
2016-09-26 14:33:21,594 INFO ---deleting index packetbeat-2016.09.19
2016-09-26 14:33:21,594 INFO ---deleting index packetbeat-2016.09.21
2016-09-26 14:33:21,596 INFO ---deleting index filebeat-2016.09.19
2016-09-26 14:33:21,596 INFO ---deleting index packetbeat-2016.09.20
2016-09-26 14:33:21,596 INFO ---deleting index topbeat-2016.09.20
2016-09-26 14:33:21,597 INFO ---deleting index topbeat-2016.09.21
2016-09-26 14:33:30,677 INFO Action ID: 1, "delete_indices" completed.
2016-09-26 14:33:30,677 INFO Job completed.

```

I hope this is helpful. FYI, my old command in pre 4.0 versions was the following:

```
#! /bin/bash
/usr/local/bin/curator --host search1 delete indices --older-than 5 --time-unit days --timestring '%Y.%m.%d'

```

- Mike

---

<div class="post-metadata">

**Author:** ![Rohini\_Choudhary](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rohini_choudhary/32/15288_2.png) [@Rohini\_Choudhary](https://discuss.elastic.co/u/Rohini_Choudhary)\
**Post date:** [February 8, 2017, 2:57pm UTC](https://discuss.elastic.co/t/deleting-indices-with-curator-4-0/55729/9 "2017-02-08T14:57:39Z")

</div>

Thank you so much for your full answer. Worked awesome for me!

---

<div class="post-metadata">

**Author:** ![vaibhav](https://avatars.discourse-cdn.com/v4/letter/v/c68b51/32.png) [@vaibhav](https://discuss.elastic.co/u/vaibhav)\
**Post date:** [March 27, 2017, 9:04am UTC](https://discuss.elastic.co/t/deleting-indices-with-curator-4-0/55729/10 "2017-03-27T09:04:30Z")

</div>

Nice..Worked for me. Thanks a lot.

---

<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:** [July 5, 2017, 10:01pm UTC](https://discuss.elastic.co/t/deleting-indices-with-curator-4-0/55729/11 "2017-07-05T22:01:51Z")

</div>


