Skip to content

Commit

Permalink
Add write timeout to Riemann output (influxdata#2576)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielnelson authored and calerogers committed Apr 5, 2017
1 parent 90c53eb commit a12ed70
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
3 changes: 3 additions & 0 deletions plugins/outputs/riemann/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
12 changes: 10 additions & 2 deletions plugins/outputs/riemann/riemann.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand All @@ -22,6 +24,7 @@ type Riemann struct {
TagKeys []string
Tags []string
DescriptionText string
Timeout internal.Duration

client *raidman.Client
}
Expand Down Expand Up @@ -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 {
Expand All @@ -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
Expand Down Expand Up @@ -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},
}
})
}

0 comments on commit a12ed70

Please sign in to comment.