influxdb output: try to connect on write if there are no conns
This commit is contained in:
parent
6284e2011c
commit
04a8e5b888
|
@ -129,6 +129,7 @@ func (i *InfluxDB) Connect() error {
|
|||
|
||||
if e != nil {
|
||||
log.Println("Database creation failed: " + e.Error())
|
||||
continue
|
||||
}
|
||||
|
||||
conns = append(conns, c)
|
||||
|
@ -156,6 +157,12 @@ func (i *InfluxDB) Description() string {
|
|||
// Choose a random server in the cluster to write to until a successful write
|
||||
// occurs, logging each unsuccessful. If all servers fail, return error.
|
||||
func (i *InfluxDB) Write(metrics []telegraf.Metric) error {
|
||||
if len(i.conns) == 0 {
|
||||
err := i.Connect()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
bp, err := client.NewBatchPoints(client.BatchPointsConfig{
|
||||
Database: i.Database,
|
||||
Precision: i.Precision,
|
||||
|
|
Loading…
Reference in New Issue