influxdata / telegraf

Agent for collecting, processing, aggregating, and writing metrics, logs, and other arbitrary data.
https://influxdata.com/telegraf
MIT License
14.62k stars 5.58k forks source link

Fix contradictory debug messages in influxdb output #11942

Open reimda opened 2 years ago

reimda commented 2 years ago

When telegraf is configured to print debug level errors and the influxdb output is begin used, if there is a server error (or any HTTP 4xx response), telegraf prints two debug messages that contradict each other:

2022-10-04T22:20:23Z E! [outputs.influxdb] E! [outputs.influxdb] Failed to write metric (will be dropped: 401 Unauthorized):
2022-10-04T22:20:23Z D! [outputs.influxdb] Wrote batch of 15 metrics in 6.440209ms

The first one says metrics were dropped, the second says they were written.

Since the RunningOutput only prints the "Wrote batch" message when there's no error, maybe the output shouldn't return nil here https://github.com/influxdata/telegraf/blob/bc2b32891103dbfb232a061e5255c3f5401edebd/plugins/outputs/influxdb/http.go#L390

and maybe it should return an APIError like it does for other cases: https://github.com/influxdata/telegraf/blob/bc2b32891103dbfb232a061e5255c3f5401edebd/plugins/outputs/influxdb/http.go#L431

reimda commented 2 years ago

I'm working on a PR for this