Created
April 10, 2022 14:02
-
-
Save dpavlin/a3250b8a287cc50e7bb6da866b9f34e5 to your computer and use it in GitHub Desktop.
drop oldest influxdb shards when disk space becomes too small
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/sh -e | |
free=`df -k /var/lib/influxdb/ | grep / | awk '{ print $4 }'` | |
test "$free" -gt 2097152 && exit 0 | |
df -h /var/lib/influxdb | |
influx -database telegraf -execute 'show shards' | grep telegraf | head -2 | tee /dev/stderr | awk '{ print $1 }' | tail -1 | xargs -i influx -database telegraf -execute 'drop shard {}' | |
df -h /var/lib/influxdb |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment