Observability Basics: Logs, Metrics, Traces
Core Concepts (5)
- 1.Logs record events, metrics count them, traces follow requests
- 2.You cannot fix what you cannot see
- 3.SLIs measure, SLOs set targets, alerts should protect SLOs
- 4.Alert on symptoms users feel, not on every cause
- 5.Structured logs and correlation ids make debugging possible
Map to Your Experience
Recall a bug you could not reproduce. What information, if it had been recorded, would have solved it quickly?
Design Brief: Instrument a Checkout Flow
Learn
Observability is the ability to understand what a system is doing from the outside by looking at the data it produces. Three kinds of data work together.
Logs are records of individual events: a payment failed, a user logged in. They carry detail and context. Write them in a structured format such as JSON, with fields for time, level, service, and a correlation id, so they can be searched and filtered rather than read by eye.
Metrics are numbers measured over time: requests per second, error rate, p95 latency, queue depth, memory use. They are cheap to store and fast to graph, which makes them ideal for dashboards and alerts. A good starting set is the four golden signals: latency, traffic, errors, and saturation.
Traces follow one request across many services. Each hop records a span with its start time and duration, joined by a shared trace id. When a page is slow, a trace shows which of the twelve services behind it spent the time.
To turn data into decisions, define service level objectives. A service level indicator, or SLI, is a measurement such as the share of checkouts completing successfully. A service level objective, or SLO, is the target, for example 99.9 percent over 30 days. The gap between the target and perfection is the error budget, here about 43 minutes of failure a month. When the budget is spent, reliability work takes priority over new features.
Alerting deserves care. Alert on symptoms users feel, such as a rising checkout error rate, rather than on every possible cause such as high CPU. Each alert that wakes a person should need action and have a runbook. Too many noisy alerts train people to ignore them, which is worse than having none.
Finally, remember that observability is a feature you design in, not bolt on. A new service should ship with its dashboard, its logs, and its alerts.
Map
List the four golden signals and, for a search service, give one concrete metric for each. Then say which one you would alert on first and why.
Design
Instrument a checkout service. Choose three metrics and describe the dashboard, define one SLI and SLO with the monthly error budget in minutes, show an example structured log line for a failed payment without sensitive data, and write one alert with its trigger condition and the first step in its runbook.
Requirements
- •Define 3 metrics
- •Define 1 SLO with an error budget
- •Specify what each log line contains
Constraints
- •Logs must not contain card numbers
- •Alerts must not wake someone for non-urgent issues
Must Cover
Trade-off Axis
visibility vs cost and noise
Referenced Patterns
Competencies Advanced
Ready to Design?
Open this day in the Design Studio. The studio follows this track: its days, concepts, patterns and trade-offs are loaded, and you keep one design across the whole track.
Open in Studio →