diff --git a/CHANGELOG.md b/CHANGELOG.md index b1655f77d..5da830d32 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -84,6 +84,7 @@ be deprecated eventually. - [#2513](https://github.com/influxdata/telegraf/issues/2513): create /etc/telegraf/telegraf.d directory in tarball. - [#2541](https://github.com/influxdata/telegraf/issues/2541): Return error on unsupported serializer data format. - [#1827](https://github.com/influxdata/telegraf/issues/1827): Fix Windows Performance Counters multi instance identifier +- [#2576](https://github.com/influxdata/telegraf/pull/2576): Add write timeout to Riemann output ## v1.2.1 [2017-02-01] diff --git a/plugins/outputs/riemann/README.md b/plugins/outputs/riemann/README.md index 2338a00dc..82615728c 100644 --- a/plugins/outputs/riemann/README.md +++ b/plugins/outputs/riemann/README.md @@ -34,6 +34,9 @@ This plugin writes to [Riemann](http://riemann.io/) via TCP or UDP. ## Description for Riemann event # description_text = "metrics collected from telegraf" + + ## Riemann client write timeout, defaults to "5s" if not set. + # timeout = "5s" ``` ### Required parameters: diff --git a/plugins/outputs/riemann/riemann.go b/plugins/outputs/riemann/riemann.go index 25cf3011a..1738ca537 100644 --- a/plugins/outputs/riemann/riemann.go +++ b/plugins/outputs/riemann/riemann.go @@ -7,9 +7,11 @@ import ( "os" "sort" "strings" + "time" "github.com/amir/raidman" "github.com/influxdata/telegraf" + "github.com/influxdata/telegraf/internal" "github.com/influxdata/telegraf/plugins/outputs" ) @@ -22,6 +24,7 @@ type Riemann struct { TagKeys []string Tags []string DescriptionText string + Timeout internal.Duration client *raidman.Client } @@ -54,6 +57,9 @@ var sampleConfig = ` ## Description for Riemann event # description_text = "metrics collected from telegraf" + + ## Riemann client write timeout, defaults to "5s" if not set. + # timeout = "5s" ` func (r *Riemann) Connect() error { @@ -62,7 +68,7 @@ func (r *Riemann) Connect() error { return err } - client, err := raidman.Dial(parsed_url.Scheme, parsed_url.Host) + client, err := raidman.DialWithTimeout(parsed_url.Scheme, parsed_url.Host, r.Timeout.Duration) if err != nil { r.client = nil return err @@ -212,6 +218,8 @@ func (r *Riemann) tags(tags map[string]string) []string { func init() { outputs.Add("riemann", func() telegraf.Output { - return &Riemann{} + return &Riemann{ + Timeout: internal.Duration{Duration: time.Second * 5}, + } }) }