Skip to content

Commit

Permalink
Buffer metrics from failed writes in influxdb2 output if token is inv…
Browse files Browse the repository at this point in the history
…alid (#5792)

(cherry picked from commit 3592433)
  • Loading branch information
glinton authored and danielnelson committed May 1, 2019
1 parent 20c8879 commit d458657
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions plugins/outputs/influxdb_v2/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion plugins/outputs/influxdb_v2/influxdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit d458657

Please sign in to comment.