Prompt
retention and downsampling for metrics
Latest observation
Oct 25, 2026
OpenAI APIWeb search: off
A good retention and downsampling strategy for metrics usually looks like a multi-resolution time-series pyramid:
1) Keep raw data only for a short period
Store high-resolution metrics (e.g., 10s / 1m granularity) for a limited window:
- 7–30 days is common for detailed debugging
- Raw data is expensive, but useful for recent investigations
2) Downsample into coarser intervals
Roll up older data into larger buckets, for example:
- 1 minute for recent history
- 5 minutes for medium term
- 1 hour for long term
- 1 day for very long term
For each bucket, store aggregations such as:
countsumavgminmaxp50 / p95 / p99if supportedlastfor gaugesratefor counters (derived from delta)
3) Use retention tiers
Example policy:
- Raw 10s data: 14 days
- 1m rollups: 90 days
- 5m rollups: 1 year
- 1h rollups: 2–5 years
This lets you:
- Investigate recent incidents in detail
- Track trends over months/years
- Control storage growth
4) Decide based on metric type
Different metric types need different handling:
- Counters: store deltas/rates, preserve monotonicity
- Gauges: keep min/max/avg/last
- Histograms/percentiles: preserve distribution carefully; raw samples may be needed longer for accurate quantiles
- Events: often better retained separately from aggregated metrics
5) Be careful with aggregation loss
Downsampling is lossy. You lose:
- spikes
- exact percentiles
- fine-grained correlation with logs/traces
So keep raw data long enough for your operational needs.
6) A practical example
For a service metrics pipeline:
- Ingest at 1-minute resolution
- Retain raw for 14 days
- Downsample to 5-minute for 90 days
- Downsample to hourly for 2 years
- Use daily aggregates for capacity planning and reporting
7) Operational considerations
- Define rollup jobs and schedules
- Ensure idempotent aggregation
- Handle late-arriving data
- Align bucket boundaries consistently
- Version your retention policy so dashboards don’t break
If you want, I can also give:
- a recommended policy by use case (SRE, business metrics, IoT), or
- a sample schema and rollup job design for Prometheus/InfluxDB/TimescaleDB/ClickHouse.