check for counter existing

This commit is contained in:
Antonio J. Delgado 2022-12-26 19:32:28 +02:00
parent 5e1c1c7fd9
commit 1f72d8f0b7

View file

@ -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: