Skip to main content

Overview

The metrics setup enables autoscaling by collecting Lightning ASR metrics with Prometheus and exposing them to Kubernetes HPA through the Prometheus Adapter.

Architecture

/* The original had a syntax error in Mermaid—edges must connect nodes, not labels. “Metrics” is now a node, and edge directions/names are consistent. */

Components

Prometheus

Collects and stores metrics from Lightning ASR pods. Included in chart:
values.yaml

ServiceMonitor

CRD that tells Prometheus which services to scrape. Enabled for Lightning ASR:
values.yaml

Prometheus Adapter

Converts Prometheus metrics to Kubernetes custom metrics API. Configuration:
values.yaml

Available Metrics

Lightning ASR exposes the following metrics:
MetricTypeDescription
asr_active_requestsGaugeCurrent number of active transcription requests
asr_total_requestsCounterTotal requests processed
asr_failed_requestsCounterTotal failed requests
asr_request_duration_secondsHistogramRequest processing time
asr_model_load_time_secondsGaugeTime to load model on startup
asr_gpu_utilizationGaugeGPU utilization percentage
asr_gpu_memory_used_bytesGaugeGPU memory used

Verify Metrics Setup

Check Prometheus

Forward Prometheus port:
Open http://localhost:9090 and verify:
  1. Status → Targets: Lightning ASR endpoints should be “UP”
  2. Graph: Query asr_active_requests - should return data
  3. Status → Service Discovery: Should show ServiceMonitor

Check ServiceMonitor

Expected output:
Describe ServiceMonitor:
Should show:

Check Prometheus Adapter

Verify custom metrics are available:
Expected output:
Query specific metric:

Custom Metric Configuration

Add New Custom Metrics

To expose additional metrics to HPA:
values.yaml

External Metrics

For cluster-wide metrics:
values.yaml
Use in HPA:

Prometheus Configuration

Retention Policy

Configure how long metrics are stored:
values.yaml

Storage

Persist Prometheus data:
values.yaml

Scrape Interval

Adjust how frequently metrics are collected:
values.yaml
Lower intervals (e.g., 15s) provide faster HPA response but increase storage.

Recording Rules

Pre-compute expensive queries:
Use recording rules in HPA for better performance.

Alerting Rules

Create alerts for anomalies:

Debugging Metrics

Check Metrics Endpoint

Directly query Lightning ASR metrics:
Expected output:

Test Prometheus Query

Access Prometheus UI and test queries:

Check Prometheus Targets

Navigate to: http://localhost:9090/targets Verify Lightning ASR targets are “UP”

View Prometheus Logs

Look for scrape errors.

Troubleshooting

Metrics Not Appearing

Check ServiceMonitor is created:
Check Prometheus is discovering:
Check service has metrics port:
Should show:

Custom Metrics Not Available

Check Prometheus Adapter logs:
Verify adapter configuration:
Test API manually:

High Cardinality Issues

If Prometheus is using too much memory:
  1. Reduce label cardinality
  2. Increase retention limits
  3. Use recording rules for complex queries

Best Practices

Pre-compute expensive queries:
Then use in HPA instead of raw query
Balance responsiveness vs storage:
  • Fast autoscaling: 15s
  • Normal: 30s
  • Cost-optimized: 60s
Always persist Prometheus data:
Track Prometheus performance:
  • Query duration
  • Scrape duration
  • Memory usage
  • TSDB size
Don’t rely on Prometheus UIUse Grafana dashboards for opsSee Grafana Dashboards

What’s Next?

HPA Configuration

Use metrics for autoscaling

Grafana Dashboards

Visualize metrics