mirror of
https://github.com/netinvent/npbackup.git
synced 2025-09-12 07:55:23 +08:00
Update additional labels now being lists of dicts
This commit is contained in:
parent
09810af24e
commit
b71005dbaf
1 changed files with 6 additions and 21 deletions
|
@ -7,7 +7,7 @@ __intname__ = "npbackup.gui.core.runner"
|
||||||
__author__ = "Orsiris de Jong"
|
__author__ = "Orsiris de Jong"
|
||||||
__copyright__ = "Copyright (C) 2022-2024 NetInvent"
|
__copyright__ = "Copyright (C) 2022-2024 NetInvent"
|
||||||
__license__ = "GPL-3.0-only"
|
__license__ = "GPL-3.0-only"
|
||||||
__build__ = "2024042401"
|
__build__ = "2024050701"
|
||||||
|
|
||||||
|
|
||||||
from typing import Optional, Callable, Union, List
|
from typing import Optional, Callable, Union, List
|
||||||
|
@ -55,26 +55,11 @@ def metric_writer(
|
||||||
destination = repo_config.g("prometheus.destination")
|
destination = repo_config.g("prometheus.destination")
|
||||||
prometheus_additional_labels = repo_config.g("prometheus.additional_labels")
|
prometheus_additional_labels = repo_config.g("prometheus.additional_labels")
|
||||||
|
|
||||||
if not isinstance(prometheus_additional_labels, list):
|
if isinstance(prometheus_additional_labels, list):
|
||||||
prometheus_additional_labels = [prometheus_additional_labels]
|
for additional_label in prometheus_additional_labels:
|
||||||
|
if isinstance(additional_label, dict):
|
||||||
# Configure lables
|
for k, v in additional_label.items():
|
||||||
try:
|
labels[k] = v
|
||||||
if prometheus_additional_labels:
|
|
||||||
for additional_label in prometheus_additional_labels:
|
|
||||||
if additional_label:
|
|
||||||
try:
|
|
||||||
label, value = additional_label.split("=")
|
|
||||||
labels[label.strip()] = value.strip()
|
|
||||||
except ValueError:
|
|
||||||
logger.error(
|
|
||||||
'Bogus additional label "{}" defined in configuration.'.format(
|
|
||||||
additional_label
|
|
||||||
)
|
|
||||||
)
|
|
||||||
except (KeyError, AttributeError, TypeError):
|
|
||||||
logger.error("Bogus additional labels defined in configuration.")
|
|
||||||
logger.debug("Trace:", exc_info=True)
|
|
||||||
|
|
||||||
# If result was a str, we need to transform it into json first
|
# If result was a str, we need to transform it into json first
|
||||||
if isinstance(result_string, str):
|
if isinstance(result_string, str):
|
||||||
|
|
Loading…
Add table
Reference in a new issue