Cluster operationsLesson 11 of 16
How Logs, Metrics and Traces Leave a Pod
Follow the three signals out of one Pod. Logs go to stdout and land in a file on the node. Metrics wait at /metrics until Prometheus pulls them. Traces are pushed to a collector over OTLP. Each path breaks in its own way.
SignalLogs · metrics · traces
Path—
Kept for—
RequestResponse / reportAppears in a later step
What you will learn
- Where stdout goes: the runtime writes a file, the kubelet rotates it
- Why logs vanish with the Pod, and what a node log agent fixes
- Prometheus discovers targets and pulls /metrics; a failed scrape sets up to 0
- Why one unbounded label can blow up a metrics store
- metrics-server is for kubectl top and HPA, not for history
- Traces are pushed over OTLP to a collector
Three signals compared
| Signal | Who moves it | Direction | Where it is kept | Typical failure |
|---|---|---|---|---|
| Logs | Container runtime writes the file, a DaemonSet agent ships it | Collected from node files | Log store (e.g. Loki, OpenSearch) | Pod deleted before shipping, agent lag during rotation, app logging to a file |
| Metrics | Prometheus, via service discovery | Pulled (scrape) | Prometheus TSDB or remote storage | Target down (up == 0), wrong port or path, high-cardinality labels |
| Traces | OpenTelemetry SDK in the app | Pushed (OTLP) | Trace backend (e.g. Jaeger, Tempo) | Collector address wrong, trace context not propagated, sampled away |
| Resource metrics | metrics-server, from each kubelet | Pulled | Memory only, latest value | metrics-server missing, so kubectl top and HPA fail |
Try it yourself
kubectl logs deploy/web --tail=50 # Read the current container's log via the kubelet
kubectl logs web-7c9d -c app --previous # Log of the last crashed instance
kubectl get daemonset -A # Is a log agent running on every node?
kubectl debug node/worker-1 -it --image=busybox -- ls /host/var/log/pods # The files on the node
kubectl port-forward deploy/web 8080 &
curl -s localhost:8080/metrics | head # What Prometheus scrapes
kubectl top pod -A # Metrics API from metrics-server
kubectl get servicemonitor,podmonitor -A # If you use the Prometheus Operator
In Prometheus, run up == 0 to list failing targets, and topk(10, count by (__name__) ({__name__=~".+"})) to find metrics with too many series.
Check yourself
Further reading: Logging architecture · Resource metrics pipeline · Prometheus kubernetes_sd_config · Prometheus naming and labels · OTLP specification · OpenTelemetry Collector · SLOs and Alert Design · Scaling with Load (HPA)