Kubernetes Observability: Metrics, Logs, Events, and the Signals That Matter
Kubernetes observability in practice: metrics-server vs Prometheus, kube-state-metrics, logs, events, tracing and alerts that matter.

Observability has come up in passing before: kubectl top for sizing requests, metrics-server for the autoscaler, and events for Pending pods and failed Jobs. Here the pieces come together into something you can run in production.
What comes out of the box, and what does not
| Signal | Built in | Retention by default | Usual production setup |
|---|---|---|---|
| Resource metrics | kubelet and cAdvisor; metrics-server for kubectl top and HPA |
Current values only | Prometheus scraping kubelets |
| Object state | Only through the API | None | kube-state-metrics into Prometheus |
| Container logs | Files on each node, kubectl logs |
Rotated on the node; lost with the pod or node | Node agent shipping to Loki, Elasticsearch or a cloud service |
| Events | API objects | About one hour | Event exporter into the log pipeline |
| Traces | None for applications | None | OpenTelemetry SDKs and Collector, a tracing backend |
Metrics
metrics-server is a small aggregator that keeps the latest CPU and memory reading for each pod and node. It powers kubectl top and the HPA and nothing more: no history, no queries, no alerts.
For monitoring, the standard is Prometheus, usually installed with the kube-prometheus-stack Helm chart (see Helm and Kustomize), which bundles the Prometheus Operator, Alertmanager, Grafana, node-exporter, kube-state-metrics and a set of default dashboards and alerts. Prometheus 3.0 is in release candidates at the time of writing; the 2.x line is what most clusters run. Its metrics come from several sources:
- cAdvisor through the kubelet: per-container usage such as
container_cpu_usage_seconds_total,container_memory_working_set_bytesand CPU throttling. - node-exporter, a DaemonSet: node-level CPU, memory, disk and network.
- kube-state-metrics: the state of Kubernetes objects as metrics, such as Deployment replicas available versus desired, pod phase, container restarts, the reason for the last termination (such as
OOMKilled), Job failures and the last successful CronJob run. - Control plane components: API server request rates and latencies, scheduler and etcd metrics, where your provider exposes them.
- Your applications, exposing
/metricsand selected with aServiceMonitororPodMonitor.
Two pitfalls. Label cardinality: a metric labelled with user IDs or full URLs creates a time series per value and can take down Prometheus. And long-term storage: a single Prometheus is meant for days or weeks of data; for longer retention or many clusters, add Thanos, Grafana Mimir or a managed Prometheus service.
Logs
Containers write to stdout and stderr; the container runtime stores this in files under /var/log/pods on the node, and the kubelet rotates them. kubectl logs reads those files, which is why logs vanish when the pod is deleted or the node is replaced. kubectl logs --previous shows the last terminated container’s output, the first thing to check in a crash loop.
The standard pattern is a node-level agent as a DaemonSet (Fluent Bit, Vector, Grafana Alloy or the OpenTelemetry Collector) that tails those files, adds Kubernetes metadata such as namespace, pod and labels, and ships them to a backend: Grafana Loki, Elasticsearch or OpenSearch, or a cloud logging service. The same rules apply as in the Docker logging article: log to stdout, write structured JSON, include a request or trace ID, and keep debug logging off in production. Log volume is often the largest observability cost, so drop noisy health-check logs at the agent.
Events
Events are the cluster’s own narrative: FailedScheduling, Pulled, BackOff, Unhealthy (failing probes), OOMKilling, FailedMount, Evicted, ScalingReplicaSet. Read them with kubectl events -n billing --for pod/billing-api-7d9f or in kubectl describe.
They are stored in etcd with a default lifetime of one hour, so by the time you investigate last night’s incident, the events are gone. Run an event exporter (kubernetes-event-exporter, or the event receiver in the OpenTelemetry Collector) to write them into your log backend, where they can be searched next to application logs and used for alerts on warnings like repeated FailedMount.
Traces
Metrics tell you that checkout latency rose; traces tell you which downstream call caused it. Instrument services with OpenTelemetry SDKs (auto-instrumentation covers most HTTP and database libraries), send spans to an OpenTelemetry Collector running as a DaemonSet or Deployment, and export them to Jaeger, Grafana Tempo or a commercial backend. The Collector’s Kubernetes attributes processor tags spans with pod, namespace and node, so traces can be joined with logs and metrics. Put the trace ID in every log line and you can move from a slow trace to its exact logs.
Signals that deserve an alert
Collecting everything is cheap compared with alerting on everything. Page on symptoms users feel, and send most cluster conditions to a ticket or a chat channel instead.
Page-worthy:
- Service-level indicators breaching their objective: error rate and latency at the ingress or service, ideally as multi-window burn-rate alerts.
- Deployments with fewer available replicas than desired for more than several minutes.
- Persistent volumes about to fill, predicted with
predict_linearover the last few hours. - Certificates close to expiry, if cert-manager renewals have failed.
Ticket or channel:
- Containers restarting repeatedly, and containers terminated with
OOMKilled. - Pods Pending for more than ten minutes.
- Nodes NotReady, or under memory or disk pressure.
- CPU throttling above a threshold for latency-sensitive services.
- Job failures and CronJobs without a recent success.
- HPAs at their maximum replicas for a long time.
Give every alert a runbook link and an owner, review the noisy ones monthly, and delete any alert nobody acts on. The default kube-prometheus-stack rules are a good starting point, but they are general; tune or silence them for your cluster rather than learning to ignore them.
Frequently Asked Questions
What is the difference between metrics-server and Prometheus?
metrics-server keeps only the latest CPU and memory usage per pod and node, for kubectl top and autoscaling. Prometheus scrapes and stores time series from many sources over time, supports queries and dashboards, and drives alerting through Alertmanager.
What does kube-state-metrics do?
It reads the Kubernetes API and exposes object state as metrics: desired and available replicas, pod phases, container restarts and termination reasons, Job and CronJob status, node conditions and more. Prometheus scrapes it to alert on cluster state rather than resource usage.
How long does Kubernetes keep events?
One hour by default, set by the API server’s event TTL. Use an event exporter to copy events into a log backend if you need them for later investigation or alerting.
How do I collect logs from all pods in a cluster?
Run a log agent such as Fluent Bit, Vector or the OpenTelemetry Collector as a DaemonSet. It reads container log files on each node, adds Kubernetes metadata and ships them to a backend like Loki, Elasticsearch or a cloud logging service.
Closing thoughts
A Kubernetes platform is built from the control plane, workloads, networking, storage, security, scheduling and packaging. Observability is what makes all of it operable: without metrics, logs and events that outlive the pods that produced them, every one of those layers is guesswork to debug. Start with kube-prometheus-stack, a log agent and an event exporter, alert on what users feel, and grow from there. For the full reference, see the Kubernetes logging architecture and the Prometheus overview.
Originally posted on 5 November 2024 and post last modified on 5 November 2024