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:
-
get_metrics_snapshot–An API for accessing in-memory Prometheus metrics.
Counter dataclass ¶
Gauge dataclass ¶
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.
Source code in vllm/v1/metrics/reader.py
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.
Source code in vllm/v1/metrics/reader.py
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.
Source code in vllm/v1/metrics/reader.py
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}")