vllm.v1.metrics.reader
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
_digest_histogram
¶
_digest_histogram(
bucket_samples: list[Sample],
count_samples: list[Sample],
sum_samples: list[Sample],
) -> list[
tuple[dict[str, str], dict[str, int], int, float]
]
Source code in vllm/v1/metrics/reader.py
_digest_num_accepted_by_pos_samples
¶
_digest_num_accepted_by_pos_samples(
samples: list[Sample],
) -> list[tuple[dict[str, str], list[int]]]
Source code in vllm/v1/metrics/reader.py
_get_samples
¶
_strip_label
¶
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}")