mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-15 00:13:30 +01:00
app/vmagent: log unsuccessful attempt number when sending data to -remoteWrite.url
This commit is contained in:
parent
3b1ecac04b
commit
6f9c1bc078
@ -185,6 +185,7 @@ func (c *client) runWorker() {
|
|||||||
|
|
||||||
func (c *client) sendBlock(block []byte) {
|
func (c *client) sendBlock(block []byte) {
|
||||||
retryDuration := time.Second
|
retryDuration := time.Second
|
||||||
|
retriesCount := 0
|
||||||
|
|
||||||
again:
|
again:
|
||||||
req, err := http.NewRequest("POST", c.remoteWriteURL, bytes.NewBuffer(block))
|
req, err := http.NewRequest("POST", c.remoteWriteURL, bytes.NewBuffer(block))
|
||||||
@ -229,6 +230,7 @@ again:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Unexpected status code returned
|
// Unexpected status code returned
|
||||||
|
retriesCount++
|
||||||
metrics.GetOrCreateCounter(fmt.Sprintf(`vmagent_remotewrite_requests_total{url=%q, status_code="%d"}`, c.urlLabelValue, statusCode)).Inc()
|
metrics.GetOrCreateCounter(fmt.Sprintf(`vmagent_remotewrite_requests_total{url=%q, status_code="%d"}`, c.urlLabelValue, statusCode)).Inc()
|
||||||
retryDuration *= 2
|
retryDuration *= 2
|
||||||
if retryDuration > time.Minute {
|
if retryDuration > time.Minute {
|
||||||
@ -237,10 +239,10 @@ again:
|
|||||||
body, err := ioutil.ReadAll(resp.Body)
|
body, err := ioutil.ReadAll(resp.Body)
|
||||||
_ = resp.Body.Close()
|
_ = resp.Body.Close()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Errorf("cannot read response body from %q: %s", c.remoteWriteURL, err)
|
logger.Errorf("cannot read response body from %q during retry #%d: %s", c.remoteWriteURL, retriesCount, err)
|
||||||
} else {
|
} else {
|
||||||
logger.Errorf("unexpected status code received after sending a block with size %d bytes to %q: %d; response body=%q; re-sending the block in %.3f seconds",
|
logger.Errorf("unexpected status code received after sending a block with size %d bytes to %q during retry #%d: %d; response body=%q; "+
|
||||||
len(block), c.remoteWriteURL, statusCode, body, retryDuration.Seconds())
|
"re-sending the block in %.3f seconds", len(block), c.remoteWriteURL, retriesCount, statusCode, body, retryDuration.Seconds())
|
||||||
}
|
}
|
||||||
t := time.NewTimer(retryDuration)
|
t := time.NewTimer(retryDuration)
|
||||||
select {
|
select {
|
||||||
|
Loading…
Reference in New Issue
Block a user