Player metrics
The player exposes real-time metrics viagetMetrics():
Reporting metrics
Send metrics to your analytics backend on playback end or periodically:What to alert on
Key server metrics
Health check
GET /health returns 200 OK when the server is running. Use this for:
- Docker health checks:
HEALTHCHECK CMD curl -f http://localhost:4100/health - Load balancer probes
- Uptime monitoring (Pingdom, Better Uptime, etc.)
Request logging
The key server logs each request to stdout in JSON format. Pipe to your log aggregator (Datadog, CloudWatch, etc.) and monitor:Prometheus metrics (optional)
If you run a reverse proxy (nginx, Caddy) in front of the key server, use its built-in Prometheus exporter to track request rates, latency histograms, and error codes.Database monitoring
Postgres
If using Postgres for lease storage:SQLite
If using SQLite (single-instance deployments):Infrastructure
CDN cache hit ratio
Target: >95% cache hit ratio for segment requests. Low hit ratios mean the CDN is fetching from origin on most requests, adding latency and cost.Dashboard template
Build a monitoring dashboard with these panels:- Player experience — Time to first frame (p50, p95, p99), stall rate
- Key server — Request rate, latency (p50, p95), error rate (4xx, 5xx)
- Leases — Active lease count, creation rate, revocation rate
- Infrastructure — Container CPU/memory, DB connections, CDN cache hit ratio
Debugging playback issues
When a viewer reports playback problems:- Check key server logs — Was the key request successful? Look for 401 (auth), 403 (lease revoked/expired), 500 (server error).
- Check player metrics — If
avgKeyFetchTimeis high, the issue is key server latency. IfstallCountis high, the issue is CDN or bandwidth. - Check CDN logs — Are segments being served? Look for 403 (CORS) or 404 (missing segments).
- Check lease state — If using leases, query the database:
SELECT * FROM leases WHERE viewer_id = 'user-123' ORDER BY created_at DESC LIMIT 5;