Prometheus metric types reference
Prometheus has four core metric types — Counter, Gauge, Histogram, and Summary — each with its own data model, exposition output, and the set of PromQL functions that make sense for it. Choosing the right type is the single most important modelling decision when instrumenting a service. This reference summarizes each type, what it exposes, and how to query it.
The four types at a glance
| Type | Changes over time | Typical use | Key PromQL functions |
|---|---|---|---|
| Counter | Only increases (resets to 0 on restart) | Request count, errors, bytes sent | rate(), increase() |
| Gauge | Can go up or down | Memory in use, queue depth, temperature | avg_over_time(), delta(), deriv() |
| Histogram | Counts observations into buckets | Request latency, response size | histogram_quantile(), rate() on _bucket |
| Summary | Client-side quantiles | Latency (single-instance, no aggregation needed) | Direct quantile label, rate() on _count |
How it works
A Counter is a monotonically increasing value; it only resets to zero when the process restarts. You never read its raw value directly — you apply rate() or increase() to get throughput, both of which detect and correct for resets. A Gauge is a snapshot that can rise and fall; functions like avg_over_time, delta, and deriv apply.
A Histogram counts observations into configurable buckets and exposes three series: _bucket{le=...} (cumulative counts per upper bound), _sum, and _count. histogram_quantile() interpolates percentiles from the buckets, and because buckets are additive you can aggregate across instances before computing the quantile. A Summary computes client-side quantiles directly (exposed with a quantile label) plus _sum and _count; its quantiles cannot be meaningfully aggregated across instances.
Naming conventions
Prometheus naming conventions exist so alerts and dashboards stay consistent across services:
- Use snake_case with a service prefix:
http_requests_total,database_query_duration_seconds. - Append
_totalto counter names. - Use base units as the suffix —
_secondsnot_milliseconds,_bytesnot_megabytes. Let PromQL convert at query time. - For histograms, the base name (e.g.,
http_request_duration_seconds) automatically produces_bucket,_sum, and_countseries — do not add those suffixes yourself.
PromQL examples
Compute request throughput and error ratio from counters:
rate(http_requests_total[5m])
sum(rate(http_requests_total{code=~"5.."}[5m]))
/ sum(rate(http_requests_total[5m]))
Estimate the 95th percentile latency from a histogram — aggregating across all replicas first, then computing the quantile:
histogram_quantile(0.95,
sum by (le) (rate(http_request_duration_seconds_bucket[5m])))
Prefer histograms over summaries when you run more than one replica, because histogram buckets are additive and can be summed across instances before the quantile is computed. Summaries compute quantiles on the client and cannot be meaningfully aggregated — you would get different percentile values per instance with no way to combine them. Align histogram bucket boundaries to your SLOs so the important thresholds (200ms, 500ms, 1s) fall on bucket edges rather than being interpolated.