From 6f9cf521f37d4ba7bd0996c38b20c929e28cf60a Mon Sep 17 00:00:00 2001 From: Rhys Bailey Date: Mon, 6 Mar 2023 15:24:43 +1100 Subject: [PATCH] Update README.md --- README.md | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 80 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 4e94ceb..f9cb04c 100644 --- a/README.md +++ b/README.md @@ -2,20 +2,96 @@ This is a docker container that runs a Prometheus exporter for [Frigate](https://frigate.video/) stats. -Tested with ghcr.io/blakeblackshear/frigate:0.12.0-beta6 docker image with a single Intel OpenVINO detector. +Tested with ghcr.io/blakeblackshear/frigate:0.12.0-beta8 docker image with a single Intel OpenVINO detector. [Docker Hub](https://hub.docker.com/r/rhysbailey/prometheus-frigate-exporter) [GitHub](https://github.com/bairhys/prometheus-frigate-exporter) +[Grafana Dashboard](https://grafana.com/grafana/dashboards/18226-frigate/) + ![Grafana](https://raw.githubusercontent.com/bairhys/prometheus-frigate-exporter/main/grafana-screenshot.png) ## Run the exporter -Modify the `FRIGATE_STATS_URL` environment variable below to point to your [Frigate API stats](https://docs.frigate.video/integrations/api#get-apistats). Then run the container: +Modify the `FRIGATE_STATS_URL` environment variable below to point to your [Frigate API stats](https://docs.frigate.video/integrations/api#get-apistats) (replace `` with your Frigate docker container IP address). Then run the container: ```bash -docker run -d -p 9100:9100 -e "FRIGATE_STATS_URL=http://:5000/api/stats" --name prometheus_frigate_exporter rhysbailey/prometheus-frigate-exporter +docker run \ + -d \ + --restart unless-stopped \ + -p 9100:9100 \ + -e "FRIGATE_STATS_URL=http://:5000/api/stats" \ + --name prometheus_frigate_exporter \ + rhysbailey/prometheus-frigate-exporter ``` -Metrics are available at http://localhost:9100/metrics \ No newline at end of file +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 `` with the IP address of your `prometheus_frigate_exporter` docker container. `` is likely the same IP address as your Frigate docker containers `` if running in the same docker instance + ```yaml + # 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=` to any timeseries scraped from this config. + - job_name: "prometheus" + static_configs: + - targets: ["localhost:9090"] + + - job_name: "prometheus_frigate_exporter" + static_configs: + - targets: [ + ":9100" + ] + ``` + +- Run Prometheus docker container by replacing `/path/to/prometheus.yml` to point to the `prometheus.yml` just created + + ```bash + 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 + + ```bash + 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://: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](https://grafana.com/grafana/dashboards/18226-frigate/)) 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 + +