From d914aaa8cb5883ce6d7100ab714dc19b1ca87912 Mon Sep 17 00:00:00 2001 From: Rhys Bailey Date: Wed, 13 Dec 2023 22:23:32 +1100 Subject: [PATCH] handle URL Errors --- prometheus_frigate_exporter.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/prometheus_frigate_exporter.py b/prometheus_frigate_exporter.py index 9bf0970..ad365fe 100644 --- a/prometheus_frigate_exporter.py +++ b/prometheus_frigate_exporter.py @@ -40,7 +40,12 @@ class CustomCollector(object): pass def collect(self): - stats = json.loads(urlopen(self.stats_url).read()) + try: + stats = json.loads(urlopen(self.stats_url).read()) + except error.URLError as e: + logging.error("URLError while opening Frigate stats url %s: %s", self.stats_url, e) + return + try: self.process_stats = stats['cpu_usages'] except KeyError: