ElasticSearch Curator删除,除非最后输入

时间:2019-07-15 11:25:39

标签: 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>

Curator会在14天后认真清理所有数据。我想要的是防止它删除特定索引的最后一个条目,因此始终有一个记录,说明集群上一次在该区域中发生了什么。

(它还会“修复”一些写得不好的代码,当这些代码原本应该存在的数据合法消失时会引发错误)。

1 个答案:

答案 0 :(得分:1)

您可以使用count filter

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将显示过滤器如何做出决定(如果有帮助的话)。

相关问题