← Lessons

quiz vs the machine

Gold1380

System Design

Metric Types Counter Gauge Histogram

The three core instrument shapes and when each one fits what you are measuring.

5 min read · core · beat Gold to climb

Measuring the right shape

A metric is a numeric signal sampled over time. Choosing the right instrument type makes your data meaningful and your queries correct.

Counter

A counter only goes up, like total requests served or errors seen. You rarely read it raw. Instead you compute its rate, the increase per second, which gives you throughput. A counter resets to zero when a process restarts, and good tools handle that.

Gauge

A gauge is a value that can rise and fall, like current memory usage, queue depth, or active connections. You read its latest value and can take averages, minimums, and maximums over time.

Histogram

A histogram records a distribution by counting observations into buckets, such as request latencies. From buckets you can estimate quantiles like the ninety fifth percentile, which a single average would hide. Histograms cost more to store because of multiple buckets per series.

Picking one

  • Count of events that accumulate, use a counter.
  • A current level that moves both ways, use a gauge.
  • A spread of values where tails matter, use a histogram.

Key idea

Counters accumulate and are read as rates, gauges move up and down, and histograms capture distributions so tail latency stays visible.

Check yourself

Answer to earn rating on the learn ladder.

1. How do you usually read a counter?

2. Which type best captures tail latency like the ninety fifth percentile?

3. Which metric fits current queue depth?