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.