Skip to main content
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—
Worker nodeApp Podstdout · /metrics · OTLP/var/log/podsWritten by runtimeLog agentDaemonSetkubeletRotates · serves logsPrometheusPulls · stores seriesOTel CollectorOTLP inLog storee.g. Loki, OpenSearchkubectllogs · topmetrics-serverLatest values only
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​

SignalWho moves itDirectionWhere it is keptTypical failure
LogsContainer runtime writes the file, a DaemonSet agent ships itCollected from node filesLog store (e.g. Loki, OpenSearch)Pod deleted before shipping, agent lag during rotation, app logging to a file
MetricsPrometheus, via service discoveryPulled (scrape)Prometheus TSDB or remote storageTarget down (up == 0), wrong port or path, high-cardinality labels
TracesOpenTelemetry SDK in the appPushed (OTLP)Trace backend (e.g. Jaeger, Tempo)Collector address wrong, trace context not propagated, sampled away
Resource metricsmetrics-server, from each kubeletPulledMemory only, latest valuemetrics-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

  1. A Pod crashed at 3 a.m. and the Deployment replaced it. kubectl logs shows only the new Pod's lines. Why?
  2. An app hangs and Prometheus can no longer scrape it. Why might the error-rate alert stay silent?
  3. You want to see what a Pod's CPU usage was yesterday. Where should you look?

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)