From eb43e39a8137be7ec63d9ffce83299b3b0012566 Mon Sep 17 00:00:00 2001 From: Andre Schinkel Date: Sun, 3 Oct 2021 08:39:57 +0200 Subject: [PATCH 1/2] normalize metric label to match prometheus data-model guide --- owrx/controllers/metrics.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/owrx/controllers/metrics.py b/owrx/controllers/metrics.py index 4d41a2a..2b2614c 100644 --- a/owrx/controllers/metrics.py +++ b/owrx/controllers/metrics.py @@ -21,7 +21,7 @@ class MetricsController(Controller): else: raise ValueError("Unexpected metric type for metric {}".format(repr(metric))) - return "{key} {value}".format(key=key.replace(".", "_"), value=value) + return "{key} {value}".format(key=re.sub('[^a-zA-Z0-9:_]', '_', key), value=value) data = ["# https://prometheus.io/docs/instrumenting/exposition_formats/"] + [ prometheusFormat(k, v) for k, v in metrics.items() From efa305eeeca56867129f4501662e5c076a710b10 Mon Sep 17 00:00:00 2001 From: Andre Schinkel Date: Sun, 3 Oct 2021 08:48:40 +0200 Subject: [PATCH 2/2] normalize metric label to match prometheus data-model guide --- owrx/controllers/metrics.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/owrx/controllers/metrics.py b/owrx/controllers/metrics.py index 2b2614c..83a3faa 100644 --- a/owrx/controllers/metrics.py +++ b/owrx/controllers/metrics.py @@ -1,6 +1,8 @@ from . import Controller from owrx.metrics import CounterMetric, DirectMetric, Metrics import json +import re + class MetricsController(Controller):