From 139f07745354a9facaf9b233c955dd3c1101fd53 Mon Sep 17 00:00:00 2001 From: bergquist Date: Mon, 23 Oct 2017 09:35:46 +0200 Subject: [PATCH] prometheus: enable gzip for /metrics endpoint closes #9464 --- pkg/api/http_server.go | 5 ++--- pkg/middleware/util.go | 4 ++++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/pkg/api/http_server.go b/pkg/api/http_server.go index 3107dcf7e4b..037d2ae98e5 100644 --- a/pkg/api/http_server.go +++ b/pkg/api/http_server.go @@ -188,9 +188,8 @@ func (hs *HttpServer) metricsEndpoint(ctx *macaron.Context) { return } - promhttp.HandlerFor(prometheus.DefaultGatherer, promhttp.HandlerOpts{ - DisableCompression: true, - }).ServeHTTP(ctx.Resp, ctx.Req.Request) + promhttp.HandlerFor(prometheus.DefaultGatherer, promhttp.HandlerOpts{}). + ServeHTTP(ctx.Resp, ctx.Req.Request) } func (hs *HttpServer) healthHandler(ctx *macaron.Context) { diff --git a/pkg/middleware/util.go b/pkg/middleware/util.go index c392f215450..22d1b56869e 100644 --- a/pkg/middleware/util.go +++ b/pkg/middleware/util.go @@ -21,6 +21,10 @@ func Gziper() macaron.Handler { return } + if strings.HasPrefix(requestPath, "/metrics") { + return + } + ctx.Invoke(macaronGziper) } }