Metric types

The Prometheus client libraries offer four core metric types. These arecurrently only differentiated in the client libraries (to enable APIs tailoredto the usage of the specific types) and in the wire protocol. The Prometheusserver does not yet make use of the type information and flattens all data intountyped time series. This may change in the future.

Counter

A counter is a cumulative metric that represents a single monotonically increasing counter whosevalue can only increase or be reset to zero on restart. For example, you canuse a counter to represent the number of requests served, tasks completed, orerrors.

Do not use a counter to expose a value that can decrease. For example, do notuse a counter for the number of currently running processes; instead use a gauge.

Client library usage documentation for counters:

Gauge

A gauge is a metric that represents a single numerical value that canarbitrarily go up and down.

Gauges are typically used for measured values like temperatures or currentmemory usage, but also "counts" that can go up and down, like the number ofconcurrent requests.

Client library usage documentation for gauges:

Histogram

A histogram samples observations (usually things like request durations orresponse sizes) and counts them in configurable buckets. It also provides a sumof all observed values.

A histogram with a base metric name of <basename> exposes multiple time seriesduring a scrape:

  • cumulative counters for the observation buckets, exposed as <basename>_bucket{le="<upper inclusive bound>"}
  • the total sum of all observed values, exposed as <basename>_sum
  • the count of events that have been observed, exposed as <basename>_count (identical to <basename>_bucket{le="+Inf"} above)Use thehistogram_quantile() functionto calculate quantiles from histograms or even aggregations of histograms. Ahistogram is also suitable to calculate anApdex score. When operating on buckets,remember that the histogram iscumulative. Seehistograms and summaries for details of histogramusage and differences to summaries.

Client library usage documentation for histograms:

Summary

Similar to a histogram, a summary samples observations (usually things likerequest durations and response sizes). While it also provides a total count ofobservations and a sum of all observed values, it calculates configurablequantiles over a sliding time window.

A summary with a base metric name of <basename> exposes multiple time seriesduring a scrape:

  • streaming φ-quantiles (0 ≤ φ ≤ 1) of observed events, exposed as <basename>{quantile="<φ>"}
  • the total sum of all observed values, exposed as <basename>_sum
  • the count of events that have been observed, exposed as <basename>_countSee histograms and summaries fordetailed explanations of φ-quantiles, summary usage, and differencesto histograms.

Client library usage documentation for summaries: