gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 22:43:16 26 4
gpt4 key购买 nike

我正在使用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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com