Observe an llm-d deployment on TPU¶
Use this guide to get every llm-d metric source into Prometheus on GKE, check that each is real, and then read the fleet with dashboards, alerts, traces and cost. Four sources matter: model servers (vllm:, port 8000), the router (llm_d_epp_, port 9090), the GKE TPU device-plugin exporter (no prefix, port 2112) and OpenCost (llm_, port 9003). The queries below are this book's code/ch21_operating/promql.md, Q01 to Q40, written against the metric names the llm-d docs define. Chapter 21 explains what each signal answers.
Prerequisites¶
- A deployed llm-d path on TPU (Optimized baseline) and
export NAMESPACE=<your-llm-d-namespace>. - Either GKE Managed Service for Prometheus (default on GKE) or the bundled Prometheus and Grafana stack.
- This book's repository for
code/ch21_operating/(source).
Steps¶
1. Scrape the model servers and the router¶
On GKE Managed Prometheus, enable automatic application monitoring (--auto-monitoring-scope=ALL): it creates PodMonitoring for vLLM and SGLang pods, but not for the EPP, so install the router with -f ${REPO_ROOT}/guides/recipes/router/features/monitoring-gke.values.yaml in MONITORING_VALUES (Optimized baseline, step 1). On a self-managed Prometheus:
./guides/recipes/observability/install-prometheus-grafana.sh
kubectl apply -n ${NAMESPACE} -k guides/recipes/modelserver/components/monitoring
and install the router with monitoring.values.yaml, which creates the EPP's ServiceMonitor.
Check: kubectl get pods -n llm-d-monitoring shows the stack (self-managed), and in Prometheus llm_d_epp_ready_endpoints (Q22) equals the number of serving pods and vllm:num_requests_running has one series per pod.
2. Scrape the TPU exporter and verify its interface¶
Follow llm-d's TPU recipe (guides/recipes/observability/tpu) to scrape the GKE device-plugin exporter, then check what it actually exports before trusting a hardware panel:
kubectl get pods -n kube-system -l k8s-app=tpu-device-plugin -o wide
kubectl port-forward -n kube-system pod/<exporter-pod> 2112:2112
# in another terminal
curl --fail --silent --show-error http://localhost:2112/metrics \
| grep -E '^(# (HELP|TYPE) )?(tensorcore_utilization|memory_bandwidth_utilization|duty_cycle|memory_used|memory_total)([ {]|$)'
# Q30 The TPU metrics exporter is scraped
up{job="kube-system/tpu-metrics-exporter"}
# Q31 Which TPU metrics each exporter instance exports
count by (__name__, instance) ({job="kube-system/tpu-metrics-exporter",__name__=~"tensorcore_utilization|memory_bandwidth_utilization|duty_cycle|memory_used|memory_total"})
Rules for reading them: tensorcore_utilization and memory_bandwidth_utilization are percent; duty_cycle, memory_used and memory_total are optional runtime metrics some TPU types omit. The model label is the TPU type, not the served LLM. With the recipe's honorLabels: false, the exporter's own labels become exported_pod and exported_namespace; the target's namespace="kube-system" does not identify the workload. Never add the _node series to the workload series. A missing series is "No data": do not replace it with zero or read it as an idle device. ICI is not in the documented interface. For a decode pool, memory_bandwidth_utilization (Q33) is the TPU metric to watch; memory_used / memory_total (Q34) is capacity.
Check: Q30 returns 1 and Q31 lists at least the two utilization metrics per instance.
3. Prove your queries name real metrics¶
python code/ch21_operating/check_queries.py --cpu-smoke
python code/ch21_operating/check_queries.py --prometheus http://localhost:9090
The first checks all 40 queries statically (balanced brackets, allowlisted metrics, histogram_quantile keeping le, no two-argument aggregation such as max(a, b), no Grafana variables) and ends cpu-smoke: OK. The second runs each against your Prometheus (port-forward it first) and reports series counts or "no data". The selectors use chapter 20's baseline (namespace llm-d-baseline, pool qwen3-32b-pool); change them to your labels.
Check: every query you rely on returns series. "No data" means a missing target, a feature gate that is off (flow-control series exist only with flow control on) or a counter that has not fired, never zero.
4. Put the SLO queries on a dashboard¶
| Question | Query |
|---|---|
| Router TTFT P90 (what clients see) | Q01 histogram_quantile(0.90, sum by(le) (rate(llm_d_epp_request_ttft_seconds_bucket{namespace="llm-d-baseline"}[1m]))) |
| Router streaming TPOT P90 | Q02 |
| Engine TTFT P99 per model | Q03 histogram_quantile(0.99, sum by(le, model_name) (rate(vllm:time_to_first_token_seconds_bucket[5m]))) |
| Engine queue | Q12 sum by(pod, model_name) (vllm:num_requests_waiting) |
| KV cache per pod | Q13 avg by(pod, model_name) (vllm:kv_cache_usage_perc) |
| Preemptions per pod | Q11 sum by(pod, instance) (rate(vllm:num_preemptions_total[5m])) |
| Prefix hit rate | Q24 sum(rate(vllm:prefix_cache_hits_total[5m])) / sum(rate(vllm:prefix_cache_queries_total[5m])) |
When router TTFT climbs and engine TTFT does not, the time is spent before the engine (flow control, Q06); when both climb, the engines are the bottleneck. With the bundled stack, load llm-d's twelve Grafana dashboards (start with llm-d-failure-saturation-dashboard, then llm-d-router, llm-d-performance-kv-cache and llm-d-tpu-overview); on GKE Managed Prometheus, Cloud Monitoring has the llm-d integration dashboard.
./guides/recipes/observability/load-llm-d-dashboards.sh
kubectl get configmaps -n llm-d-monitoring -l grafana_dashboard=1
Check: the ConfigMap list includes llm-d-tpu-overview, and Q01 and Q03 move together under a load test.
5. Alert¶
kubectl apply -n ${NAMESPACE} -f guides/recipes/observability/alerts/epp-alerting-rules.yaml
kubectl get prometheusrules -n ${NAMESPACE}
The bundled EPP rules: EPPHighErrorRatio (above 5% for 10 minutes, warning), EPPCriticalErrorRatio (above 20% for 5 minutes), EPPNoReadyEndpoints (2 minutes) and EPPMetricsAbsent (5 minutes), plus self-health on data-layer errors. Your own Prometheus ruleSelector must match the rule's app: epp-metrics label. Latency alerts are yours to write; keep a request-rate floor and add the per-pool vanish check that absent() misses:
# Q08 Error ratio above 5%, silent below 1 request per second
sum(rate(llm_d_epp_request_error_total[5m])) / sum(rate(llm_d_epp_request_total[5m])) > 0.05
and sum(rate(llm_d_epp_request_total[5m])) > 1
# Q10 A pool whose EPP metrics vanished in the last 15 minutes
llm_d_epp_ready_endpoints offset 15m unless llm_d_epp_ready_endpoints
Check: the PrometheusRule is listed and its alerts appear in Prometheus' Alerts page as inactive.
6. Trace one slow request¶
vLLM exports spans with --otlp-traces-endpoint=http://otel-collector:4317 and --collect-detailed-traces=all. On GKE, enable Managed OpenTelemetry (--managed-otel-scope=COLLECTION_AND_INSTRUMENTATION_COMPONENTS) and re-run your router install with -f ${REPO_ROOT}/guides/recipes/router/features/tracing-gke.values.yaml after the guide's values files; without it, deploy the self-managed Cloud Trace collector with ./guides/recipes/observability/install-otel-collector-jaeger.sh --gke -n ${NAMESPACE} and use tracing.values.yaml. Sampling defaults to 5% (samplerArg: "0.05"); set router.tracing.sampling.samplerArg="1.0" while verifying with a few requests.
Check: one request's trace shows the EPP spans (filter_endpoints, scoring, pick_endpoints, tokenize) beside the engine's llm_request.
7. Track cost per model¶
Install llm-d's inference cost recipe (guides/recipes/observability/inferencecost): OpenCost on port 9003 publishes llm_total_hourly_cost, llm_cost_per_million_tokens and llm_cache_savings_fraction.
# Q35 Hourly infrastructure cost per model, chargeback basis
sum by(model_name) (llm_total_hourly_cost{cost_basis="allocation"})
# Q36 Cost per million generated tokens
llm_cost_per_million_tokens{phase="generation",cost_basis="allocation"}
Check allocation_method: compute_time splits prefill and decode by vLLM's timings; multiplier is a fixed 2.5x estimate used when timings are missing.
Check: Q35 returns one series per served model, and llm_cache_savings_fraction is non-zero when the prefix hit rate (Q24) is.
Troubleshooting¶
| Symptom | Cause | Fix |
|---|---|---|
| Router panels empty on GKE | Auto-monitoring does not scrape the EPP | Router values monitoring-gke.values.yaml |
| Dashboard flat after a router upgrade | llm-d 0.10 / llm-d-router 0.11.0 removed old EPP metric names | Use the current names (Q01 onward) |
| TPU scrape health 0 | Exporter unreachable, wrong port | Target error, exporter pod, port 2112 |
| TPU scrape health 1, hardware panels empty | Filters, or runtime omits metrics | Reset model and topology filters to All; compare with /metrics |
histogram_quantile returns nothing |
le dropped in the aggregation |
sum by(le) before the quantile |
| Error-ratio alert never fires | Error series appear only after the first error | Expected; the ratio is 0/0-safe |
| A pool vanished and nothing paged | absent() fires only when every series is gone |
Q10 |
| No traces at low traffic | 5% sampling | samplerArg="1.0" while verifying |
| Cost per token looks fixed | allocation_method="multiplier" |
Enable vLLM timing metrics |
References¶
- llm-d: Observability
- llm-d: Set Up the Monitoring Stack
- llm-d: Collect Metrics
- llm-d: Model Server Metrics
- llm-d: Router Metrics
- llm-d: Monitor GKE TPUs
- llm-d: PromQL Query Reference
- llm-d: Use Grafana Dashboards
- llm-d: Configure Alerts
- llm-d: Trace Requests
- llm-d: Track Inference Cost
- Companion code: code/ch21_operating/
- Chapter 21: Operating llm-d: autoscaling, rollouts, observability