Compare commits

...

10 Commits

Author SHA1 Message Date
Dustin cbd8a3dad9 ci: Add Jenkins build script 2024-10-20 20:34:13 -05:00
Dustin 0614222ad3 Clean up container image build script 2024-10-20 20:33:27 -05:00
Rhys Bailey 8a5b45c3f8
Update README.md to Frigate 0.14.0 #14 2024-08-13 21:35:55 +10:00
Rhys Bailey 251624919d Update docker-image.yml 2024-07-16 22:42:02 +10:00
Rhys Bailey 3c6fe882a6 build and push to docker on version tag and tag image #12 2024-07-16 22:05:08 +10:00
Rhys Bailey 582d8e5fd7 not handling gpu mem usage correctly #11 2024-06-15 00:22:58 +10:00
Rhys Bailey 2d3182c9be
Merge pull request #10 from Rauks/feature/storage-mount-type-info-fix
Fix storage paths for frigate_storage_mount_type_info
2024-05-13 23:06:55 +10:00
Karl Woditsch 292e362945 Fix storage paths for frigate_storage_mount_type_info 2024-05-11 20:18:29 +02:00
Rhys Bailey d62fffcabb grafana models updated at https://grafana.com/grafana/dashboards/18226-frigate/ 2024-03-18 23:53:50 +11:00
Rhys Bailey e3dd5a41f4 Update prometheus_frigate_exporter.py 2024-03-18 23:02:35 +11:00
6 changed files with 34 additions and 2082 deletions

View File

@ -2,32 +2,37 @@ name: Docker Image CI
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
jobs:
docker:
runs-on: ubuntu-latest
steps:
-
name: Set up QEMU
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ secrets.DOCKERHUB_USERNAME }}/prometheus-frigate-exporter
tags: type=semver,pattern={{version}}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
-
name: Set up Docker Buildx
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Login to Docker Hub
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Build and push
- name: Build and push
uses: docker/build-push-action@v5
with:
push: true
file: Dockerfile
platforms: linux/amd64,linux/arm64
tags: ${{ secrets.DOCKERHUB_USERNAME }}/prometheus-frigate-exporter:latest
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

View File

@ -1,7 +1,7 @@
FROM alpine
RUN apk update && apk add py3-prometheus-client
COPY prometheus_frigate_exporter.py /var/python_scripts/prometheus_frigate_exporter.py
CMD /usr/bin/python3 /var/python_scripts/prometheus_frigate_exporter.py $FRIGATE_STATS_URL
RUN --mount=type=cache,target=/var/cache apk update && apk add py3-prometheus-client
COPY prometheus_frigate_exporter.py /prometheus_frigate_exporter.py
ENTRYPOINT ["/usr/bin/python3", "/prometheus_frigate_exporter.py"]
# docker build -t rhysbailey/prometheus-frigate-exporter .
# docker push rhysbailey/prometheus-frigate-exporter:latest
# docker push rhysbailey/prometheus-frigate-exporter:latest

View File

@ -2,7 +2,7 @@
This is a docker container that runs a Prometheus exporter for [Frigate](https://frigate.video/) stats.
Tested with 0.12.0 and 0.13.2 Frigate docker images.
Tested with 0.13.0 and 0.14.0 Frigate docker images.
Exports from Frigate API:
@ -313,10 +313,10 @@ frigate_storage_free_bytes{storage="/media/frigate/recordings"} 2e+09
frigate_storage_free_bytes{storage="/tmp/cache"} 2e+09
# HELP frigate_storage_mount_type_info Storage mount type
# TYPE frigate_storage_mount_type_info gauge
frigate_storage_mount_type_info{mount_type="tmpfs",storage="/"} 1.0
frigate_storage_mount_type_info{mount_type="ext4",storage="/"} 1.0
frigate_storage_mount_type_info{mount_type="ext4",storage="/"} 1.0
frigate_storage_mount_type_info{mount_type="overlay",storage="/"} 1.0
frigate_storage_mount_type_info{mount_type="tmpfs",storage="/dev/shm"} 1.0
frigate_storage_mount_type_info{mount_type="ext4",storage="/media/frigate/clips"} 1.0
frigate_storage_mount_type_info{mount_type="ext4",storage="/media/frigate/recordings"} 1.0
frigate_storage_mount_type_info{mount_type="overlay",storage="/tmp/cache"} 1.0
# HELP frigate_storage_total_bytes Storage total bytes
# TYPE frigate_storage_total_bytes gauge
frigate_storage_total_bytes{storage="/dev/shm"} 3e+09

1
ci/Jenkinsfile vendored Normal file
View File

@ -0,0 +1 @@
buildContainerImage2()

File diff suppressed because it is too large Load Diff

View File

@ -13,9 +13,9 @@ from prometheus_client import start_http_server
def add_metric(metric, label, stats, key, multiplier=1.0):
try:
string = str(stats[key])
value = float(re.findall(r'\d+', string)[0])
value = float(re.findall(r'-?\d*\.?\d*', string)[0])
metric.add_metric(label, value * multiplier)
except (KeyError, TypeError, IndexError):
except (KeyError, TypeError, IndexError, ValueError):
pass
@ -231,7 +231,7 @@ class CustomCollector(object):
try:
for gpu_name, gpu_stats in stats['gpu_usages'].items():
add_metric(gpu_usages, [gpu_name], gpu_stats, 'gpu')
add_metric(gpu_usages, [gpu_name], gpu_stats, 'mem')
add_metric(gpu_mem_usages, [gpu_name], gpu_stats, 'mem')
except KeyError:
pass
@ -267,7 +267,7 @@ class CustomCollector(object):
yield temperatures
storage_free = GaugeMetricFamily('frigate_storage_free_bytes', 'Storage free bytes', labels=['storage'])
storage_mount_type = InfoMetricFamily('frigate_storage_mount_type', 'Storage mount type', labels=['storage'])
storage_mount_type = InfoMetricFamily('frigate_storage_mount_type', 'Storage mount type', labels=['mount_type', 'storage'])
storage_total = GaugeMetricFamily('frigate_storage_total_bytes', 'Storage total bytes', labels=['storage'])
storage_used = GaugeMetricFamily('frigate_storage_used_bytes', 'Storage used bytes', labels=['storage'])
@ -276,7 +276,7 @@ class CustomCollector(object):
add_metric(storage_free, [storage_path], storage_stats, 'free', 1e6) # MB to bytes
add_metric(storage_total, [storage_path], storage_stats, 'total', 1e6) # MB to bytes
add_metric(storage_used, [storage_path], storage_stats, 'used', 1e6) # MB to bytes
storage_mount_type.add_metric(storage_path, {'mount_type': storage_stats['mount_type']})
storage_mount_type.add_metric(storage_path, {'mount_type': storage_stats['mount_type'], 'storage': storage_path})
except KeyError:
pass