Skip to content

Instantly share code, notes, and snippets.

@fnzv
Created November 12, 2018 13:43
Show Gist options
  • Save fnzv/a8310668a0bed2417525dd4fe81f6a8c to your computer and use it in GitHub Desktop.
Save fnzv/a8310668a0bed2417525dd4fe81f6a8c to your computer and use it in GitHub Desktop.
Simple ES index retention script
TODAY=`date +%Y.%m.%d`
URL="http://127.0.0.1:9200"
close_week_old_indices()
{
WEEK_FROM_TODAY=`date +%Y.%m.%d -d -7days`
INDEX=*beat*-$WEEK_FROM_TODAY
curl -XPOST $URL/$INDEX/_close
}
delete_7day_old_indices()
{
DAYS7_FROM_TODAY=`date +%Y.%m.%d -d -7days`
INDEX=*beat*-$DAYS7_FROM_TODAY
curl -XDELETE $URL/$INDEX
}
# main()
close_week_old_indices
delete_7day_old_indices
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment