How to clear graphite whisper data?

I want to delete the graph storage graph data, but there is nothing in the graphite documents.

One way is to delete the files in /opt/graphite...../whispers/stats... manually.

But this is tiring, so how do I do this?

+79
graphite
Mar 06 '12 at 15:53
source share
3 answers

currently deleting files from / opt / graphite / storage / whisper / is the correct way to delete whisper data.

As for the tedious side of the process, you can use the find command if there is a specific template that is trying to delete.

find / opt / graphite / storage / whisper -name loadavg.wsp -delete

A similar question at answer.launchpad.net/graphite

+67
Apr 30 2018-12-12T00:
source share

I assume this is happening on Server Fault, but I added the following cron job to delete old metrics that have not been recorded for more than 30 days (for example, cloud instances that were located):

 find /mnt/graphite/storage -mtime +30 | grep -E \ "/mnt/graphite/storage/whisper/collectd/app_name/[^/]*" -o \ | uniq | xargs rm -rf 

This will delete directories that have valid data.

Firstly:

 find whisperDir -mtime +30 -type f | xargs rm 

And then remove the empty dirs

 find . -type d -empty | xargs rmdir 

This last step should be repeated as new empty directories may be left.

+43
Sep 20
source share

As people say, deleting files is the way to go. Expanding in previous answers, I made this script that deletes any file that exceeded its maximum storage age. Perform it regularly as a cronjob .

 #!/bin/bash d=$1 now=$(date +%s) MINRET=86400 if [ -z "$d" ]; then echo "Must specify a directory to clean" exit 1 fi find $d -name '*.wsp' | while read w; do age=$((now - $(stat -c '%Y' "$w"))) if [ $age -gt $MINRET ]; then retention=$(whisper-info.py $w maxRetention) if [ $age -gt $retention ]; then echo "Removing $w ($age > $retention)" rm $w fi fi done find $d -empty -type d -delete 

A few bits to be aware of - calling whisper-info pretty tough. To reduce the number of calls to it, I set the MINRET constant, so that no file will be considered for deletion until it becomes 1-day (24 * 60 * 60 seconds) - adjust it according to your needs. Perhaps there are other things that can be done to scald the work or even increase its effectiveness, but I still did not need to do this.

+3
Mar 15 '16 at 15:01
source share



All Articles