Prometheus histograms vs summaries for latency

Choosing between Prometheus histograms and summaries determines whether you can aggregate latency across instances and how accurately you can meet an SLO. This page compares the options and the work to set them up.

On this page

Prometheus histograms vs summaries: which one fits latency you need to aggregate

If your service team needs request latency aggregated across instances and checked against an SLO, use a histogram. Classic histograms record observations into cumulative buckets with the _bucket suffix, so Prometheus can sum those counters across every replica and then estimate a quantile at query time with histogram_quantile(). Summaries compute quantiles inside each instance before the data reaches Prometheus, so the exported quantile values cannot be averaged or merged across instances in a meaningful way. For a latency SLO that covers the whole service, that difference decides the question. Summaries still have a place when you need an exact per-instance quantile and never need to combine it with other instances.

This trade-off follows from what Prometheus is built for. The overview documentation says Prometheus values reliability over precision and is not a suitable choice where 100% accuracy is required, such as per-request billing. A histogram quantile is an estimate whose accuracy depends on where your bucket boundaries fall, so the bucket layout is a design decision you own. Pick boundaries around the SLO threshold, for example the value your objective is written against, and add a few points on either side so the quantile is not interpolated across a wide gap. Confirm the bucket list with the team that owns the SLO before instrumentation ships, because changing buckets later creates a break in the series history.

Native histograms are the newer option and need their own check. Confirm that your Prometheus version supports them and that your scrape configuration and remote storage accept the format before you rely on them for SLO dashboards, because the classic and native forms are not interchangeable in existing rules. Ask your platform owner which format the Alertmanager rules and long-term store expect. The Prometheus overview is the right starting point for confirming the design goals before you commit to one form across the estate.

Classic histograms, native histograms and summaries compared

This table compares the three ways to record request latency in Prometheus on aggregation, accuracy, cost, configuration and SLO fit. Read each row as a trade-off, then match the option to how many instances serve the endpoint and which quantiles or SLO thresholds you must answer. Most teams that need to aggregate latency across instances should favor histograms over summaries.

CriterionClassic histogramNative histogramSummary
Aggregation across instancesYesYesNo
Quantiles computed in PromQLYes, with histogram_quantile over bucket ratesYes, with histogram_quantile over the native seriesNo, quantiles are fixed client-side per instance
Quantile accuracyLimited to bucket boundaries; interpolated within a bucketHigher resolution without hand-picked buckets; confirm the schema in your versionExact for the configured quantiles on one instance, not valid to average
Bucket or quantile configurationBucket boundaries chosen in code; changing them breaks historyFew settings; bucket growth is set by the library and schemaQuantile objectives and error set in code
Storage and query costOne series per bucket plus sum and count; cost grows with bucket countOne series per histogram; cost depends on bucket density in useOne series per quantile plus sum and count; low query cost
SLO fitGood for a latency threshold that matches a bucket edgeGood for SLO thresholds without re-instrumenting; confirm support in your server and clientsWeak; a per-instance quantile cannot show a fleet-wide SLO
Best whenFleet-wide latency SLOs and mature dashboards on a known bucket layoutYou need detailed latency shape and can run a native-histogram-capable serverA single instance or a legacy stack that only exposes summaries
Main trade-offBucket choice is hard to change laterNewer feature; check client, server and remote storage support firstQuantiles cannot be combined or re-aggregated across instances

How histogram quantiles are estimated and where the error comes from

A classic histogram does not store individual request latencies. It stores cumulative counts in _bucket series, one per le boundary, and histogram_quantile() estimates a quantile by linear interpolation inside the bucket where the target rank falls. The estimate is therefore only as precise as the boundaries allow. If the 99th percentile lands in a bucket spanning 1 to 2.5 seconds, the function returns a value somewhere inside that range, and no amount of query tuning recovers the detail the buckets discarded. Before you choose a histogram, list the le values your SLO and alerts depend on and confirm, with a sample of real traffic, that the quantiles you care about fall between boundaries you have deliberately placed.

A bucket boundary placed at the SLO threshold matters more than the number of buckets. If the objective is that 99% of requests finish within 300 milliseconds, a bucket with le="0.3" lets you read the fraction of requests under the threshold directly, which is exact for that boundary. Without it, the interpolated value near 300 milliseconds carries error that can flip an alert between firing and resolved. Review bucket sets whenever the SLO changes, and keep the threshold on a boundary rather than relying on interpolation around it.

Summaries work differently. The client library computes quantiles in the process over a sliding window and exports them as quantile labels, so the values cannot be aggregated across instances by averaging or by histogram_quantile(). The Prometheus overview states that the system values reliability over precision and is not a good choice where 100% accuracy is required, such as per-request billing (Prometheus overview). Neither type gives exact percentiles, so the decision is about where approximation error is acceptable. Confirm with your SLO owners which error margin they will accept and document it next to the alert rules.

Choosing bucket boundaries for latency SLOs

Bucket boundaries decide what questions a classic histogram can answer later. The four to six decisions below connect the SLO threshold, the traffic you actually see, and the number of series each bucket adds to every label set.

Place a boundary at the SLO threshold

If your latency objective says 99% of requests finish within 300 ms, a bucket with an upper bound of 0.3 seconds must exist. Without it, histogram_quantile and bucket ratios can only estimate the fraction of requests under the threshold, and the estimate gets coarser as the nearest boundaries get farther apart. Confirm the threshold with the service owner before you write the bucket list, and check that the boundary uses the same unit as the metric, which is seconds for a _seconds histogram.

Cover the expected tail

Bucket ranges should reach past the slowest request you need to distinguish from a timeout. If your client timeout is 10 seconds and your largest bucket is 1 second, every slow request lands in +Inf and you lose the ability to see how slow the tail really is. Ask for the p99.9 latency and the timeout value from the team that owns the service, then extend the top bucket beyond the timeout so that timed-out requests are counted with a meaningful upper bound.

Bound the bucket count

Every classic histogram bucket is a separate time series for each combination of other labels, so a 20-bucket histogram on a service with 10 endpoints and 5 status codes adds 1,000 series before any other labels are counted. Keep the bucket list short and reviewed, and avoid putting high-cardinality labels such as user IDs or raw paths on a histogram. Ask the platform team for a current series budget before the change ships, and check the count after rollout.

Use one bucket layout per metric

Histograms can only be aggregated across instances and services when they share identical boundaries. If checkout uses 0.1, 0.5 and 1 second buckets while payments uses 0.2, 0.4 and 2 seconds, a combined percentile across both services is not valid. Publish a shared bucket standard for each unit of latency in your organization, store it in a common library or configuration file, and let teams deviate only with a written reason tied to their SLO.

Validate against real traffic

Before rollout, compare the proposed boundaries with a week of production request latencies, or with a staging load test that resembles production. Look for buckets that receive almost no requests, which waste series, and for large gaps where most requests fall between two boundaries, which blur the estimate. Ask the service team for a sample of their current latency distribution and record the decision so reviewers can see why each boundary exists.

Keep native histograms in view

Classic buckets are fixed at instrumentation time, so changing them later splits the history of the metric. Native histograms are a separate option that avoids most fixed-boundary decisions, but support depends on your Prometheus version, client library and storage path. Confirm native histogram support in your server and client libraries, and in any remote storage you send data to, before you base an SLO on a native histogram. Until then, treat the classic bucket list as a commitment that is expensive to change.

Prometheus storage docs

How to instrument a service with a histogram and verify it

This sequence takes a service from an uninstrumented handler to a latency histogram that Prometheus scrapes, queries and checks against a known load. The end result is an SLO query you can trust because you have tested it under conditions you chose.

  1. Choose the client library and metric name

    The service team picks the Prometheus client library for the service language, then names the metric using base units, so request latency is recorded in seconds with a suffix such as _seconds and a histogram type such as http_request_duration_seconds. Confirm the naming with your metric naming standard before code is written. Done means the name, unit and label set are written down and reviewed, and the labels are limited to low-cardinality values such as route template, method and status class rather than raw URLs or user IDs.

  2. Define the bucket boundaries

    Bucket boundaries are set in the code and are fixed for the life of the series, so the team decides them before deployment. Place boundaries close to the latency thresholds in the SLO, such as the target response time and a few values either side, and include the target itself as an explicit boundary so the bucket ratio can be computed exactly. Done means the bucket list is committed in code and reviewed against the SLO threshold. Changing buckets later creates new series, so record the decision in the service documentation.

  3. Record observations in the handler

    The developer wraps the request handler so each request observes its duration in seconds into the histogram, with the status and route labels attached. This happens in middleware or an equivalent shared layer so no endpoint is missed. Verify by sending a few test requests locally and checking that the exposed text output shows the _bucket, _sum and _count series for the metric, including a le label for each boundary and the +Inf bucket.

  4. Expose the metrics endpoint securely

    The service exposes the metrics on an HTTP endpoint, commonly /metrics, on a port or path that is reachable by the Prometheus server and not by end users. If the endpoint must be protected, configure TLS or authentication on the Prometheus side and confirm the scrape settings match. Verify with a direct HTTP request from the network segment where Prometheus runs, and confirm that a request from an untrusted segment is refused.

  5. Add the scrape job and confirm targets

    The platform team adds a scrape job to the Prometheus configuration, using service discovery or static targets, and reloads the configuration through the path your deployment allows. Confirm in the Prometheus targets page that the target is up and that the last scrape succeeded without errors. Done means the target shows as healthy and the scrape duration is recorded. If the target is down, check the endpoint path, port and any TLS settings before changing the job.

  6. Confirm series with a query

    In the Prometheus expression browser or an API call, the engineer runs a query that returns the histogram bucket series for the service, such as a count of the _bucket series filtered by the job label, and checks that the le values match the bucket list committed in code. Run a rate query over a short window to confirm counts are increasing under traffic. Done means the bucket series exist for every route, status and boundary you expected, with no unexpected label values.

  7. Write the SLO query with a bucket ratio

    The team writes the SLO query using rate over the _bucket series, summed by le, and either histogram_quantile for a percentile view or a ratio of the bucket at the SLO threshold divided by the total count for an availability-style view. The bucket ratio is usually the simpler choice for a threshold SLO because it counts requests under the target directly. Confirm the query returns a value between 0 and 1 for the ratio, or a time value for the quantile, over a period with known traffic.

  8. Check the result against a known load test

    Run a load test with a known request rate and a known latency distribution, such as a controlled delay injected in a test endpoint, then compare the SLO query output with the expected share of slow requests. Differences larger than the bucket resolution point to a wrong boundary, a label mismatch or a missing observation. Record the test parameters, the query used and the result in the service runbook. Done means the query matches the load test within the precision your bucket layout allows, and the team knows where the estimate is coarse.

How latency samples flow from the service to an SLO query

The path starts in the application, where the client library increments cumulative bucket counters for each observed request duration and exposes them on the /metrics endpoint. Prometheus pulls that text over HTTP on each scrape and writes every bucket as its own series into its local time series database. A rate() over the bucket series and histogram_quantile() then feed alert rules and dashboards. Native histograms take a different route: one sample carries the whole distribution, so the bucket layout is not stored as many separate series. Check that your scrape interval and bucket boundaries match the SLO you are measuring.

Latency samples move from client buckets through scrapes and storage to PromQL queries.

What drives storage and query cost for each option

Cost in Prometheus follows series count, which is set by your bucket layout, label combinations and traffic. The four cards below cover the cost drivers that matter most when you choose between classic histograms, native histograms and summaries. Cost depends on your own label and traffic profile, so measure before you commit, and confirm that your Prometheus version supports native histograms.

Buckets times label combinations

A classic histogram creates one series per bucket, plus a sum and a count, for every unique label combination. A latency histogram with 12 buckets on a route label with 200 values creates roughly 2,600 bucket series before you add status codes or pods. Each extra label multiplies that figure, so label count is the cost lever that teams most often underestimate. Count your bucket boundaries and label values together before you ship.

Storage docs

Sparse encoding of native histograms

Native histograms store one sample per histogram with exponential buckets encoded sparsely, so empty buckets cost little. This shifts cost from series count toward the size of each sample, and it reduces the need to choose bucket boundaries in advance. Confirm that your Prometheus server, your client library and your remote storage all support native histograms before you rely on them, since older components may drop or misread the data.

Summary quantiles cannot be merged

A summary computes quantiles inside each instance, and the results are stored as fixed series. Averaging or merging those quantiles across pods gives a number that has no statistical meaning, so you cannot build a fleet-wide p99 from summaries. The cost shows up later, when a dashboard or SLO needs a view that the stored data cannot provide. Check whether any cross-instance question is on your roadmap before you choose summaries.

Query cost of histogram_quantile

The histogram_quantile function reads every bucket series across the query range, so wide ranges and high-cardinality histograms make queries slow. Dashboards that refresh often or alert rules that evaluate every short interval multiply that load. Limit quantile queries to the range and aggregation you need, use recording rules for frequently used percentiles, and test query time against your real series count rather than a sample.

Prometheus overview

Which option to choose for your environment

A service runs as several replicas behind a load balancer, and the team wants alerts on latency SLOs for the whole service. Use a classic histogram. Each replica exports cumulative bucket counters, and Prometheus can sum those counters across instances before it calculates a quantile with histogram_quantile(). Averaging quantiles calculated on each instance does not give a service-wide figure, so the aggregation requirement usually settles the choice.

  • Bucket boundaries: Place a bucket boundary at the SLO threshold so the share of requests under target can be read directly. Set the bucket list before release, because changing it breaks continuity for existing series.
  • Label cardinality: Each bucket is a separate series for every label combination, so keep labels to route templates and status classes, and keep user or request IDs out of them.
  • Query shape: Apply sum by (le) to rate() output before histogram_quantile(), so the result reflects every replica.
  • Recording rules: Precompute latency quantiles and burn-rate inputs in recording rules so dashboards and alerts stay responsive.

Check that your SLO threshold matches an existing bucket boundary and that the service labels are identical across all replicas.

Security and operational considerations for latency metrics

Latency histograms and summaries look harmless, but they carry labels, scrape traffic and retention decisions that affect privacy, exposure and audit evidence. The cards below cover the checks to make before latency series go into production dashboards and SLO reports.

Labels that leak identifiers

Latency series are often labeled by route, method and status, and it is tempting to add user, tenant or account identifiers for debugging. Each distinct value creates a new series and can expose personal or customer data to anyone who can query the server. Keep latency labels to bounded route templates and status classes, and review new label names before they ship. Confirm with your data protection owner which fields are allowed in metric labels.

Scrape endpoint exposure

The /metrics endpoint that serves histogram buckets and summary quantiles is readable by any client that can reach it. Latency data can reveal traffic patterns, internal route names and capacity limits. Restrict network access to the Prometheus servers that scrape the target, and confirm that no ingress rule publishes the endpoint to untrusted networks.

TLS and basic authentication

The security model supports TLS with client certificates, with TLS 1.2 as the minimum, and HTTP basic authentication with bcrypt-hashed passwords. Basic authentication without TLS sends credentials in cleartext, so latency endpoints scraped over plain HTTP should use TLS first. Set tls_config and basic_auth in the scrape configuration, and keep password hashes and certificates in your secret store.

Security model

Admin APIs left disabled

Prometheus admin HTTP APIs are disabled by default. The --web.enable-admin-api flag enables destructive operations such as deleting series, and --web.enable-lifecycle enables reload and shutdown endpoints. Leave both off in production unless a documented runbook needs them, and restrict any enabled endpoint to an administrative network. Check the running process arguments during each review.

Exporter abuse through targets

Some exporters take their target from URL parameters, so anyone with HTTP access to them can make the exporter send requests to arbitrary endpoints. This matters for latency checks that probe your own services from inside the network. Limit who can reach these exporters and restrict the destinations they are allowed to call.

Retention of SLO evidence

Default local retention is 15 days, and local storage is not clustered or replicated. If latency series support SLO reports or incident reviews, a shorter window than your reporting period will remove the evidence. Decide the retention your reporting needs, size local disk for it, and confirm with your compliance owner whether remote write to long-term storage is required.

Storage docs

Questions teams ask before choosing a latency metric type

Should we use histograms or summaries for request latency in Prometheus?

For most request latency work, use histograms, because they can be aggregated across instances and label sets at query time, and summaries cannot. A summary stores quantiles computed inside each process, so you cannot correctly combine them across replicas or compute a fleet-wide p99 from them. Histograms let you pick the quantile when you query, and they fit SLO calculations that count requests under a latency threshold. Summaries remain useful only when you need an exact quantile for a single process and never need to combine it with other instances.

What does the rollout effort depend on?

The effort depends on how many services emit latency, how many languages and client libraries are in use, and how much of the estate already has instrumentation you can reuse. It also depends on how many dashboards and alert rules must be rewritten, and whether your team has agreed on bucket boundaries and label names before code changes start. Teams that already standardize metric names usually move faster. Ask any partner to break the work down by service group, library and alert rule, so you can see which parts are one-time and which recur as services change.

Can our internal team set up latency metrics without outside help?

Yes, many internal teams do this alone, especially when they already run Prometheus and have engineers familiar with PromQL. The work is mostly code changes in each service, a short review of bucket layouts, and updates to recording rules and alerts. Outside help is most useful when many teams must follow one naming standard, when the SLO design needs agreement from risk or compliance owners, or when the team lacks capacity to test changes across the estate. Ask a partner to name the parts they would hand back to your team so ownership stays clear.

How long does validation take, and what does it need from our team?

Validation depends on how long you need to observe real traffic before trusting the new series. You need access to the services under test, a staging or canary path where changes can run, and someone who can confirm that the new latency queries match what users experience. Check that bucket counts, label cardinality and scrape sizes stay within the limits your Prometheus server can handle. Prometheus keeps local data for a default retention of 15 days, so a comparison window shorter than that is easy to check, but the duration of your own validation depends on your traffic patterns and change process. Confirm the window and sign-off criteria in writing before work starts.

Do changes to SLO buckets break our historical latency data?

Changing bucket boundaries does not delete old data, but it does change what you can compare. A histogram series is stored per bucket boundary, so a query that counts requests under 300 ms only works for periods where that bucket existed. Queries that span the change may return gaps, misleading ratios or sudden jumps. To avoid this, keep the SLO threshold bucket in every layout, add new buckets alongside old ones where possible, and record the change date on your SLO dashboards. Native histograms reduce this problem because they do not require fixed bucket boundaries in the same way, but you should confirm how your Prometheus version and storage behave before relying on it.

Does Prometheus give exact latency numbers for compliance or billing?

No. The Prometheus documentation says it values reliability over precision and is not a good choice where 100% accuracy is required, such as per-request billing. Histogram-based latency is an estimate of the distribution, and quantile results depend on bucket placement. For monitoring, alerting and SLO tracking this is normally acceptable, but if an auditor or customer needs exact per-request timings, record those in a separate system designed for that purpose. Compliance teams can use the metrics as operational evidence, but they should not treat quantile estimates as transaction records.

What should we ask for in a written scope before the work starts?

Ask for a list of services and libraries in scope, the metric names and label rules to be used, the bucket layout for each latency metric, and the recording rules and alerts that will change. Request the validation method, the environments where changes will be tested, and the criteria that count as done. Also ask who maintains the dashboards and SLO queries after handover, and how bucket changes will be reviewed later. Most engagements are fixed-scope with deliverables and timelines agreed in writing, so these items should appear in that document, with any recurring support priced separately.

How DeployOpen works on this

DeployOpen plans and implements Prometheus latency instrumentation inside infrastructure you control, starting with the SLO questions and label budget that decide histograms or summaries. Each engagement is fixed-scope, with deliverables and timelines agreed in writing before work starts.

How we scope

  • Inventory the services, endpoints and SLOs that need latency data, and the queries your alerts will run.
  • Agree in writing whether classic histograms, native histograms or summaries fit each service, with bucket boundaries tied to SLO thresholds.
  • Set a label and series budget per service so bucket count and cardinality are known before instrumentation ships.

How we build

  • Instrument services with the agreed client libraries and naming standard, and check bucket layouts against real request durations.
  • Verify aggregation: confirm that quantiles can be computed across instances, pods and regions in PromQL.
  • Test recording rules and alert rules against sample traffic, including the query cost of histogram_quantile on busy services.

How we hand over

  • Deliver a written decision record explaining each metric type choice, its trade-offs and the bucket design behind it.
  • Document the metric names, labels, bucket boundaries and dashboards so your platform and service teams can extend them.
  • Walk your engineers through the runbook for changing buckets, retiring metrics and checking series growth after a release.

How we support

  • Offer ongoing support and upgrades for the Prometheus estate as a retainer, if your team wants continued help.
  • Review new services and metrics against the agreed naming, label and bucket standards before they reach production.
  • Confirm with your vendor or our team which Prometheus release line and features your environment supports before changes.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.