From ee5f69beb45f9c8e450426932ed1187656ddece7 Mon Sep 17 00:00:00 2001 From: Carl Bergquist Date: Thu, 12 Oct 2017 12:02:36 +0200 Subject: [PATCH] metrics: disable gzip for /metrics endpoint (#9468) Prometheus client lib support gzip by itself. Which caused the response to be double gzipped sometimes. We should use the Grafana middle ware instead. closes #9464 --- pkg/api/http_server.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/api/http_server.go b/pkg/api/http_server.go index b43d55b2a8f..c2c78b8737d 100644 --- a/pkg/api/http_server.go +++ b/pkg/api/http_server.go @@ -11,6 +11,8 @@ import ( "path" "time" + "github.com/prometheus/client_golang/prometheus" + "github.com/prometheus/client_golang/prometheus/promhttp" gocache "github.com/patrickmn/go-cache" @@ -187,7 +189,9 @@ func (hs *HttpServer) metricsEndpoint(ctx *macaron.Context) { return } - promhttp.Handler().ServeHTTP(ctx.Resp, ctx.Req.Request) + promhttp.HandlerFor(prometheus.DefaultGatherer, promhttp.HandlerOpts{ + DisableCompression: true, + }).ServeHTTP(ctx.Resp, ctx.Req.Request) } func (hs *HttpServer) healthHandler(ctx *macaron.Context) {