Created
June 4, 2015 20:50
-
-
Save jclosure/80a138d717a31071af18 to your computer and use it in GitHub Desktop.
Bash Script to Trim Elasticsearch By Date Indexes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
DAYS_AGO=$1 | |
TARGET_INDEX=logstash-`date --date="$DAYS_AGO days ago" +%Y.%m.%d`; | |
if [[ "$DAYS_AGO" ]]; then | |
# echo "computed target index: $TARGET_INDEX" | |
curl -XDELETE "http://localhost:9200/$TARGET_INDEX" | |
else | |
echo "you need to pass in a parameter for DAYS_AGO" | mail -s "no days passed to script. cannot delete ES index: $TARGET_INDEX" [email protected] | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment