Skip to content

Instantly share code, notes, and snippets.

@math3vz
Created April 24, 2019 14:42
Show Gist options
  • Save math3vz/e375808acd881dd225f84a4c56bb9c6e to your computer and use it in GitHub Desktop.
Save math3vz/e375808acd881dd225f84a4c56bb9c6e to your computer and use it in GitHub Desktop.
#!/bin/bash
# : ${2?"Usage: $0 [number of days] [base url of elastic]"}
days="30"
baseURL=${2}
indexes=("my-cool-index" "my-not-so-cool-index")
for i in "${indexes[@]}"
do
:
curl -XPOST "$baseURL/$i/_delete_by_query" -H 'Content-Type: application/json' -d "
{
\"query\": {
\"range\": {
\"datetime\": {
\"lt\": \"now-"$days"d/d\"
}
}
}
}"
printf "\n\n";
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment