prometheus / jmx_exporter

A process for exposing JMX Beans via HTTP for Prometheus consumption
Apache License 2.0
2.98k stars 1.19k forks source link

Content-Length response header is incorrect when the request has accept-encoding: gzip #616

Closed wGEric closed 3 years ago

wGEric commented 3 years ago

When making a request with the header accept-encoding: gzip the Content-Length header is the size of the uncompressed data. This causes some clients to error because they expect to receive more data than what is being sent.

In the below example, the content length is 59803 bytes and curl only downloads 6743 bytes.

$ curl -v \
  -H "user-agent: Prometheus/2.24.0" \
  -H "application/openmetrics-text; version=0.0.1,text/plain;version=0.0.4;q=0.5,*/*;q=0.1" \
  -H "accept-encoding: gzip" \
  --output metrics.gz \
  http://localhost:5556/metrics
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0* About to connect() to localhost port 5556 (#0)
*   Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 5556 (#0)
> GET /metrics HTTP/1.1
> Host: localhost:5556
> Accept: */*
> user-agent: Prometheus/2.24.0
> accept-encoding: gzip
>
< HTTP/1.1 200 OK
< Content-encoding: gzip
< Date: Mon, 28 Jun 2021 20:32:26 GMT
< Transfer-encoding: chunked
< Content-type: text/plain; version=0.0.4; charset=utf-8
< Content-length: 59803
<
{ [data not shown]
 11 59803   11  6743    0     0   373k      0 --:--:-- --:--:-- --:--:--  387k
* Connection #0 to host localhost left intact

I ran into this issue in a cluster with Linkerd installed. Prometheus was unable to scrape metrics from the jmx exporter because Linkerd thinks the request is incomplete. Prometheus was showing the error "unexpected EOF."

fstab commented 3 years ago

Please open this issue on github.com/prometheus/client_java because jmx_exporter uses client_java's HttpServer for exposing metrics.

wGEric commented 3 years ago

Looks like it was fixed a long time ago. I'll make sure we are using the latest version. Thanks!