AlgoMaster Logo

Metrics & Instrumentation

Medium Priority20 min readUpdated July 4, 2026
AI Mock Interview

Practice this topic in a realistic system design interview

Logs describe individual events, but no one can read a million log lines to answer a simple question: is the system healthy right now? For that, you need numbers that summarize what is happening across many requests at once.

Metrics are those numbers. They are measurements collected over time. They reveal trends in latency, error rate, traffic, and resource usage. They power dashboards, trigger alerts, and help teams add capacity before the system runs out of room.

This chapter covers the main metric types, the golden signals worth tracking, how to add metrics to code, how to name metrics, how to avoid runaway labels, and how Prometheus-style systems collect and store metrics.

1. What Metrics Reveal

To see why metrics matter, consider an e-commerce platform during a flash sale.

What Logs Show

Logs show individual events: order 123 completed in 250ms, order 124 completed in 280ms, order 125 completed in 310ms, and so on across tens of thousands of orders.

What Metrics Show

Metrics summarize the workload: request rate at 2,500/sec, p99 latency at 450ms, error rate at 0.3%, and CPU at 78%.

Logs show individual events. To understand the flash sale's impact from logs alone, you would need to count and group thousands of entries. Metrics give you the shape immediately: request rate tripled, latency increased by 40%, error rate is still acceptable, and CPU is climbing.

Metrics vs Logs Comparison

Metrics and logs answer different questions. The table compares what each one does best.

AspectMetricsLogs
Data typeNumbers over timeText events
Question answeredHow much? How many?What happened?
Storage efficiencyVery efficient (numbers)Less efficient (text)
Query styleGroup, graphSearch, filter
RetentionMonths to yearsDays to weeks
AlertingPrimary use caseSecondary use case
DebuggingFind the problemUnderstand the problem

Both are essential. Metrics tell you that something changed. Logs and traces help you understand why. Think of metrics like a hospital vital-signs monitor: it quickly shows that something needs attention, but doctors still need more information to diagnose the cause.

2. Types of Metrics

Premium Content

This content is for premium members only.