2017-02-15 55 views
1

我想刪除7天以前的elasticsearch索引。所以我安裝了curator 4.2,因爲我的elasticsearch版本是5.0.0(4.x之前的版本控制器版本與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

您是否100%確定所有內容都格式正確?我複製並粘貼了您的動作YAML文件,並且它爲我運行得非常好。 – untergeek

+0

我認爲只有縮進問題。我刪除了文件並重新創建。 **它的工作** –

回答

0

我在你的curatorAction.yml文件中找不到任何不正確的東西。事實上,下面是我運行它的輸出。我剪切/粘貼正是你有以上,減去disable_action: Truetest2.yml什麼:

 
[email protected]:~/.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換行符?

+1

不,我沒有使用DOS換行符。問題僅在於縮進。它通過重新創建文件得到修復。 –