Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

prometheus_pushgateway failed decompressing payload #20381

Open
sosop opened this issue Apr 26, 2024 · 3 comments
Open

prometheus_pushgateway failed decompressing payload #20381

sosop opened this issue Apr 26, 2024 · 3 comments
Labels
source: prometheus_pushgateway Anything `prometheus_pushgateway` source related type: bug A code related bug.

Comments

@sosop
Copy link

sosop commented Apr 26, 2024

A note for the community

  • Please vote on this issue by adding a 馃憤 reaction to the original issue to help the community and maintainers prioritize this request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Problem

reporting node exporter metrics with gzip, prometheus_pushgateway can not get the metrics, failed decompressing payload, encoding=gzip

Configuration

No response

Version

0.37.0

Debug Output

No response

Example Data

No response

Additional Context

No response

References

No response

@sosop sosop added the type: bug A code related bug. label Apr 26, 2024
@jszwedko jszwedko added type: feature A value-adding code addition that introduce new functionality. source: prometheus_pushgateway Anything `prometheus_pushgateway` source related meta: good first issue Anything that is good for new contributors. type: bug A code related bug. and removed type: bug A code related bug. meta: good first issue Anything that is good for new contributors. type: feature A value-adding code addition that introduce new functionality. labels Apr 26, 2024
@jszwedko
Copy link
Member

Thanks for filing this @sosop ! Are you able to capture one of the requests that the client is sending? I took a quick look at the code and it is already handling gzip decompression if the Content-Encoding is set to gzip. This happens here:

pub fn decode(header: Option<&str>, mut body: Bytes) -> Result<Bytes, ErrorMessage> {
if let Some(encodings) = header {
for encoding in encodings.rsplit(',').map(str::trim) {
body = match encoding {
"identity" => body,
"gzip" => {
let mut decoded = Vec::new();
MultiGzDecoder::new(body.reader())
.read_to_end(&mut decoded)
.map_err(|error| handle_decode_error(encoding, error))?;
decoded.into()
}
"deflate" => {
let mut decoded = Vec::new();
ZlibDecoder::new(body.reader())
.read_to_end(&mut decoded)
.map_err(|error| handle_decode_error(encoding, error))?;
decoded.into()
}
"snappy" => SnappyDecoder::new()
.decompress_vec(&body)
.map_err(|error| handle_decode_error(encoding, error))?
.into(),
"zstd" => zstd::decode_all(body.reader())
.map_err(|error| handle_decode_error(encoding, error))?
.into(),
encoding => {
return Err(ErrorMessage::new(
StatusCode::UNSUPPORTED_MEDIA_TYPE,
format!("Unsupported encoding {}", encoding),
))
}
}
}
}
Ok(body)
}

@sosop
Copy link
Author

sosop commented Apr 29, 2024

thanks, it's already handling gzip decompression!!

@jszwedko
Copy link
Member

Thanks @sosop . Do you mean it is working for you now?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
source: prometheus_pushgateway Anything `prometheus_pushgateway` source related type: bug A code related bug.
Projects
None yet
Development

No branches or pull requests

2 participants