elasticsearch-curator - ElasticSearch Curator 删除,除非最后一个条目
问题描述
按时间删除时,有没有办法阻止馆长删除最后一个索引?
actions:
1:
action: delete_indices
description: Delete kube- indices older than 14 days. Ignore the error if there are none and exit cleanly.
options:
disable_action: False
ignore_empty_list: True
filters:
- filtertype: pattern
kind: prefix
value: kube-
- filtertype: age
source: name
direction: older
timestring: '%Y.%m.%d'
unit: days
unit_count: 14
我有这个非常适合检查当前运行的 K8s 集群日志。但是,当我们移动 AWS 区域时,日志名称会更改,例如从 更改kube-eu-west-1-<date>
为kube-eu-west-2-<date>
.
策展人在 14 天后努力清理所有数据。我想要的是防止它删除特定索引的最后一个条目,因此始终记录集群最后一次在该区域中发生的事情。
(它还会“修复”一些写得不太好的代码片段,当他们期望的数据合法地消失时会抛出错误)。
解决方案
您可以使用count
过滤器:
filters:
# your existing filters go BEFORE the count filter...
- filtertype: count
count: 1
此示例应从可操作索引列表中排除(尽管有exclude: false
)最近的索引,并保留它。如果这不是您要排除的索引,请使用exclude: true/false
(默认为true
)和/或reverse: true/false
(默认为true
)探索,直到它排除您想要的索引。
注意:--dry-run
在将过滤器部署到实际数据之前,请始终使用该标志来测试过滤器。迭代直到看起来正确。如果有帮助,loglevel: DEBUG
在您的客户端设置中使用将显示过滤器如何做出决定。
推荐阅读
- laravel - Laravel 6 - 刀片中的命名路由不允许参数中的特殊字符或大写字母
- string - 用于用户输入的 stol 和 stoi 的 C++ 精度
- c++ - 如果 C++ 使用 cdecl 调用约定,为什么 Godbolt 会显示在 edi 中传递的参数?
- python - 检查输入时出错:预期dense_1_input 的形状为(784,),但得到的数组的形状为(10,)
- python - 如何使用 pandas 导入下三角矩阵?
- r - 如何在 R 中“总结”带有分类变量的列?
- javascript - 转换 BTC 单位并将其反转
- javascript - 导出 unirest req 结束数据时遇到问题
- r - RODBC 使用 EXEC @variable 查询
- delphi - 在 inifiles 中写入 unicode 文本