Skip to content

Deleting a Time Series

Video Lecture

Deleting a Time Series Deleting a Time Series

 (Pay Per View)

You can use PayPal to purchase a one time viewing of this video for $1.49 USD.

Pay Per View Terms

  • One viewing session of this video will cost the equivalent of $1.49 USD in your currency.
  • After successful purchase, the video will automatically start playing.
  • You can pause, replay and go fullscreen as many times as needed in one single session for up to an hour.
  • Do not refresh the browser since it will invalidate the session.
  • If you want longer-term access to all videos, consider purchasing full access through Udemy or YouTube Memberships instead.
  • This Pay Per View option does not permit downloading this video for later viewing or sharing.
  • All videos are Copyright © 2019-2025 Sean Bradley, all rights reserved.

Description

There may be a time when you want to delete data from the Prometheus TSDB database.

Data will be automatically deleted after the storage retention time has passed. By default, it is 15 days.

If you want to delete specific data earlier, then you are able.

You need to enable the admin API in Prometheus before you can.

sudo nano /etc/default/prometheus

Add --web.enable-admin-api to the ARGS="" variable. E.g.,

ARGS="--web.enable-admin-api"

Restart Prometheus and check status

sudo service prometheus restart
sudo service prometheus status

You can now make calls to the admin API.

In my example I want to delete all time series for the instance="sbcode.net:9100"

So I run the delete_series API endpoint providing the value to match. E.g.,

curl -X POST -g 'http://localhost:9090/api/v1/admin/tsdb/delete_series?match[]={instance="sbcode.net:9100"}'

When I re-execute the Prometheus query, the time series I wanted to be deleted no longer exists.

You can have more complicated match queries, e.g.,

curl -X POST -g 'http://localhost:9090/api/v1/admin/tsdb/delete_series?match[]=a_bad_metric&match[]={region="mistake"}'

curl -X POST -g 'http://localhost:9090/api/v1/admin/tsdb/delete_series?match[]=node_exporter:memory:percent'

curl -X POST -g 'http://localhost:9090/api/v1/admin/tsdb/delete_series?match[]=node_filesystem_free_percent'

curl -X POST -g 'http://localhost:9090/api/v1/admin/tsdb/delete_series?match[]=node_memory_MemFree_percent'

curl -X POST -g 'http://localhost:9090/api/v1/admin/tsdb/delete_series?match[]=ALERTS'

curl -X POST -g 'http://localhost:9090/api/v1/admin/tsdb/delete_series?match[]=ALERTS_FOR_STATE'

After deleting you should disable the admin API again,

sudo nano /etc/default/prometheus

Remove --web.enable-admin-api from the ARGS variable. E.g.,

ARGS=""

Restart Prometheus and check status

sudo service prometheus restart
sudo service prometheus status

Delete Series

Prometheus 2.31 and Ubuntu 22.04 Notes

In the video, I demonstrate the --storage.tsdb.retention flag. This flag has been deprecated. Now use --storage.tsdb.retention.time instead.

E.g.,

ARGS="--storage.tsdb.retention.time=1y"

The default value remains 15d. Units Supported: y, w, d, h, m, s, ms.