1

我正在使用 ES 2.3.3 和 Logstash 2.3.3。我一直在使用 Logstash 发送数据并将它们映射到 ES 中进行索引,ielogstash-{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 的存储位置/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并将这部分添加到我的操作中.yml 文件以便在一年内删除 logstash 索引?

谢谢

4

2 回答 2

6

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

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

但是,如果您.curator在将运行 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在这样做时使用标志,以防止在测试时采取任何行动。

于 2016-07-07T18:44:59.230 回答
1

Curator 还附带 curator_cli,您可以在其中运行以下命令以快速进行。

curator_cli --host https://full-url:port delete_indices --ignore_empty_list --filter_list '[{"filtertype":"pattern","kind":"prefix","value":"logstash-"}]'
于 2018-03-07T03:59:43.633 回答