retry connections instead of doing nothing
@@ -88,12 +88,16 @@ func (p *probe) sendMetrics() {
logrus.Debug("write complete")
} else {
logrus.Errorf("error writing to influxdb: %v", err)
+
+ for {
logrus.Info("attempting to reconnect")
if service, ok := p.ctx.GetService(ProbeService); ok {
if err := p.connectToInfluxDb(service); err == nil {
- logrus.Info("reconnected, attempting to write")
+ logrus.Info("reconnected")
if _, err = p.influxDb.Write(*bp); err != nil {
- logrus.Errorf("failed to write after reconnect, giving up")
+ logrus.Errorf("failed to write after reconnect")
+ } else {
+ break
}
} else {
logrus.Errorf("failed to reconnect: %v", err)
@@ -101,6 +105,9 @@ func (p *probe) sendMetrics() {
} else {
logrus.Errorf("could not find %s", ProbeService)
}
+ time.Sleep(30 * time.Second)
+ }
+
}
}
}
