From 1f72d8f0b7973309520fc7858f4d0ce63a3143e8 Mon Sep 17 00:00:00 2001 From: "Antonio J. Delgado" Date: Mon, 26 Dec 2022 19:32:28 +0200 Subject: [PATCH] check for counter existing --- restic_exporter/restic_exporter.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/restic_exporter/restic_exporter.py b/restic_exporter/restic_exporter.py index 006f360..ea89e02 100644 --- a/restic_exporter/restic_exporter.py +++ b/restic_exporter/restic_exporter.py @@ -57,7 +57,8 @@ class restic_exporter: print(f"# HELP {self.metric_name} {self.metric_description}.") print(f"# TYPE {self.metric_name} counter") for counter in counters: - print(f"{self.metric_name}_{counter}{labels} {float(self.summary[counter])} {self.summary['timestamp']}") + if counter in self.summary: + print(f"{self.metric_name}_{counter}{labels} {float(self.summary[counter])} {self.summary['timestamp']}") def _read_summary_from_json(self, json_file): try: