Skip to content
Prometheus Metrics & Monitoring

Prometheus Metrics & Monitoring

TorrPlay exports real-time application metrics in standard Prometheus format, enabling seamlessly integrated observability with Prometheus, Grafana, and OpenTelemetry collector setups.

Endpoints

  • /metrics — Prometheus metrics scraping endpoint
  • /api/system/metrics — JSON activity summary containing active_torrents, download_speed, and upload_speed

The metric families below are exposed only by /metrics.

Exported Metrics

Application & Torrent Activity

Metric NameTypeLabelsDescription
torrplay_downloading_torrentsGauge—Torrents currently being downloaded in the background
torrplay_loaded_torrentsGaugereasonLoaded torrents by reason: background or on_demand
torrplay_streaming_torrentsGauge—Torrents with an open playback session, counted once per torrent

Streaming

Metric NameTypeLabelsDescription
torrplay_stream_read_duration_secondsHistogramstorageStream read latency, including waits for torrent data
torrplay_stream_requests_in_flightGauge—Streaming HTTP requests currently being served

HTTP Traffic & Latency

Metric NameTypeLabelsDescription
http_request_duration_secondsHistogramcode, method, pathRequest processing duration histogram
http_request_size_bytesSummarycode, method, pathSummary of request payload sizes in bytes
http_requests_totalCountercode, method, pathTotal count of processed HTTP requests
http_response_size_bytesSummarycode, method, pathSummary of response payload sizes in bytes

BitTorrent Client

Metric NameTypeLabelsDescription
torrplay_torrent_banned_peersGauge—Peer addresses banned for sending bad data
torrplay_torrent_data_bytes_totalCounterdirectionUseful piece bytes downloaded or uploaded
torrplay_torrent_peersGaugestateConnected peers, connecting peers, or pending addresses
torrplay_torrent_pieces_hashed_totalCounterresultPieces whose hash check was good or bad

Memory Storage

Metric NameTypeLabelsDescription
torrplay_storage_completion_misses_totalCounter—Pieces gone when the torrent client marked them complete
torrplay_storage_evicted_incomplete_bytes_totalCounter—Downloaded bytes lost when incomplete pieces were evicted
torrplay_storage_evicted_pieces_totalCounterstateComplete or incomplete pieces evicted from memory
torrplay_storage_memory_limit_bytesGauge—Configured memory-storage limit
torrplay_storage_memory_used_bytesGauge—Memory currently reserved for piece data
torrplay_storage_protected_evictions_totalCounterprotectionLast-resort evictions of boundary or active-range pieces
torrplay_storage_read_failures_totalCounterreasonReads that failed because piece data was evicted or incomplete
torrplay_storage_refused_hashes_totalCounter—Hash checks refused because eviction removed part of a piece

Go Runtime & System Collectors

TorrPlay also registers standard Go runtime collectors (go_*) and process stats collectors (process_*), providing insights into RAM allocation, heap size, garbage collection pauses, open file descriptors, and CPU usage.

Prometheus Scrape Configuration

When authentication is disabled, add the following target to your prometheus.yml:

scrape_configs:
  - job_name: "torrplay"
    scrape_interval: 15s
    static_configs:
      - targets: ["localhost:8090"]

When TorrPlay uses Basic authentication, add credentials to the scrape job:

scrape_configs:
  - job_name: "torrplay"
    scrape_interval: 15s
    basic_auth:
      username: "your-username"
      password_file: "/etc/prometheus/torrplay-password"
    static_configs:
      - targets: ["localhost:8090"]

When TorrPlay uses Bearer authentication, store an administrative access token in a file and reference it from the scrape job:

scrape_configs:
  - job_name: "torrplay"
    scrape_interval: 15s
    authorization:
      type: Bearer
      credentials_file: "/etc/prometheus/torrplay-token"
    static_configs:
      - targets: ["localhost:8090"]

Obtain the administrative token from /oauth/token. Playback tokens cannot access /metrics.

Access tokens expire after 24 hours, so the token file must be refreshed at least daily, for example by a scheduled job that requests a new token from /oauth/token. Prometheus rereads credentials_file on every scrape, so no reload is needed. For unattended scraping, Basic authentication is simpler because its credentials do not expire.

Example Query

Count torrents with an open playback session across all instances:

sum(torrplay_streaming_torrents)

Count streaming HTTP requests currently in flight:

sum(torrplay_stream_requests_in_flight)

Track 95th percentile HTTP request latency:

histogram_quantile(0.95, sum(rate(http_request_duration_seconds_bucket[5m])) by (le))
Last updated on