]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: Fix prometheus '# TYPE' and '# HELP' headers
authorAnthonin Bonnefoy <anthonin.bonnefoy@datadoghq.com>
Wed, 7 Aug 2019 15:45:25 +0000 (17:45 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Mon, 12 Aug 2019 06:51:28 +0000 (08:51 +0200)
Prometheus protocol defines HELP and TYPE as a token after the '#' and
the space after the '#' is necessary.
This is expected in the prometheus python client for example
(https://github.com/prometheus/client_python/blob/a8f5c80f651ea570577c364203e0edbef67db727/prometheus_client/parser.py#L194)
and the missing space is breaking the parsing of metrics' type.

This patch must be backported to 2.0.

contrib/prometheus-exporter/service-prometheus.c

index 67914f602fff6343d0030737187a9fa8b6f027ff..9b9ef2ea8e2e8ee0cc63364500d39fc08009fb8d 100644 (file)
@@ -1126,11 +1126,11 @@ static int promex_dump_metric_header(struct appctx *appctx, struct htx *htx,
                types = promex_st_metric_types;
        }
 
-       if (istcat(out, ist("#HELP "), max) == -1 ||
+       if (istcat(out, ist("# HELP "), max) == -1 ||
            istcat(out, name, max) == -1 ||
            istcat(out, ist(" "), max) == -1 ||
            istcat(out, desc[appctx->st2], max) == -1 ||
-           istcat(out, ist("\n#TYPE "), max) == -1 ||
+           istcat(out, ist("\n# TYPE "), max) == -1 ||
            istcat(out, name, max) == -1 ||
            istcat(out, ist(" "), max) == -1 ||
            istcat(out, types[appctx->st2], max) == -1 ||