From 855e23d97816fdb295276f82bd3293652627bb4b Mon Sep 17 00:00:00 2001 From: Joshua Powers Date: Tue, 22 Feb 2022 09:42:37 -0800 Subject: [PATCH] fix: include influxdb bucket name in error messages (#10706) Fixes: #10690 --- plugins/outputs/influxdb_v2/http.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/plugins/outputs/influxdb_v2/http.go b/plugins/outputs/influxdb_v2/http.go index a571a92b0..0cf2c84fa 100644 --- a/plugins/outputs/influxdb_v2/http.go +++ b/plugins/outputs/influxdb_v2/http.go @@ -284,7 +284,7 @@ func (c *httpClient) writeBatch(ctx context.Context, bucket string, metrics []te switch resp.StatusCode { // request was too large, send back to try again case http.StatusRequestEntityTooLarge: - c.log.Errorf("Failed to write metric, request was too large (413)") + c.log.Errorf("Failed to write metric to %s, request was too large (413)", bucket) return &APIError{ StatusCode: resp.StatusCode, Title: resp.Status, @@ -298,10 +298,10 @@ func (c *httpClient) writeBatch(ctx context.Context, bucket string, metrics []te // Clients should *not* repeat the request and the metrics should be dropped. http.StatusUnprocessableEntity, http.StatusNotAcceptable: - c.log.Errorf("Failed to write metric (will be dropped: %s): %s\n", resp.Status, desc) + c.log.Errorf("Failed to write metric to %s (will be dropped: %s): %s\n", bucket, resp.Status, desc) return nil case http.StatusUnauthorized, http.StatusForbidden: - return fmt.Errorf("failed to write metric (%s): %s", resp.Status, desc) + return fmt.Errorf("failed to write metric to %s (%s): %s", bucket, resp.Status, desc) case http.StatusTooManyRequests, http.StatusServiceUnavailable, http.StatusBadGateway, @@ -310,14 +310,14 @@ func (c *httpClient) writeBatch(ctx context.Context, bucket string, metrics []te c.retryCount++ retryDuration := c.getRetryDuration(resp.Header) c.retryTime = time.Now().Add(retryDuration) - c.log.Warnf("Failed to write; will retry in %s. (%s)\n", retryDuration, resp.Status) - return fmt.Errorf("waiting %s for server before sending metric again", retryDuration) + c.log.Warnf("Failed to write to %s; will retry in %s. (%s)\n", bucket, retryDuration, resp.Status) + return fmt.Errorf("waiting %s for server (%s) before sending metric again", retryDuration, bucket) } // if it's any other 4xx code, the client should not retry as it's the client's mistake. // retrying will not make the request magically work. if len(resp.Status) > 0 && resp.Status[0] == '4' { - c.log.Errorf("Failed to write metric (will be dropped: %s): %s\n", resp.Status, desc) + c.log.Errorf("Failed to write metric to %s (will be dropped: %s): %s\n", bucket, resp.Status, desc) return nil }