export network bandwidth stats

main
Rhys Bailey 2024-03-11 21:57:46 +11:00
parent 33eaea1075
commit bc03c4d466
2 changed files with 36 additions and 1 deletions

View File

@ -9,9 +9,10 @@ Exports from Frigate API:
- Inference Speed
- CPU and MEM process stats
- Camera, detection and skipped FPS
- Camera audio stats
- Storage total, used and free
- Device Temperature (Coral temp)
- Event counter for each camera label
- Event counters for detected labels on each camera
[Docker Hub](https://hub.docker.com/r/rhysbailey/prometheus-frigate-exporter)
@ -39,6 +40,14 @@ The default internal exporter port can be modified with `-e "PORT=9100"`
Metrics are available at http://localhost:9100/metrics
If you want to export network bandwidth stats, include the section below in your Frigate config (see [here](https://docs.frigate.video/configuration/reference)):
```yml
telemetry:
stats:
network_bandwidth: True
```
### Setup Prometheus
If you don't already have Prometheus set up to scrape the `prometheus-frigate-exporter` metrics,

View File

@ -220,6 +220,32 @@ class CustomCollector(object):
yield storage_total
yield storage_used
# bandwidth stats
bandwidth_usages = GaugeMetricFamily('frigate_bandwidth_usages_kBps', 'bandwidth usages kilobytes per second', labels=['pid', 'name', 'process', 'type', 'cmdline'])
try:
for b_pid, b_stats in stats['bandwidth_usages'].items():
label = [b_pid] # pid label
try:
n = stats['cpu_usages'][b_pid]['cmdline']
for p_name, p_stats in stats['processes'].items():
if str(p_stats['pid']) == b_pid:
n = p_name
break
# new frigate:0.13.0-beta3 stat 'cmdline'
label.append(n) # name label
label.append(stats['cpu_usages'][b_pid]['cmdline']) # process label
label.append('Other') # type label
label.append(stats['cpu_usages'][b_pid]['cmdline']) # cmdline label
add_metric(bandwidth_usages, label, b_stats, 'bandwidth')
except KeyError:
pass
except KeyError:
pass
yield bandwidth_usages
# count events
events = []
try: