Add write timeout to Riemann output (#2576)

This commit is contained in:
Daniel Nelson 2017-03-27 15:49:45 -07:00 committed by GitHub
parent a855718cd9
commit 29ea9be71e
3 changed files with 14 additions and 2 deletions

View File

@ -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]

View File

@ -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:

View File

@ -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},
}
})
}