我们的弹性搜索有几个索引。他们来自FluentD从我们的码头集装箱中收集发送日志。我们希望删除旧索引,不仅基于索引名称而不是特定天数,而是根据日志字段应用不同的删除规则。
以下是日志的示例:
{
"_index": "fluentd-2018.03.28",
"_type": "fluentd",
"_id": "o98123bcbd_kqpowkd",
"_version": 1,
"_score": null,
"_source": {
"container_id": "bbd72ec5e46921ab8896a05684a7672ef113a79e842285d932f",
"container_name": "/redis-10981239d5",
"source": "stdout",
"log": "34:M 28 Mar 15:07:51.086 * 10 changes in 300 seconds. Saving...\r34:M 28 Mar 15:07:51.188 * Background saving terminated with success\r",
"@timestamp": "2018-03-28T15:07:56.217739954+00:00",
"@log_name": "docker.redis"
},
"fields": {
"@timestamp": [
"2018-03-28T15:07:56.217Z"
]
}
}
在这种情况下,我们希望删除与7天以前@log_name = docker.redis
匹配的所有日志。
是否可以定义一个Curator操作来删除由这样的字段值过滤的索引?
我们尝试了不同的过滤而没有任何成功。我们成功执行的唯一操作是基于索引名称:
actions:
1:
action: delete_indices
description: >-
Delete indices older than 30 days
options:
ignore_empty_list: True
disable_action: True
filters:
- filtertype: pattern
kind: prefix
value: fluentd-
- filtertype: age
source: name
direction: older
timestring: '%Y.%m.%d'
unit: days
unit_count: 30
答案 0 :(得分:3)
策展人仅提供索引级别保留配置。如果您需要基于文档级别的保留,则可以尝试使用执行a delete by query。
的脚本否则,使用curator,您需要将不同索引中的数据分开以应用不同的保留。