From 24e207c0c6e819422e3b965b9d430623a68ab953 Mon Sep 17 00:00:00 2001 From: TwiN Date: Thu, 19 Jan 2023 23:06:38 -0500 Subject: [PATCH] fix(metrics): Disable compression on prometheus/client_golang's handler Fixes #406 Root cause seems to be that promhttp.Handler() has its own gzip compression https://github.com/prometheus/client_golang/issues/622 --- controller/handler/handler.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/controller/handler/handler.go b/controller/handler/handler.go index 306934a5a..7d2a783bd 100644 --- a/controller/handler/handler.go +++ b/controller/handler/handler.go @@ -8,13 +8,16 @@ import ( static "github.com/TwiN/gatus/v5/web" "github.com/TwiN/health" "github.com/gorilla/mux" + "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promhttp" ) func CreateRouter(cfg *config.Config) *mux.Router { router := mux.NewRouter() if cfg.Metrics { - router.Handle("/metrics", promhttp.Handler()).Methods("GET") + router.Handle("/metrics", promhttp.InstrumentMetricHandler(prometheus.DefaultRegisterer, promhttp.HandlerFor(prometheus.DefaultGatherer, promhttp.HandlerOpts{ + DisableCompression: true, + }))).Methods("GET") } router.Use(GzipHandler) api := router.PathPrefix("/api").Subrouter()