0

Basically, I'm developing an HTTP endpoint to get the metrics from prometheus package. Following the instructions in this link [https://stackoverflow.com/a/65609042/17150602] I created a handler to be able to call promhttp.Handler() like so:

g.GET("/metrics", prometheusHandler())

func prometheusHandler() gin.HandlerFunc {
        h := promhttp.Handler()
        return func(c *gin.Context) {
            h.ServeHTTP(c.Writer, c.Request)
        }
    }

The thing is, when I call localhost:1080/metrics the output shows like this (btw, I'm using Postman):

Postman request to get metrics with wrong output

But if, for instance, I change the port and use http instead of gin package like so:

http.Handle("/metrics", promhttp.Handler())
http.ListenAndServe(promAddr, nil)

The output shows OK as you can see here:

Postman reuest to get metrics with correct output

What and why is this happening? Thanks

Toloy
  • 1

1 Answers1

0

You probably forgot to remove a compression middleware like gzip.

Hrun
  • 132
  • 1
  • 5