Observing Kubernetes: events, logs, metrics and traces

ExplainedKubernetesDevOps, Hands OnBy Cloud Hands On

What each signal tells you about a cluster, where it comes from, and a quick order for using them in an incident.

Four signals answer different questions. Events say what the control plane did and why it failed (scheduling, image pulls, probes, evictions); they expire after about an hour. Logs are what containers print, kept by the node until rotated, so ship them to a store if you need them later. Metrics are numbers over time (CPU, memory, request rate, errors); metrics-server gives the current values, Prometheus keeps history. Traces follow one request across services.

Good alerts are about symptoms users feel (error rate, latency, failed jobs) plus a few causes worth waking someone for (nodes not ready, disks filling, pods crash-looping). Dashboards should start from the service, then drill into pods and nodes.

In an incident, a fast order works: recent events, the failing pod's describe, its previous logs, then kubectl top and dashboards for pressure and trends.

Cost. Free to learn on kind. Hosted monitoring (Azure Monitor, Managed Prometheus, Grafana) is charged mostly by the volume of data kept.

Use it when

How it works

Events
kubectl get events; short-lived, the quickest clue.
Logs
kubectl logs, with --previous for crashes; ship them for history.
Metrics
metrics-server now, Prometheus for history and alerts.
Traces
OpenTelemetry follows requests across services.
Alerts
On user-facing symptoms first, then key causes.

Options

Azure Monitor and Container insights
Managed, integrated with AKS.
Managed Prometheus and Grafana
Open standards, hosted for you.
Self-hosted Prometheus stack
Full control, more to run.

Example. Kestwick Hotels alerts on booking errors over 2% and p95 latency over 800 ms, plus pods restarting more than five times an hour. Everything else stays on dashboards, which halved their night-time pages.

Don't confuse it with

Monitoring
Watches known signals and thresholds.
Observability
Being able to ask new questions of the data when something unexpected happens.

Words to know

Prometheus
Collects and stores metrics, and evaluates alert rules.
OpenTelemetry
An open standard for collecting traces, metrics and logs.
p95 latency
The response time 95% of requests are faster than.

Where to look

  1. kubectl get events
  2. kubectl logs
  3. kubectl top
  4. Grafana

Practise it

Read it in the guide, next to the tasks and labs.

Open in DevOps, Hands On

Keep going