nest checks for summary message type

This commit is contained in:
Antonio J. Delgado 2022-12-26 19:46:33 +02:00
parent 84ca57eb47
commit a2abee8456

View file

@ -73,10 +73,11 @@ class restic_exporter:
line_data = json.loads(line)
except json.decoder.JSONDecodeError as error:
self._log.error(f"Error decoding line '{line}'. {error}")
if 'message_type' in line_data and line_data['message_type'] == 'summary':
self.summary = line_data
if 'snapshot_id' in line_data:
self.labels["snapshot_id"] = line_data['snapshot_id']
if 'message_type' in line_data:
if line_data['message_type'] == 'summary':
self.summary = line_data
if 'snapshot_id' in line_data:
self.labels["snapshot_id"] = line_data['snapshot_id']
file_stats = os.stat(json_file)
self.summary['timestamp'] = round(file_stats.st_mtime * 1000)
self._log.debug(f"Summary: {json.dumps(self.summary, indent=2)}")