1,下载安装
- rpm包下载安装
# 防止安装rpm包报错:error: [upel]: elasticsearch-curator NOKEY ;
# error: [upel]: elasticsearch-curator signature check fail
rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch #参考https://www.elastic.co/guide/en/elasticsearch/reference/7.17/rpm.html
rpm -ivh https://packages.elastic.co/curator/5/centos/7/Packages/elasticsearch-curator-5.8.4-1.x86_64.rpm
2, 配置使用
配置1: filtertype: pattern +正则匹配 + 过期时间
- 关闭索引,action.yaml 加上
ignore_empty_list: True
, 防止条件不满足时报错,导致任务不能继续执行 - 删除索引,action.yaml 加上
continue_if_exception: True
, 防止删除索引报错,导致任务不能继续执行 - 调试方法:
curator --config xxconfig.yml action.yml --dry-run
, 运行时会打印相关匹配的索引和动作,以备参考 - action.yaml 配置参考:
action-close模板:https://www.elastic.co/guide/en/elasticsearch/client/curator/current/ex_close.html - 索引名匹配-正则参考:https://www.elastic.co/guide/en/elasticsearch/client/curator/current/filtertype_pattern.html
- 排查索引名称:https://www.elastic.co/guide/en/elasticsearch/client/curator/current/fe_exclude.html
TEST1:/root # cat action.yml
---
actions:
1:
action: close
description: >-
关闭指定索引,5天前的:test_logstash_
options:
skip_flush: False
delete_aliases: False
ignore_sync_failures: True
ignore_empty_list: True
disable_action: False
filters:
- filtertype: pattern
kind: prefix
#value: test_logstash_2023_11_12
value: test_logstash_
#排除某些索引
- filtertype: pattern
kind: prefix
value: metric_
exclude: True
- filtertype: age
source: name
direction: older
#timestring: '%Y.%m.%d'
timestring: '%Y_%m_%d'
unit: days
unit_count: 5
2:
action: close
description: >-
关闭指定索引,10天前的:^(\w+)_logstash_.*$
options:
skip_flush: False
delete_aliases: False
ignore_sync_failures: True
ignore_empty_list: True
disable_action: False
filters:
- filtertype: pattern
kind: regex
#value: logstash-
#value: test_logstash_2023_11_12
value: '^(\w+)_logstash_.*$'
- filtertype: age
source: name
direction: ol