在Elasticsearch中删除超过10天的数据 [英] Delete data older than 10 days in elasticsearch
本文介绍了在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屋!
查看全文