Skip to content

Commit

Permalink
InfluxDB output should not default to 'no timeout' for http writes
Browse files Browse the repository at this point in the history
default to 5s instead, since even if it times out we will cache the
points and move on

closes influxdata#685
  • Loading branch information
sparrc authored and geodimm committed Mar 10, 2016
1 parent b737cba commit aba9fe6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 3 additions & 3 deletions etc/telegraf.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 6 additions & 4 deletions plugins/outputs/influxdb/influxdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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},
}
})
}

0 comments on commit aba9fe6

Please sign in to comment.