mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-10-23 07:02:48 +03:00
expose frigate_camera_events as a gauge
The metric reports the current count of events in the database, which drops when retention prunes old events. As a counter, each prune read as a counter reset, so increase() and rate() inflated event counts. The series name changes from frigate_camera_events_total to frigate_camera_events. The test's porch/inside assertion was missing its `in event.text` and always passed.
This commit is contained in:
@@ -69,7 +69,7 @@ These gauges report the operating system's figures for the whole filesystem (the
|
||||
|
||||
### Event Metrics
|
||||
|
||||
- `frigate_camera_events{camera="", label=""}` - Count of camera events since exporter started
|
||||
- `frigate_camera_events{camera="", label=""}` - Current number of events stored in the database for each camera and label
|
||||
|
||||
## Configuring Prometheus
|
||||
|
||||
@@ -101,8 +101,8 @@ rate(frigate_detection_fps{camera_name="front_door"}[5m])
|
||||
# Storage usage percentage
|
||||
(frigate_storage_used_bytes / frigate_storage_total_bytes) * 100
|
||||
|
||||
# Event count by camera in last hour
|
||||
increase(frigate_camera_events[1h])
|
||||
# Number of events currently stored in the database by camera
|
||||
sum by (camera) (frigate_camera_events)
|
||||
```
|
||||
|
||||
## Grafana Dashboard
|
||||
@@ -121,8 +121,7 @@ A sample Grafana dashboard JSON will be provided in a future update.
|
||||
|
||||
The metrics exposed by Frigate use the following Prometheus metric types:
|
||||
|
||||
- **Counter**: Cumulative values that only increase (e.g., `frigate_camera_events`)
|
||||
- **Gauge**: Values that can go up and down (e.g., `frigate_cpu_usage_percent`)
|
||||
- **Gauge**: Values that can go up and down (e.g., `frigate_cpu_usage_percent`, `frigate_camera_events`)
|
||||
- **Info**: Key-value pairs for metadata (e.g., `frigate_storage_mount_type`)
|
||||
|
||||
For more information about Prometheus metric types, see the [Prometheus documentation](https://prometheus.io/docs/concepts/metric_types/).
|
||||
|
||||
@@ -5,7 +5,6 @@ from typing import Any
|
||||
from prometheus_client import CONTENT_TYPE_LATEST, generate_latest
|
||||
from prometheus_client.core import (
|
||||
REGISTRY,
|
||||
CounterMetricFamily,
|
||||
GaugeMetricFamily,
|
||||
InfoMetricFamily,
|
||||
)
|
||||
@@ -472,9 +471,9 @@ class CustomCollector:
|
||||
yield storage_total
|
||||
yield storage_used
|
||||
|
||||
camera_events = CounterMetricFamily(
|
||||
camera_events = GaugeMetricFamily(
|
||||
"frigate_camera_events",
|
||||
"Count of camera events since exporter started",
|
||||
"Current number of events stored in the database per camera and label",
|
||||
labels=["camera", "label"],
|
||||
)
|
||||
|
||||
|
||||
@@ -563,23 +563,20 @@ class TestHttpApp(BaseTestHttp):
|
||||
assert "# TYPE frigate_detection_total_fps gauge" in event.text
|
||||
assert "frigate_detection_total_fps 13.7" in event.text
|
||||
assert (
|
||||
"# HELP frigate_camera_events_total Count of camera events since exporter started"
|
||||
"# HELP frigate_camera_events Current number of events stored in the database per camera and label"
|
||||
in event.text
|
||||
)
|
||||
assert "# TYPE frigate_camera_events_total counter" in event.text
|
||||
assert "# TYPE frigate_camera_events gauge" in event.text
|
||||
assert (
|
||||
'frigate_camera_events_total{camera="front_door",label="Mock"} 3.0'
|
||||
'frigate_camera_events{camera="front_door",label="Mock"} 3.0' in event.text
|
||||
)
|
||||
assert (
|
||||
'frigate_camera_events{camera="front_door",label="inside"} 2.0'
|
||||
in event.text
|
||||
)
|
||||
assert (
|
||||
'frigate_camera_events_total{camera="front_door",label="inside"} 2.0'
|
||||
'frigate_camera_events{camera="front_door",label="outside"} 2.0'
|
||||
in event.text
|
||||
)
|
||||
assert (
|
||||
'frigate_camera_events_total{camera="front_door",label="outside"} 2.0'
|
||||
in event.text
|
||||
)
|
||||
assert (
|
||||
'frigate_camera_events_total{camera="porch",label="Mock"} 2.0' in event.text
|
||||
)
|
||||
assert 'frigate_camera_events_total{camera="porch",label="inside"} 2.0'
|
||||
assert 'frigate_camera_events{camera="porch",label="Mock"} 2.0' in event.text
|
||||
assert 'frigate_camera_events{camera="porch",label="inside"} 2.0' in event.text
|
||||
|
||||
Reference in New Issue
Block a user