count
- filtertype: count
count: 10
空值和注释掉的行将导致选择默认值(如果有)。如果设置已设置,但给定 filtertype 未使用,则可能会生成错误。
此 filtertype 将迭代可操作的索引或快照列表。它们按年龄或字母顺序排列,以确保根据 count、exclude 和 reverse 的值,正确的项目将保留在可操作列表中或从中移除。
对于对“相似”项目进行计数的用例,并且它们的名称模式保证日期排序与字母排序相等,则无需将 use_age 设置为 True
,因为项目名称默认将按 reverse 顺序排序。这意味着项目计数将从最新的索引或快照开始,然后遍历到最旧的。
如果情况并非如此,则可以使用 use_age
设置来确保索引或快照的年龄在排序时得到适当考虑
- filtertype: count
count: 10
use_age: True
source: creation_date
支持 age
过滤器中的所有年龄相关设置,并且在过滤索引与快照方面适用相同的限制。
- filtertype: count
count: 1
pattern: '^(.*)-\d{6}$'
reverse: true
此特定示例将匹配遵循 indexname-######
基本 rollover 模式的索引,并为每个组保留编号最高的索引。
例如,给定索引 a-000001
、a-000002
、a-000003
以及 b-000006
和 b-000007
,将被匹配的索引是 a-000003
和 b-000007
。不匹配 pattern
中正则表达式的索引将自动排除。
这对于使用 Rollover API 创建和管理的索引特别有用,因为您可以使用上述示例仅选择活动索引(exclude
默认为 False
)。将 exclude
设置为 True
并使用上述示例将移除活动的 rollover 索引,只留下已 rolled-over 的索引。
虽然这对于上述场景可能最有用,但它也可以用于基于年龄的索引。
使用默认配置,reverse
为 True
。给定这些索引
index1
index2
index3
index4
index5
以及此过滤器
- filtertype: count
count: 2
索引 index5
和 index4
将被识别为 2
个最新的索引,并将从可操作列表中移除,留下 index1
、index2
和 index3
由给定 action 处理。
类似地,给定这些索引
index-2017.03.01
index-2017.03.02
index-2017.03.03
index-2017.03.04
index-2017.03.05
以及此过滤器
- filtertype: count
count: 2
use_age: True
source: name
timestring: '%Y.%m.%d'
结果将类似。索引 index-2017.03.05
和 index-2017.03.04
将被识别为 2
个最新的索引,并将从可操作列表中移除,留下 index-2017.03.01
、index-2017.03.02
和 index-2017.03.03
由给定 action 处理。
在某些情况下,您可能希望过滤出最新的索引。为此,请将 reverse
设置为 False
- filtertype: count
count: 2
reverse: False
这次,索引 index1
和 index2
将是从可操作列表中移除的 2
个索引,留下 index3
、index4
和 index5
由给定 action 处理。
同样对于按年龄排序的索引
- filtertype: count
count: 2
use_age: True
source: name
timestring: '%Y.%m.%d'
reverse: True
索引 index-2017.03.01
和 index-2017.03.02
将是从可操作列表中移除的 2
个索引,留下 index-2017.03.03
、index-2017.03.04
和 index-2017.03.05
由给定 action 处理。
- reverse
- use_age
- pattern
- source(如果
use_age
为True
,则必需) - timestring(如果
source
为name
,则必需) - exclude(默认为
True
)
- field(如果
source
为field_stats
,则必需) - stats_result(仅在
source
为field_stats
时使用)