@Override
  public void run() {
    try {
      if (!MetastoreConf.getBoolVar(conf, ConfVars.SCHEDULED_QUERIES_ENABLED)) {
        return;
      }
      RawStore ms = HMSHandler.getMSForConf(conf);
      int maxRetainSecs = (int) MetastoreConf.getTimeVar(conf, ConfVars.REPL_METRICS_MAX_AGE, TimeUnit.SECONDS);
      LOG.info("Cleaning up Metrics older than {} ", maxRetainSecs);
      int deleteCnt = ms.deleteReplicationMetrics(maxRetainSecs);
      if (deleteCnt > 0L) {
        LOG.info("Number of deleted entries: {} " + deleteCnt);
      }
    } catch (Exception e) {
      LOG.error("Exception while trying to delete: " + e.getMessage(), e);
    }
  }
Metastore task to remove old replication metrics.
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/ReplicationMetricsMaintTask.java