Prometheus metricbeat module doesn't fetch metrics when content type is blank
- Dominant language
- Go
- Stars
- 12.7k
- Forks
- 5k
- Avg merge
- 2d 15m
- Merged PRs (30d)
- 385
Description
#### Current behavior
Prometheus v3 has stricter handling of the Content-Type header: it expects a valid header, and if none is present, returns a fallback type. Code [here](https://github.com/prometheus/prometheus/blob/1f56e8492c31a558ccea833027db4bd7f8b6d0e9/model/textparse/interface.go#L93).
The current [fallback](https://github.com/elastic/beats/blob/98d1d4810b1c78cb7ace079f17092a9e4e3fc7b1/metricbeat/helper/prometheus/textparse.go#L45) `text/plain; version=0.0.4; charset=utf-8` in Beats does not match any known [media type](https://github.com/prometheus/prometheus/blob/1f56e8492c31a558ccea833027db4bd7f8b6d0e9/model/textparse/interface.go#L133) while initializing the text parser. This causes the Prometheus library to send a nil parser, and a non-fatal error which isn't handled properly in Beats.
#### Potential Fix
Use `text/plain` as the fallback type and only return error if it's not the one that is returned when the content type is blank and a fallback is used instead.
Contributor guide
Assessment
This issue has not been assessed yet.