SDSystem DesignConcepts to case studies
System DesignDSA
x
0/311
Part 1: Foundations
Part 2: APIs and Communication
Part 3: Caching
Part 4: Data and Storage
Part 5: Architecture
Part 6: Distributed Systems
Part 7: Advanced Data Topics
Part 8: Operations and Security
  • Three Pillars of Observability
  • Logging Best Practices
  • Log Aggregation
  • Metrics and Instrumentation
  • Distributed Tracing
  • Alerts and Monitoring
  • Dashboards and Runbooks
  • SLOs and Error Budgets
  • Incident Management and Postmortems
  • Profiling
  • Audit Logs
Part 9: Estimation and Interview Method
Part 10: Case Studies
System Design/Operations and Security/Observability

Three Pillars of Observability

Logs, metrics and traces: three views that together explain what a system is doing.

⏱ 12 min readBeginnerMust KnowHas visualizer
SummaryConceptReal-Life ExampleWhy?Where?How It WorksStepsKey TermsPros & ConsMistakesReal WorldRead NextInterview Q&ACheat-Sheet

01Quick Summary

Observability is how well you can understand what is happening inside a running system by looking at what it sends out. The three classic kinds of output are metrics, logs and traces. They are called the three pillars.

  • Metrics are numbers over time (requests per second, error rate). They tell you that something is wrong.
  • Logs are records of single events ("payment failed for order 42"). They tell you why.
  • Traces follow one request across many services. They tell you where the time or the failure is.

02Concept: What is it?

When a program runs on your laptop you can add a print statement or open a debugger. In production, the code runs on many machines that you cannot touch, for users you cannot see. The only way to understand it is to make the system report on itself. A system that reports well is observable.

Monitoring and observability are close cousins. Monitoring watches for problems you already know about ("alert if the error rate is above 5%"). Observability is the ability to ask new questions about a problem you did not predict ("why are only users in one country slow?"). Good observability makes monitoring easy, but not the other way around.

One system, three views
Metrics
πŸ“ˆNumbers over time
❓Is something wrong?how bad, since when
Traces
🧡One request's journey
❓Where is it wrong?which service or call
Logs
πŸ“œDetailed event records
❓Why is it wrong?the exact error and context
Each pillar answers a different question. You usually move from metrics to traces to logs.
🧠Each pillar has a weakness
Metrics are cheap but have no detail. Logs have detail but are costly and hard to connect. Traces connect services but are usually sampled, so you do not see every request. Together they cover each other's gaps.

03Real-Life Example

🍡The Hospital Patient
A patient is brought into a hospital. A monitor beside the bed shows heart rate and temperature as lines over time: that is the quick check that something is off. The nurse's chart lists every event with a time: 09:10 fever, 09:40 medicine, 10:05 vomiting. That is the detail. To understand how a problem moved through the body, doctors follow one thing, such as a dye injected into the blood, as it travels through each organ. Nobody uses only one of these. The monitor says "worry", the dye test says "where", and the chart says "why".
Hospital
Observability
The bedside monitor (heart rate over time)
Metrics: numbers sampled over time
The nurse's chart of events
Logs: a record of each event
Following dye through the body
Traces: one request through all services
An alarm when the heart rate is too high
An alert on a metric
Patient ID on every page and test
A request ID shared by logs and traces
A test nobody ever ordered
A question you cannot answer, because the data was never recorded
A typical investigation
πŸ””Alert fireserror rate 12%
→↓metrics
🧭Which service?open a slow trace
→↓traces
πŸ”ŽRead the logsfor that request ID
→↓logs
πŸ› οΈFix

04Why Do We Need It?

🚨Find problems before users do
Metrics and alerts show a rising error rate before the support inbox fills up.
⏱️Fix faster
The time to find the cause is often longer than the time to fix it. Good data cuts the search.
πŸ•ΈοΈCope with many services
With dozens of services, nobody can hold the whole picture in their head. Data has to do it.
πŸ”¬Learn from incidents
Recorded history lets you explain what happened afterwards, not only guess.
πŸ“ŠPlan capacity
Trends in metrics show when you will run out of room, before you do.
πŸ§ͺRelease with confidence
Canary and rollback decisions depend on health numbers after each release.
You cannot fix, tune or trust what you cannot see. Observability is how a running system shows you its insides.

05Where Do We Use It?

🌐Web and API services
Request rate, errors, latency, and a trace for each slow request.
🧩Microservices
Traces connect the calls between services, which logs alone cannot do.
πŸ—„οΈDatabases and queues
Metrics on query time, connections, queue depth and consumer lag.
☁️Cloud and containers
Resource metrics (CPU, memory) and logs from short-lived containers.
πŸš€Release pipelines
Compare health before and after a deployment to decide to go on or roll back.
πŸ“±Mobile and browser apps
Crash reports, page load times and error logs sent from the user device.

06Types / Parts / How It Works

The three pillars side by side

PillarWhat it isBest question it answersCost and limit
MetricsNumbers measured at regular intervals and stored as time seriesIs something wrong? How much? Is it getting worse?Cheap and fast. No detail about single requests. Too many label values (high cardinality) makes it costly.
LogsTimestamped records of single events, as text or JSONWhat exactly happened, and what was the error?Rich detail, but large. Costly to store and search. Hard to connect across services without an ID.
TracesA tree of timed steps (spans) for one request across servicesWhere did the time or the failure happen?Needs every service to pass a trace ID along. Often sampled, so some requests are not recorded.

How they connect

One request ID ties the pillars together
πŸ“¨Requesttrace_id = t-77
↓
πŸ–₯️API
πŸ’³Payment
πŸ—„οΈDatabase
πŸ“ˆMetricscount and time, by service
🧡Trace t-77spans in a tree
πŸ“œLogseach line carries t-77
Aggregated Per request Per event
The same trace or request ID appears in the trace, in each log line and (as an example link) beside a metric spike.

Other signals you will hear about

  • Events and profiles. Some teams add deployment events, error reports with stack traces, and CPU or memory profiles as extra signals.
  • The word "pillars". Some people prefer to call them signals or telemetry types, because what matters is how you combine them, not how many you collect.
VisualizerWhich pillar answers which question?Pick an incident, then switch metrics, logs and traces off one by one. Watch which questions turn into slow workarounds or pure guessing.
The incident

At 14:02 customers start seeing an error page at checkout.

Question 1Is something really wrong? How bad?πŸ“ˆ answered by Metrics
Error-rate chart: 0.2% jumps to 12% at 14:02. An alert fires.
~1 min (illustrative)
Question 2Which service is failing?🧡 answered by Traces
A sample trace shows the payment span failing after 3.0 s, inside the card gateway call.
~2 min (illustrative)
Question 3Why is it failing?πŸ“œ answered by Logs
Log line: gateway timeout after 3000 ms, request_id=r-8841, gateway=eu-2.
~3 min (illustrative)
Time to explain
6 min
best case 6 min
Pillars on
3 of 3
metrics, logs, traces
Answered the hard way
0
with the wrong pillar
Blind spots
0
pure guessing
With all three pillars each question has a natural tool: metrics tell you something is wrong, traces tell you where, logs tell you why. About 6 minutes (illustrative).

The minutes are made-up round numbers to show the idea, not measurements. Real teams can often answer more questions with one pillar than shown here, but usually slower.

07How to Use It / Steps / Implementation

Building observability into a service

  1. 1
    Start with the user questions
    Ask what you need to know: is checkout working? how fast? for whom? Collect data to answer those, not everything you can.
  2. 2
    Add the basic metrics first
    For every service track the rate of requests, the rate of errors, and the duration (RED). For resources track utilization, saturation and errors (USE).
  3. 3
    Log in a structured way
    Write one JSON object per event, with a level, a message and fields such as user ID and request ID. Never write secrets.
  4. 4
    Pass a trace ID everywhere
    Create it at the edge and send it in a header to every call and message. Put it in each log line too.
  5. 5
    Link the pillars
    Make it easy to jump from a chart spike to example traces, and from a trace to its logs, using the same IDs and labels.
  6. 6
    Control the cost
    Sample traces, keep log levels sensible, limit label values on metrics, and set retention times.
  7. 7
    Test it in a calm moment
    Run a practice incident. Can a new engineer find the cause using only your dashboards, traces and logs?
πŸ’‘Standard tools help
Open standards such as OpenTelemetry give one way to produce metrics, logs and traces from your code, and send them to many different back ends. That keeps you from being locked into one vendor.
⚠️Collecting is not understanding
A wall of unlinked data is not observability. If you cannot go from a symptom to a cause in a few clicks, add the missing links before adding more data.

08Key Terms to Know

TermMeaning in easy words
ObservabilityHow well you can understand a system's inside state from the data it produces
MonitoringWatching known signals and alerting when they cross a limit
TelemetryThe data a system sends out: metrics, logs, traces and more
MetricA number measured over time, such as requests per second
LogA timestamped record of one event
TraceThe full journey of one request through the system
SpanOne timed step inside a trace, such as a database call
Trace ID / request IDA unique label passed along a request so all its data can be joined
CardinalityThe number of different values a label can take. Very high cardinality makes metrics costly
SamplingKeeping only a share of traces or logs to save cost
OpenTelemetryAn open standard and set of tools for producing and sending telemetry

09Pros, Cons and Trade-offs

βœ… Pros
  • Problems are found and explained much faster
  • You can ask new questions without new code (if the data is rich enough)
  • Shows how services depend on each other
  • Supports safe releases, capacity planning and learning from incidents
  • Open standards avoid lock-in
⚠️ Cons
  • Storage and tooling can be a large cost
  • Needs discipline: IDs, naming and labels must be consistent
  • Sampling means some requests are never seen
  • Too many alerts and charts cause noise
  • Telemetry code adds a small run-time overhead

Trade-offs

ChoiceWe gainWe lose
Log everythingFull detail to look back onHigh cost, noise and a risk of leaking data
Log littleLow cost, quiet logsGaps when you need a detail the most
Trace every requestComplete picture of every callLarge cost and extra delay in each request
Sample tracesLow cost, still a good picture on averageA rare failing request may not be recorded
Many metric labelsRich slicing by region, version, customerCardinality explosion and a big bill
One vendor for all threeEverything in one place, easy linksLock-in and a single bill that grows fast

10Common Problems and Mistakes

Common mistakes

  1. Only logs. Searching text to detect a slow trend is slow and expensive. Use metrics for trends.
  2. No shared ID. Without a request or trace ID, logs from different services cannot be joined.
  3. Averages only. An average hides the slow few. Track percentiles such as p95 and p99.
  4. Alerting on everything. Alert fatigue makes people ignore the real alert.
  5. Secrets in logs. Passwords, tokens and card numbers must never be written to telemetry.
  6. Adding it after the outage. The data you need was not being recorded when it happened.
  7. High-cardinality labels. Putting a user ID in a metric label creates millions of series.

Things to watch

πŸ’ΈCost growth
Telemetry volume tends to grow faster than traffic. Review it often.
πŸ•³οΈBlind spots
A service without instrumentation is a hole in every trace.
πŸ•°οΈClock differences
Machines with different clocks order events wrongly. Keep clocks in sync.
πŸ”’Privacy rules
Personal data in telemetry may fall under legal limits and retention rules.

11Real-World Examples

πŸ”₯Prometheus and Grafana
A very common open-source pair for metrics collection and dashboards.
🧡Jaeger and Zipkin
Open-source tracing back ends that store and show traces as timelines.
πŸ“œElastic stack and Loki
Popular ways to collect, store and search logs.
πŸ“‘OpenTelemetry
A vendor-neutral standard and set of libraries for producing all three signals.
☁️Cloud services
Cloud providers offer built-in monitoring, log and trace services for their platforms.
🧰All-in-one vendors
Commercial platforms such as Datadog and New Relic combine all three pillars in one product.
πŸ“Note
Tools change quickly. Pick them by how well they link the three pillars and what they cost at your scale, not by name.
Mini case: a slow checkout
πŸ“ˆp99 latency 5 sdashboard
→↓open a slow trace
🧡DB span 4.2 sorders service
→↓search its request ID
πŸ“œSlow query logmissing index
Metrics found it, a trace located it and a log explained it. About an hour of guessing becomes a few minutes.

12Related Topics to Read Next

Logging Best Practices→

How to write logs that are useful and safe.

Log Aggregation→

Collecting logs from every machine in one searchable place.

Metrics and Instrumentation→

How to measure your code with counters, gauges and histograms.

Distributed Tracing→

Following one request through many services.

Alerts and Monitoring→

Turning your data into a signal that wakes the right person.

Dashboards and Runbooks→

How to show the data and what to do when it looks bad.

Microservices→

Many small services are the main reason traces are needed.

13Interview Questions with Short Answers

14Quick Revision Cheat-Sheet

  • βœ”Metrics: numbers over time. Tell you something is wrong.
  • βœ”Traces: one request across services. Tell you where.
  • βœ”Logs: detailed event records. Tell you why.
  • βœ”Glue: one trace or request ID in every signal.
  • βœ”Start with: RED for services (rate, errors, duration) and USE for resources.
  • βœ”Avoid: averages only, secrets in logs, high-cardinality labels, alert noise.
  • βœ”Standard: OpenTelemetry to produce signals without vendor lock-in.
  • βœ”One line: β€œMetrics say something is wrong, traces say where, logs say why.”
← Previous
Shadow Traffic and Dark Launches
Next β†’
Logging Best Practices