normalize metric label to match prometheus data-model guide

This commit is contained in:
Andre Schinkel 2021-10-03 08:39:57 +02:00
parent c4687816c1
commit eb43e39a81
1 changed files with 1 additions and 1 deletions

View File

@ -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()