Skip to content

vllm.v1.metrics.reader

Classes:

  • Counter –

    A monotonically increasing integer counter.

  • Gauge –

    A numerical value that can go up or down.

  • Histogram –

    Observations recorded in configurable buckets.

  • Metric –

    A base class for prometheus metrics.

  • Vector –

    An ordered array of integer counters.

Functions:

Counter dataclass

Bases: Metric

A monotonically increasing integer counter.

Gauge dataclass

Bases: Metric

A numerical value that can go up or down.

Histogram dataclass

Bases: Metric

Observations recorded in configurable buckets.

Buckets are represented by a dictionary. The key is the upper limit of the bucket, and the value is the observed count in that bucket. A '+Inf' key always exists.

The count property is the total count across all buckets, identical to the count of the '+Inf' bucket.

The sum property is the total sum of all observed values.

Metric dataclass

A base class for prometheus metrics.

Each metric may be associated with key=value labels, and in some cases a single vLLM instance may have multiple metrics with the same name but different sets of labels.

Vector dataclass

Bases: Metric

An ordered array of integer counters.

This type - which doesn't exist in Prometheus - models one very specific metric, vllm:spec_decode_num_accepted_tokens_per_pos.

get_metrics_snapshot()

An API for accessing in-memory Prometheus metrics.

Example

for metric in llm.get_metrics(): ... if isinstance(metric, Counter): ... print(f"{metric} = {metric.value}") ... elif isinstance(metric, Gauge): ... print(f"{metric} = {metric.value}") ... elif isinstance(metric, Histogram): ... print(f"{metric}") ... print(f" sum = {metric.sum}") ... print(f" count = {metric.count}") ... for bucket_le, value in metrics.buckets.items(): ... print(f" {bucket_le} = {value}")