Configure Metric Retention

By default, OpenTSDB stores two weeks of metrics. Based on your requirements, you can change metric retention period.

The following cron job runs each day to purge metrics based on the retention period.
$min $hour * * * $OTSDB_HOME/bin/ -purgeData >> $OTSDB_HOME/var/log/opentsdb/purgeData.log 2>&1 
Complete the following steps to edit the metric retention period:
  1. Open the /opt/mapr/opentsdb/opentsdb-<version>/bin/ file.
  2. In the following line, update the value of '2 weeks ago' to the new retention period.
    $OT_HOME/bin/tsdb scan --delete 2000/01/01 $(date --date='2 weeks ago' +'%Y/%m/%d') sum $metric
    For example, to delete metrics from 1/1/2000 to [current date - 2 days]:
    $OT_HOME/bin/tsdb scan --delete 2000/01/01 $(date --date='2 days ago' +'%Y/%m/%d') sum $metric
    Note: For more information, see the OpenTSDB scan command documentation.