How to delete logs from elasticsearch automatically

HI Experts,

We are using Elasticsearch 7.9 .
We need to purge automatically the logs that we persist in Elasticsearch index based on a frequency/date

I need a proper guide for that.

thanks,
Sriguruvel.

You will need to create a Index Lifecycle Policy, check out this part of the documentation about Index Lifecycle Management.

hi @leandrojmp ,

thanks for your reply.

thanks,
sriguruvel.

hi @leandrojmp ,
I tried below api . And also set in template mapping. but its not delete that index after 1 minute

PUT _ilm/policy/testpolicy
{
"policy": {
"phases": {
"hot": {
"actions": {
"rollover": {
"max_age": "1m",
"max_size": "50gb"
},
"set_priority": {
"priority": 100
}
},
"min_age": "0ms"
},
"delete": {
"min_age": "1m",
"actions": {
"delete": {}
}
}
}
}
}

please give me correct API.
thanks,
Sriguruvel.

Hi experts,

I have done this automatic index delete process. thanks for giving suggestion .
And I have another question,
I created a policy for 1 minute(60s) And also I created 1 index with 1 document in 1st second.
Then I created another document with same index in 30th second. But both documents are deleted in 60th second. But I need 1st created document will be deleted at 60th second and that 2nd one will be deleted at 90th second (30th second to 90th second = 1minute). Could you please help on this.

thanks ,
Sriguruvel

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.