← Lessons

quiz vs the machine

Silver1080

System Design

Metrics Counters Gauges Histograms

The three core metric shapes and when each one is the right tool.

4 min read · intro · beat Silver to climb

Metric types

A metric is a numeric measurement sampled over time. Most monitoring systems offer three basic shapes, and choosing the right one keeps your data honest.

Counter

A counter only ever goes up, resetting to zero when the process restarts. It tracks cumulative totals such as requests served or errors raised. You rarely read the raw value. Instead you compute a rate, the change per second, which reveals how busy the system is right now.

Gauge

A gauge can rise and fall. It captures a value at a moment, such as memory in use, queue depth, or active connections. You read a gauge directly because its current level is the point.

Histogram

A histogram records the distribution of many observations by sorting them into buckets. From the buckets you estimate percentiles such as the median or the ninety ninth latency. Averages hide outliers, so histograms are essential for understanding tail behavior that users actually feel.

Key idea

Use counters for cumulative totals, gauges for current levels, and histograms for distributions and percentiles.

Check yourself

Answer to earn rating on the learn ladder.

1. Which metric type is best for tracking the current number of active connections?

2. Why prefer a histogram over an average for request latency?