Skip to content

Jellyfin Module API Explanation

The Jellyfin module monitors active user playback sessions and media streaming devices.


API Execution Logic

The module locates the service definition matching the identifier jellyfin. The API key is loaded from the JELLYFIN_API_KEY environment variable and attached to requests using the X-Emby-Token header.

Request Execution

A GET request is sent to the /Sessions endpoint under the target URL. A 5-second timeout is enforced.

Data Parsing and Active Session Filtering

The module processes the sessions list to extract active telemetry:

  • Active Sessions: The module filters out idle sessions by verifying that the LastActivityDate timestamp occurred within the last 900 seconds (15 minutes).
  • Active Streams: From the active sessions, the module filters sessions actively streaming media by checking if NowPlayingItem is defined and PlayState.IsPaused is false (or undefined).
  • Active Devices: A unique Set of device names (DeviceName) is generated across all active sessions.

Metric Output

  • Primary Metric: The count of active streaming sessions (streams).
  • Secondary Metric: The count of active connected devices.

Caching Strategy

To maintain real-time accuracy while avoiding unnecessary load on the media server, session data is cached for 15 seconds (TTL) with a stale window of 60 seconds.