mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2025-03-11 15:34:56 +00:00
lib/promscrape: log the actual response size in the error message when the response size exceeds -promscrape.maxScrapeSize
This is a follow-up for 7ad9fff7e5
This commit is contained in:
parent
8dc04a86f6
commit
8e9548f050
1 changed files with 3 additions and 3 deletions
|
@ -322,12 +322,12 @@ func (c *client) ReadData(dst []byte) ([]byte, error) {
|
||||||
} else if !swapResponseBodies {
|
} else if !swapResponseBodies {
|
||||||
dst = append(dst, resp.Body()...)
|
dst = append(dst, resp.Body()...)
|
||||||
}
|
}
|
||||||
|
fasthttp.ReleaseResponse(resp)
|
||||||
if len(dst) > c.hc.MaxResponseBodySize {
|
if len(dst) > c.hc.MaxResponseBodySize {
|
||||||
maxScrapeSizeExceeded.Inc()
|
maxScrapeSizeExceeded.Inc()
|
||||||
return dst, fmt.Errorf("the response from %q exceeds -promscrape.maxScrapeSize=%d; "+
|
return dst, fmt.Errorf("the response from %q exceeds -promscrape.maxScrapeSize=%d (the actual response size is %d bytes); "+
|
||||||
"either reduce the response size for the target or increase -promscrape.maxScrapeSize", c.scrapeURL, maxScrapeSize.N)
|
"either reduce the response size for the target or increase -promscrape.maxScrapeSize", c.scrapeURL, len(dst), maxScrapeSize.N)
|
||||||
}
|
}
|
||||||
fasthttp.ReleaseResponse(resp)
|
|
||||||
if statusCode != fasthttp.StatusOK {
|
if statusCode != fasthttp.StatusOK {
|
||||||
metrics.GetOrCreateCounter(fmt.Sprintf(`vm_promscrape_scrapes_total{status_code="%d"}`, statusCode)).Inc()
|
metrics.GetOrCreateCounter(fmt.Sprintf(`vm_promscrape_scrapes_total{status_code="%d"}`, statusCode)).Inc()
|
||||||
return dst, fmt.Errorf("unexpected status code returned when scraping %q: %d; expecting %d; response body: %q",
|
return dst, fmt.Errorf("unexpected status code returned when scraping %q: %d; expecting %d; response body: %q",
|
||||||
|
|
Loading…
Reference in a new issue