ES中如何定时自动删除索引?
How to delete indexes automatically regularly in ES?
我正在使用 ES 2.3.3 和 Logstash 2.3.3。我一直在使用Logstash发送数据并将它们映射到ES中进行索引,i.e.logstash-{Date}。我只想保留最近 1 年的文件。任何超过一年的索引都应删除。我之前使用的是 3.5.1。我删除索引的方法是每天输入一个指令
curator --host 10.0.0.2 delete indices --older-than 30 --time-unit days \
--timestring '%Y.%m.%d'
最近,我将 curator 3.5.1 升级到 curator 4。但是,即使我通读了 https://www.elastic.co/guide/en/elasticsearch/client/curator/current/command-line.html 中的示例,我也找不到 curator 的存储位置因此,我想知道在哪里配置文件会是什么,为什么会缺少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
路径(表面上是通过 cron),它将在那里寻找一个名为 curator.yml
,例如/home/username/.curator/curator.yml
在该位置正确配置该文件后,Curator 将不需要 --config
标志。
Curator 仅使用最后一个参数作为操作文件:
» 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.
运行 Curator 在 $HOME/.curator/curator.yml
中具有默认配置文件的示例是:
curator /path/to/actionfile.yml
并使用自定义配置文件:
curator --config /path/to/curator_config.yml /path/to/actionfile.yml
遵循操作文件示例是一个很好的起点。随意尝试新配置,但一定要在这样做时使用 --dry-run
标志,以防止在测试时采取任何操作。
Curator 还附带了 curator_cli,您可以在其中 运行 下面的命令进行快速操作。
curator_cli --host https://full-url:port delete_indices --ignore_empty_list --filter_list '[{"filtertype":"pattern","kind":"prefix","value":"logstash-"}]'
我正在使用 ES 2.3.3 和 Logstash 2.3.3。我一直在使用Logstash发送数据并将它们映射到ES中进行索引,i.e.logstash-{Date}。我只想保留最近 1 年的文件。任何超过一年的索引都应删除。我之前使用的是 3.5.1。我删除索引的方法是每天输入一个指令
curator --host 10.0.0.2 delete indices --older-than 30 --time-unit days \
--timestring '%Y.%m.%d'
最近,我将 curator 3.5.1 升级到 curator 4。但是,即使我通读了 https://www.elastic.co/guide/en/elasticsearch/client/curator/current/command-line.html 中的示例,我也找不到 curator 的存储位置因此,我想知道在哪里配置文件会是什么,为什么会缺少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
路径(表面上是通过 cron),它将在那里寻找一个名为 curator.yml
,例如/home/username/.curator/curator.yml
在该位置正确配置该文件后,Curator 将不需要 --config
标志。
Curator 仅使用最后一个参数作为操作文件:
» 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.
运行 Curator 在 $HOME/.curator/curator.yml
中具有默认配置文件的示例是:
curator /path/to/actionfile.yml
并使用自定义配置文件:
curator --config /path/to/curator_config.yml /path/to/actionfile.yml
遵循操作文件示例是一个很好的起点。随意尝试新配置,但一定要在这样做时使用 --dry-run
标志,以防止在测试时采取任何操作。
Curator 还附带了 curator_cli,您可以在其中 运行 下面的命令进行快速操作。
curator_cli --host https://full-url:port delete_indices --ignore_empty_list --filter_list '[{"filtertype":"pattern","kind":"prefix","value":"logstash-"}]'