diff --git a/etc/telegraf.conf b/etc/telegraf.conf index db87251d58bdb..eaf66db968181 100644 --- a/etc/telegraf.conf +++ b/etc/telegraf.conf @@ -67,9 +67,9 @@ # note: using second precision greatly helps InfluxDB compression precision = "s" - # Connection timeout (for the connection with InfluxDB), formatted as a string. - # If not provided, will default to 0 (no timeout) - # timeout = "5s" + ## Write timeout (for the InfluxDB client), formatted as a string. + ## If not provided, will default to 5s. 0s means no timeout (not recommended). + timeout = "5s" # username = "telegraf" # password = "metricsmetricsmetricsmetrics" # Set the user agent for HTTP POSTs (can be useful for log differentiation) diff --git a/plugins/outputs/influxdb/influxdb.go b/plugins/outputs/influxdb/influxdb.go index 68322771781cf..5a215298ba00a 100644 --- a/plugins/outputs/influxdb/influxdb.go +++ b/plugins/outputs/influxdb/influxdb.go @@ -52,9 +52,9 @@ var sampleConfig = ` ## note: using "s" precision greatly improves InfluxDB compression precision = "s" - ## Connection timeout (for the connection with InfluxDB), formatted as a string. - ## If not provided, will default to 0 (no timeout) - # timeout = "5s" + ## Write timeout (for the InfluxDB client), formatted as a string. + ## If not provided, will default to 5s. 0s means no timeout (not recommended). + timeout = "5s" # username = "telegraf" # password = "metricsmetricsmetricsmetrics" ## Set the user agent for HTTP POSTs (can be useful for log differentiation) @@ -185,6 +185,8 @@ func (i *InfluxDB) Write(metrics []telegraf.Metric) error { func init() { outputs.Add("influxdb", func() telegraf.Output { - return &InfluxDB{} + return &InfluxDB{ + Timeout: internal.Duration{time.Second * 5}, + } }) }