【问题标题】:Error while running curator for deleting older indices运行 curator 以删除旧索引时出错
【发布时间】:2017-02-15 18:10:01
【问题描述】:

我想删除超过 7 天的 elasticsearch 索引。所以我安装了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

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.

【问题讨论】:

  • 您是否 100% 确定所有内容的格式都完全正确?我复制并粘贴了您的操作 YAML 文件,它对我来说运行良好。
  • 我认为只有缩进的问题。我删除了文件并重新创建。 成功了

标签: elasticsearch elasticsearch-curator


【解决方案1】:

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

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 换行符或类似的东西?

【讨论】:

  • 不,我没有使用 DOS 换行符。问题仅在于缩进。它通过重新创建文件得到修复。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-07-05
  • 1970-01-01
  • 2019-06-05
  • 1970-01-01
  • 2018-09-07
  • 2015-05-23
相关资源
最近更新 更多