0

I have different logs in elasticsearch 2.2 separate by 'type'. How can delete all data, only one of type, older one week? thanks

Example of logs:

{
  "_index": "logstash-2016.02.23",
  "_type": "dns_ns",
  "_id": "AVMOj--RqgDl5Axva2Nt",
  "_score": 1,
  "_source": {
    "@version": "1",
    "@timestamp": "2016-02-23T14:37:07.029Z",
    "type": "dns_ns",
    "host": "11.11.11.11",
    "clientip": "22.22.22.22",
    "queryname": "api.bing.com",
    "zonetype": "Public_zones",
    "querytype": "A",
    "querytype2": "+ED",
    "dnsip": "33.33.33.33"
  },
  "fields": {
    "@timestamp": [
      1456238227029
    ]
  }
}
kllaud
  • 3
  • 3

2 Answers2

0

See here or here on how to delete by query. In Elasticsearch 2.*, you might find the Delete by Query plugin useful.

Community
  • 1
  • 1
Michele Palmia
  • 2,402
  • 2
  • 25
  • 28
0

Deleting "types" is no longer directly supported in ES 2.x A better plan is to have rolling indexes, that way deleting indexes older than 7 days becomes very easy.

Take the example of logstash, it creates an index for every day. You can then create an alias for logstash so that it queries all indexes. And then when it comes time to delete old data you can simply remove the entire index with:

DELETE logstash-2015-12-16

enter image description here

jhilden
  • 12,207
  • 5
  • 53
  • 76