Buffer metrics from failed writes in influxdb2 output if token is invalid (#5792)

(cherry picked from commit 3592433b06)
This commit is contained in:
Greg
2019-05-01 16:49:40 -07:00
committed by Daniel Nelson
parent 20c8879f60
commit d458657218
2 changed files with 4 additions and 3 deletions
+3 -2
View File
@@ -228,10 +228,11 @@ func (c *httpClient) writeBatch(ctx context.Context, bucket string, metrics []te
}
switch resp.StatusCode {
case http.StatusBadRequest, http.StatusUnauthorized,
http.StatusForbidden, http.StatusRequestEntityTooLarge:
case http.StatusBadRequest, http.StatusRequestEntityTooLarge:
log.Printf("E! [outputs.influxdb_v2] Failed to write metric: %s\n", desc)
return nil
case http.StatusUnauthorized, http.StatusForbidden:
return fmt.Errorf("failed to write metric: %s", desc)
case http.StatusTooManyRequests, http.StatusServiceUnavailable:
retryAfter := resp.Header.Get("Retry-After")
retry, err := strconv.Atoi(retryAfter)
+1 -1
View File
@@ -165,7 +165,7 @@ func (i *InfluxDB) Write(metrics []telegraf.Metric) error {
log.Printf("E! [outputs.influxdb_v2] when writing to [%s]: %v", client.URL(), err)
}
return errors.New("could not write any address")
return err
}
func (i *InfluxDB) getHTTPClient(ctx context.Context, url *url.URL, proxy *url.URL) (Client, error) {