Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add write timeout to Riemann output #2576

Merged
merged 2 commits into from
Mar 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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},
}
})
}