RousselTMLEARNING

Observability

Metric types in Prometheus

Discover in detail the four metric types supported by Prometheus (Counter, Gauge, Histogram, Summary) and their specific use cases.

Counter #

A cumulative metric that only increases or is reset to zero.

How it works and use cases #

A Counter is a cumulative metric representing a monotonically increasing value. It can only increase or be reset to zero (for example when a service restarts).

Use cases: counting the total number of HTTP requests served, the number of errors encountered, or the volume of data transferred.

PromQL tip: Never use a Counter directly to display a raw value, because service restarts would distort the curve. Always use the rate() or increase() functions to evaluate its rate of change.

# Taux de requêtes par seconde sur les 5 dernières minutes
rate(http_requests_total{method="GET"}[5m])

Gauge #

An instantaneous numeric value that can go up or down arbitrarily.

How it works and use cases #

A Gauge is a metric that captures a value at a point in time T. Unlike a counter, its value can go up as well as down.

Use cases: measuring current states such as memory usage, CPU temperature, the number of connected users, or queue size.

PromQL tip: You can display a Gauge directly or compute averages with avg_over_time(). Functions such as predict_linear() are very useful with Gauges to anticipate disk saturation.

# Moyenne d'utilisation de la mémoire sur 5 minutes
avg_over_time(node_memory_Active_bytes[5m])

Histogram #

Samples observations and counts them in configurable buckets.

How it works and use cases #

A histogram samples events (usually durations or sizes) and distributes them into predefined buckets. A histogram produces 3 distinct time series for a single metric:

  • _bucket{le="X"}: a cumulative counter for each bucket (e.g. requests under 0.5s).
  • _sum: the total sum of observed values.
  • _count: the total number of observed events.

PromQL tip: The great strength of the histogram is its ability to aggregate data from several instances to compute percentiles (e.g. the 95th percentile of latency) directly on the server side with the histogram_quantile() function.

# 95e percentile de la durée des requêtes agrégée sur tout le cluster
histogram_quantile(0.95, sum(rate(http_request_duration_seconds_bucket[5m])) by (le))

Summary #

Dynamically computes quantiles (percentiles) on the client side.

How it works and use cases #

A Summary also samples observations, but computes quantiles (e.g. the 50th or 99th percentile) directly in the application code (client side) instead of in Prometheus. Like the histogram, it also exposes _sum and _count series.

PromQL tip: Quantiles precomputed by a Summary cannot be aggregated mathematically (the average of two 95th percentiles is not a valid 95th percentile). They are therefore limited to analyzing individual instances.

# Récupération directe du 99e percentile exposé par l'application
go_gc_duration_seconds{quantile="0.99"}

When to choose Histogram or Summary? #

The key criteria for choosing between these two distribution metrics.

Comparison #

CriterionHistogramSummary
Aggregation (e.g. Kubernetes)Yes, mathematically exact via histogram_quantile()No, quantiles cannot be aggregated across pods
Percentile computationServer side (Prometheus, via PromQL)Client side (application code)
ConfigurationRequires defining bucket boundaries in advanceComputes values dynamically (simpler to configure)
Resource impactLight on the client, more costly on Prometheus (bucket storage)Heavy on the client (CPU/memory for computation)

Golden rule: In distributed architectures (microservices, Kubernetes), where you need a cluster-wide view, always use the Histogram.

2026 update: what has changed #

Recent changes worth knowing (checked in November 2026).

Native histograms #

Prometheus 3 brings a fifth format for distributions: the native histogram, stable since version 3.8. Instead of one series per bucket (_bucket{le=…}), a single series holds automatically computed exponential buckets: better accuracy, far fewer series, and no need to choose thresholds in advance.

# prometheus.yml (Prometheus 3.9 and later)
scrape_configs:
  - job_name: api
    scrape_native_histograms: true     # ingest native histograms exposed by the app
    static_configs: [{ targets: ["api:8080"] }]

# PromQL: same function, no _bucket suffix or le label
histogram_quantile(0.99, sum by (job) (rate(http_request_duration_seconds[5m])))
  • They still have to be enabled explicitly (scrape_native_histograms), and remote write sending is configured separately (send_native_histograms).
  • OpenTelemetry exponential histograms convert directly into native histograms.
  • Not every client library exposes them yet: check the one for your language.

Related articles

Time-based vs event-based SLO: understanding, computing and choosing (with the Qonto example)

Differences between time-based SLOs (time slices, uptime) and event-based SLOs (good events over total): defi…

The observability trilemma: cost, completeness and performance, and how solutions resolve it

Understanding the observability trilemma (cost, data completeness, query performance), its three trade-offs, …

Prometheus recording rules: speeding up your queries and dashboards

Understand and master Prometheus recording rules: evaluation, naming convention, pitfalls (ratios, empty seri…

Keep learning

Support us

♥ SUPPORT US

Support RousselTM Learning

Courses, articles, labs and certificates stay free with no intrusive ads. A voluntary contribution, of any amount you choose, pays for hosting, lab environments and new content.

Contribute with PayPal Any amount · card or PayPal accountLearn more
QR code PayPal
Or scan this QR code with your phone

Thank you, every contribution counts!