mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-23 20:37:12 +01:00
lib/promscrape: send Accept
header similar to Prometheus when scraping targets
This should fix scraping Spring Boot servers, which return incorrect response unless `Accept: text/plain` request header is set. See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/608
This commit is contained in:
parent
47c7ea5c60
commit
3e1d7d8489
@ -80,6 +80,12 @@ func (c *client) ReadData(dst []byte) ([]byte, error) {
|
||||
req := fasthttp.AcquireRequest()
|
||||
req.SetRequestURI(c.requestURI)
|
||||
req.SetHost(c.host)
|
||||
// The following `Accept` header has been copied from Prometheus sources.
|
||||
// See https://github.com/prometheus/prometheus/blob/f9d21f10ecd2a343a381044f131ea4e46381ce09/scrape/scrape.go#L532 .
|
||||
// This is needed as a workaround for scraping stupid Java-based servers such as Spring Boot.
|
||||
// See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/608 for details.
|
||||
// Do not bloat the `Accept` header with OpenMetrics shit, since it looks like dead standard now.
|
||||
req.Header.Set("Accept", "text/plain;version=0.0.4;q=1,*/*;q=0.1")
|
||||
if !*disableCompression || c.disableCompression {
|
||||
req.Header.Set("Accept-Encoding", "gzip")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user