使用Elasticsearch策展人,如何删除与模式匹配的所有索引,但最新的除外?
我尝试使用,filtertype: age
但是它似乎没有满足我的需求。
您需要两个过滤器:(pattern
以匹配要删除的索引)和age
(以指定要删除的索引的期限)。
例如,下面的Curator配置配置为删除
example_dev_*
组态:
actions:
1:
action: delete_indices
description: >-
Delete indices older than 10 days (based on index name), for example_dev_
prefixed indices.
options:
ignore_empty_list: True
disable_action: True
filters:
- filtertype: pattern
kind: prefix
value: example_dev_
- filtertype: age
source: creation_date
direction: older
unit: days
unit_count: 10
- filtertype: count
count: 1
您需要使两种过滤条件都适应您的需求,但这将达到您的期望。
如果索引既适合模式又适合年龄,那是唯一的索引怎么办?在那种情况下,我不想删除它。
您的索引如何命名?如果您将所有数据都存储在一个索引中,但只想从该索引中删除旧数据,那么Curator不会为您提供帮助,而是需要这样的解决方案:stackoverflow.com/a/57975075/4604579
索引的名称为:example_dev_1_v {increment},例如:example_dev_1_v1,example_dev_1_v5,example_dev_2_v1,example_dev_2_v2
问题是您需要始终删除整个索引,还是有时只删除部分索引?
我需要删除适合模式的整个索引:example_dev_1_v ...,但最新版本除外。请注意,
v
可能在后面的值也可能不是最新版本的最高值。除了最新的索引,是否可以使用Curator根据创建日期删除索引?