Retention and downsampling#

This page explains how long the stack keeps data and how it bounds the cost of keeping it. The short answer is a tiered strategy: keep recent data at full resolution, then trade resolution for time as data ages.

Local Prometheus retention#

Prometheus keeps its own data for a short window, two days by default. A short window is deliberate. Local storage is on a persistent volume, and keeping it small keeps Prometheus fast to query and cheap to run. Two days is comfortably longer than the time a Thanos sidecar needs to upload a completed block to S3, so nothing is lost when the local window rolls over.

Local retention answers recent queries directly from Prometheus, which is the common case for dashboards and active alerting.

Long-term metrics in Thanos#

Everything beyond the local window lives in S3 and is served by Thanos. The Thanos Compactor enforces three retention windows, one per resolution.

Raw resolution

The original samples, kept for thirty days by default.

5-minute resolution

Downsampled data, kept for one hundred and eighty days by default.

1-hour resolution

Further downsampled data, kept for seven hundred and thirty days by default.

Downsampling is what makes long-range queries practical. A two-year query at raw resolution would scan an enormous number of samples; the same query at one-hour resolution scans a tiny fraction and still renders a faithful trend. Thanos Query picks an appropriate resolution for the time range automatically, so a dashboard spanning years stays responsive while a dashboard spanning hours stays precise.

Each window also bounds storage. Raw data is the largest and is discarded first; the coarser resolutions are small enough to keep for years.

Loki log retention#

Logs follow the same principle of bounded cost, but without downsampling, since logs do not aggregate the way numeric samples do. Loki keeps logs for a fixed retention, seven hundred and forty-four hours, or thirty-one days, by default, after which old chunks in S3 are removed.

Tuning the windows#

All of these values are defaults you can override per cluster. A cluster with cheap storage might keep raw metrics longer; a cluster with strict cost limits might shorten log retention. The Override the defaults guide shows how, and Configuration options lists every retention field and its default.

See also#