删除amazon elasticsearch中的旧索引

Dar*_*ary 9 amazon-web-services elasticsearch

我们将AWS Elasticsearch用于日志.日志通过Logstash连续流式传输.定期删除旧索引的最佳方法是什么?

我搜索过,推荐的各种方法是:

  1. 使用lambda删除旧索引 - https://medium.com/@egonbraun/periodically-cleaning-elasticsearch-indexes-using-aws-lambda-f8df0ebf4d9f

  2. 使用预定的泊坞容器 - http://www.tothenew.com/blog/running-curator-in-docker-container-to-remove-old-elasticsearch-indexes/

对于像"删除15天以上的索引"这样的基本要求,这些方法似乎有些过分

实现这一目标的最佳方法是什么?AWS是否提供我可以调整的任何设置?

Rod*_*goM 5

Elasticsearch 6.6 带来了一项名为Index Lifecycle Manager 的新技术, 请参见此处。每个索引都分配有一个生命周期策略,该策略控制索引如何过渡特定阶段直至被删除。

例如,如果您要将一组 ATM 的指标数据索引到 Elasticsearch 中,您可以定义一个策略:

  1. 当索引达到 50GB 时,滚动到新索引。
  2. 将旧索引移至温暖阶段,将其标记为只读,并将其缩小为单个分片。
  3. 7 天后,将索引移至冷阶段并将其移至较便宜的硬件。
  4. 一旦达到所需的 30 天保留期,请删除索引。

该技术尚处于测试阶段,但可能是从现在开始的发展方向。


Nic*_*owe 1

运行 curator 非常轻松。

在这里您可以找到 Dockerfile、配置和操作文件。

https://github.com/zakkg3/curator

此外,如果您需要(除其他外),Curator 可以帮助您:

  • 从别名中添加或删除索引(或两者!)
  • 更改分片路由分配
  • 删除快照
  • 开盘、闭盘指数
  • 强制合并索引
  • 重新索引索引,包括来自远程集群的索引
  • 更改索引的每个分片的副本数
  • 展期指数
  • 拍摄索引快照(备份)
  • 恢复快照

https://www.elastic.co/guide/en/elasticsearch/client/curator/current/index.html

以下是删除超过 15 天的索引的典型操作文件:

     actions:
      1:
        action: delete_indices
        description: >-
          Delete indices older than 15 days (based on index name), for logstash-
          prefixed indices. Ignore the error if the filter does not result in an
          actionable list of indices (ignore_empty_list) and exit cleanly.
        options:
          ignore_empty_list: True
          disable_action: True
        filters:
        - filtertype: pattern
          kind: prefix
          value: logstash-
        - filtertype: age
          source: name
          direction: older
          timestring: '%Y.%m.%d'
          unit: days
          unit_count: 15
Run Code Online (Sandbox Code Playgroud)