Skip to content

About

GPU observability: DCGM to Prometheus to Grafana with cost dashboard

Resources

Stars

2 stars

Watchers

0 watching

Forks

Latest commit

 

History

7 Commits

Folders and files

Repository files navigation

Project 4 — GPU Observability (DCGM → Prometheus → Grafana, with a cost panel)

GPU-level metrics and a cost-per-million-tokens panel over a two-model vLLM stack.

Standalone: this project owns its VPC, EKS cluster, GPU nodes and GPU Operator via its own Terraform (terraform/) in its own HCP Terraform workspace (gpu-inference-observability). It shares nothing with projects 1 or 2. values-observability.yaml is a complete values file — the two models, the router, and the monitoring stack — so it installs from scratch here rather than upgrading someone else's release.

The interesting thing about this project is that the DCGM exporter is essentially free: the GPU Operator ships it as a DaemonSet the moment you install the Operator, whether or not you asked. On most clusters it's running and nothing is scraping it. This project connects those wires and puts a number on what the GPUs cost per token served.

Done when: there's one Grafana dashboard I can screenshot and narrate panel by panel: GPU utilization, GPU memory, TTFT p99, KV cache usage, tokens/sec, and cost per million tokens.

Hardware

2× g6.xlarge (L4, 24 GB, ~$0.805/hr each), observed through their DCGM exporter pods. Keep it at two — the cost panel hardcodes 2 * 0.805, so changing the node count without editing the dashboard makes it report the wrong cost per token.

Prometheus and Grafana run on the m7i.large system node, whose root disk is provisioned at 50 GB rather than the 20 GB default — a 5.3 GB router image plus the monitoring images filled 20 GB and triggered an ephemeral-storage eviction. Worth remembering: monitoring stacks are small at runtime, but the images around them are not. If monitoring pods land Pending on insufficient CPU/memory, raise the system group's desired_size to 2 (its max_size is already 2) instead of resizing the instance type.

Deploy

Prereqs: aws CLI configured, and an HCP Terraform workspace named gpu-inference-observability in the Shikha_Projects org with Execution Mode = Local. Create that workspace before the first apply.

# 0. Infrastructure: VPC, EKS, 1x system node (50GB disk), 2x GPU node, NVIDIA GPU Operator
#    — which is also what brings the DCGM exporter into the cluster. ~15-20 min.
cd terraform
terraform init
terraform apply
terraform output -raw configure_kubectl | bash
cd ..

# 1. Install the full stack: 2 models + router + Prometheus + Grafana + ServiceMonitors
#    + the DCGM scrape job. values-observability.yaml is self-contained.
#    --repo resolves the chart directly — no `helm repo add`, no local cache to drift.
helm install vllm vllm-stack \
  --repo https://vllm-project.github.io/production-stack -f values-observability.yaml

# 2. Wait for the monitoring pods to come up on the system node
kubectl get pods -w

# 2b. Confirm Prometheus actually found both DCGM pods and the engines.
#     Every target should be UP — an empty dcgm-exporter target list is the single
#     most common reason the GPU panels stay blank.
kubectl get svc -l app.kubernetes.io/name=prometheus       # find the service name
kubectl port-forward svc/<name-from-above> 9090:9090
#     then open http://localhost:9090/targets

# 3. Tunnel to Grafana
kubectl port-forward svc/vllm-grafana 3000:80
#    Login: admin / vllm-demo   (set in values, demo only)

# 4. Import the dashboard: Grafana UI -> Dashboards -> New -> Import -> upload
#    dashboard-gpu-cost.json, and pick the bundled Prometheus as the data source.

# 5. Generate load so the panels move (the script handles the router port-forward itself)
bash scripts/generate-load.sh                                  # 30 sequential requests
REQUESTS=40 CONCURRENT=true MAX_TOKENS=512 bash scripts/generate-load.sh
#    ^ the heavier run: concurrent long generations. KV cache visibly fills and
#      cost per million tokens drops the hardest.

Why values-observability.yaml repeats project 2's whole config. helm upgrade -f replaces the values set, it doesn't merge with what the release already had. So a values file containing only the monitoring additions would drop both modelSpec entries and the router on the next upgrade. Carrying the full config is what makes the same file work as a fresh helm install here and as a helm upgrade on an existing release. That "-f replaces, not merges" behaviour is a good interview answer and a very common production outage.

The cost panel

This is the panel that makes the dashboard worth building.

cost per 1M tokens = (GPU $/hr) / (tokens/sec × 3600 / 1,000,000)

As PromQL:

(2 * 0.805) / clamp_min((sum(rate(vllm:generation_tokens_total[5m])) * 3600) / 1e6, 0.001)

The story it tells: an idle GPU is pure cost. As the token rate goes to zero the cost per token goes to infinity, which is exactly right, because you're paying $1.61/hr to produce nothing. Batch more requests onto the same card and the cost per token falls. One panel ties GPU economics to serving efficiency, and it's the number an inference platform is actually judged on.

The clamp_min is there to stop a divide-by-zero from blanking the panel when traffic stops.

Where each panel gets its data

Panel Metric Exporter
GPU util / memory DCGM_FI_DEV_GPU_UTIL, DCGM_FI_DEV_FB_USED DCGM exporter, gpu-operator namespace
TTFT p99 vllm:time_to_first_token_seconds_bucket vLLM engines, /metrics
KV cache % vllm:kv_cache_usage_perc vLLM engines
Cost and throughput vllm:generation_tokens_total vLLM engines

Two different sources, and that split matters. DCGM tells you what the hardware is doing. vLLM tells you what the engine is doing. High GPU utilization with low tokens/sec means the card is busy being inefficient, and you only see that by having both.

Results

vLLM's own metrics, via the dashboard bundled with the production-stack chart:

vLLM dashboard — overview

vLLM dashboard — serving engine load

The custom dashboard: GPU utilization, KV cache, TTFT p99 and cost per million tokens on one screen.

Custom GPU-serving cost & health dashboard

Teardown

# Between sessions — park the GPUs, keep the cluster and its dashboards.
cd terraform && terraform output -raw scale_gpus_to_zero | bash

# Bring them back later
aws eks update-nodegroup-config --cluster-name gpu-inference-observability --nodegroup-name gpu \
  --scaling-config minSize=0,maxSize=2,desiredSize=2 --region us-east-1

# Done for good — removes the cluster, node groups, VPC and NAT gateway.
helm uninstall vllm
cd terraform && terraform destroy

Uninstall the Helm release before terraform destroy, and note the caveat that's specific to a monitoring stack: helm uninstall deliberately leaves the kube-prometheus-stack CRDs behind (Helm never deletes CRDs it installed via the crds/ directory). They're harmless once the cluster is destroyed, but they will collide if you reinstall onto a cluster that still has them — kubectl delete crd -l app.kubernetes.io/name=kube-prometheus-stack clears them.

With both GPUs up this runs $1.85/hr. Parked, the EKS control plane ($0.10/hr) and NAT gateway (~$0.045/hr) still cost ~$3.50/day, so destroy rather than park if the next session is more than a couple of days out.

About

GPU observability: DCGM to Prometheus to Grafana with cost dashboard

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages