Is it possible to get ingress usage for whip witho...
# ask-ai
f
Is it possible to get ingress usage for whip without transcoding from ingress prometheus metrics
t
Thanks for reaching out, Punit. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
You're asking if you can get WHIP ingress usage (only sessions without transcoding) from Ingress Prometheus metrics. Short answer: not as a single direct metric, but you can derive it. What you can do: • Configure
whip_bypass_transcoding_cpu_cost
(and
whip_cpu_cost
) so WHIP bypass sessions reserve a distinct, lower CPU cost. • Monitor
livekit_ingress_available
and use the configured CPU costs to infer how many bypass (non‑transcoding) WHIP sessions are consuming capacity. • Emit and capture Ingress lifecycle events (use the
ingress_started
/
ingress_ended
webhooks) or log/scrape Ingress start/stop info to record
enable_transcoding: false
for each session. • Correlate Prometheus-derived capacity changes with your webhook/log records externally to compute exact WHIP-without-transcoding usage. If you want, I can: • Outline the exact data points to record from webhooks and how to correlate them with
livekit_ingress_available
, or • Provide a short example workflow (webhook event fields + Prometheus query) to calculate usage. Which would help you more? Sources: Self-hosting the Ingress Service | LiveKit docs | Webhooks | LiveKit docs
f
does the LiveKit SFU server track bytes when the ingress stream flows through it
t
You’re asking whether the LiveKit SFU tracks bytes when an ingress stream flows through it. Yes — LiveKit meters data transfer for media that flows through the SFU. Key points: • Bandwidth (data transfer in GB) is metered for upstream and downstream traffic and is used for billing/analytics. • Track-level telemetry (bitrate, packets) is collected for published/subscribed tracks, which implies byte-level usage is measured. • There isn’t a documented single “ingress byte count” metric exposed by name, but the SFU’s telemetry and LiveKit Cloud billing capture the bandwidth caused by ingested streams as they’re distributed to participants. • To get precise per-ingress-session bytes you can: ◦ Use track-level analytics (bitrate) and aggregate over the session, or ◦ Capture webhook/log events for ingress start/stop and correlate with SFU telemetry to compute bytes per session. If you want, I can outline the exact telemetry endpoints/fields to read and a short Prometheus or aggregation query to compute per-ingress bytes — which would you prefer? Sources: The end of Participant Minute pricing | LiveKit Cloud billing | LiveKit docs | Announcing LiveKit Cloud
f
what about metrics form the SFU, can I get session level info on how much data went in and out
t
You're asking whether the SFU exposes session-level metrics for bytes in/out. Yes — LiveKit provides session-level bandwidth metrics. What you can use: • Analytics API (List sessions) — returns
bandwidthIn
and
bandwidthOut
(bytes) per session. This is available to LiveKit Cloud customers on the Scale plan or higher. • SFU telemetry / track-level stats — realtime track metrics (bitrate, packets) available from the SFU; you can aggregate these per session to compute bytes in/out for self-hosted setups. • Exporting telemetry — self-hosted servers can export the same telemetry data for custom processing and dashboards. If you want, I can: • Show the exact fields returned by the Analytics API and an example aggregation, or • Suggest how to aggregate track-level stats into session bytes for a self-hosted deployment. Which would you like? Sources: Announcing LiveKit Cloud | Analytics API | LiveKit docs
f
• Suggest how to aggregate track-level stats into session bytes for a self-hosted deployment.
t
Good — below is a concise, practical plan to turn SFU track-level stats into session-level bytes for a self-hosted LiveKit deployment, plus example Prometheus queries and a simple aggregation script approach. What to collect • Per-track metrics (published and subscribed): bitrate (bps) or bytes, packet counts, track id, participant id, room/session id, timestamp. • SFU telemetry endpoint or Prometheus exporter that exposes track metrics (bitrate or bytes) per track. • Ingress lifecycle events (optional) to mark session start/stop and map ingress streams to sessions. High-level approach 1. Map tracks to sessions: use track metadata (participant id, room id, session id) so each track belongs to one session. 2. Sample/collect periodic rate metrics (bitrate in bps) or cumulative byte counters. 3. Convert to bytes over time: ◦ If bitrate (bps): bytes during interval = (bitrate_bps / 8) * seconds. ◦ If cumulative bytes counter: bytes = counter_now - counter_prev (handle resets). 1. Sum across all tracks for a session: ◦ bandwidthIn (ingress) = sum of bytes from published tracks belonging to that session where source = ingress/publisher. ◦ bandwidthOut (egress) = sum of bytes sent to subscribers for tracks from that session. 1. Persist per-session aggregates (time-series DB, Prometheus remote write, or a simple DB) and handle session start/stop to report totals. Prometheus query examples • If exporter exposes
livekit_track_bitrate_bps{track_id,session_id,...}
sampled as an instant: ◦ Bytes over last minute per track: ▪︎ (livekit_track_bitrate_bps{session_id="S"} / 8) * 60 ◦ Session ingress bytes (last minute): ▪︎ sum((livekit_track_bitrate_bps{session_id="S",role="publisher"} / 8) * 60) • If exporter exposes cumulative bytes `livekit_track_bytes_total`: ◦ Bytes per minute per track: ▪︎ increase(livekit_track_bytes_total{session_id="S"}[1m]) ◦ Session ingress bytes per minute: ▪︎ sum(increase(livekit_track_bytes_total{session_id="S",role="publisher"}[1m])) Practical script example (pseudo-Python) • Poll Prometheus or scrape telemetry at fixed interval (e.g., 15s or 60s). • Keep last value per
track_id
to compute deltas. • Convert deltas to bytes if needed, then aggregate per
session_id
. Pseudo:
Copy code
# on each poll:
for sample in samples:   # sample includes track_id, session_id, metric_value, timestamp
  prev = last_seen.get(sample.track_id)
  if prev:
    delta = sample.value - prev.value
    if delta < 0: delta += counter_reset_correction
    bytes = delta  # if metric is bytes; if bitrate, bytes = (value/8) * interval_seconds
    session_sum[sample.session_id] += bytes
  last_seen[sample.track_id] = sample
Edge cases & tips • Handle counter resets and restarts. • Align sampling interval and bitrate-to-bytes math to avoid off-by-one. • Distinguish publisher vs subscriber direction when labeling metrics (role or direction label). • Include track lifecycle: drop tracks no longer published to avoid double-counting. • Use webhooks (ingress_started/ended) to finalize session totals and detect sessions that have no explicit end. • Choose aggregation window (1m common) for smoothness vs. real-time granularity. If you want, I can: • Provide exact Prometheus queries tailored to the metric names your exporter exposes, or • Convert the pseudo script into a runnable Python example that queries Prometheus and writes per-session totals to a CSV or DB. Which would you like?
f
can I see track level bytes in and out without custom implementation
t
You’re asking if you can view track-level bytes in/out without building custom aggregation. Short answer: yes, but details depend on Cloud vs self‑host. • LiveKit collects track-level telemetry (bitrate, packets, and cumulative byte counters) so you can get per-track ingress/egress metrics. • LiveKit Cloud exposes session and track bandwidth via the Analytics API (session fields `bandwidthIn`/`bandwidthOut`) for Scale+ customers. • For self‑hosted, the SFU telemetry / Prometheus exporter exposes per‑track metrics (bitrate or cumulative bytes). Using those built‑in metrics you can query per‑track bytes with Prometheus functions like: ◦ If you have cumulative bytes: use increase(livekit_track_bytes_total{track_id="..."}[1m]) ◦ If you have bitrate: convert (livekit_track_bitrate_bps{track_id="..."} / 8) * interval_seconds If you tell me whether you’re on LiveKit Cloud (and your plan) or self‑hosted, and the exact metric names you see (e.g.,
livekit_track_bytes_total
or
livekit_track_bitrate_bps
), I’ll give exact Prometheus queries or the Analytics API call you should use.
f
I am on self hosted. But I just see these 4 livekit_track info
t
Thanks — you’re on self‑hosted and your exporter shows only those four
livekit_track*
metrics. That explains why you don’t yet see per‑track bytes/bitrate out of the box. Here’s exactly what to do next to get track‑level bytes in/out without heavy custom code. What’s missing • Your current metrics list (
livekit_track_publish_counter
,
livekit_track_published_total
,
livekit_track_subscribe_counter
,
livekit_track_subscribed_total
) are counters for publish/subscribe events, not byte or bitrate telemetry. Options to get track bytes/bitrate • Enable the SFU telemetry exporter that exposes track bitrate or cumulative bytes. The SFU can emit track telemetry (bitrate, packets, cumulative bytes) when telemetry/export is enabled. • If using Prometheus, enable the exporter or build that exposes metrics like: ◦
livekit_track_bitrate_bps{track_id,...}
or ◦
livekit_track_bytes_total{track_id,...}
Prometheus queries once those metrics exist • From bitrate (bps) to bytes over 1 minute: ◦ (livekit_track_bitrate_bps{track_id="..."} / 8) * 60 • From cumulative bytes: ◦ increase(livekit_track_bytes_total{track_id="..."}[1m]) • Session totals (sum tracks by
session_id
or
room
label): ◦ sum(increase(livekit_track_bytes_total{session_id="S"}[1m])) by (session_id) ◦ sum((livekit_track_bitrate_bps{session_id="S"} / 8) * 60) by (session_id) Practical steps 1. Confirm SFU telemetry/exporter is enabled in your config and scraping endpoint is reachable by Prometheus. 2. Restart SFU if you change telemetry flags so the exporter exposes the new metrics. 3. Verify available metric names in Prometheus (use label values/filtering) and then run the sample queries above. 4. If your exporter exposes only bitrate, use the bitrate→bytes formula; if it exposes cumulative bytes, prefer
increase()
for correctness. If you want, tell me: • the SFU config you’re running (telemetry/export flags) or • the exact metric names you see after enabling telemetry I’ll give the exact config lines to add and the precise Prometheus queries tailored to those metric names.