运行curator删除旧索引时出错

时间:2017-02-15 18:10:01

标签: elasticsearch elasticsearch-curator

我想删除超过7天的elasticsearch索引。所以我安装了curator 4.2,因为我的弹性搜索版本是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.

1 个答案:

答案 0 :(得分: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 INFO      Preparing Action ID: 1, "delete_indices"
2017-02-15 15:48:53,713 INFO      Trying Action ID: 1, "delete_indices": 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.
2017-02-15 15:48:54,034 INFO      DRY-RUN MODE.  No changes will be made.
2017-02-15 15:48:54,034 INFO      (CLOSED) indices may be shown that may not be acted on by action "delete_indices".
2017-02-15 15:48:54,034 INFO      DRY-RUN: delete_indices: logstash-2017.01.06 with arguments: {}
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 INFO      DRY-RUN: delete_indices: logstash-2017.02.02 with arguments: {}
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 INFO      DRY-RUN: delete_indices: logstash-2017.02.04 with arguments: {}
2017-02-15 15:48:54,035 INFO      DRY-RUN: delete_indices: logstash-2017.02.05 with arguments: {}
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 INFO      DRY-RUN: delete_indices: logstash-2017.02.07 with arguments: {}
2017-02-15 15:48:54,035 INFO      DRY-RUN: delete_indices: logstash-2017.02.08 with arguments: {}
2017-02-15 15:48:54,035 INFO      Action ID: 1, "delete_indices" completed.
2017-02-15 15:48:54,035 INFO      Job completed.

同样,我所做的唯一更改是设置disable_action: False - 或者只是完全删除该行 - 因为设置为True时不会运行任何内容。

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

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