Skip to content

Instantly share code, notes, and snippets.

@HariSekhon
Forked from d10v/tsdb_delete_old.sh
Created October 15, 2018 09:01
Show Gist options
  • Save HariSekhon/b08f17207be41ca92bdb4a268d06c9c9 to your computer and use it in GitHub Desktop.
Save HariSekhon/b08f17207be41ca92bdb4a268d06c9c9 to your computer and use it in GitHub Desktop.
opentsdb delete old data
#!/bin/bash
set -o nounset
set -o errexit
set -o pipefail
EXTRA_TAGS=${1}
TSDB_CMD=$( /usr/bin/which tsdb )
START_TIME="1y-ago"
END_TIME="45d-ago"
METRICS=$( ${TSDB_CMD} uid grep . | grep -a ^metrics | cut -d\ -f2 | sed 's/\:$//g' )
for METRIC in ${METRICS}; do
CMD="${TSDB_CMD} scan --delete ${START_TIME} ${END_TIME} sum ${METRIC} ${EXTRA_TAGS}"
echo "RUNNING: ${CMD}"
${CMD} > /dev/null
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment