Elasticsearch馆长删除操作-翻转后删除“ n”个旧索引吗?

时间:2018-11-15 13:13:57

标签: elasticsearch nest elasticsearch-curator

以下curator-actions.yml中的Elasticsearch策展人(下)设置被配置为基于年龄过滤器删除索引,但我想设置一个与翻转兼容的配置如下:

仅保留最后一个索引和新创建的过渡索引->,因此,在过渡成功后将删除所有其他索引。做到这一点的最佳方法是什么?可以在代码中使用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

1 个答案:

答案 0 :(得分:2)

实际上比您想象的要容易。您可以使用count过滤器轻松地保留两个最新索引。以下示例在执行后立即合并了top: 100px操作和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 匹配的索引都将采用翻转样式,并且将以数字方式递增。不过,您可以根据需要添加其他选项或过滤器。

相关问题