Elasticsearch 策展人删除操作 - 翻转后删除 "n" 旧索引?

Elasticsearch curator delete action - delete "n" older indices after rollover?

以下 elasticsearch 策展人 (下)curator-actions.yml 中的设置配置为根据年龄过滤器删除索引,但我想设置一个配置与翻转一起工作,如下所示:

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

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

馆长-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

实际上比您想象的要容易。您可以使用 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 匹配的索引都将是翻转式的,并且会在数字上递增。不过,您可以根据需要添加其他选项或过滤器。