Created
January 13, 2016 18:39
-
-
Save d10v/f45a2a0b092ff9f9f777 to your computer and use it in GitHub Desktop.
Delete old data from OpenTSDB using `scan --delete`
This file contains 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 | |
set -o nounset | |
set -o errexit | |
set -o pipefail | |
TSDB_CMD=$( /usr/bin/which tsdb ) | |
START_TIME="1y-ago" | |
END_TIME="21d-ago" | |
SLEEP=10 | |
METRICS=$( /usr/bin/tsdb uid grep . | grep -a ^metrics | awk '{print $2}' | sed 's/\:$//g' ) | |
for METRIC in ${METRICS}; do | |
CMD="${TSDB_CMD} scan --delete ${START_TIME} ${END_TIME} sum ${METRIC}" | |
echo "RUNNING: ${CMD}" | |
${CMD} > /dev/null | |
sleep ${SLEEP} | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment