Metrics, logs and traces
Quick answer
Observability helps explain system behavior from evidence. Metrics summarize measurements, logs record events, and traces follow operations across components.
For a slow request, a metric shows how widespread the slowdown is, a log may describe an error, and a trace may locate the delayed component. Correlate timestamps and request identifiers where available; none of the signals alone proves causation.
Prepare the practice environment
Run python3 lab-fixtures/observability/setup.py from the extracted root as an ordinary user. Enter the printed fresh private path and check pwd. Use fresh fixtures, Bash with set -e -o pipefail, LC_ALL=C and umask 077. Run each snippet in a separate Bash process, not your interactive shell. Only private files are used; optional examples require an authorized snapshot VM. Do not change live monitoring or services. All supplied records are fictional. Review the lab guide.
Prerequisites
Review: Deployment and rollback, Systemd timers.
How it works
Start with a user symptom: requests are slow or failing. Measure request rate, error ratio and latency; inspect saturation of CPU, memory, disk and network resources. A counter normally increases until reset; a gauge can rise or fall; a histogram counts observations in buckets. Rates need a time interval and units. A log describes a particular event; structured fields allow filtering without guessing at free text. A trace contains spans representing operations, with parent relationships and durations. Correlate records by trace ID and time, not merely by matching timestamps. Sampling can omit traces; missing telemetry is not evidence of success. Use a fixed UTC window and record its boundaries. All supplied records are fictional. The latency column is milliseconds; throughput is requests per second. The fixture contains one slow request with a database span, suggesting an investigation, not proving causality.
Try the examples
The threshold is a teaching choice; 503 indicates failure, and 850 ms is the duration.
Expected stdout:
t3 503 850The trace ID links the event to the request.
Expected stdout:
2025-01-01T10:00:02Z ERROR trace=t3 upstream timeoutThe nested 800 ms span is part of 850 ms, not an additional duration to add.
Expected stdout:
gateway 850database 800Common mistakes
Do not sum overlapping spans, treat missing samples as zero, or paste customer identifiers into metrics.
Practice
Explain which record links the failed request to the database span. State a hypothesis and one additional measurement to test it.
Related references
Study: journalctl. These are reference names, not deployed links.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Metrics, logs and traces — Knowledge Check
Apply observability and reliability concepts to synthetic fixtures and VM-only scenarios.
Which signal follows a request across components?
What distinguishes a gauge?
What does missing telemetry prove?
Why use trace IDs?