From 4750dcc48093cb2309c63d409096e717ec17290f Mon Sep 17 00:00:00 2001 From: PovilasID <396243+PovilasID@users.noreply.github.com> Date: Sun, 26 Nov 2023 11:00:48 +0200 Subject: [PATCH 1/3] change: default port change via env --- prometheus_frigate_exporter.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/prometheus_frigate_exporter.py b/prometheus_frigate_exporter.py index b550096..4beb880 100644 --- a/prometheus_frigate_exporter.py +++ b/prometheus_frigate_exporter.py @@ -208,10 +208,11 @@ if __name__ == '__main__': "e.g. FRIGATE_STATS_URL=http://:5000/api/stats") exit() - start_http_server(9100) + port = int(os.environ.get('PORT', 9100)) + start_http_server(port) logging.info('Started, Frigate API URL: ' + sys.argv[1]) - logging.info('Metrics at: http://localhost:9100/metrics') + logging.info('Metrics at: http://localhost:' + str(port) + '/metrics') while True: time.sleep(1) From 5947650b013632095be826bf7ce5ad2005dfac55 Mon Sep 17 00:00:00 2001 From: PovilasID <396243+PovilasID@users.noreply.github.com> Date: Sun, 26 Nov 2023 11:05:21 +0200 Subject: [PATCH 2/3] fix: missing os import --- prometheus_frigate_exporter.py | 1 + 1 file changed, 1 insertion(+) diff --git a/prometheus_frigate_exporter.py b/prometheus_frigate_exporter.py index 4beb880..13eb814 100644 --- a/prometheus_frigate_exporter.py +++ b/prometheus_frigate_exporter.py @@ -6,6 +6,7 @@ import re import time import sys import logging +import os def add_metric(metric, label, stats, key, multiplier=1.0): From e16b626d1741375b709113784d71f72484e8eb4a Mon Sep 17 00:00:00 2001 From: PovilasID <396243+PovilasID@users.noreply.github.com> Date: Sun, 26 Nov 2023 11:44:58 +0200 Subject: [PATCH 3/3] fix: env var position change --- prometheus_frigate_exporter.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/prometheus_frigate_exporter.py b/prometheus_frigate_exporter.py index 13eb814..d513b67 100644 --- a/prometheus_frigate_exporter.py +++ b/prometheus_frigate_exporter.py @@ -201,7 +201,7 @@ if __name__ == '__main__': logging.basicConfig(format='%(asctime)s - %(message)s', level=logging.INFO) try: - url = sys.argv[1] + url = str(os.environ.get('FRIGATE_STATS_URL', 'http://localhost:5000/api/stats')) REGISTRY.register(CustomCollector(url)) except IndexError: logging.error( @@ -212,7 +212,7 @@ if __name__ == '__main__': port = int(os.environ.get('PORT', 9100)) start_http_server(port) - logging.info('Started, Frigate API URL: ' + sys.argv[1]) + logging.info('Started, Frigate API URL: ' + url) logging.info('Metrics at: http://localhost:' + str(port) + '/metrics') while True: