Start with the failure mode, not the product diagram
At 18:02, a load-shedding event switched a payment platform onto backup power. The application kept serving traffic, but its monitoring stack did not: exporters retried, Kubernetes targets churned, and a single Prometheus instance began falling behind on remote…
Scalable Metrics Processing Architectures: Designing for Bursts, Budget and Broken Links
At 18:02, a load-shedding event switched a payment platform onto backup power. The application kept serving traffic, but its monitoring stack did not: exporters retried, Kubernetes targets churned, and a single Prometheus instance began falling behind on remote writes. By the time the lights returned, the team had a six-hour gap in the metrics that should have explained the incident.
This is the practical problem behind Scalable Metrics Processing Architectures. The challenge is not simply collecting more samples. It is absorbing bursts, controlling cardinality, surviving disconnected sites, keeping query performance predictable and storing only what is useful. Prometheus, Mimir, Grafana, Loki and Tempo can form a strong platform, but only when each component has a clear job.
Start with the failure mode, not the product diagram
A small South African platform often begins with one Prometheus server scraping Kubernetes, node exporters, databases and a few legacy virtual machines. That is a sensible starting point. It becomes fragile when the estate expands across Johannesburg, Cape Town, an on-premises data centre and a cloud region in eu-west.
Three pressures usually arrive together:
- Scrape volume increases as teams add services, pods and application metrics.
- Labels become more detailed, producing expensive time series such as request IDs, user IDs or unbounded URL paths.
- Remote-write traffic competes with application traffic across links that may be slow, expensive or temporarily unavailable.
The first design decision should therefore be operational: which data must be available locally during an outage, which data needs global visibility, and how much delay is acceptable? A node-level saturation alert may need to fire within seconds at a branch. A 13-month service-level trend can tolerate delayed ingestion.
Grafana is useful here because dashboards can expose both the local and central view without forcing every operator to query the same backend. A regional team can work against a nearby Prometheus while the central SRE function uses long-term data in Mimir.
A four-layer architecture that scales without hiding failure
A dependable architecture separates collection, processing, storage and presentation.
- Collection: Prometheus agents or full Prometheus servers scrape targets close to the workload.
- Processing: relabel rules, recording rules and optional OpenTelemetry Collector pipelines remove noise and standardise metadata.
- Storage: Mimir receives remote writes for durable, horizontally scalable metrics.
- Presentation and correlation: Grafana queries metrics, Loki handles logs and Tempo stores traces, with exemplars and shared labels connecting the signals.
For a regional site, an agent mode Prometheus can scrape locally and forward samples to a central Mimir cluster. It uses fewer resources than a full query-and-storage server, but it should not be the only copy of critical operational data if the wide-area link is unreliable. Keep enough local retention, or run a full Prometheus for alerts and short-term investigation.
Mimir’s distributed architecture is valuable when several teams or regions write to the same metrics platform. It separates ingestion, querying and long-term storage so that a dashboard surge does not necessarily take down ingestion. That separation is not magic: object storage, compaction, ring membership and tenant limits still require monitoring.
Use tenants to separate environments or business units where appropriate. Apply per-tenant ingestion and query limits. Without limits, one poorly designed dashboard or a noisy development namespace can consume resources needed by production.
Make the edge boring: scrape locally and ship deliberately
Remote write should be treated as a queue, not a fire-and-forget network call. Configure bounded queues, sensible retry behaviour and a maximum samples-per-send rate. Watch queue depth, failed samples and the age of the oldest pending sample. A green application dashboard is not evidence that the metrics pipeline is healthy.
remote_write:
- url: https://mimir.example.net/api/v1/push
queue_config:
capacity: 10000
max_shards: 8
min_shards: 1
max_samples_per_send: 2000
batch_send_deadline: 5s
send_exemplars: true
The exact values depend on scrape volume and link capacity; copying them unchanged into production would be poor engineering. The important controls are explicit queue bounds, limited concurrency and telemetry around backlog growth.
For intermittent connectivity, keep alerts local. A central alert rule cannot protect a branch when the branch-to-cloud link is down. Prometheus should evaluate availability, disk, power and network alerts near the affected workload, while Alertmanager can continue routing notifications when connectivity returns.
Load-shedding-aware alerting also needs inhibition. A site-wide power event may cause hundreds of downstream alerts. Use a parent condition, such as loss of the site gateway or UPS state, to suppress symptoms while preserving the incident signal. Do not silence everything: a critical database running on generator power may still require immediate action.
Cardinality is the budget line nobody sees
Storage cost in ZAR is often dominated by labels rather than scrape frequency. A metric with method, status and service labels is manageable. Add customer ID, full URL, pod UID and request ID, and the same metric can become a time-series creation engine.
Drop dangerous labels at the edge and replace unbounded dimensions with controlled categories:
metric_relabel_configs:
- source_labels: [__name__]
regex: "http_request_duration_seconds_bucket"
action: keep
- source_labels: [path]
regex: "/users/[^/]+"
target_label: path
replacement: "/users/:id"
- source_labels: [request_id]
action: labeldrop
Metric relabelling reduces what is stored, while target relabelling controls discovery metadata before scraping. Use recording rules for expensive, frequently viewed calculations such as service error ratios. This moves computation from every dashboard refresh to a controlled evaluation interval.
Histograms deserve particular attention. Classic histograms multiply series by the number of buckets, while native histograms use a sparse representation and were highlighted in Prometheus 3.0’s 2024 release as a more efficient alternative for many workloads.[3] They still need compatibility testing across Prometheus, remote write and Mimir, especially when mixed with existing classic histograms.
Define a cardinality review in the pull request process. A useful review asks: what labels exist, which are bounded, how many targets emit the metric, and whether a recording rule could replace repeated high-cost queries?
Keep metrics, logs and traces connected but independently scalable
Metrics should answer whether a system is unhealthy. Loki can explain what changed, and Tempo can show where latency accumulated. Treating them as one pipeline creates unnecessary coupling. Each backend should have independent ingestion limits, retention and failure handling.
Use consistent resource labels such as cluster, namespace, service and environment across all three signals. Avoid turning every log field into a Loki label; high-cardinality labels are costly there too. Store variable fields in the log body and query them with LogQL when needed.
{cluster="jhb-prod", namespace="payments"} |= "timeout"
| json
| line_format "{{.service}} {{.route}} {{.error}}"
Tempo trace IDs can be attached to exemplars on latency metrics. An engineer investigating a spike in a Grafana panel can jump from the metric to a representative trace, then inspect corresponding Loki entries. This is especially useful when the application is split across a local cluster and services in eu-west, where network latency can be mistaken for application slowness.
OpenTelemetry is increasingly used as a vendor-neutral instrumentation and collection layer. Prometheus 3.0 also added improvements around Remote-Write 2.0, metadata, exemplars and native histograms.[3] That does not mean every estate should replace Prometheus immediately. Introduce the Collector where it solves a real boundary problem: protocol translation, filtering, enrichment or routing to multiple backends.
Operate the pipeline like production software
Metrics infrastructure needs its own service-level objectives. Track ingestion availability, scrape success, remote-write lag, query latency, dropped samples and storage compaction health. Alert on symptoms that affect decisions, not merely on process restarts.
- Scrape freshness: the age of the newest sample for critical jobs.
- Remote-write backlog: queue depth and oldest unsent sample.
- Cardinality growth: active series by tenant, namespace and service.
- Query pressure: slow queries, concurrent queries and frontend queue time.
- Data loss: rejected samples, out-of-order samples and failed compactions.
Run failure tests before the next outage: disconnect a regional link, throttle object storage, restart an ingester, overload a dashboard and generate a controlled cardinality spike. Confirm that local alerts still fire, queues recover and operators can distinguish delayed data from absent data.
The strongest Scalable Metrics Processing Architectures are intentionally unglamorous. They keep collection close to workloads, process data before it becomes expensive, limit every noisy tenant, and preserve a local path for urgent alerts. Grafana then becomes the working surface for that design rather than a dashboard placed over an unexamined pipeline.