Observability on Kubernetes is a stack, not a tool. The three pillars — metrics, logs, traces — answer different questions, and any production system worth running needs all three. Metrics tell you that the 95th percentile latency on /api/v1/checkout doubled at 14:02. Logs tell you that fourteen of those requests returned a database connection refused line at the same minute. Traces tell you exactly which downstream call inside which pod inside which deployment burned the missing two seconds. Take any pillar away and the on-call ends up guessing through the part you removed.
The reference stack on Kubernetes — Prometheus for metrics, Loki for logs, Tempo for traces, OpenTelemetry as the collection and instrumentation backbone, Grafana as the single pane — is the path of least friction. Each component is open-source, scales horizontally, runs on the same object store, and is wired through the same query language family in Grafana. This article walks through what each piece does in production, where the failure modes live, and where cost discipline has to apply before the bill outpaces the value.
What “production-grade” means for observability
Production observability is a different problem from a demo dashboard. A staging Prometheus running with default retention and three node_exporter targets is a toy. The production version has to answer four things at once:
- Retention — how far back can you query, and with what granularity. Hot metrics for two weeks at full resolution, downsampled to one minute for ninety days, downsampled to one hour for one or more years.
- Redundancy — what happens when one Prometheus pod dies during an incident. The right answer is “nothing visible to the on-call.” That requires either an HA pair or a remote-write target that holds the durable copy.
- Query latency — when an on-call hits a dashboard mid-incident, the panels need to render in under three seconds. Slow Grafana during a Sev-1 is its own incident.
- Cost shape — observability bills grow with cardinality, log volume, and trace sample rate. A stack that costs more than the workload it observes is a stack you stop trusting and eventually turn off.
A production-grade observability stack is one where on-call engineers reach for it during incidents instead of around it.
Reference architecture
The reference architecture has three columns: sources on the left (every pod, node, and instrumented application), collection in the middle (the OpenTelemetry Collector running as a gateway, with per-node collectors as DaemonSets), and storage on the right (Prometheus for short-term metrics with remote-write to Mimir or Thanos for long-term, Loki for logs backed by S3, Tempo for traces backed by S3). Grafana sits across all three storage backends as the query and visualization layer.
The shape of the diagram matters: telemetry flows one way (left to right), and queries flow the other (Grafana to backends only). Nothing ever queries the application directly; everything goes through storage. That is the property that lets you scale Grafana, change retention, or swap a backend without touching application code.
Component tier by tier
Instrumentation
Instrumentation is the contract between application code and the rest of the stack. Get this layer right and everything downstream becomes easier. Get it wrong — proprietary SDK per language, no trace propagation, magic numbers in metric names — and the whole stack becomes a series of one-way doors.
The right choice is OpenTelemetry, the vendor-neutral instrumentation standard. OpenTelemetry has stable SDKs for every production language (Go, Java, Python, Node.js, .NET, Ruby, Rust) and stable specifications for metrics, logs, and traces. An application instrumented with OpenTelemetry can send its telemetry to any backend that speaks OTLP — Prometheus via the OTLP receiver, Loki, Tempo, or any commercial vendor. You are not locked into a vendor protocol, and switching backends is a collector-config change, not a code change.
Three Kubernetes-specific telemetry sources sit next to the application SDKs:
- kube-state-metrics — exposes the state of every Kubernetes object (Deployments, Pods, Nodes, PVCs) as Prometheus metrics. This is how you build dashboards like “pods in CrashLoopBackOff by namespace” or “deployments with replica count not matching desired.”
- node-exporter — the standard host-level exporter for CPU, memory, disk, network, file descriptors, conntrack table size. Runs as a DaemonSet on every node.
- cAdvisor — container resource accounting, already exposed by the kubelet on every node. No separate install; just a scrape job.
Skipping any of these three leaves a blind spot. A cluster running only application metrics cannot tell you that pods are getting OOM-killed by the kernel, or that a node is at 95% file descriptor exhaustion. Those are the failure modes that take down clusters.
Collection
The OpenTelemetry Collector is the gateway between sources and storage. It has three roles in this stack:
- Per-node DaemonSet — runs on every node, scrapes local metric endpoints, tails container logs, accepts OTLP from application pods. Forwards everything to the gateway. This is the layer that keeps a single high-cardinality application from saturating the gateway.
- Cluster gateway Deployment — receives telemetry from all node collectors, does tail sampling, attribute redaction (strip secrets, hash user IDs), batching, and routing to backends. Horizontally autoscaled.
- Cluster-scoped scrape configuration — the gateway can run the Prometheus scrape loop for Kubernetes-wide targets (kube-state-metrics, control-plane components) instead of running a separate Prometheus scraper.
The two-tier collector pattern is what separates a toy from a production deployment. Per-node collectors batch and pre-process; the gateway makes routing and sampling decisions with cluster-wide context. A single-collector deployment forces every routing decision through one pod and falls over the first time traffic doubles.
A common mistake is running tool-specific agents — Promtail for Loki, the Tempo agent for traces, the Prometheus agent for metrics. This works until you need to change anything. The OpenTelemetry Collector replaces all of those with one process, one config file, and one set of operational knowledge. The collector also runs the OTLP receivers, the Prometheus receiver, and the journald receiver in the same binary, so the “what is this agent doing” question has one answer per node.
Metrics storage — Prometheus + long-term store
Prometheus is the short-term, high-resolution metrics store. The standard production deployment is an HA pair (two Prometheus replicas scraping the same targets with the same rules, deduplicated downstream) with a 2-hour Write-Ahead Log and 12–24 hours of local TSDB.
The HA pair handles the failure of a single Prometheus pod during an incident, which is otherwise the worst possible time for the observability stack to go dark. Both replicas write to the same long-term store via remote_write, which deduplicates samples. If one pod restarts during a node drain, the other keeps scraping. The long-term copy is durable.
For long-term storage you have three options:
- Mimir — Grafana Labs’ horizontally-scalable Prometheus-compatible TSDB. Stores blocks in S3. Reads scale by adding queriers; writes scale by adding ingesters. Native multi-tenancy. The right choice if you have more than one team or environment sharing a cluster.
- Thanos — the older project. Sidecar pattern with Prometheus, blocks in S3, querier fans out to sidecars and store gateways. Simpler operationally if you already run Prometheus and want to add long-term storage without changing the scrape side.
- Grafana Cloud / managed service — a fit for teams who do not want to operate the metrics store themselves.
The remote_write config in Prometheus needs back-pressure tuning. The default queue settings can drop samples if the long-term store is slow. Set queue_config.max_shards and max_samples_per_send based on your sample rate, and alert on prometheus_remote_storage_samples_dropped_total > 0.
Federation — one Prometheus scraping another — is a pattern from the era before remote_write. It still has narrow uses (pulling a small set of aggregated metrics across cluster boundaries) but it should not be the primary long-term storage mechanism. Use remote_write.
Logs storage — Loki + object storage
Loki is Grafana Labs’ log database. The core insight: index the labels, not the log content. Every log line gets a small set of labels (cluster, namespace, pod, container, level) that act like a Prometheus selector, and the log content itself is stored as compressed chunks in S3. Query latency is fast on label-selected streams; full-text grep across all logs is slow but cheap to keep on hand.
The trade-off is cardinality discipline. A request_id label in Loki creates one stream per request, which destroys the index. The label set is for stream selection (which pod, which namespace, which level); the content is for grep.
Two patterns for log shipping:
- Promtail — Grafana Labs’ purpose-built log shipper. Lightweight, runs as a DaemonSet, supports the
kubernetes_sd_configspattern. The minimum-effort choice. - OpenTelemetry Collector with
filelogreceiver— sends logs over OTLP. The right choice if you want one agent for everything (metrics + logs + traces).
For storage, S3-compatible object storage is the only path that scales. Loki on a local volume works for staging; for production, point it at S3, Minio, R2, or GCS, and let object lifecycle policies handle retention tiering. A common retention curve: 30 days hot (queryable in seconds), 365 days cold (queryable in minutes from Glacier-equivalent storage).
Traces storage — Tempo + S3 backend
Tempo stores trace data — sequences of timed, structured spans linked by a common trace ID — as Parquet blocks in S3. The key property: Tempo does not maintain a full-text index over span attributes. It is optimized for “given a trace ID, fetch the full trace fast” and “find traces by a small set of attributes via TraceQL.”
This is a deliberate cost trade-off. A Jaeger-style backend with Cassandra or Elasticsearch behind it lets you search for “all traces where customer_id = X” in milliseconds, but the index storage is enormous. Tempo gives up that path in exchange for one to two orders of magnitude lower storage cost. The intended workflow is: a Prometheus alert fires on high latency, the alert links to a Grafana dashboard with an exemplar trace ID, the on-call clicks through to the full trace.
Sampling strategies — head-based vs tail-based — are a whole section below. The relevant fact at this layer is that Tempo accepts whatever the collector sends and stores it; the sampling decision lives upstream.
Tempo also ships with a metrics-generator component that derives RED metrics (rate, error, duration) directly from spans and writes them to Prometheus. This means you get service-level latency metrics without any application change — instrumenting once gets you traces and metrics. Turn it on; the savings in dashboarding effort are substantial.
Visualization and alerting — Grafana
Grafana is the only piece your team touches daily. Dashboards, ad-hoc queries during incidents, alert rules — all of it goes through Grafana once the backends are wired up. Two things to get right at this layer:
Dashboards as code. Click-built dashboards drift, never get reviewed, and become the property of whoever made them. The production pattern is to define dashboards in code — grafonnet (Jsonnet library), Terraform with the Grafana provider, or Grafana’s own File Provisioning — and check them into the same repository as the application. A dashboard becomes a PR-reviewable artifact, the way an alerting rule should be.
Alerting — Grafana Alerting or Prometheus Alertmanager. Both work. Grafana Alerting unifies alerts across data sources (you can alert on a Loki query, not just a Prometheus query), runs from a single UI, and uses Alertmanager as the routing layer under the hood. Prometheus Alertmanager direct, with alerts defined in Prometheus rule files, is the older and simpler pattern; if you only alert on Prometheus, this is fine. Mixing both — some alerts in Grafana, some in Prometheus rules — leads to “where is this alert defined” questions during incidents. Pick one.
Cardinality — the operational hazard
Cardinality is the number of distinct label combinations a metric has. A metric http_requests_total{method, path, status_code} with 5 methods, 200 paths, and 10 status codes has 10,000 series. Add a user_id label with one million distinct values and the metric has one billion series. Prometheus will not survive.
The same pattern hits Loki (streams) and Tempo (per-trace overhead). Cardinality is the cost knob for all three:
- Prometheus cardinality. Every distinct label set is a separate time series with its own samples, its own WAL entry, its own index entry. High-cardinality labels in metric names —
user_id,request_id,pod_namein metrics that should be aggregated by service — will quietly burn through memory. Detect withtopk(20, count by (__name__)({__name__=~".+"}))to find the highest-cardinality metric names, then drill into label values. - Loki stream cardinality. Every distinct combination of stream labels creates a new chunk file in S3. A namespace with 50 pods producing logs has 50 streams; adding
request_idas a label creates one stream per request and destroys query performance and storage cost simultaneously. Stream labels are for selecting which logs to read; they are not for searching. - Tempo per-trace overhead. Tempo stores full traces, so the cost driver is sample rate (how many of the traces you keep) and per-span attribute count. Very wide attribute sets — every database query attached to a span — make traces large.
The operational pattern is cardinality budgets: set explicit limits per namespace (max_global_series_per_user in Mimir, similar in Loki and Tempo), alert when a metric crosses 80% of its budget, and refuse to ingest above 100%. The pain of an alert for a noisy team is much less than the pain of an outage when the metrics store falls over during an incident. See also prometheus-federation-cardinality-budgets for the full pattern.
Sampling strategies
Sampling is “we cannot afford to keep every trace, so which ones do we keep.” Two strategies, with very different operational properties:
Head sampling. Decide at trace start (when the first span is created) whether to keep the trace. Implemented in the SDK — TraceIdRatioBased sampler at 1% means roughly 1% of traces have all their spans recorded; the other 99% are dropped entirely. Cheap, deterministic, works without a central collector. The downside: every dropped trace is gone, including any trace that turned into an error or a slow request. The interesting traces are the ones you most want to keep, and head sampling cannot know whether a trace will be interesting at the moment the decision is made.
Tail sampling. Decide after all spans are collected. The collector buffers spans for a window (typically 30 seconds), reconstructs the full trace, then applies sampling policies — keep all errors, keep all traces above the p99 latency threshold, sample 10% of the rest. This is the right answer for production, but it requires the collector to hold spans in memory for the buffering window. The OpenTelemetry Collector tail_sampling processor implements this; size your gateway accordingly.
Probability vs rate-based. Probability sampling (1% of traces) is the default. Rate-based sampling (10 traces per second per service) is the right choice for high-volume services where 1% would still be too much. For low-volume services, keep 100%; the per-trace cost is negligible and the value of every trace is high.
The right policy is usually: 100% for low-volume/high-value services (payments, checkout), tail-sample for high-volume services with “keep all errors + all p99-and-above + 5% baseline,” and explicit per-service overrides for services that hit cardinality budgets.
High availability of the stack itself
The observability stack is critical infrastructure during incidents. If Prometheus is down when the on-call hits the alert, the stack is worse than useless. HA design for each component:
Prometheus HA pair. Two replicas, identical scrape config and rule files, both writing to the long-term store. Grafana datasource points at a Prometheus aggregator (e.g. prom-deduplicator sidecar) that picks the healthier replica per query. Alertmanager handles deduplication of identical alerts emitted twice.
Alertmanager cluster gossip. Three Alertmanager replicas in gossip cluster mode. Each Prometheus replica sends alerts to all three. The cluster deduplicates and routes once. See alertmanager-ha-cluster-gossip-deploy for the deploy pattern.
Loki distributed. The single-binary Loki is fine for small clusters. For production, run Loki in distributed mode: distributors (accept writes), ingesters (in-memory + recent chunks), queriers (read from S3 + ingesters), query-frontends (cache and split queries), and a small Memcached for index cache. Each tier is independently scalable.
Tempo distributed. Same pattern as Loki. Distributors, ingesters, queriers, compactors. The distributed mode is what handles the trace volume of a real production workload.
Grafana HA. Multiple Grafana pods behind a load balancer, with the database (PostgreSQL or MySQL) running externally. The session store needs to be shared — Grafana’s default file-based sessions break under HA. Use the database session store, or front Grafana with sticky sessions.
None of this is exotic. All of it is the difference between a stack that holds during an incident and a stack that goes dark at the worst possible moment.
Cost shape — what drives the bill
Three cost drivers, three different conversations:
Metrics cardinality. Long-term metrics storage charges by ingested series and queried series. The cost knob is cardinality — number of distinct label combinations — and it scales with the carelessness of the worst metric. One high-cardinality metric in a shared cluster can dominate the bill. Cardinality budgets are the only durable control.
Logs ingest volume. Loki charges by ingest GB and storage GB. The dominant cost is ingest. The control is logging discipline — drop debug logs in production, structure logs so the high-volume ones (request access logs) can be sampled at the source, route audit logs to a separate retention tier. A team that logs at debug level by default has a bill two orders of magnitude higher than a team that does not.
Traces sample rate. Tempo charges by stored span. The control is the sample rate set in the collector. A 1% sample rate with tail sampling that keeps all errors will catch every interesting incident at one one-hundredth the cost of 100% sampling. Per-service overrides let you keep 100% for high-value services without paying for it elsewhere.
A reasonable starting budget: metrics 30% of the observability spend, logs 40%, traces 30%. If any one is dominating, that is the conversation. If all three are growing faster than the underlying workload, the conversation is about discipline at the source.
When Stack Harbor runs this for you
Standing up this stack from scratch — Prometheus HA, Loki distributed on S3, Tempo distributed on S3, the OpenTelemetry Collector gateway, Grafana with single sign-on, dashboards as code, cardinality budgets enforced — is roughly four to eight weeks of focused engineering work the first time. Six months later, it has to be upgraded. Twelve months later, someone has to figure out why the Loki ingester is OOMing during the daily traffic peak.
Stack Harbor’s Managed Operations practice runs this stack — and the upgrades, the cardinality reviews, the on-call rotation behind the alerts it generates — as a managed service. The senior engineer who owns your Sev-1 response is the same person who tuned the alert rules; the alert that wakes the on-call is one that someone is on the hook to make less noisy week over week. See also our HA Clustered Environments solution for the underlying infrastructure pattern, and Multi-Region Environments for the cross-region observability stack.
See also
- Deploying a Prometheus + Grafana stack on AlmaLinux 9 (production-ready) — the underlying Prometheus deploy
- Deploying Loki for log aggregation on AlmaLinux 9 with S3 backend — the logs tier in isolation
- Deploying Grafana Tempo for distributed tracing on AlmaLinux 9 with OTLP + S3 backend — the traces tier in isolation
- Deploying Grafana Mimir for long-term Prometheus storage on S3 — long-term metrics
- OpenTelemetry Collector gateway on Ubuntu 22.04 — collector deploy patterns
- Prometheus federation and cardinality budgets — cardinality discipline
- SLOs, error budgets, and alerts that don’t burn out the on-call — the operational companion to this article