Skip to content

Commit

Permalink
handle URL Errors
Browse files Browse the repository at this point in the history
  • Loading branch information
bairhys committed Dec 13, 2023
1 parent dc7e614 commit d914aaa
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion prometheus_frigate_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,12 @@ def add_metric_process(self, metric, camera_stats, camera_name, pid_name, proces
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:
Expand Down

0 comments on commit d914aaa

Please sign in to comment.