通过 vLLM API 的指标#

LMCache 通过 Prometheus 端点提供详细的指标,允许对缓存性能和行为进行深入监控。本节概述了如何启用和配置来自嵌入式 vLLM /metrics API 端点的可观察性。

快速入门指南#

1) 在 vLLM/LMCache 端#

在 v1 中,vLLM 和 LMCache 运行在不同的进程中,因此您必须使用多进程 Prometheus。

PROMETHEUS_MULTIPROC_DIR 环境变量在两个进程中必须相同,作为 IPC 目录。

PROMETHEUS_MULTIPROC_DIR=/tmp/lmcache_prometheus \
#.. other environment variables \
vllm serve $MODEL -port 8000 ...

一旦 HTTP 服务器运行,您可以在 /metrics 端点访问 LMCache 指标。

curl http://$<vllm-worker-ip>:8000/metrics | grep lmcache

# Replace $IP with the IP address of a vLLM worker

您还会在 $PROMETHEUS_MULTIPROC_DIR 目录中找到一些 .db 文件。

2) Prometheus 配置#

要使用 Prometheus 服务器抓取 LMCache 指标,请将以下作业添加到您的 prometheus.yml 配置中,或等效配置以抓取指标端点:

scrape_configs:
  - job_name: 'lmcache'
    static_configs:
      - targets: ['<vllm-worker-ip>:8000']
    scrape_interval: 15s

可用指标#

LMCache 提供多种指标以监控其性能。下表列出了按类别组织的所有可用指标:

LMCache 指标#

指标名称

类型

描述

核心请求指标

lmcache:num_retrieve_requests

计数器

检索请求的总数

lmcache:num_store_requests

计数器

存储请求的总数

lmcache:num_lookup_requests

计数器

查找请求的总数

lmcache:num_requested_tokens

计数器

检索请求的总令牌数

lmcache:num_hit_tokens

计数器

从检索中获得的缓存命中令牌的总数

lmcache:num_lookup_tokens

计数器

查找操作中请求的令牌总数

lmcache:num_lookup_hits

计数器

查找操作中命中的总令牌数

lmcache:num_vllm_hit_tokens

计数器

vLLM 中的命中令牌数量

命中率指标

lmcache:retrieve_hit_rate

仪表

检索请求的命中率

lmcache:lookup_hit_rate

仪表

查找请求的命中率

缓存使用指标

lmcache:local_cache_usage

仪表

本地缓存使用量(字节)

lmcache:remote_cache_usage

仪表

远程缓存使用量(字节)

lmcache:local_storage_usage

仪表

本地存储使用量(字节)

性能指标

lmcache:time_to_retrieve

直方图

从缓存中检索所需的时间(秒)

lmcache:time_to_store

直方图

存储到缓存所需的时间(秒)

lmcache:retrieve_speed

直方图

检索速度(每秒令牌数)

lmcache:store_speed

直方图

存储速度(每秒令牌数)

远程后端指标

lmcache:num_remote_read_requests

计数器

对远程后端的读取请求总数

lmcache:num_remote_read_bytes

计数器

从远程后端读取的字节总数

lmcache:num_remote_write_requests

计数器

远程后端写请求的总数

lmcache:num_remote_write_bytes

计数器

写入远程后端的字节总数

lmcache:remote_time_to_get

直方图

从远程后端获取数据所花费的时间(毫秒)

lmcache:remote_time_to_put

直方图

将数据放入远程后端所需的时间(毫秒)

lmcache:remote_time_to_get_sync

直方图

从远程后端同步获取数据所需的时间(毫秒)

网络监控指标

lmcache:remote_ping_latency

仪表

最新的远程后端 ping 延迟(毫秒)

lmcache:remote_ping_errors

计数器

远程后端的 ping 错误数量

lmcache:remote_ping_successes

计数器

远程后端的 ping 成功次数

lmcache:remote_ping_error_code

仪表

最新的远程后端 ping 错误代码

本地 CPU 后端指标

lmcache:local_cpu_evict_count

计数器

本地 CPU 后端的总逐出次数

lmcache:local_cpu_evict_keys_count

计数器

本地 CPU 后端中被逐出的键的总数

lmcache:local_cpu_evict_failed_count

计数器

本地 CPU 后端中失败的逐出总数

lmcache:local_cpu_hot_cache_count

仪表

热缓存的大小

lmcache:local_cpu_keys_in_request_count

仪表

请求中键的大小

内存管理指标

lmcache:active_memory_objs_count

仪表

活动内存对象的数量

lmcache:pinned_memory_objs_count

仪表

固定内存对象的数量