with self hosted agents on LK cloud, is there a wa...
# ask-ai
a
with self hosted agents on LK cloud, is there a way to have a metric of avg agent sessions per worker?
✅ 1
t
Thanks for reaching out, Sebastián. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — I’m following up about getting an average “agent sessions per worker” metric for self‑hosted agents on LiveKit Cloud. I need a few quick clarifying details to give an exact solution or PromQL/Grafana query: 1. By “agent” do you mean a participant/client in a room, a SIP/worker process, or another custom agent process? 2. By “worker” do you mean LiveKit server instances (SFU/gateway), Kubernetes pods, or a separate custom worker service? 3. Are you running LiveKit Cloud with self‑hosted agents (your phrase), or fully self‑hosted LiveKit? How are workers deployed (K8s, VMs, autoscaling group)? 4. Do you already have Prometheus/Grafana (or another metrics system) scraping metrics from these workers? If so, share the metric names you see or a short sample of the /metrics output. 5. What time window and aggregation do you want (instant, 1h average, 24h), and do you want per‑worker series or a single aggregated value? Once you reply I’ll either: • Provide the exact PromQL/Grafana query to compute avg sessions per worker, or • Tell you which metric to enable/expose and how to compute it., with interactive elements
a
1. a worker process 2. pods 3. LiveKit Cloud with self‑hosted agents 4. no 5. 24h average
t
Thanks — this is helpful. I’ll walk you through how to get a 24‑hour average of agent sessions per worker (pods) for LiveKit Cloud with self‑hosted agents. Summary of what you need • Export per‑worker session metrics to Prometheus (one metric that increments on session start or reports current active sessions per worker). • Export worker presence so Prometheus can count pods (e.g.,
up{job="livekit-agent"}
or a
livekit_worker_info
metric with
worker_id
label). • Use PromQL to compute the 24h average sessions per worker. If you already have no metrics scraping (you answered “no”), next step is to enable metrics on the agent pods: • Ensure the agent process exposes Prometheus metrics (HTTP /metrics). • Add a Prometheus scrape config for the agent pod endpoints (or use ServiceMonitor if using Prometheus Operator). Recommended metrics to expose (or create) • A counter
livekit_session_started_total{worker_id="<id>"}
that increments when a session starts (or) • A gauge
livekit_worker_active_sessions{worker_id="<id>"}
reporting current active sessions per worker. Example PromQL (24‑hour avg) 1. If you have a session start counter: ◦ Sessions started per worker over 24h: sum(increase(livekit_session_started_total[24h])) by (worker_id) • Average sessions per worker (24h): avg(sum(increase(livekit_session_started_total[24h])) by (worker_id)) 1. If you have an active‑sessions gauge and want time‑averaged active sessions: ◦ Per worker 24h average: avg_over_time(livekit_worker_active_sessions[24h]) by (worker_id) • Overall average across workers: avg(avg_over_time(livekit_worker_active_sessions[24h]) ) If you need a ratio of total sessions to worker count (workers may come and go): • Total sessions started over 24h: sum(increase(livekit_session_started_total[24h])) • Worker count (instant or average over 24h): count(up{job="livekit-agent"}) # instant avg_over_time(count_over_time(up{job="livekit-agent"}[5m])[24h]) # approximate • 24h average sessions per worker: sum(increase(livekit_session_started_total[24h])) / count(up{job="livekit-agent"}) How I can help next • If you tell me which metric names your agent exposes (or paste a sample /metrics output), I’ll give the exact PromQL/Grafana panels. • I can provide a scrape_config snippet for Prometheus or a ServiceMonitor for Prometheus Operator if you’re on Kubernetes. Sources: Voice Agent Architecture: STT, LLM, and TTS Pipelines Explained | LiveKit, with interactive elements
a
what's the difference between session.start and room.connect in the LK agent?
t
Thanks — good question. Here’s the short difference I’m responding to: "what's the difference between
session.start
and
room.connect
in the LK agent?" •
room.connect
◦ Low‑level LiveKit SDK call that joins a participant to a LiveKit room (handles signaling/WebRTC, auth with a token, and media transport). ◦ Use it when you only need to establish the WebRTC connection for a client or participant. •
session.start
◦ High‑level Agents framework call that starts an agent session. It internally performs the room connection (via
room.connect
or equivalent) and also initializes the agent lifecycle: STT, LLM, TTS, VAD, I/O plumbing, and any agent orchestration logic. ◦ Use it when you want the full agent pipeline and session management rather than just a raw room join. If you want, tell me which SDK/class you’re using (AgentSession vs Session vs plain Room) and I’ll point to the exact code paths or events that fire for each. Sources: Agent session | LiveKit Documentation | How to Build a Background Observer for Voice AI Guardrails | LiveKit | Build agent experiences faster with Session APIs | LiveKit, with interactive elements