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

This commit is contained in:
Greg 2019-05-01 17:46:52 -06:00 committed by Daniel Nelson
parent 2e6701b44e
commit 3592433b06
2 changed files with 4 additions and 3 deletions

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)

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) {