green open ab_namespacename_namespaceid_appName_appId-2019.02.13 5 1 540 0 1.2mb 617kb
I have a lot of logs in the format of above, I want to delete the old logs (let say which are older than 5 days) by @timestamp
(in the above log (2019.02.13)) range. I have made the query to delete logs by query.
let query = { index: '*', headers: null, body: { query: { filter: { '@timestamp': { 'gte': 'now-5d', }, }, }, }, }; try { results = await this.elasticSearchClient.deleteByQuery(query); console.log('results', results); return results; } catch (e) { throw new LogHubException(e.message, HttpStatus.NOT_FOUND);
I have got the below error:
[parsing_exception] no [query] registered for [@timestamp], with { line=1 & col=42 }
NOTE: I am using NestJS to call the elasticsearch api, and using elasticsearch[6.4]. I don't want to use elasticsearch-curator.
You query should look like as below:
{
"query": {
"range": {
"@timestamp": {
"gte": "now-5d"
}
}
}
}
update the changes accordingly in NestJS code.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.