How To Empty the Cache in Prometheus Using Curl

Published Date Author: , Posted May 7th, 2020 at 3:17:16pm

I wanted to empty the time series data cache from the Prometheus server to start clean.

The best practice is to use the administrative HTTP API via curl. For example, to clear all data for job mysqld as defined in the prometheus.yml configuration file:

If you want to delete ALL data from Prometheus, then execute:

Since Prometheus keeps deleted data for 15 days by default, you may want to speed up that process by executing:

You can change the default of 15 days by setting the --storage.tsdb.retention option.


NOTE: The administrative HTTP API is disabled by default!

To enable it, add the --web.enable-admin-api argument to the prometheus commend at startup.

For example, this is an excerpt from my /etc/init.d/prometheus service script:

Credits:
Thanks to ShellHacks – https://www.shellhacks.com/prometheus-delete-time-series-metrics/

No comments as yet.

Leave Your Comment  Leave a comment

All fields marked with "*" are required.