Skip to content

Commit

Permalink
export network bandwidth stats
Browse files Browse the repository at this point in the history
  • Loading branch information
bairhys committed Mar 11, 2024
1 parent 33eaea1 commit bc03c4d
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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,
Expand Down
26 changes: 26 additions & 0 deletions prometheus_frigate_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,32 @@ def collect(self):
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:
Expand Down

0 comments on commit bc03c4d

Please sign in to comment.