【问题标题】:deleting old indexes in amazon elasticsearch删除亚马逊弹性搜索中的旧索引
【发布时间】:2018-10-04 15:35:15
【问题描述】:

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

我已经搜索并推荐的各种方法是:

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

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

对于“删除超过 15 天的索引”这样的基本要求,这些方法似乎有点过头了

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

【问题讨论】:

    标签: amazon-web-services elasticsearch


    【解决方案1】:

    Elasticsearch 6.6 带来了一项名为 Index Lifecycle Manager See here 的新技术。每个索引都分配有一个生命周期策略,该策略控制索引如何通过特定阶段转换,直到它们被删除。

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

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

    该技术还处于测试阶段,但可能是从现在开始的方式。

    【讨论】:

      【解决方案2】:

      运行策展人非常轻松。

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

      https://github.com/zakkg3/curator

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

      • 从别名中添加或删除索引(或两者!)
      • 更改分片路由分配
      • 删除快照
      • 打开封闭索引
      • forceMerge 索引
      • 重新索引索引,包括来自远程集群的索引
      • 更改索引的每个分片的副本数
      • 翻转指数
      • 对索引进行快照(备份)
      • 恢复快照

      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
      

      【讨论】:

        【解决方案3】:

        我按照 elasticsearch-curator 文档安装包:

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

        然后我使用了 AWS 基础示例,说明如何使用 requests_aws4auth 包提供的基于签名的身份验证自动清理索引:

        https://docs.aws.amazon.com/elasticsearch-service/latest/developerguide/curator.html

        它就像一个魅力。

        您可以决定在 lambda、docker 中运行它,或者将其包含在您自己的 DevOps cli 中。

        【讨论】:

          猜你喜欢
          • 2015-05-23
          • 2016-01-30
          • 2016-12-16
          • 2016-06-30
          • 2013-01-06
          • 1970-01-01
          • 2014-05-28
          • 2016-01-28
          • 1970-01-01
          相关资源
          最近更新 更多