billowy-psychiatrist-32507
09/17/2025, 5:47 AMtall-airline-16756
09/17/2025, 5:48 AMtall-airline-16756
09/17/2025, 5:48 AMprometheus_port field to your LiveKit configuration file (config.yaml). For example:
`prometheus_port: 6789`This will make metrics available at <LIVEKIT_SERVER_URL>/metrics. It’s a simple but important step!
2. Configure Prometheus:
Next, update your Prometheus configuration file (prometheus.yml) to start scraping metrics from LiveKit:
`scrape_configs:
- job_name: 'livekit'
scrape_interval: 10s
static_configs:
- targets: ['<LIVEKIT_SERVER_URL>']`Just remember to replace <LIVEKIT_SERVER_URL> with your actual server’s hostname or IP address.
3. Import Grafana Dashboard:
LiveKit offers a handy pre-built Grafana dashboard. You can download the JSON file from the LiveKit GitHub repository (deploy/grafana/livekit-server-overview.json) and then import it into Grafana by going to Dashboards > Import. Don’t forget to set the data source to your Prometheus instance to see your metrics beautifully visualized.
4. (Optional) Kubernetes Deployment:
If you’re running LiveKit on Kubernetes, the Helm chart has built-in support for Prometheus scraping through ServiceMonitor. You can enable it by adding these settings to your Helm values:
livekit:
prometheus_port: 6789
serviceMonitor:
create: true
interval: 10s
Once you’ve completed these steps, you’ll be able to monitor key metrics like room and participant counts, message rates, and network performance—all in real-time. If you have any questions along the way, feel free to reach out. I’m here to help!
Sources: config-sample.yaml | Deploying LiveKit | LiveKit Docs | tools/server/bench/prometheus.yml | livekit-server/templates/servicemonitor.yaml | pkg/stats/monitor_prom.gobillowy-psychiatrist-32507
09/17/2025, 5:57 AMjob=<job_name> to any timeseries scraped from this config.
- job_name: "prometheus"
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
static_configs:
- targets: ["localhost:9090"]
# The label name is added as a label label_name=<label_value> to any timeseries scraped from this config.
labels:
app: "prometheus"tall-airline-16756
09/17/2025, 5:57 AMtargets: ["localhost:6789"]) in your prometheus.yml? If not, no worries! You can easily add it under scrape_configs like this:
scrape_configs:
- job_name: 'livekit'
scrape_interval: 10s
static_configs:
- targets: ['localhost:6789']
If you’d like, I’m here to help you through the process or answer any questions you might have!billowy-psychiatrist-32507
09/17/2025, 6:04 AM# HELP python_gc_objects_collected_total Objects collected during gc
# TYPE python_gc_objects_collected_total counter
python_gc_objects_collected_total{generation="0"} 5379.0
python_gc_objects_collected_total{generation="1"} 991.0
python_gc_objects_collected_total{generation="2"} 169.0
# HELP python_gc_objects_uncollectable_total Uncollectable objects found during GC
# TYPE python_gc_objects_uncollectable_total counter
python_gc_objects_uncollectable_total{generation="0"} 0.0
python_gc_objects_uncollectable_total{generation="1"} 0.0
python_gc_objects_uncollectable_total{generation="2"} 0.0
# HELP python_gc_collections_total Number of times this generation was collected
# TYPE python_gc_collections_total counter
python_gc_collections_total{generation="0"} 403.0
python_gc_collections_total{generation="1"} 36.0
python_gc_collections_total{generation="2"} 3.0
# HELP python_info Python platform information
# TYPE python_info gauge
python_info{implementation="CPython",major="3",minor="12",patchlevel="2",version="3.12.2"} 1.0
# HELP lk_agents_proc_initialize_duration_seconds Time taken to initialize a process
# TYPE lk_agents_proc_initialize_duration_seconds histogram
# HELP lk_agents_active_job_count Active jobs
# TYPE lk_agents_active_job_count gauge
# HELP lk_agents_child_process_count Total number of child processes
# TYPE lk_agents_child_process_count gauge
lk_agents_child_process_count{nodename="IN-B3M7YX3"} 0.0
i get abov eresponsetall-airline-16756
09/17/2025, 6:04 AM<LIVEKIT_METRICS_URL>. To help Prometheus start scraping these metrics, please make sure you've added the following scrape job to your `prometheus.yml`:
scrape_configs:
- job_name: 'livekit'
scrape_interval: 10s
static_configs:
- targets: ['localhost:6789']
Once you've updated the configuration, just restart Prometheus to put those changes into effect. You can then double-check if the metrics are being scraped by looking at the "Targets" section in the Prometheus UI.
If you run into any hiccups or have more questions, please don't hesitate to reach out—I'm here to help!billowy-psychiatrist-32507
09/17/2025, 6:07 AMtall-airline-16756
09/17/2025, 6:07 AMmetrics_collected event in your LiveKit agent to gather metrics for LLM, STT, and TTS. Here’s a simple example:
@session.on("metrics_collected")
def _on_metrics_collected(ev):
handle_metrics(ev.metrics)
2. Expose Metrics:
Next, use the prometheus_client library to expose these metrics through an HTTP endpoint. You can define metrics like LLM token generation rate, STT audio duration, and TTS time-to-first-byte.
3. Prometheus Configuration:
Then, add your custom metrics endpoint (for example, `http://localhost:8000/metrics`) to your Prometheus configuration under scrape_configs.
4. Visualize in Grafana:
Finally, add Prometheus as a data source in Grafana and create dashboards to visualize important metrics like LLM token throughput, STT audio duration, and TTS latency.
If you’d like, I’m here to help with detailed code examples or walk you through setting up the metrics exporter. Just let me know!
Sources: Logs, metrics, and telemetry | LiveKit Docs | metrics/send-metrics-to-3p/send_metrics_to_3p.py | Capturing metrics | LiveKit Docs | livekit-agents/livekit/agents/metrics/utils.pybillowy-psychiatrist-32507
09/17/2025, 6:09 AMtall-airline-16756
09/17/2025, 6:09 AMprometheus_client library. Here’s a simple example to get you going:
from prometheus_client import start_http_server, Gauge, Counter
# Define Prometheus metrics
LLM_TTFT = Gauge('livekit_llm_ttft_seconds', 'Time to First Token for LLM')
LLM_TOKENS_PER_SECOND = Gauge('livekit_llm_tokens_per_second', 'LLM token generation rate')
STT_AUDIO_DURATION = Gauge('livekit_stt_audio_duration_seconds', 'STT input audio duration')
TTS_TTFB = Gauge('livekit_tts_ttfb_seconds', 'Time to First Byte for TTS')
# Start Prometheus metrics server
start_http_server(8000)
print("Prometheus metrics server started at <http://localhost:8000/metrics%22|http://localhost:8000/metrics">)
2. Capture Metrics in LiveKit:
Next, you’ll want to subscribe to the metrics_collected event in your LiveKit agent to grab those metrics. Here’s how you might do it:
@session.on("metrics_collected")
def _on_metrics_collected(ev):
LLM_TTFT.set(ev.metrics.llm_ttft)
LLM_TOKENS_PER_SECOND.set(ev.metrics.llm_tokens_per_second)
STT_AUDIO_DURATION.set(ev.metrics.stt_audio_duration)
TTS_TTFB.set(ev.metrics.tts_ttfb)
3. Configure Prometheus:
To make sure Prometheus picks up your metrics, add the endpoint to your prometheus.yml configuration like this:
`scrape_configs:
- job_name: 'livekit'
scrape_interval: 10s
static_configs:
- targets: ['localhost:8000']`Then, just restart Prometheus so these changes take effect.
4. Visualize in Grafana:
Finally, add Prometheus as a data source in Grafana. From there, you can create dashboards to easily visualize metrics such as LLM token throughput, STT audio duration, and TTS latency.
If you have any questions or need a hand with any of these steps, please don’t hesitate to ask. I’m here to help!