Storage, Retention & Cost

This content was generated with the assistance of AI and should be verified against the official documentation before being relied on in production.

Checked on 2026-11-09 against Grafana 13.3.x and Kibana 9.5.x.

Every dashboard panel and every alert rule is a query over stored telemetry, so what you store, for how long and in which shape decides what you can see, how fast a query answers and what the platform costs. This page explains the two storage families used in this section (the Grafana backends and Elasticsearch), how retention works in each, which factors make the bill grow and which controls bring it down. It deliberately describes cost by capability and by driver only: it quotes no prices, because pricing and tiers change and are published by the vendors.

The telemetry itself is explained in Observability Fundamentals and the way it gets into a backend in Telemetry Collection Pipelines. Prometheus storage internals are covered in the Prometheus section, and Elasticsearch lifecycle internals in Index Lifecycle and Scaling; this page only adds what matters for monitoring.

Two storage families

The Grafana stack keeps one purpose-built backend per signal, all of them designed to keep data in cheap object storage where possible. Elasticsearch keeps all signals in one engine and gives you different on-disk layouts (index modes) for different shapes of data. Grafana itself stores no telemetry: it queries these backends through data sources (see Data Sources).

Signal Grafana stack Elasticsearch stack

Metrics

Prometheus (single node, local disk) or Mimir (horizontally scalable, object storage)

Time series data stream (TSDS, index.mode: time_series) with optional downsampling; since 9.5 also Prometheus remote-write ingestion and native PromQL in Kibana

Logs

Loki: indexes only labels and stores compressed log chunks in object storage

Logs data stream (LogsDB, index.mode: logsdb), full-text searchable

Traces

Tempo: block storage in object storage, looked up by trace ID or searched by attributes

APM data streams (traces) in standard data streams

Profiles

Pyroscope

Not covered by this section

The practical consequence of the difference is the cost model. Prometheus and Mimir pay for the number of active series and samples; Loki pays for log volume but keeps its index small, so a search that is not narrowed by labels scans chunks and is slower; Tempo stores traces cheaply but needs a trace ID, an exemplar or a search to find one. Elasticsearch pays for indexed data: every field of every document is searchable, which is flexible and fast but is the reason the two space-saving index modes below matter.

Retention in each backend

Retention is the rule that deletes old data. It is the single most effective cost lever, and the one most often left at a default nobody chose. Two traps are common: some backends keep data forever until you enable deletion, and a retention change usually applies only to data written afterwards or is not retroactive.

Prometheus

Prometheus deletes samples older than --storage.tsdb.retention.time, which defaults to 15d when neither retention flag is set. --storage.tsdb.retention.size caps the total size of persistent blocks and removes the oldest data first; it is off by default, and when both flags are set whichever limit is reached first wins. The documentation advises a size limit of at most 80 to 85 percent of the disk, because compaction needs temporary space. Samples are grouped into two-hour blocks that are compacted in the background, and the in-memory head block is protected by a write-ahead log.

The docs give a sizing rule of thumb of about 1 to 2 bytes per sample, which turns into needed_disk_space = retention_time_seconds * ingested_samples_per_second * bytes_per_sample. The same page notes that cutting the number of series is usually more effective than raising the scrape interval. Local storage is neither clustered nor replicated, so it is limited to one node’s durability: long retention or high availability is the reason to add remote write to a system such as Mimir.

# docker-compose.yml fragment: Prometheus with 30 days or 20 GB of retention, whichever comes first
services:
  prometheus:
    image: prom/prometheus:v3.5.0
    command:
      - --config.file=/etc/prometheus/prometheus.yml
      - --storage.tsdb.retention.time=30d
      - --storage.tsdb.retention.size=20GB
    volumes:
      - prometheus-data:/prometheus
volumes:
  prometheus-data:

Source: https://prometheus.io/docs/prometheus/latest/storage/ (sections "Operational aspects" and "Remote storage integrations"). The image tag is an example: use the Prometheus version of your lab.

Mimir

Mimir keeps blocks in object storage and, by default, keeps them indefinitely, so storage grows until you set a retention period. The compactor deletes blocks older than -compactor.blocks-retention-period, or compactor_blocks_retention_period under limits in the YAML file. A per-tenant value under overrides in the runtime configuration takes precedence, and 0 disables deletion for that tenant. Mimir cannot delete or retain individual series and does not support the Prometheus delete-series API, so a series that was ingested by mistake stays until its block expires.

# mimir.yaml fragment
limits:
  compactor_blocks_retention_period: 90d

Loki

Loki retention is implemented by the compactor and is off by default, so logs are kept indefinitely until retention_enabled is set. The compactor marks chunks for deletion and a sweeper removes them after retention_delete_delay (default 2h). The period is set in limits_config: retention_period globally or per tenant, and retention_stream rules for streams that match a label selector. Each stream period must be at least 24h; when several rules match, the highest priority wins and, on a tie, the shorter period applies. Per-stream rules are what let you keep audit logs for a year and debug logs from a dev namespace for a day. The older Table Manager is deprecated and is needed only for legacy index types.

# loki.yaml fragment: 31 days by default, 24 hours for the dev namespace
compactor:
  working_directory: /loki/retention
  compaction_interval: 10m
  retention_enabled: true
  delete_request_store: filesystem
limits_config:
  retention_period: 744h
  retention_stream:
    - selector: '{namespace="dev"}'
      priority: 1
      period: 24h

Source: https://grafana.com/docs/loki/latest/operations/storage/retention/. The page’s full example also needs a schema_config with a 24h index period and a delete_request_store that matches your object store; filesystem here is only an assumption for the single-node lab.

Tempo

Tempo deletes whole blocks once they are older than the compactor’s block_retention, which defaults to 336h (14 days). It can be overridden per tenant. Tempo’s production backends are S3, GCS and Azure Blob Storage; local disk is for development and monolithic mode only.

# tempo.yaml fragment
compactor:
  compaction:
    block_retention: 168h

Source: https://grafana.com/docs/tempo/latest/configuration/ (compactor and storage sections).

Elasticsearch: data stream lifecycle and ILM

Elasticsearch has two lifecycle mechanisms for the data streams that hold metrics, logs and traces. The data stream lifecycle is the simpler, recommended one: you set how long data must be kept (data_retention) and, for a TSDS, a list of downsampling rounds, and Elasticsearch handles rollover and cleanup without you thinking about hardware tiers. Index lifecycle management (ILM) gives per-index control over hot, warm, cold, frozen and delete phases and the actions in them (rollover, shrink, force merge, searchable snapshots, delete), and is the choice when you move data across hardware tiers to trade performance against cost. ILM is not available on Serverless, where only the data stream lifecycle exists. Deletion is based on each backing index’s generation time, so data is kept at least as long as the retention period and may remain a little longer.

PUT _data_stream/logs-bookshelf-default/_lifecycle
{
  "data_retention": "30d"
}

PUT _data_stream/metrics-bookshelf-default/_lifecycle
{
  "data_retention": "90d",
  "downsampling": [
    { "after": "7d",  "fixed_interval": "1h" },
    { "after": "30d", "fixed_interval": "1d" }
  ]
}

Reference: https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-put-data-lifecycle (request body fields data_retention, downsampling, downsampling_method, enabled) and https://www.elastic.co/docs/manage-data/lifecycle/data-stream. The downsampling array applies to time series data streams only and the data stream names are the lab’s assumed names. On 9.5 and later (not Serverless) the lifecycle also accepts frozen_after to move older backing indices to frozen searchable snapshots, which needs a default snapshot repository and an appropriate licence (https://www.elastic.co/docs/manage-data/lifecycle/data-stream/tutorial-update-existing-data-stream). A change to the lifecycle applies to every backing index of the stream.

Which to choose: ILM and the data stream lifecycle are compared on https://www.elastic.co/docs/manage-data/lifecycle/index-lifecycle-management. A data stream with an ILM policy keeps using ILM unless index.lifecycle.prefer_ilm is set to false; do not leave both configured by accident.

Elasticsearch layouts that save space

Time series data streams are the metric-optimised layout. You enable them with index.mode: time_series in the index template, mark identifying fields with time_series_dimension: true and numeric fields with time_series_metric (counter, gauge or histogram; histograms are generally available since 9.4). Elasticsearch derives the document ID from the dimensions and the timestamp, routes each series to one shard and sorts internally by _tsid and @timestamp. Elastic’s benchmark shows roughly 70 percent less disk than a regular data stream, with the caveat that real savings depend on the data. The trade-offs: custom _id values are not supported, a second document with the same dimensions and timestamp is rejected with 409 Conflict, _source is synthetic, and from 9.4 sequence numbers are disabled by default, which weakens optimistic concurrency for update-by-query and delete-by-query. In ES|QL the TS command and the time series aggregation functions query a TSDS (generally available since 9.4).

PUT _index_template/metrics-bookshelf
{
  "index_patterns": ["metrics-bookshelf-*"],
  "data_stream": {},
  "priority": 500,
  "template": {
    "settings": { "index.mode": "time_series" },
    "mappings": {
      "properties": {
        "@timestamp": { "type": "date" },
        "service.name": { "type": "keyword", "time_series_dimension": true },
        "http.route":   { "type": "keyword", "time_series_dimension": true },
        "http.requests": { "type": "long", "time_series_metric": "counter" },
        "jvm.memory.used": { "type": "long", "time_series_metric": "gauge" }
      }
    }
  }
}

Reference: https://www.elastic.co/docs/manage-data/data-store/data-streams/set-up-tsds and https://www.elastic.co/docs/manage-data/data-store/data-streams/time-series-data-stream-tsds. The field names are illustrative; the EDOT pipeline of the lab creates its own mappings, so use this snippet as a model, not a copy target. Priority 500 stays above the 200 minimum the page recommends so that built-in templates do not win.

Downsampling reduces the footprint of older metrics by replacing many samples with one per interval: documents with the same _tsid are bucketed by timestamp, dimensions are copied once per bucket and each metric is stored according to its downsampling method. aggregate keeps min, max, sum and value_count for gauges as an aggregate_metric_double; last_value keeps only the latest value, saves the most space and loses the most accuracy. Counters keep the first value plus up to two reset points from 9.4, and delta counters keep the bucket sum from 9.5. A downsampled index replaces the original on the same tier, and a second round must use an interval that is a multiple of the first. In ES|QL a downsampled gauge behaves as a double holding each interval’s average, so a maximum computed from downsampled data is the maximum of averages: if you alert on peaks, alert on recent, not-yet-downsampled data. Sources: https://www.elastic.co/docs/manage-data/data-store/data-streams/downsampling-time-series-data-stream and https://www.elastic.co/docs/manage-data/data-store/data-streams/downsampling-concepts.

LogsDB (index.mode: logsdb) is the log-optimised layout. Elastic’s benchmark reports up to 60 percent less log storage with a 10 to 20 percent cost in indexing speed. It is the default for new logs-*-* data streams on Elastic Stack 9.0 and later and on Serverless; data streams created on 8.x are not switched automatically, and a stack upgraded from 8.x gets it for new streams only if no logs-*-* data stream existed at upgrade time. To enable it, set the index mode in the template (or in a @custom component template for an integration); the change applies at the next rollover. Source: https://www.elastic.co/docs/manage-data/data-store/data-streams/logs-data-stream.

The Kibana side of these layouts, together with Streams, is described in Data Streams, TSDS & Lifecycle.

What drives cost

Cost is the product of a few drivers, and most of them can be measured before they hurt:

  • Cardinality. In a Prometheus-style system every distinct combination of label values is a separate series with its own index entry, memory and samples, so one label that holds a user ID, a URL with identifiers or a pod hash multiplies the series count. Cardinality is the first thing to check when memory, disk or query time grows unexpectedly. In Elasticsearch the equivalent is the number of dimension combinations in a TSDS and the number of distinct field mappings.

  • Log volume. Bytes per day, driven by verbosity, line size and stack traces. Debug logging left on in production is the classic cause.

  • Retention. Storage grows linearly with the retention period, and everything above is multiplied by it.

  • Query load. Dashboards that refresh every few seconds over wide ranges, and rules evaluated every minute, are paid for continuously. Hand-written queries over unbounded ranges are a separate risk.

  • Egress and cross-zone traffic. Shipping telemetry between zones, regions or clouds is billed by the network, not by the monitoring product.

  • Agent overhead. Collectors and instrumentation consume CPU and memory on every node, and tracing everything adds latency and allocation to the service. Sizing guidance for collectors is on Telemetry Collection Pipelines.

Cost controls

Apply the controls in this order, because the first ones are free and the later ones remove information you may need:

  1. Measure before you cut. List the heaviest metric names and series counts, and the heaviest log streams.

  2. Drop what nobody uses. Remove labels and metrics at the collector (relabeling in Prometheus and Alloy, processors in the OpenTelemetry Collector and EDOT) so they never reach the backend. In Prometheus, metric_relabel_configs with the labeldrop or drop actions is the standard tool.

  3. Pre-compute. Recording rules turn an expensive query into a cheap lookup, which cuts query cost and dashboard latency at the price of one extra series per aggregated result; see Recording Rules and Recording and Alerting Rules.

  4. Sample traces. Keep all error and slow traces and a small percentage of the healthy ones. Head sampling decides at the start of a trace; tail sampling in the collector decides after seeing the whole trace and therefore needs the buffering discussed on the pipelines page.

  5. Shorten or tier retention. Keep raw data briefly, downsampled data longer, and archive only what you must keep.

  6. Use the managed optimisers where you have them. Grafana Cloud’s Adaptive Metrics analyses how metrics are used in dashboards, alerts, recording rules and queries and recommends aggregating under-used series into lower-cardinality versions, applied through the UI, API or Terraform; it is a Grafana Cloud feature, not part of the OSS stack. Cloud billing views and usage alerts are described under https://grafana.com/docs/grafana-cloud/platform/cost-management-and-billing/. Log volume and adaptive logs and traces tooling is documented in the same Grafana Cloud section; check it for the current feature names.

# Top 10 metric names by number of series (run in Explore against the Prometheus data source)
topk(10, count by (__name__) ({__name__=~".+"}))

# Series per label for one metric, to find the label that explodes cardinality
count by (uri) (http_server_requests_seconds_count{job="bookshelf"})

Reference: https://prometheus.io/docs/prometheus/latest/querying/basics/ (selecting series by metric name matcher). The first query is expensive on a large server; the Prometheus TSDB status page (Status, then TSDB Status) shows the same top-series information without running it.

# prometheus.yml fragment: drop a high-cardinality label before storage
scrape_configs:
  - job_name: bookshelf
    metrics_path: /actuator/prometheus
    static_configs:
      - targets: ["bookshelf:8080"]
    metric_relabel_configs:
      - action: labeldrop
        regex: "user_id"

Reference: https://prometheus.io/docs/prometheus/latest/configuration/configuration/#metric_relabel_configs. The Bookshelf metrics do not carry a user_id label, which is the point: if your own service ever exposes one, this is the guard.

Return on investment and MTTR

Observability spending is justified by shorter outages, not by data volume. Two measures keep the conversation honest. Mean time to detect (MTTD) and mean time to resolve (MTTR) show whether the platform is working: good alerts shorten detection, and good dashboards, logs and trace links shorten diagnosis. Track both per incident rather than as a fleet-wide average, which hides the long incidents that cost the most. Second, attach the cost of each signal to the questions it answers: metrics answer "is it broken, and for whom" cheaply, logs answer "what exactly happened" at higher cost per byte, and traces answer "where in the call chain" at the price of instrumentation and sampling. If a signal costs more than it is ever queried, reduce it; if an incident lacked a signal, that gap is the argument for paying for it. The reasoning on service objectives continues in SLIs, SLOs & Error Budgets.

What can go wrong

  • Retention is enabled in the config file but nothing is deleted: Loki needs retention_enabled: true and a compatible schema, and Mimir needs a retention period because it defaults to keeping data forever.

  • The disk fills even though retention is set: Prometheus size limits do not delete the write-ahead log, and without headroom for compaction the node can run out of space. Alert on disk usage and keep the size cap at 80 to 85 percent.

  • A retention change seems ignored: changes are not retroactive in Loki, and Elasticsearch deletes whole backing indices, not individual documents.

  • Dashboards go blank after downsampling: the series now have fewer points, so rate-style math over a window shorter than the new interval returns nothing. Keep alerting data raw for as long as the alert windows need.

  • A cardinality spike appears right after a deployment: a new label with unbounded values, for example a raw URL instead of a route template. Fix it at the instrumentation or in metric_relabel_configs, then wait for the old series to expire.

Verify it in the lab

The lab is described in Hands-on Lab. With the grafana profile up:

  1. Open Prometheus at http://localhost:9090/query, run the topk query above and note the count of series for the bookshelf job.

  2. Run the load generator for a few minutes and run the query again; the series count should be stable, which means the labels are bounded.

  3. Open the Prometheus Status, Runtime and Build Information page and check the retention value matches the flag you set.

  4. Check the volume of data written with du -sh on the Prometheus data volume before and after the load run to see how quickly it grows.

With the kibana profile up:

  1. The lab’s EDOT Collector writes in OTel mapping mode, so its data streams match logs-*.otel-* and traces-*.otel-* rather than the logs-bookshelf-default names above. In Kibana Dev Tools, send the logs PUT body above to _data_stream/logs-*.otel-*/_lifecycle, then run GET _data_stream/logs-*.otel-*/_lifecycle to confirm the retention was stored.

  2. Run GET logs-*.otel-*/_settings?filter_path=*.settings.index.mode and check it returns logsdb on a 9.x stack.

In the books

Hausenblas, Cloud Observability in Action, discusses backend destinations for each signal and what to weigh when choosing one: cost, open standards, back pressure, and cardinality and query behaviour. Chapman and Holmes, Observability with Grafana, chapter 11, covers architecting an observability platform, including data architecture and who may access which telemetry. Both predate the TSDS, LogsDB and downsampling features above, the Grafana Agent end of life (use Grafana Alloy) and the 9.x data stream lifecycle, and their cloud pricing is intentionally not reproduced. Publisher pages are listed in the bibliography of the section index.