From 584a52ac21d54c7d9a524c38da1a32613621c915 Mon Sep 17 00:00:00 2001 From: Cameron Sparr Date: Fri, 19 Feb 2016 14:46:03 -0700 Subject: [PATCH] InfluxDB output should not default to 'no timeout' for http writes default to 5s instead, since even if it times out we will cache the points and move on closes #685 --- Makefile | 7 +++++-- etc/telegraf.conf | 6 +++--- plugins/outputs/influxdb/influxdb.go | 10 ++++++---- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index fc8d71de0..84b3a1fe0 100644 --- a/Makefile +++ b/Makefile @@ -92,14 +92,17 @@ docker-kill: -docker rm nsq aerospike redis opentsdb rabbitmq postgres memcached mysql kafka mqtt riemann snmp # Run full unit tests using docker containers (includes setup and teardown) -test: docker-kill docker-run +test: vet docker-kill docker-run # Sleeping for kafka leadership election, TSDB setup, etc. sleep 60 # SUCCESS, running tests go test -race ./... # Run "short" unit tests -test-short: +test-short: vet go test -short ./... +vet: + go vet ./... + .PHONY: test diff --git a/etc/telegraf.conf b/etc/telegraf.conf index db87251d5..eaf66db96 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 683227717..60d235511 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{Duration: time.Second * 5}, + } }) }