在 elasticsearch 中删除超过 10 天的数据 [英] Delete data older than 10 days in elasticsearch

查看:56
本文介绍了在 elasticsearch 中删除超过 10 天的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 elasticsearch 的新手,我想删除我的 elasticsearch 索引中超过 10 天的文档.我只想保留最近 10 天的数据.所以有什么办法可以自动删除最后 11 天的索引.我尝试过的..

I am new to elasticsearch and I want to delete documents in my elasticsearch index which are older than 10 days. I want to keep only last 10 days of data.So is there any way to delete last 11nth day index automatically. What I have tried..

DELETE logstash-*/_query
{
 "query": {
   "range": {
     "@timestamp": {
       "lte": "now-10d"
      }
    }
  }
}

我在 kibana 开发工具上运行时遇到的错误

Error I'm getting while running on kibana dev tools

{
"error": "Incorrect HTTP method for uri [/logstash-*/_query?pretty] and method [DELETE], 
allowed: [POST]",
"status": 405
}

请帮助解决此问题.

推荐答案

您需要利用 通过查询端点删除,像这样:

You need to leverage the Delete by Query Endpoint, like this:

use POST           use this endpoint
 |                      |
 V                      V
POST logstash-*/_delete_by_query
{
 "query": {
   "range": {
     "@timestamp": {
       "lte": "now-10d"
      }
    }
  }
}
  ^
  |
the query part is fine !!

这篇关于在 elasticsearch 中删除超过 10 天的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆