Scalable Metrics Processing Architectures: A Practical Guide for DevOps and SREs
As a South African SRE working with large, distributed systems and Grafana at the centre of our observability stack, I’ve learned that the difference between a calm incident response and a 3 a.m. disaster often comes down to…
Scalable Metrics Processing Architectures: A Practical Guide for DevOps and SREs
As a South African SRE working with large, distributed systems and Grafana at the centre of our observability stack, I’ve learned that the difference between a calm incident response and a 3 a.m. disaster often comes down to one thing: whether your Scalable Metrics Processing Architectures can keep up with reality. When your infrastructure grows faster than your monitoring pipeline, you end up with delayed dashboards, dropped time series, and alert storms that arrive too late.
In this post, I’ll walk through how to design and operate Scalable Metrics Processing Architectures that work in real-world environments: multi-region clouds, on-prem data centres in Johannesburg or Cape Town, and hybrid setups where network links are anything but perfect. We’ll focus on Prometheus-style metrics, Grafana as the visualization layer, and practical patterns you can apply today.
What Are Scalable Metrics Processing Architectures?
Scalable Metrics Processing Architectures are designs for collecting, transporting, storing, and querying metrics that continue to work as:
- The number of services and pods grows into the thousands
- Cardinality (unique time series) explodes with labels like
tenant,region, andversion - Your team needs low-latency dashboards and reliable alerts, even during traffic spikes
A scalable architecture must handle:
- Ingestion throughput: Millions of samples per second
- Query performance: Sub-second queries for dashboards and alerts
- Reliability: No data loss during network blips or node failures
- Cost efficiency: Reasonable storage and compute costs (especially important when you’re paying in ZAR)
Core Building Blocks of a Metrics Pipeline
At a high level, most Scalable Metrics Processing Architectures use the same building blocks:
- Instrumentation – Exporting metrics from applications and infrastructure
- Collection – Scraping or receiving metrics
- Aggregation & transformation – Reducing and shaping metrics
- Storage & indexing – Time-series databases / metric backends
- Query & visualization – Grafana dashboards and alerts
Let’s go through each layer with practical examples.
1. Instrumentation: Getting Metrics Right at the Source
If you get instrumentation wrong, no architecture will save you. Use consistent naming conventions and limit unnecessary label cardinality. For Prometheus-compatible metrics in a Go microservice:
package main
import (
"net/http"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
)
var httpRequests = prometheus.NewCounterVec(
prometheus.CounterOpts{
Name: "http_requests_total",
Help: "Total number of HTTP requests",
},
[]string{"method", "code"},
)
func main() {
prometheus.MustRegister(httpRequests)
http.HandleFunc("/health", func(w http.ResponseWriter, r *http.Request) {
httpRequests.WithLabelValues(r.Method, "200").Inc()
w.WriteHeader(http.StatusOK)
w.Write([]byte("ok"))
})
http.Handle("/metrics", promhttp.Handler())
http.ListenAndServe(":8080", nil)
}
Key practices:
- Use low-cardinality labels (e.g.
code,method), avoid labels likeuser_id. - Expose a
/metricsendpoint for Prometheus scrapes. - Standardize metric names across teams to simplify queries and dashboards.
2. Collection: From Node to Region
In South African environments with limited cross-region bandwidth, a hub-and-spoke pattern works well: local collection in each region (Johannesburg, Cape Town, EU, etc.) with optional cross-region federation.
Pattern: Prometheus Sharding per Cluster
For a large Kubernetes cluster, a single Prometheus instance can’t handle all targets. Instead, shard by namespace or label:
- Use multiple Prometheus instances in the same cluster.
- Each instance scrapes a subset of pods using
relabel_configs. - Grafana uses a Prometheus-compatible gateway (e.g. Cortex/Mimir/Thanos) or multiple data sources.
# Example: Prometheus scrape with namespace-based sharding
scrape_configs:
- job_name: "kubernetes-pods-shard-a"
kubernetes_sd_configs:
- role: pod
relabel_configs:
- source_labels: [__meta_kubernetes_namespace]
regex: "team-a-.*"
action: keep
You can run another Prometheus with team-b-.* to share the load.
3. Aggregation and Metric Gateway Layer
To build truly Scalable Metrics Processing Architectures, you usually introduce an aggregation layer between local Prometheus instances and long-term storage. This layer:
- Accepts remote-write traffic from Prometheus
- Applies downsampling and retention policies
- Provides a horizontally scalable query API for Grafana
Typical tools include Grafana Mimir, Cortex, or Thanos for Prometheus metrics, and Loki for logs.
Example: Prometheus Remote Write to a Central Mimir Cluster
remote_write:
- url: "https://mimir.example.za/api/v1/push"
queue_config:
capacity: 10000
max_samples_per_send: 10000
batch_send_deadline: 5s
write_relabel_configs:
- source_labels: [__name__]
regex: ".*_debug_.*"
action: drop
This configuration:
- Uses remote_write to push metrics to a central, scalable backend.
- Applies write-time relabeling to drop noisy
*_debug_*metrics and save storage. - Buffers metrics (via
queue_config) to handle short network interruptions between regions.
4. Storage: Horizontal Scale with Long-Term Retention
The heart of Scalable Metrics Processing Architectures is the storage layer. For very large environments, you need:
- Horizontally scalable ingestion (multiple replicas, consistent hashing)
- Object storage (S3-compatible) for cost-efficient retention
- Compaction and downsampling to keep query performance acceptable
A common pattern is:
- Short-term, high-resolution metrics (e.g. 15 days at 10–30s resolution)
- Medium-term, downsampled metrics (e.g. 90 days at 1m resolution)
- Long-term, heavily downsampled metrics (e.g. 1 year at 5m or 15m resolution)
In Grafana Mimir or Thanos, this is configured at the backend, but as an SRE you design the policy and validate that queries in Grafana still answer questions like:
- “How did 99th percentile latency change during last quarter’s Black Friday in South Africa?”
- “What was our CPU utilization trend over the last 6 months?”
5. Query and Visualization: Making Grafana Work at Scale
Grafana is the main interface your teams use to interact with your Scalable Metrics Processing Architectures. To keep it fast and reliable:
- Use templating variables carefully to avoid expensive queries.
- Enforce max data points