Riemann output: remove some of the object referencing/dereferencing
closes #378 closes #379
This commit is contained in:
parent
a8294c2c34
commit
a3feddd8ed
|
@ -1,5 +1,13 @@
|
||||||
## v0.2.3 [unreleased]
|
## v0.2.3 [unreleased]
|
||||||
|
|
||||||
|
### Release Notes
|
||||||
|
- Riemann output added
|
||||||
|
|
||||||
|
### Features
|
||||||
|
- [#379](https://github.com/influxdb/telegraf/pull/379): Riemann output, thanks @allenj!
|
||||||
|
|
||||||
|
### Bugfixes
|
||||||
|
|
||||||
## v0.2.2 [2015-11-18]
|
## v0.2.2 [2015-11-18]
|
||||||
|
|
||||||
### Release Notes
|
### Release Notes
|
||||||
|
|
|
@ -14,7 +14,7 @@ type Riemann struct {
|
||||||
URL string
|
URL string
|
||||||
Transport string
|
Transport string
|
||||||
|
|
||||||
client raidman.Client
|
client *raidman.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
var sampleConfig = `
|
var sampleConfig = `
|
||||||
|
@ -31,7 +31,7 @@ func (r *Riemann) Connect() error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
r.client = *c
|
r.client = c
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ func (r *Riemann) Write(points []*client.Point) error {
|
||||||
var events []*raidman.Event
|
var events []*raidman.Event
|
||||||
for _, p := range points {
|
for _, p := range points {
|
||||||
ev := buildEvent(p)
|
ev := buildEvent(p)
|
||||||
events = append(events, &ev)
|
events = append(events, ev)
|
||||||
}
|
}
|
||||||
|
|
||||||
var senderr = r.client.SendMulti(events)
|
var senderr = r.client.SendMulti(events)
|
||||||
|
@ -68,10 +68,9 @@ func (r *Riemann) Write(points []*client.Point) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func buildEvent(p *client.Point) raidman.Event {
|
func buildEvent(p *client.Point) *raidman.Event {
|
||||||
host := p.Tags()["host"]
|
host, ok := p.Tags()["host"]
|
||||||
|
if !ok {
|
||||||
if len(host) == 0 {
|
|
||||||
hostname, err := os.Hostname()
|
hostname, err := os.Hostname()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
host = "unknown"
|
host = "unknown"
|
||||||
|
@ -86,7 +85,7 @@ func buildEvent(p *client.Point) raidman.Event {
|
||||||
Metric: p.Fields()["value"],
|
Metric: p.Fields()["value"],
|
||||||
}
|
}
|
||||||
|
|
||||||
return *event
|
return event
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|
Loading…
Reference in New Issue