策展人根据非日期类型的字段删除超过30天或更长的索引

时间:2017-06-13 17:22:22

标签: elasticsearch elasticsearch-curator

{
 "_index": "user:1494813192000",
 "_type": "fruits",
 "_id": "pbyac5r88-yghe-v1ez-cpgb-sqdjipr54alzgj/tp4oqalbd-bo2v-ikj1-atfq-wezcoeeuf6wiqpt/apple",
 "_score": 1,
 "_routing": "pbyac5r88-yghe-v1ez-cpgb-sqdjipr54alzgj",
 "_source": {
 "numCal": 442,
 "eventTime": 1497315192000,
 "fruitName": "apple"
}

这就是我的elasticsearch中的索引的样子。 eventTime是基于UTC的当前时间(以毫秒为单位)。我想使用该字段使用策展人删除我的索引。

这就是我的ACTION_FILE.YML的样子

actions:
  1:
    action: delete_indices 
    description: >-
      Delete indices older than 45 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
      timeout_override:
      continue_if_exception: False
      disable_action: False
    filters:
    - filtertype: age
      source: field_stats
      field: 'eventTime'
      direction: older
      unit: days
      unit_count: 30
      exclude:

策展人是否支持根据数据格式的字段进行删除?

1 个答案:

答案 0 :(得分:0)

我最初回答了这个问题here,但也包括在这里。

日期和时间比较基于纪元时间在策展人中工作。由于Elasticsearch在内部将日期条目存储为纪元值,因此在使用field_stats进行比较时,通常需要使用存储为日期戳的字段。

但是,如果字段纪元时间在Elasticsearch中正确映射为long,并存储了一个纪元,或一个纪元加上毫秒(但不是十进制),它应该可以正常使用{ {1}}。

作为参考,演示此原则的代码是here