0

以下 elasticsearch curator (如下)设置curator-actions.yml被配置为根据年龄过滤器删除索引,但我想设置一个适用于翻转的配置,如下所示:

仅保留最后一个索引和新创建的翻转索引 -> 从而在翻转成功后删除所有其他索引。实现这一目标的最佳方法是什么?可以在代码中使用 NEST 吗?

这是我当前的删除操作...非常感谢任何帮助,谢谢!

curator-actions.yml中

action: delete_indices
description: >-
  Delete indices older than 3 days (based on index creation date)
options:
  ignore_empty_list: True
  continue_if_exception: True
filters:
- filtertype: pattern
  kind: prefix
  value: applogging-test
- filtertype: age
  source: creation_date
  direction: older
  unit: days
  unit_count: 3
4

1 回答 1

2

它实际上比你想象的要容易。count您可以使用过滤器轻松保留两个最近的索引。下面的例子包含了rollover动作和delete_indices紧随其后的动作(我使用了conditions你在上面的评论中提供的——适当地调整你的翻转条件):

actions:
  1:
    action: rollover
    description: Rollover index associated with alias name
    options:
      name: aliasname
      conditions:
        max_age: 7d
        max_docs: 1000
        max_size: 5gb
  2:
    action: delete_indices
    description: Keep only the two most recent indices
    options:
      ignore_empty_list: true
    filters:
    - filtertype: pattern
      kind: prefix
      value: applogging-test
    - filtertype: count
      count: 2

现在,这假设所有与前缀匹配的索引applogging-test都是翻转样式的,并且会按数字递增。不过,您可以根据需要添加其他选项或过滤器。

于 2018-11-17T17:35:30.157 回答