elasticsearch - 如何在ES中定期自动删除索引?

标签 elasticsearch elasticsearch-curator

我正在使用ES 2.3.3和Logstash 2.3.3。我一直在使用Logstash发送数据并将其映射到ES中以进行索引,即logstash- {Date}。我只想保留最近一年的文件。一年中的任何索引都应删除。我以前使用3.5.1。我删除索引的方法是每天输入一条命令。

curator --host 10.0.0.2 delete indices --older-than 30 --time-unit days \
   --timestring '%Y.%m.%d' 

最近,我随后将策展人3.5.1升级到策展人4。但是,即使我已阅读https://www.elastic.co/guide/en/elasticsearch/client/curator/current/command-line.html中的示例,我也找不到策展人的存储位置。缺少action_file?这是否意味着我需要创建一个新的.curator目录以及我自己的curator.yml和action.yml文件?

在创建action.yml文件之后,是否应该按照https://www.elastic.co/guide/en/elasticsearch/client/curator/current/examples.html#ex_delete_indices并将其添加到action.yml文件中,以便在一年内删除logstash索引?

谢谢

最佳答案

只要您使用--config标志启动Curator,配置文件就可以在任何地方:

curator --config /path/to/curator_config.yml

但是,如果您在将要运行Curator的用户的主目录中创建.curator路径(表面上是通过cron),它将在该目录中查找名为curator.yml的文件,例如/home/username/.curator/curator.yml
在该位置正确配置该文件后,Curator将不需要--config标志。

策展人仅将最终参数用作操作文件:
» curator --help
Usage: curator [OPTIONS] ACTION_FILE

  Curator for Elasticsearch indices.

  See http://elastic.co/guide/en/elasticsearch/client/curator/current

Options:
  --config PATH  Path to configuration file. Default: ~/.curator/curator.yml
  --dry-run      Do not perform any changes.
  --version      Show the version and exit.
  --help         Show this message and exit.

使用$HOME/.curator/curator.yml中的默认配置文件运行Curator的示例为:
curator /path/to/actionfile.yml

并带有一个自定义配置文件:
curator --config /path/to/curator_config.yml /path/to/actionfile.yml

遵循操作文件示例是一个很好的起点。可以随意尝试新的配置,但是一定要使用--dry-run标志,以防止在测试时采取任何措施。

关于elasticsearch - 如何在ES中定期自动删除索引?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38180288/

相关文章:

elasticsearch - 如何查看 ElasticSearch 索引的内容?

elasticsearch - 策展人未清除CloudWatch提供的过期索引

elasticsearch - 如何在一段时间后从elasticsearch中的特定索引中删除数据?

elasticsearch - 运行 curator 以删除旧索引时出错

elasticsearch - Elasticsearch Curator:不按时间字符串显示索引

amazon-web-services - 使用SSH连接到Amazon Elasticsearch

elasticsearch - Elasticsearch-是否带有 “doc.”?

regex - 如何在ElasticSearch中的URL上执行RegExp查询?

elasticsearch - 使用timelion绘制同一 Elasticsearch 索引中两个时间字段之间的差异