From 6ad37267e44e6f920d2888612048779a9af05d67 Mon Sep 17 00:00:00 2001 From: Orne Brocaar Date: Fri, 10 Jul 2015 20:17:26 +0200 Subject: [PATCH] Add connection timeout configuration for InfluxDB. --- agent.go | 1 + config.go | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/agent.go b/agent.go index 7ac924f63..6cf476d2a 100644 --- a/agent.go +++ b/agent.go @@ -70,6 +70,7 @@ func (agent *Agent) Connect() error { Username: config.Username, Password: config.Password, UserAgent: config.UserAgent, + Timeout: config.Timeout * time.Second, }) if err != nil { diff --git a/config.go b/config.go index 013b8d281..24acc4b3b 100644 --- a/config.go +++ b/config.go @@ -34,6 +34,7 @@ type Config struct { Password string Database string UserAgent string + Timeout time.Duration Tags map[string]string agent *ast.Table @@ -243,6 +244,10 @@ url = "http://localhost:8086" # required. # The target database for metrics. This database must already exist database = "telegraf" # required. +# Timeout in seconds (for the connection with InfluxDB). +# If not provided, will default to 0 (no timeout) +# timeout = 5 + # username = "telegraf" # password = "metricsmetricsmetricsmetrics"