介绍
Elasticsearch Curator通过以下方式帮助您策划或管理您的Elasticsearch索引和快照:
- 从集群中获取索引(或快照)的完整列表,作为可操作列表
- 迭代用户定义的过滤器列表,根据需要逐步从此可操作列表中删除索引(或快照)
- 对用户定义的动作列表中的项目执行各种操作(包括Create Index、Delete Indices、Reindex、Snapshot等)
使用
curator的命令行语法如下:
curator [--config CONFIG.YML] [--dry-run] ACTION_FILE.YML
- CONFIG.YML:配置ES的基本信息
- ACTION_FILE.YML:具体的执行脚本
- dry-run:curator将尽可能接近地模拟ACTION_FILE.YML中的动作,而不实际进行任何更改
下面是具体的使用例子:
curator.yml:
client:hosts:- 192.168.1.188port: 9200url_prefix:use_ssl: Falsecertificate:client_cert:client_key:ssl_no_validate: Falsehttp_auth:timeout: 30master_only: Falselogging:loglevel: INFOlogfile:logformat: defaultblacklist: ['elasticsearch', 'urllib3']
deleteIndecies.yml:
actions:1:action: delete_indicesdescription: >-删除超过120天的索引(基于索引名称),用于nessus-前缀索引。如果过滤器没有导致错误,请忽略错误可操作的索引列表(ignore_empty_list)并彻底退出.options:ignore_empty_list: Truedisable_action: Falsefilters:- filtertype: patternkind: prefixvalue: nessus-- filtertype: agesource: namedirection: oldertimestring: '%Y.%m.%d'unit: daysunit_count: 1202:action: delete_indicesdescription: >-删除超过60天的索引(基于索引名称),用于metricbeat-6.2.2-前缀索引。options:ignore_empty_list: Truedisable_action: Falsefilters:- filtertype: patternkind: prefixvalue: metricbeat-6.2.2-- filtertype: agesource: namedirection: oldertimestring: '%Y.%m.%d'unit: daysunit_count: 60
最后执行curator --config curator.yml --dry-run deleteIndecies.yml即可删除nessus120天之前的索引运行(实际使用时记得删除–dry-run)
其它功能可以前往官网查看官方文档或使用实例