mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2026-05-17 08:36:55 +03:00
lib/promscrape: allow scraping targets with responses equal to c.maxScrapeSize
Return "too big response size" error only for responses bigger than c.maxScrapeSize (this option can be set either via max_scrape_size option inside scrape config or via -promscrape.maxScrapeSize command-line flag). Previously responses with sizes equal to c.maxScrapeSize were incorrectly rejected.
This commit is contained in:
@@ -167,7 +167,7 @@ func (c *client) ReadData(dst *chunkedbuffer.Buffer) (bool, error) {
|
||||
scrapesOK.Inc()
|
||||
|
||||
// Read the data from resp.Body
|
||||
lr := ioutil.GetLimitedReader(resp.Body, c.maxScrapeSize)
|
||||
lr := ioutil.GetLimitedReader(resp.Body, c.maxScrapeSize+1)
|
||||
_, err = dst.ReadFrom(lr)
|
||||
ioutil.PutLimitedReader(lr)
|
||||
if err != nil {
|
||||
@@ -176,7 +176,7 @@ func (c *client) ReadData(dst *chunkedbuffer.Buffer) (bool, error) {
|
||||
}
|
||||
return false, fmt.Errorf("cannot read data from %s: %w", c.scrapeURL, err)
|
||||
}
|
||||
if int64(dst.Len()) >= c.maxScrapeSize {
|
||||
if int64(dst.Len()) > c.maxScrapeSize {
|
||||
maxScrapeSizeExceeded.Inc()
|
||||
return false, fmt.Errorf("the response from %q exceeds -promscrape.maxScrapeSize or max_scrape_size in the scrape config (%d bytes). "+
|
||||
"Possible solutions are: reduce the response size for the target, increase -promscrape.maxScrapeSize command-line flag, "+
|
||||
|
||||
Reference in New Issue
Block a user