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."
When making a request with the header
accept-encoding: gzip
theContent-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.
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."