Skip to content

Downsampling and rollups

Downsampling replaces dense raw samples with coarser summaries (count, sum, min, max) per interval as data ages, so a year of metrics stays queryable at a bounded cost. The question is what each tier keeps and what each rollup loses.

On this page

What it is

Downsampling rewrites a time series so that it holds fewer points per unit of time; a rollup is the summary row written for each coarser interval. The Thanos compactor documentation (its development tip, read in November 2026) describes the process as rewriting series to lower their resolution while keeping results accurate over long ranges. Graphite's whisper files (Graphite 1.2.0) build the same idea into the storage format: a metric gets a chain of retention levels, each a frequency and a history such as 15s:7d,1m:21d,15m:5y, listed from most precise with the shortest history to least precise with the longest, and whisper downsamples points as they cross each boundary.

What a rollup row keeps decides what you can still ask later. In Thanos, a downsampled chunk carries, for each 5-minute or 1-hour interval, a count, a sum, a min, a max and a counter aggregate; count and sum give an average, min and max keep the peaks, and the counter aggregate is what rate, increase and resets work from. Graphite's default is a single average per level, with sum, min, max and last as alternatives chosen per metric pattern in storage-aggregation.conf. An average can be turned back into a total by multiplying by the ratio of fine to coarse points, so a stored hourly mean of per-minute sales times 60 gives the hour's sales. What an average loses is the spike: a five-minute mean says nothing about the single 15-second sample that was ten times higher.

Metric kindKeep per intervalWhy

Gauge (CPU, queue depth, temperature)

count, sum, min, max

Mean from count and sum; peaks and troughs from min and max

Counter (requests served, bytes sent)

a counter aggregate that tracks progression and resets (Thanos); a plain last value per interval can miss resets

Rate and increase need the counter's progression, not its average

Histogram (latency buckets)

bucket counts, total count, sum

Buckets add across intervals, so a percentile can be computed at query time

A percentile already computed (a p99 per minute)

the series as it is, for display; it can't be combined into a coarser exact p99

Percentiles don't re-aggregate as expected; keep the histogram instead

Who does the rolling up. Three mechanisms show up in practice. A background compactor rewrites stored blocks: Thanos runs two passes, turning raw blocks older than 40 hours into 5-minute resolution and 5-minute blocks older than 10 days into 1-hour resolution. A scheduled query inside the database can do it instead, grouping recent raw rows by a time bucket and writing the aggregates into a longer-lived table; because such a query covers a recent window, a point that arrives after its window has been processed is not rolled up unless the job is rerun. Or the file format does it on write, as whisper does when a point ages past a retention level.

Retention is set per tier, and the order of operations matters. Thanos takes a retention flag per resolution (raw, 5m, 1h), treats an unset flag as keep everything, and applies retention right after its compaction and downsampling loops, so if those loops fail, nothing gets deleted. The documented trap is the reverse: raw retention shorter than the 40-hour age at which the first pass runs means raw data is removed before any rollup exists for it, and the same applies between the 5-minute and 1-hour tiers. Whisper avoids the ordering problem by construction, since each level's history is part of the file and a point moves to the coarser level as it ages out of the finer one.

Space and speed are different goals. In Thanos, downsampling does not reduce storage: each raw block gains two more blocks of similar size, roughly tripling the footprint when all resolutions are kept, because the aggregates are stored alongside the raw data; the point is that a range query over months reads far fewer samples. Whisper, by contrast, saves disk and I/O because the coarse points replace the fine ones. In a design, say which you want: cheaper storage, faster long-range queries, or both, and the answer decides whether raw data is deleted or kept beside the rollups.

When to use it

Roll up when queries span weeks or months and a screen can show a point per hour at most. The Thanos documentation frames downsampling as the way to get fast results for range queries over months or years, and warns that without it such queries become much more expensive, since they would read each raw sample in the range.

Roll up when retention is long and storage per series has to be bounded. Graphite's multi-level retentions exist so a metric can keep years of history while spending disk and I/O on fine detail for recent days and not for old ones; its example keeps 15-second points for a week, 1-minute points for three weeks and 15-minute points for five years.

A second axis is rolling up across series rather than across time. Graphite's aggregation rules add several incoming metrics into one as they arrive, so a dashboard that wants the service total does not have to sum hundreds of per-instance series on each request. Our advice for a design with ten million series: precompute the few cross-series totals the dashboards and alerts read most, and leave the long tail to query-time aggregation.

When not to

Skip rollups when nobody will query long ranges. Thanos offers a flag to turn downsampling off and suggests it when the system serves the last couple of weeks, or serves alerting and nothing else, adding that a plain Prometheus may then be the simpler choice. A single raw tier with a retention limit is easier to run and has one fewer pass that can fall behind.

Don't delete raw data if you expect to zoom into an incident months later. In Thanos, raw retention shorter than the 5-minute and 1-hour retentions leaves a downsampled picture of history with no way back to the raw shape; the recommended setting is equal retention at each resolution, or none. If storage allows it, keep raw and rollups together and let the query layer pick.

Don't roll up what doesn't summarize. Percentiles are one example: Graphite's own caution is that re-aggregating percentile outputs does not behave as people expect, so a stored per-minute p99 should not be averaged into an hourly p99. Roll up histogram buckets or keep raw latencies, and compute the percentile when asked. Sparse series are another: whisper's xFilesFactor, 0.5 by default, requires that fraction of the finer level's slots to hold values before a coarser value is written, so a metric that reports in fewer than half its slots rolls up to nothing unless you lower the factor for it. Individual events, audit records and traces are a different case: the record itself can't be averaged, so our advice is to decide separately how long to keep the records whole and which counts or histograms to derive from them.

And don't reach for rollups to fix a series explosion. A rollup works per series, so it reduces samples within each one and leaves the number of series unchanged. If a label carries an unbounded value such as a user or request id, the series count grows with it, and the fix is dropping or relabeling that label at ingestion, which is covered in Time-series storage.

Compared

ApproachWhat it costsChoose it whenThe alternative wins when

Raw samples with one retention limit

Long-range queries read each raw sample

Retention is a few weeks, or the store feeds alerting

Dashboards span months; a year of raw data won't fit the budget

Rollups keeping count, sum, min, max and a counter (Thanos style)

Roughly three times the storage if raw is kept too

Averages, peaks and rates must stay right over months

Storage is the constraint and the mean is all anyone asks for

Rollups keeping a single average (Graphite's default)

Peaks and troughs are lost for good

Disk and I/O are tight and totals can be recovered from the mean

Someone will ask what the maximum was in an hour last quarter

Rollups written by a scheduled query inside the database

Covers a recent window; points that land after the window was processed are not rolled up

The database has it built in and the schema is simple

Writes arrive late or out of order, so a compactor over stored blocks is safer

Aggregate at query time, no rollups

Query cost grows with the range

Data is small or ranges are short, and exactness matters

A chart over a year times out or costs more than storing the summaries

In a picture

Scraper, 15sRaw blocks

Step 1 of 4

Raw samples land in blocks

Scrapers write samples at the scrape interval into raw blocks. This tier is the one you can zoom into, and it is the most expensive per day of history.

How to say it in an interview

The common mistake

Quiz

A system keeps 10-second samples for two hours and a 30-minute mean for a year. Six months later someone asks for the highest value seen within one hour of a given day. What can they get?
Raw retention is set to 24 hours, and the first rollup pass handles raw blocks once they are older than 40 hours. What ends up in the 5-minute tier?
You have a p99 latency computed per minute. Which gives a correct hourly p99 for a year of history?
A metrics store is growing because a label carries the request id, creating a new series per request. Which change helps?

Questions that use this

Related

Sources

  1. Thanos documentation (tip): Compactor
  2. Graphite 1.2.0 documentation: Configuring Carbon
Sign in to report a mistake