diff --git a/pkg/influxunifi/influxdb.go b/pkg/influxunifi/influxdb.go index 3b8c8c9a..ed7a332f 100644 --- a/pkg/influxunifi/influxdb.go +++ b/pkg/influxunifi/influxdb.go @@ -260,12 +260,14 @@ func (u *InfluxUnifi) ReportMetrics(m *poller.Metrics, e *poller.Events) (*Repor r.writer = u.influxV2.WriteAPI(u.Org, u.Bucket) go u.collect(r, r.ch) + go u.drainErrors(r) // Batch all the points. u.loopPoints(r) r.wg.Wait() // wait for all points to finish batching! // Flush all the points. r.writer.Flush() + go u.drainErrors(r) } else { var err error @@ -292,6 +294,12 @@ func (u *InfluxUnifi) ReportMetrics(m *poller.Metrics, e *poller.Events) (*Repor return r, nil } +func (u *InfluxUnifi) drainErrors(r *Report) { + for e := range r.writer.Errors() { + u.LogErrorf("error encountered by influx flush: %v", e) + } +} + // collect runs in a go routine and batches all the points. func (u *InfluxUnifi) collect(r report, ch chan *metric) { for m := range ch {