Go to file
Rhys Bailey ed6b9bd568 refactor 2023-03-06 15:45:55 +11:00
.gitattributes Initial commit 2023-02-12 22:47:45 +11:00
Dockerfile Update Dockerfile 2023-03-05 23:48:22 +11:00
README.md Update README.md 2023-03-06 15:24:43 +11:00
frigate_grafana_model.json Update Grafana dashboard model 2023-03-05 23:48:11 +11:00
grafana-screenshot.png Update Grafana dashboard model 2023-03-05 23:48:11 +11:00
prometheus_frigate_exporter.py refactor 2023-03-06 15:45:55 +11:00

README.md

Prometheus Frigate stats exporter

This is a docker container that runs a Prometheus exporter for Frigate stats.

Tested with ghcr.io/blakeblackshear/frigate:0.12.0-beta8 docker image with a single Intel OpenVINO detector.

Docker Hub

GitHub

Grafana Dashboard

Grafana

Run the exporter

Modify the FRIGATE_STATS_URL environment variable below to point to your Frigate API stats (replace <your-frigate-ip> with your Frigate docker container IP address). Then run the container:

docker run \
    -d \
    --restart unless-stopped \
    -p 9100:9100 \
    -e "FRIGATE_STATS_URL=http://<your-frigate-ip>:5000/api/stats" \
    --name prometheus_frigate_exporter \
    rhysbailey/prometheus-frigate-exporter

Metrics are available at http://localhost:9100/metrics

Setup Prometheus

If you don't already have Prometheus set up to scrape the prometheus-frigate-exporter metrics,

  • create Prometheus config file prometheus.yml

  • copy example below into prometheus.yml, replacing <your-prometheus-frigate-exporter-ip> with the IP address of your prometheus_frigate_exporter docker container. <your-prometheus-frigate-exporter-ip> is likely the same IP address as your Frigate docker containers <your-frigate-ip> if running in the same docker instance

    # my global config
    global:
      scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
      evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
      # scrape_timeout is set to the global default (10s).
    
    # A scrape configuration containing exactly one endpoint to scrape:
    # Here it's Prometheus itself.
    scrape_configs:
      # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
      - job_name: "prometheus"
        static_configs:
          - targets: ["localhost:9090"]
    
      - job_name: "prometheus_frigate_exporter"
        static_configs:
          - targets: [
                        "<your-prometheus-frigate-exporter-ip>:9100"
                     ]
    
  • Run Prometheus docker container by replacing /path/to/prometheus.yml to point to the prometheus.yml just created

    docker run \
        -d \
        --restart unless-stopped \
        -p 9090:9090 \
        -v /path/to/prometheus.yml:/etc/prometheus/prometheus.yml \
        prom/prometheus
    

To see if Prometheus is scraping the Frigate exporter, go to Prometheus targets page http://:9090/targets and look for UP for prometheus_frigate_exporter job.

Setup Grafana

If you don't already have Grafana set up,

  • run Grafana

    docker run \
        -d \
        --restart unless-stopped \
        -p 3000:3000 \
        grafana/grafana-oss
    
  • Go to Grafana http://:3000 (might take a few minutes first run). Use admin:admin to log in

  • Go to http://:3000/datasources

    • add Prometheus datasource
    • Set Prometheus URL http://<your-prometheus-frigate-exporter-ip>:9090
    • Click Save and Test to check if connected
  • Go to http://:3000/dashboards

    • New -> Import
    • Enter in Import via grafana.com: 18226 (can be found at Grafana Dashboard) and click Load
    • Set the datasource as Prometheus instance set up before then click Import
  • Should now be able to see Frigate time series metrics in the Grafana dashboard