2

我想删除超过 7 天的弹性搜索索引。所以我安装了curator 4.2,因为我的elasticsearch版本是5.0.0(4.x之前的curator版本与elasticsearch v5不兼容)

我们需要创建配置文件和操作文件来完成这项工作。我已经在根目录中创建了我的配置和操作文件

我的配置文件 curator.yml 是

---
# Remember, leave a key empty if there is no value.  None will be a string,
# not a Python "NoneType"
client:
  hosts:
    - 127.0.0.1
  port: 9200
  url_prefix:
  use_ssl: False
  certificate:
  client_cert:
  client_key:
  aws_key:
  aws_secret_key:
  aws_region:
  ssl_no_validate: False
  http_auth:
  timeout: 30
  master_only: False

logging:
  loglevel: INFO
  logfile:
  logformat: default
  blacklist: ['elasticsearch', 'urllib3']

我的动作文件 curatorAction.yml 是

actions:
  1:
    action: delete_indices
    description: >-
      Delete indices older than 45 days (based on index name), for logstash-
      prefixed indices. Ignore the error if the filter does not result in an
      actionable list of indices (ignore_empty_list) and exit cleanly.
    options:
      ignore_empty_list: True
      timeout_override:
      continue_if_exception: False
      disable_action: True
    filters:
    - filtertype: pattern
      kind: prefix
      value: logstash-
      exclude:
    - filtertype: age
      source: name
      direction: older
      timestring: '%Y.%m.%d'
      unit: days
      unit_count: 7
      exclude:

我正在使用 CLI 运行策展人

curator --config curator.yml --dry-run curatorAction.yml

但我收到了这个错误。我在任何地方都找不到有关此的任何信息。任何帮助将不胜感激。

  2017-02-15 17:52:02,991 ERROR     Schema error: extra keys not allowed @ data[1]
    Traceback (most recent call last):
      File "/usr/local/bin/curator", line 11, in <module>
        load_entry_point('elasticsearch-curator==4.2.6', 'console_scripts', 'curator')()
      File "/usr/local/lib/python2.7/site-packages/click/core.py", line 722, in __call__
        return self.main(*args, **kwargs)
      File "/usr/local/lib/python2.7/site-packages/click/core.py", line 697, in main
        rv = self.invoke(ctx)
      File "/usr/local/lib/python2.7/site-packages/click/core.py", line 895, in invoke
        return ctx.invoke(self.callback, **ctx.params)
      File "/usr/local/lib/python2.7/site-packages/click/core.py", line 535, in invoke
        return callback(*args, **kwargs)
      File "/usr/local/lib/python2.7/site-packages/curator/cli.py", line 126, in cli
        action_dict = validate_actions(action_config)
      File "/usr/local/lib/python2.7/site-packages/curator/utils.py", line 1085, in validate_actions
        root = SchemaCheck(data, actions.root(), 'Actions File', 'root').result()
      File "/usr/local/lib/python2.7/site-packages/curator/validators/schemacheck.py", line 68, in result
        self.test_what, self.location, self.badvalue, self.error)
    curator.exceptions.ConfigurationError: Configuration: Actions File: Location: root: Bad Value: "{'action': 'delete_indices', 'description': 'Delete selected indices', 'filters': [{'exclude': None, 'kind': 'prefix', 'filtertype': 'pattern', 'value': 'logstash-'}, {'source': 'name', 'direction': 'older', 'unit_count': 30, 'timestring': '%Y.%m.%d', 'exclude': None, 'filtertype': 'age', 'unit': 'days'}], 'options': {'continue_if_exception': False, 'timeout_override': None, 'disable_action': False}}", extra keys not allowed @ data[1]. Check configuration file.
4

1 回答 1

0

我找不到您的 curatorAction.yml 文件有任何不正确之处。事实上,下面是我运行它的输出。我完全剪切/粘贴了您上面的内容,disable_action: True减去test2.yml

root@esclient:~/.curator# curator --config test.yml --dry-run test2.yml
2017-02-15 15:48:53,705 信息准备操作 ID:1,“delete_indices”
2017-02-15 15:48:53,713 信息尝试操作 ID:1,“delete_indices”:删除 45 天以上的索引(基于索引名称),用于以 logstash 为前缀的索引。如果过滤器没有产生可操作的索引列表(ignore_empty_list),则忽略该错误并干净地退出。
2017-02-15 15:48:54,034 信息试运行模式。不会进行任何更改。
2017-02-15 15:48:54,034 可能会显示信息(已关闭)索引,这些索引可能无法通过操作“delete_indices”执行。
2017-02-15 15:48:54,034 信息空运行:delete_indices:logstash-2017.01.06,参数:{}
2017-02-15 15:48:54,034 INFO DRY-RUN: delete_indices: logstash-2017.02.01 (CLOSED) with arguments: {}
2017-02-15 15:48:54,034 信息空运行:delete_indices:logstash-2017.02.02,参数:{}
2017-02-15 15:48:54,034 INFO DRY-RUN: delete_indices: logstash-2017.02.03 with arguments: {}
2017-02-15 15:48:54,034 信息空运行:delete_indices:logstash-2017.02.04,参数:{}
2017-02-15 15:48:54,035 信息空运行:delete_indices:logstash-2017.02.05,参数:{}
2017-02-15 15:48:54,035 INFO DRY-RUN: delete_indices: logstash-2017.02.06 with arguments: {}
2017-02-15 15:48:54,035 信息空运行:delete_indices:logstash-2017.02.07,参数:{}
2017-02-15 15:48:54,035 信息空运行:delete_indices:logstash-2017.02.08,参数:{}
2017-02-15 15:48:54,035 信息操作 ID:1,“delete_indices”已完成。
2017-02-15 15:48:54,035 信息 工作已完成。

同样,我所做的唯一更改是设置disable_action: False- 或完全删除该行 - 因为将其设置为True.

这并不能解释您的错误,这表明您的文件格式不正确。有一个它不喜欢的根级密钥,但是剪切/粘贴,它对我有用,所以我不知道你的格式如何或为什么不正确。

您是否为您的 curatorAction.yml 文件使用了 DOS 换行符,或者类似的东西?

于 2017-02-15T22:54:57.517 回答