How to delete metrics from a specific datacollection?

In some cases you may want to delete all rrd archives from a specific datacollection for all nodes in all requisitions. This would be needed if you have changed the rrd configuration or collecting interval as these changes require fresh rrd files.

It can be very difficult because sometimes the metrics are stored directly in the rrd root folder of a node and there is no easy way to match against the files you want to delete.

(Note: this does not apply to Newts users as all data points are kept in the Newts database)


The following example is based on the ElasticSearch XML datacollection. With a little Bash kung fu, it is very easy to solve the problem.

  1. Select all Elasticsearch metrics from the collection definition, add the file extension .rrd at the end of the file name and create a temporary file list:
    grep name $OPENNMS_HOME/etc/xml-datacollection/elasticsearch-cluster-stats.xml | cut -d'"' -f 2 | sed 's/$/\.rrd/' > filelist.txt

  2. Based on the list, find all files and delete them:
    find $OPENNMS_HOME/share/rrd/snmp/ | grep -f <(sed 's@^@/@; s/$/$/; s/\([\.[\*]\|\]\)/\\\1/g' filelist.txt) | xargs rm


This procedure also fits for other SNMP data collections. Just change search pattern in the first command and proceed with the second one as written above:

grep alias $OPENNMS_HOME/etc/datacollection/apc.xml | cut -d'"' -f 6 | sed 's/$/\.rrd/' > filelist.txt

1 Like

I made a wiki article out of this post to have a chance somebody can change during his existence of life :slight_smile:

1 Like