]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
modules/http: fix compatibility with the Prometheus text format
authorMarek Vavruša <mvavrusa@cloudflare.com>
Tue, 8 Aug 2017 05:00:32 +0000 (22:00 -0700)
committerMarek Vavruša <mvavrusa@cloudflare.com>
Tue, 8 Aug 2017 05:00:32 +0000 (22:00 -0700)
The Prometheus text format requires histogram parameters to be quoted,
and the result to end with an empty newline characted.

modules/http/prometheus.lua

index 3831b3d298b875486b8e966b3564c7a4db156fbc..ad9d20e608d0dc437d8b5060906773310cffc48c 100644 (file)
@@ -133,11 +133,11 @@ local function serve_prometheus()
                -- as a timeout (3000ms) for metrics purposes
                count = count + e[2]
                sum = sum + e[2] * (math.min(tonumber(e[1]), 3000.0))
-               table.insert(render, string.format('latency_bucket{le=%s} %f', e[1], count))
+               table.insert(render, string.format('latency_bucket{le="%s"} %f', e[1], count))
        end
        table.insert(render, string.format('latency_count %f', count))
        table.insert(render, string.format('latency_sum %f', sum))
-       return table.concat(render, '\n')
+       return table.concat(render, '\n') .. '\n'
 end
 
 -- Export endpoints