2

I want to delete the elasticsearch indices older than 7 days. So I have installed curator 4.2 as my elasticsearch version is 5.0.0 (curator version before 4.x are not compatible with elasticsearch v5)

we need to create configuration file and action file to make this work. I have created my config and action file in root directory

My configuration file curator.yml is

---
# 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']

My action file curatorAction.yml is

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:

I am running the curator with the CLI as

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

but I am getting this error. I can't find anything regarding this anywhere. Any help will be appreciated.

  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.
Randgalt
  • 2,907
  • 1
  • 17
  • 31
Sachchit Bansal
  • 486
  • 5
  • 11
  • 1
    Are you 100% certain that everything is formatted completely correctly? I copied and pasted your action YAML file and it ran beautifully for me. – untergeek Feb 15 '17 at 22:46
  • I think there was problem of indentation only. I deleted the files and recreated. **It worked** – Sachchit Bansal Feb 16 '17 at 07:53

1 Answers1

0

I cannot find anything incorrect with your curatorAction.yml file. In fact, the below is the output from my running it. I cut/pasted exactly what you have above, minus disable_action: True in 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.

Again, the only change I made was to set disable_action: False—or just delete the line altogether—as nothing would run with it set to True.

That does not explain your error, which indicates that your file is incorrectly formatted. There is a root-level key it does not like, but cut/paste, and it works for me, so I can't tell how or why yours may be formatted incorrectly.

Did you use a DOS newline character for your curatorAction.yml file, or something like that?

untergeek
  • 863
  • 4
  • 13