Skip to content

Commit 9289e57

Browse files
authored
add cache_config's info to prometheus metrics. (#3100)
1 parent a6d471c commit 9289e57

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

vllm/config.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,10 @@ def __init__(
308308
self.num_gpu_blocks = None
309309
self.num_cpu_blocks = None
310310

311+
def metrics_info(self):
312+
# convert cache_config to dict(key: str, value:str) for prometheus metrics info
313+
return {key: str(value) for key, value in self.__dict__.items()}
314+
311315
def _verify_args(self) -> None:
312316
if self.gpu_memory_utilization > 1.0:
313317
raise ValueError(

vllm/engine/llm_engine.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ def __init__(
138138
self.stat_logger = StatLogger(
139139
local_interval=_LOCAL_LOGGING_INTERVAL_SEC,
140140
labels=dict(model_name=model_config.model))
141+
self.stat_logger.info("cache_config", self.cache_config)
141142

142143
self.forward_dag = None
143144
if USE_RAY_COMPILED_DAG:

vllm/engine/metrics.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from vllm.logger import init_logger
2-
from prometheus_client import Counter, Gauge, Histogram, REGISTRY, disable_created_metrics
2+
from prometheus_client import Counter, Gauge, Histogram, Info, REGISTRY, disable_created_metrics
33

44
import time
55
import numpy as np
@@ -23,6 +23,10 @@ def __init__(self, labelnames: List[str]):
2323
if hasattr(collector, "_name") and "vllm" in collector._name:
2424
REGISTRY.unregister(collector)
2525

26+
self.info_cache_config = Info(
27+
name='vllm:cache_config',
28+
documentation='information of cache_config')
29+
2630
# System stats
2731
self.gauge_scheduler_running = Gauge(
2832
name="vllm:num_requests_running",
@@ -128,6 +132,10 @@ def __init__(self, local_interval: float, labels: Dict[str, str]) -> None:
128132
self.labels = labels
129133
self.metrics = Metrics(labelnames=list(labels.keys()))
130134

135+
def info(self, type: str, obj: object) -> None:
136+
if type == "cache_config":
137+
self.metrics.info_cache_config.info(obj.metrics_info())
138+
131139
def _get_throughput(self, tracked_stats: List[int], now: float) -> float:
132140
return float(np.sum(tracked_stats) / (now - self.last_local_log))
133141

0 commit comments

Comments
 (0)