Lab: Visualizing Token and Request Data
Estimated reading time: 30 minutes.
- Objective
-
Access Grafana to build queries tracking rate limit hits, token counts, request success, and latency-focused metrics like Time To First Token (TTFT) and Time Per Output Token (TPOT). Create custom dashboards for monitoring MaaS performance and consumption patterns.
| Not started yet. |
Before you begin
Ensure you have:
-
Access to OpenShift monitoring (Prometheus + Grafana)
-
User Workload Monitoring enabled
-
MaaS models deployed with metrics instrumentation
-
Grafana dashboard creation permissions
Instructions
Step 1: Enable User Workload Monitoring
-
Enable user workload monitoring in OpenShift:
apiVersion: v1 kind: ConfigMap metadata: name: cluster-monitoring-config namespace: openshift-monitoring data: config.yaml: | enableUserWorkload: true -
Verify Prometheus is running:
$ oc get pods -n openshift-user-workload-monitoring NAME READY STATUS RESTARTS AGE prometheus-user-workload-0 5/5 Running 0 5m prometheus-user-workload-1 5/5 Running 0 5m thanos-ruler-user-workload-0 3/3 Running 0 5m thanos-ruler-user-workload-1 3/3 Running 0 5m
Step 2: Create ServiceMonitor for MaaS Metrics
Create a ServiceMonitor to scrape metrics from your model endpoints:
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: maas-models-metrics
namespace: maas-models
labels:
app: maas-models
spec:
selector:
matchLabels:
serving.kserve.io/inferenceservice: nemotron-3-nano
endpoints:
- port: metrics
interval: 30s
path: /metrics
scheme: http
Apply the ServiceMonitor:
$ oc apply -f servicemonitor.yaml
Step 3: Access Grafana
-
Get the Grafana route:
$ oc get route grafana -n openshift-monitoring -
Log in using your OpenShift credentials
Step 4: Create MaaS Performance Dashboard
Create a new dashboard with the following panels:
Panel 1: Total Requests per Service Tier
Query:
sum by (service_tier) (
rate(maas_tier_requests_total[5m])
) * 60
Visualization: Time series graph
Unit: requests/minute
Legend: {{service_tier}}
Panel 2: Total Tokens Generated per Tier
Query:
sum by (service_tier) (
rate(maas_tier_tokens_total[5m])
) * 60
Visualization: Time series graph
Unit: tokens/minute
Legend: {{service_tier}}
Panel 3: Time To First Token (TTFT) P50, P95, P99
Query for P50:
histogram_quantile(0.50,
sum by (le, model_name) (
rate(vllm_llmd_time_to_first_token_seconds_bucket[5m])
)
)
Query for P95:
histogram_quantile(0.95,
sum by (le, model_name) (
rate(vllm_llmd_time_to_first_token_seconds_bucket[5m])
)
)
Query for P99:
histogram_quantile(0.99,
sum by (le, model_name) (
rate(vllm_llmd_time_to_first_token_seconds_bucket[5m])
)
)
Visualization: Time series graph Unit: seconds Legend: P50, P95, P99
Panel 4: Time Per Output Token (TPOT)
Query:
histogram_quantile(0.95,
sum by (le, model_name) (
rate(vllm_llmd_time_per_output_token_seconds_bucket[5m])
)
)
Visualization: Gauge Unit: milliseconds Thresholds: - Green: < 20ms - Yellow: 20-50ms - Red: > 50ms
Panel 5: KV Cache Hit Rate
Query:
avg by (model_name) (
vllm_llmd_kv_cache_hit_rate
) * 100
Visualization: Gauge Unit: percent Target: 90%
Panel 6: GPU Utilization per Node
Query:
avg by (node) (
DCGM_FI_DEV_GPU_UTIL
)
Visualization: Heat map or time series Unit: percent
Panel 7: Rate Limit Hits by Tier
Query:
sum by (service_tier) (
rate(limitador_rate_limit_hits_total[5m])
) * 60
Visualization: Time series graph or bar gauge Unit: hits/minute
Step 5: Create Chargeback Dashboard
Create a second dashboard for cost tracking:
Panel 1: GPU Hours per Team
Query:
sum by (team) (
rate(vllm_llmd_gpu_utilization_seconds[1h])
)
Visualization: Table Calculation: Multiply by hourly GPU cost
Panel 2: Token Cost per Team
Query:
sum by (team) (
rate(maas_tier_tokens_total[1h]) * 3600
) / 1000000
Visualization: Table with transformation Calculation: Multiply by cost per 1M tokens
Panel 3: Daily Cost Projection
Query:
(
sum by (team) (rate(vllm_llmd_gpu_utilization_seconds[24h])) * 2 * 24
+
sum by (team) (rate(maas_tier_tokens_total[24h])) * 86400 / 1000000 * 0.50
)
Visualization: Bar chart Unit: USD per day
Panel 4: Cost Trend Over Time
Query:
sum(
rate(vllm_llmd_gpu_utilization_seconds[1h]) * 2 +
rate(maas_tier_tokens_total[1h]) * 3600 / 1000000 * 0.50
)
Visualization: Time series Unit: USD per hour
Step 6: Set Up Alerts
Create PrometheusRules for important thresholds:
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
name: maas-alerts
namespace: maas-models
spec:
groups:
- name: maas
interval: 30s
rules:
- alert: HighTTFT
expr: |
histogram_quantile(0.95,
sum by (le, model_name) (
rate(vllm_llmd_time_to_first_token_seconds_bucket[5m])
)
) > 2
for: 5m
labels:
severity: warning
annotations:
summary: "High TTFT detected for {{ $labels.model_name }}"
description: "95th percentile TTFT is {{ $value }}s (threshold: 2s)"
- alert: LowCacheHitRate
expr: |
avg by (model_name) (vllm_llmd_kv_cache_hit_rate) < 0.7
for: 10m
labels:
severity: info
annotations:
summary: "Low cache hit rate for {{ $labels.model_name }}"
description: "Cache hit rate is {{ $value | humanizePercentage }} (target: 90%)"
- alert: GPUOverutilization
expr: |
avg by (node) (DCGM_FI_DEV_GPU_UTIL) > 95
for: 15m
labels:
severity: warning
annotations:
summary: "GPU overutilization on {{ $labels.node }}"
description: "GPU utilization is {{ $value }}% for 15+ minutes"
- alert: ExcessiveRateLimiting
expr: |
sum by (service_tier) (
rate(limitador_rate_limit_hits_total[5m])
) > 10
for: 5m
labels:
severity: info
annotations:
summary: "Excessive rate limiting on {{ $labels.service_tier }} tier"
description: "{{ $value }} rate limit hits/sec - consider tier upgrade"
Apply the alerts:
$ oc apply -f prometheusrule.yaml
Step 7: Export and Share Dashboards
-
Export the dashboard as JSON from Grafana
-
Store in Git repository for version control:
monitoring/ ├── dashboards/ │ ├── maas-performance.json │ └── maas-chargeback.json └── alerts/ └── maas-alerts.yaml -
Use Grafana provisioning to automatically deploy dashboards:
apiVersion: v1 kind: ConfigMap metadata: name: grafana-dashboards namespace: openshift-monitoring data: maas-performance.json: | { "dashboard": { ... } }
You have successfully created comprehensive monitoring dashboards for MaaS!
Key Metrics Summary
| Metric Category | Key Indicators | Target Values | |----------------|----------------|---------------| | Performance | TTFT P95, TPOT | TTFT < 2s, TPOT < 30ms | | Efficiency | GPU Utilization, Cache Hit Rate | 70-85%, >90% | | Consumption | Tokens/min, Requests/min | Track trends | | Governance | Rate Limit Hits | Minimize by tier sizing | | Cost | GPU hours, Token cost | Budget alignment |