How to curl this query to shell script

I want to delete the 5 days old data of all my indexes. How to curl this query to shell script

POST _all/_delete_by_query
{
 "query": {
   "range": {
     "@timestamp": {
       "lte": "now-5d"
      }
    }
  }
}

Thanks in advance!

Hi
Have a look into Kibana's Console

curl -XPOST "{Elasticsearch}/_all/_delete_by_query" -H 'Content-Type: application/json' -d'
{
 "query": {
   "range": {
     "@timestamp": {
       "lte": "now-5d"
      }
    }
  }
}'

Best,
Matthias

1 Like

You're welcome!

Hope these aren't your real credentials :slight_smile:

Good day, the updated solution that works for me.

curl -XPOST "YourLocalhost:9200/YourIndexName/_delete_by_query" -H 'Content-Type: application/json' -d' { "query": { "range": { "@timestamp": { "lte": "now-5d" } } } }' -u YourElasticUsername:AndPassword

I added my Elastic Username and Password to the last of the command.
Thank you!

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