Python Prometheus Client Supported Metric Types

Monitoring Python applications with Prometheus requires tracking performance data using specific data structures designed for time-series analysis. The official prometheus_client Python library provides four core metric types defined by the Prometheus specification—Counter, Gauge, Summary, and Histogram—along with specialized utilities like Info and Enum. This guide outlines how each metric type works, their specific behavioral rules, and typical use cases in application instrumentation.

Counter

A Counter is a cumulative metric that represents a single monotonically increasing value. Its value can only increase or be reset to zero upon application restart.

Gauge

A Gauge represents a single numerical value that can arbitrarily go up and down. It reflects a snapshot of the current state of a particular component.

Histogram

A Histogram samples observations (usually request durations or response sizes) and counts them into configurable, cumulative buckets. It also provides a sum of all observed values and a count of events.

Summary

A Summary samples observations and, like a Histogram, provides total counts and sums. Additionally, it calculates configurable quantiles over a sliding time window directly on the client side.

Info

The Info metric is an extended type used to expose key-value label data that remains static or changes infrequently during runtime.

Enum

The Enum metric tracks states from a predefined set of distinct values. It exposes a single gauge metric where the active state has a value of 1 and all other states have a value of 0.