Fix bugs in metrics tooling

This commit is contained in:
Raphael Michel
2017-03-25 21:16:07 +01:00
parent f03ad7c68f
commit c932892dbd
2 changed files with 4 additions and 3 deletions

View File

@@ -43,7 +43,7 @@ class Metric(object):
else:
named_labels = []
for labelname in self.labelnames:
named_labels.append('{}="{}",'.format(labelname, labels[labelname]))
named_labels.append('{}="{}"'.format(labelname, labels[labelname]))
return metricname + "{" + ",".join(named_labels) + "}"

View File

@@ -1,3 +1,4 @@
import base64
import hmac
from django.conf import settings
@@ -26,7 +27,7 @@ def serve_metrics(request):
if method.lower() != "basic":
return unauthed_response()
user, passphrase = credentials.strip().decode("base64").split(":", 1)
user, passphrase = base64.b64decode(credentials.strip()).decode().split(":", 1)
if not hmac.compare_digest(user, settings.METRICS_USER):
return unauthed_response()
@@ -37,7 +38,7 @@ def serve_metrics(request):
m = metrics.metric_values()
output = []
for metric, value in m:
for metric, value in m.items():
output.append("{} {}".format(metric, str(value)))
content = "\n".join(output)