我们的 elasticsearch 上有几个索引。它们来自 FluentD 插件,从我们的 docker 容器中发送日志。我们不仅希望根据索引名称删除超过特定天数的旧索引,还希望根据日志字段应用不同的删除规则。
下面是一个日志示例:
{
"_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"
]
}
}
在这种情况下,我们想删除所有匹配@log_name = docker.redis
超过 7 天的日志。
是否可以定义一个 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