capabilities.work

Delete Series and Reclaim the Space

A 6-step recipe with Prometheus. We can help you get access.

Recipe · 6 steps

Delete Series and Reclaim the Space

Safely delete matching series and force the space to be reclaimed.

  1. Resolve the selector to the exact label sets it matches. This is the last chance to catch a selector that is broader than intended, and the count here is precisely what the delete will destroy.
  2. Record the TSDB head statistics before the deletion so the reclaimed series count can be shown rather than assumed.
  3. Create deletion tombstones for the matched series. This returns 204 and the data becomes unqueryable immediately, but nothing has actually left the disk yet.
  4. Force the tombstoned data off disk rather than waiting for the next natural compaction. This triggers a compaction of every block carrying tombstones and is the step that actually reclaims the space.
  5. Re-run the preview selector and confirm it now matches nothing, proving the deletion took effect rather than silently failing.
  6. Read the TSDB head statistics again so the before and after series counts quantify what the deletion actually reclaimed.
What you'll need to have ready
  • seriesSelector: The series selector identifying what to delete (e.g. http_requests_total{job="deprecated-api"}). Verify this against the preview before trusting it.
  • start: Start of the deletion time range. Defaults to the minimum possible time when omitted, meaning all history.
  • end: End of the deletion time range. Defaults to the maximum possible time when omitted, meaning all future data already ingested.
For your developer

Arazzo workflow prometheus:delete-series-reclaim-space, 6 operations: querySeries → getTsdbStatus → deleteTsdbSeries → cleanTombstones → querySeries → getTsdbStatus. Specs on APIs.io.