I'm trying to delete old indices, but I can't get it working. I have curator version 5.1 installed. I found info stating to use the following command curator --host localhost delete indices --older-than 30 --time-unit days --timestring %Y-%m-%dt%H but that errors with no such --host option. I tried using the host IP & the hostname as well. I know deleting indices can be set up with a cron job, but right now, I just want to be able to delete manually.
I've seen info about a YML file for curator, but for the life of me I can't find it. If I need to create it, where does it need to be located? I'm just all kinds of confused about curator... I'm familair with Linux, but don't get to use it as much as I'd like, so be nice...
There are 2 operating modes for Curator. The one you've got is for the singleton CLI, which means you need to replace curator with curator_cli. The other operating mode is via a yml config. That generally offers a much richer set of options and workflows. For that, you use the curator CLI and you can find the format and you can find the format of the configuration as well as detailed actions, options and filters here. There are also some examples in the docs to get you started.
Unfortunately, that info is for Curator v3. Curator is currently on version 5. @shanec has given you links to the current documentation, which is for Elasticsearch v5.
In the event that you are using Elasticsearch 2.x, Curator v4 is still downloadable. The documentation for Curator v4 will be available via dropdown in the official documentation.
Thanks for your response! I'm just now getting back to this... I've tried the following curator_cli delete_indices --filter_list --unit_count 30 --unit days --timestring %Y.%m.%d and I get an error about --unit not being an option, yet that's what I see in the documentation. Am I not supposed to use double hyphens? Sorry...
@waterwalker23 you can't quite use curator_cli that way. That's the older 3.x syntax. The new syntax is a bit more complex, since it tries to allow for complex filters.
Note that I replaced delete_indices with show_indices. That's kind of like a --dry-run, in that it shows you which indices would be acted on without doing anything to them. It's a great way to test your --filter_list and see exactly what will happen to your filtered indices.
Just be sure you don't have other indices with %Y.%m.%d in them that you don't want deleted, or they will be affected too, as there are no other filters.
This would look like this in a yaml file (you have to create it yourself):
---
actions:
1:
action: delete_indices
description: Delete indices with %Y.%m.%d in the name where that date is older than 30 days
options:
ignore_empty_list: True
filters:
- filtertype: age
source: name
timestring: '%Y.%m.%d'
unit: days
unit_count: 30
If you were to save that file to say, /path/to/action.yml, all you'd have to do to run this would be:
curator --dry-run /path/to/action.yml
Again, I add --dry-run here so you don't accidentally delete anything before verifying.
When I run curator_cli show_indices --filter_list '{"filtertype":"age","source":"name","timestring":"%Y.%m.%d","unit":"days","unit_count":30}' I get the following
Unable to create client connection to Elasticsearch. Error: ConnectionError(<urllib3.connection.HTTPConnection object at 0x7fb3037ebef0>: Failed to establish a new connection: [Errno 111] Connection refused) caused by: NewConnectionError(<urllib3.connection.HTTPConnection object at 0x7fb3037ebef0>: Failed to establish a new connection: [Errno 111] Connection refused)
---
actions:
1:
action: delete_indices
description: Delete indices with %Y.%m.%d in the name where that date is older than 30 days
options:
ignore_empty_list: True
filters:
- filtertype: age
source: name
timestring: '%Y.%m.%d'
unit: days
unit_count: 30
direction: older
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.