Skip to content

Viewers and analytics

Nyquist counts everyone watching over HLS, LL-HLS, DASH and MPEG-TS. Every player gets a playback session, and the panel, the API and /metrics all show the same numbers.

MPEG-TS is the easy one, a connection is a session and it ends when the connection closes.

HLS and DASH players send a new request for every playlist and segment, so Nyquist puts a session id in the links it writes for each player: variant playlists, segments, parts, preload hints, init sections, DASH templates and a <Location> in the MPD, so DASH players refresh with it too. Every request that comes back with the id counts for that player, which means two people behind the same address still count as two. The links you share stay exactly the same, index.m3u8, index.ll.m3u8, index.mpd and mpegts work like always.

Some players reload the playlist from the address they started with. LL-HLS players always do, HLS has no way to send them somewhere else. Nyquist recognizes those by address and user agent, so each one stays one session for as long as it plays. The catch is that two identical players doing this from behind the same address count as one.

A session ends once a player stops asking for anything for a while, that’s idle_timeout in [viewers]. Session ids are random and signed, so nobody can make them up.

There’s a cap on how many sessions Nyquist tracks at once, max_sessions. Past that, new viewers still play just fine, they just don’t get counted. nyquist_untracked_sessions_total in the metrics tells you how many slipped by.

Got a cache or a CDN in front? Per player links mean every player fetches its own copy of each segment, so set tracking = "address":

[viewers]
tracking = "address"

Then links stay the same for everyone and players get recognized by address and user agent instead. Behind a CDN that’s the address of the CDN edge, so expect one session per edge rather than per viewer.

Bytes sent count for every protocol. The output bitrate gets measured every interval, and Nyquist keeps a sample of viewers, bitrates and live streams for the last span, for the whole server and for each stream. A stream’s history goes away with the stream, and all of it lives in memory, so it starts fresh after a restart.

Bitrates are in bits per second, byte counts are plain numbers and _ms fields are milliseconds.

Any logged-in user can read these:

Endpoint What you get
GET /api/v1/server usage with viewers, bitrate_in and bitrate_out for the whole server.
GET /api/v1/streams/NAME clients per protocol plus a total, and bytes_sent and bitrate_out in stats. The stream list has them too.
GET /api/v1/history Samples for the whole server, oldest first. Add ?since_ms= with a unix time in milliseconds to only get the newer ones.
GET /api/v1/history/NAME The same for one stream.
GET /api/v1/sessions Who’s watching right now, newest first, with the protocol, address, user agent, start time, last request and bytes sent. Add ?stream=NAME for one stream.
Terminal window
curl -u admin:YOUR_PASSWORD "http://192.0.2.10:8080/api/v1/sessions?stream=live/demo"

The sessions list stops at max_listed entries, and total still counts all of them.

Prometheus metrics live at /metrics and need a user too. Create a viewer on the Users page of the panel and add it to your scrape config:

scrape_configs:
- job_name: nyquist
basic_auth:
username: prometheus
password: YOUR_PASSWORD
static_configs:
- targets: ["192.0.2.10:8080"]

You’ll get live status, bytes and frames received, publish counts, viewers per protocol, bytes sent and the input and output bitrates for every stream, plus totals for the whole server. Metrics lists every one of them.