【发布时间】:2021-03-06 02:29:51
【问题描述】:
我正在使用 Elasticsearch 来存储微服务日志。
所有微服务都以通用模式登录,并由 Fluentd 收集的日志收集并发送到索引名称模式,如log-${serviceName}-%Y.%m.%d。
我为 log-- 定义了一个索引模板,并创建了一个 ILM 策略以在 2 天后将索引翻转到删除阶段并在 4 天后将其删除。并使用my-log-alias 将 ILM 策略连接到索引模板。
所以我需要这样的东西:
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.
- 我可以为我的所有服务使用一个索引模板和一个 ILM 策略吗?
- 我在 elasticsearch 索引模板和策略上的设置有什么问题?
- 我是否以正确的方式使用此功能?
感谢您的阅读。
索引模板:
{
"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"
}
}
}
}
}
ilm 政策
{
"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
}
}
}
}
}
}
【问题讨论】:
标签: elasticsearch elasticsearch-indices