Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep statistics of total frame count as well as average frame rate for time series databases #13686

Open
dsnet opened this issue Sep 11, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@dsnet
Copy link

dsnet commented Sep 11, 2024

Hi, thank you for your hard work on Frigate.

The /api/stats API currently exposes fields like:

alley-left: {
    audio_dBFS: 0,
    audio_rms: 0,
    camera_fps: 5.1,
    capture_pid: 955,
    detection_enabled: true,
    detection_fps: 0,
    ffmpeg_pid: 961,
    pid: 812,
    process_fps: 5.1,
    skipped_fps: 0
},

In particular, fields like camera_fps (and related fields) report a metric that's a rate (some quantity per time). This is fundamentally hard to scrape since the consumer now needs to know the sampling rate at which this metric is updated. If the field is scraped too slowly, then the consumer may miss sudden dips or spikes in the rate.

Instead of (or in addition to) reporting a rate, I propose that we provide a monotonically increasing counter. So instead of camera_fps, it would be camera_frames, which is the total number of camera frames seen. If this data is being dumped into prometheus or influxdb, it's trivial to take the derivative to produce a more accurate rate (one that cannot miss dips and peaks).

@dsnet dsnet added the enhancement New feature or request label Sep 11, 2024
@NickM-27 NickM-27 changed the title api/stats: should record counts, not rates Keep statistics of total frame count as well as average frame rate for time series databases Sep 12, 2024
@jrcichra
Copy link

This would also be useful for alerting when a camera is offline. Right now I don't see a way from /api/stats to see if a camera stream isn't working. If the frame count was available and weren't increasing that would be one way to know.

@NickM-27
Copy link
Sponsor Collaborator

You can use camera_fps = 0 which is deliberately set if a camera goes offline. This is what the integration and webui already use

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants