Skip to content

Lesson 7 of 9 · 27m

Long-Term Metrics Storage Beyond Local Prometheus

Design remote-write and object-storage architectures with Prometheus, Thanos, or Mimir while understanding replication, query fanout, and failure domains.

Local Prometheus is excellent at being a fast, self-contained metrics database. It is not naturally a globally durable, multi-year, multi-cluster query system. Once you need long retention, high availability, cross-cluster views, or multi-tenant ingestion, you are designing a distributed system whether you wanted one or not.

Know which problem you are solving

Common requirements look similar but lead to different architectures:

HA pair for ingest continuity
object storage for cheap long retention
global query across clusters
multi-tenant isolation
downsampled historical analytics
disaster recovery independent of the cluster

Thanos often extends Prometheus with object storage, sidecars, compactors, and query fanout. Mimir is a horizontally scalable multi-tenant TSDB that receives remote write directly. Both can work. The mistake is adopting either before writing down the operational requirement.

Prometheus remote write is a pipeline edge

Prometheus can send samples to remote storage:

remote_write:
  - url: https://mimir-gateway.internal/api/v1/push
    queue_config:
      capacity: 10000
      max_shards: 30
      max_samples_per_send: 2000
      batch_send_deadline: 5s
    write_relabel_configs:
      - source_labels: [__name__]
        regex: "experimental_.*"
        action: drop

This is not fire-and-forget backup. Remote write is a queue with memory pressure, retry behavior, ordering concerns, and backpressure. If the remote endpoint is down long enough, samples can drop or Prometheus memory can grow.

Object storage changes the durability model

Thanos sidecars upload TSDB blocks to object storage. A simplified bucket layout might be:

s3://metrics-prod/
  01JZX.../chunks/
  01JZX.../index
  01JZX.../meta.json

Object storage gives durability and cheap retention, but query now depends on index discovery, block download/cache behavior, compaction state, and network performance. The CAP theorem does not care that the dashboard is called Grafana.

Replication is not deduplication unless designed that way

HA Prometheus pairs often scrape the same targets. If both remote-write the same data, the backend needs deduplication logic keyed by replica labels. Example external labels:

global:
  external_labels:
    cluster: prod-us-east
    prometheus_replica: prom-a

Thanos Query can deduplicate when replica labels are configured consistently. Mimir ingestion has its own HA tracker model. Inconsistent labels create double lines, doubled rates, or silent dedupe failure.

Query fanout is a distributed systems problem

A global query may touch many edge Prometheus servers, object-store gateways, or tenant partitions:

sum by (cluster) (
  rate(http_requests_total{service="checkout"}[5m])
)

Ask where aggregation happens, how much data crosses the network, what timeout applies, and whether partial results are accepted. Partial data is sometimes appropriate for dashboards and dangerous for alerts.

Multi-tenancy is more than a header

Tenant isolation needs authentication, per-tenant limits, ingestion accounting, query isolation, and operational ownership. A tenant label alone is not a security boundary. If one tenant can send unlimited cardinality, every tenant shares the outage.

Minimum controls:

authenticated remote-write identity
per-tenant active series limits
per-tenant ingestion rate limits
query concurrency and timeout controls
tenant-level usage and rejection metrics

Choose boring operability

The best long-term metrics architecture is the one your on-call team can rebuild at 03:00. Document block flow, replication behavior, object storage lifecycle, compaction ownership, and restore expectations. Draw the write path and read path separately; they fail differently.

Field notes

  • Remote write does not backfill local historical data automatically unless the receiver and Prometheus features support it.
  • Object storage lifecycle rules can delete metrics blocks while metadata still references them if configured carelessly.
  • Compaction and downsampling are not optional background noise; under-provisioned compactors create query chaos.
  • Test disaster recovery by querying after losing a Prometheus node, not by reading the architecture diagram.
  • Keep local alerting close to ingestion even when long-term storage is remote.

Was this lesson helpful?

Sign in to rate