Compare commits
10 Commits
9b4af20584
...
cbd8a3dad9
Author | SHA1 | Date |
---|---|---|
|
cbd8a3dad9 | |
|
0614222ad3 | |
|
8a5b45c3f8 | |
|
251624919d | |
|
3c6fe882a6 | |
|
582d8e5fd7 | |
|
2d3182c9be | |
|
292e362945 | |
|
d62fffcabb | |
|
e3dd5a41f4 |
|
@ -2,32 +2,37 @@ name: Docker Image CI
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ "main" ]
|
tags:
|
||||||
pull_request:
|
- 'v[0-9]+.[0-9]+.[0-9]+'
|
||||||
branches: [ "main" ]
|
|
||||||
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
docker:
|
docker:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
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
|
uses: docker/setup-qemu-action@v3
|
||||||
-
|
|
||||||
name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
-
|
|
||||||
name: Login to Docker Hub
|
- name: Login to Docker Hub
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
-
|
|
||||||
name: Build and push
|
- name: Build and push
|
||||||
uses: docker/build-push-action@v5
|
uses: docker/build-push-action@v5
|
||||||
with:
|
with:
|
||||||
push: true
|
push: true
|
||||||
file: Dockerfile
|
file: Dockerfile
|
||||||
platforms: linux/amd64,linux/arm64
|
platforms: linux/amd64,linux/arm64
|
||||||
tags: ${{ secrets.DOCKERHUB_USERNAME }}/prometheus-frigate-exporter:latest
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
|
@ -1,7 +1,7 @@
|
||||||
FROM alpine
|
FROM alpine
|
||||||
RUN apk update && apk add py3-prometheus-client
|
RUN --mount=type=cache,target=/var/cache apk update && apk add py3-prometheus-client
|
||||||
COPY prometheus_frigate_exporter.py /var/python_scripts/prometheus_frigate_exporter.py
|
COPY prometheus_frigate_exporter.py /prometheus_frigate_exporter.py
|
||||||
CMD /usr/bin/python3 /var/python_scripts/prometheus_frigate_exporter.py $FRIGATE_STATS_URL
|
ENTRYPOINT ["/usr/bin/python3", "/prometheus_frigate_exporter.py"]
|
||||||
|
|
||||||
# docker build -t rhysbailey/prometheus-frigate-exporter .
|
# docker build -t rhysbailey/prometheus-frigate-exporter .
|
||||||
# docker push rhysbailey/prometheus-frigate-exporter:latest
|
# docker push rhysbailey/prometheus-frigate-exporter:latest
|
10
README.md
10
README.md
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
This is a docker container that runs a Prometheus exporter for [Frigate](https://frigate.video/) stats.
|
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:
|
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
|
frigate_storage_free_bytes{storage="/tmp/cache"} 2e+09
|
||||||
# HELP frigate_storage_mount_type_info Storage mount type
|
# HELP frigate_storage_mount_type_info Storage mount type
|
||||||
# TYPE frigate_storage_mount_type_info gauge
|
# 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="tmpfs",storage="/dev/shm"} 1.0
|
||||||
frigate_storage_mount_type_info{mount_type="ext4",storage="/"} 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="/"} 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="/"} 1.0
|
frigate_storage_mount_type_info{mount_type="overlay",storage="/tmp/cache"} 1.0
|
||||||
# HELP frigate_storage_total_bytes Storage total bytes
|
# HELP frigate_storage_total_bytes Storage total bytes
|
||||||
# TYPE frigate_storage_total_bytes gauge
|
# TYPE frigate_storage_total_bytes gauge
|
||||||
frigate_storage_total_bytes{storage="/dev/shm"} 3e+09
|
frigate_storage_total_bytes{storage="/dev/shm"} 3e+09
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
buildContainerImage2()
|
File diff suppressed because it is too large
Load Diff
|
@ -13,9 +13,9 @@ from prometheus_client import start_http_server
|
||||||
def add_metric(metric, label, stats, key, multiplier=1.0):
|
def add_metric(metric, label, stats, key, multiplier=1.0):
|
||||||
try:
|
try:
|
||||||
string = str(stats[key])
|
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)
|
metric.add_metric(label, value * multiplier)
|
||||||
except (KeyError, TypeError, IndexError):
|
except (KeyError, TypeError, IndexError, ValueError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
@ -231,7 +231,7 @@ class CustomCollector(object):
|
||||||
try:
|
try:
|
||||||
for gpu_name, gpu_stats in stats['gpu_usages'].items():
|
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, 'gpu')
|
||||||
add_metric(gpu_usages, [gpu_name], gpu_stats, 'mem')
|
add_metric(gpu_mem_usages, [gpu_name], gpu_stats, 'mem')
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -267,7 +267,7 @@ class CustomCollector(object):
|
||||||
yield temperatures
|
yield temperatures
|
||||||
|
|
||||||
storage_free = GaugeMetricFamily('frigate_storage_free_bytes', 'Storage free bytes', labels=['storage'])
|
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_total = GaugeMetricFamily('frigate_storage_total_bytes', 'Storage total bytes', labels=['storage'])
|
||||||
storage_used = GaugeMetricFamily('frigate_storage_used_bytes', 'Storage used 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_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_total, [storage_path], storage_stats, 'total', 1e6) # MB to bytes
|
||||||
add_metric(storage_used, [storage_path], storage_stats, 'used', 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:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue