Last Updated: February 3, 2026
Logs tell you what happened to specific requests. But what if you need to know how the system is performing overall? Are response times getting slower? Is the error rate increasing? How many requests are we handling per second?
These questions require metrics: numerical measurements collected over time.
Metrics answer questions like "how many?" and "how fast?" across thousands or millions of requests. They power dashboards, drive alerts, and enable capacity planning. Good instrumentation gives you early warning when things degrade, often before users notice.
In this chapter, you will learn:
This builds on the observability foundation we established earlier. Metrics complement logs by providing the aggregate view that logs cannot offer.
To understand why metrics are indispensable, consider an e-commerce platform during a flash sale.
Logs show individual events. To understand the flash sale's impact, you would need to aggregate 50,000 log entries. Metrics give you instant visibility: request rate tripled, latency increased by 40%, error rate is still acceptable, CPU is climbing.
| Aspect | Metrics | Logs |
|---|---|---|
| Data type | Numeric time series | Text events |
| Question answered | How much? How many? | What happened? |
| Storage efficiency | Very efficient (numbers) | Less efficient (text) |
| Query style | Aggregate, graph | Search, filter |
| Retention | Months to years | Days to weeks |
| Alerting | Primary use case | Secondary use case |
| Debugging | Find the problem | Understand the problem |
Both are essential. Metrics alert you that something is wrong. Logs and traces help you understand why. Think of metrics as the vital signs monitor in a hospital: it tells doctors instantly when something needs attention, but they still need tests and exams to diagnose the cause.