0

我正在使用 Elasticsearch 来存储微服务日志。所有微服务都以通用模式登录,并通过 Fluentd 日志收集并发送到索引名称模式,如log-${serviceName}-%Y.%m.%d.

我为日志定义了一个索引模板-并创建了一个 ILM 策略以在 2 天后将索引翻转到删除阶段并在 4 天后将其删除。并使用 . 将 ILM 策略连接到索引模板my-log-alias

所以我需要这样的东西: each day, there are for example 10 active indices that log documents written to them. and after 2 days these indices all go to the delete phase.

  1. 我可以为我的所有服务使用一个索引模板和一个 ILM 策略吗?
  2. 我对弹性搜索索引模板和策略的设置有什么问题?
  3. 我是否以正确的方式使用此功能?

感谢您的阅读。

索引模板:

{
  "order": 0,
  "index_patterns": [
    "log-*-*"
  ],
  "settings": {
    "index": {
      "lifecycle": {
        "name": "my-log",
        "rollover_alias": "my-log-alias"
      },
      "number_of_replicas": "1"
    }
  },
  "aliases": {
    "sb-log": {}
  },
  "mappings": {
    "_doc": {
      "properties": {
        "level": {
          "ignore_above": 256,
          "type": "keyword"
        },
        "message": {
          "type": "text"
        }
      }
    }
  }
}

政策

{
  "policy": {
    "phases": {
      "hot": {
        "min_age": "0ms",
        "actions": {
          "rollover": {
            "max_age": "2d",
            "max_size": "50gb"
          },
          "set_priority": {
            "priority": 100
          }
        }
      },
      "delete": {
        "min_age": "4d",
        "actions": {
          "delete": {
            "delete_searchable_snapshot": true
          }
        }
      }
    }
  }
}
4

1 回答 1

-1
  1. 我可以为我的所有服务使用一个索引模板和一个 ILM 策略吗?

是的你可以。

  1. 我对弹性搜索索引模板和策略的设置有什么问题?

根据您的定义,索引在 2 天(或 50gb)后滚动更新,并且在滚动操作 4 天后将被删除。

于 2020-12-09T16:15:32.767 回答