add overwrite tags for Riemann
This commit is contained in:
parent
747f39a7da
commit
8c555661eb
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|
||||||
|
- [#1845](https://github.com/influxdata/telegraf/pull/1845): Send measurement as Riemann tag, add overwrite tags.
|
||||||
- [#1782](https://github.com/influxdata/telegraf/pull/1782): Allow numeric and non-string values for tag_keys.
|
- [#1782](https://github.com/influxdata/telegraf/pull/1782): Allow numeric and non-string values for tag_keys.
|
||||||
- [#1694](https://github.com/influxdata/telegraf/pull/1694): Adding Gauge and Counter metric types.
|
- [#1694](https://github.com/influxdata/telegraf/pull/1694): Adding Gauge and Counter metric types.
|
||||||
- [#1606](https://github.com/influxdata/telegraf/pull/1606): Remove carraige returns from exec plugin output on Windows
|
- [#1606](https://github.com/influxdata/telegraf/pull/1606): Remove carraige returns from exec plugin output on Windows
|
||||||
|
@ -29,6 +30,7 @@
|
||||||
|
|
||||||
### Bugfixes
|
### Bugfixes
|
||||||
|
|
||||||
|
- [#1501](https://github.com/influxdata/telegraf/issues/1501): Send metric tags as Riemann tags and attributes.
|
||||||
- [#1746](https://github.com/influxdata/telegraf/issues/1746): Fix handling of non-string values for JSON keys listed in tag_keys.
|
- [#1746](https://github.com/influxdata/telegraf/issues/1746): Fix handling of non-string values for JSON keys listed in tag_keys.
|
||||||
- [#1628](https://github.com/influxdata/telegraf/issues/1628): Fix mongodb input panic on version 2.2.
|
- [#1628](https://github.com/influxdata/telegraf/issues/1628): Fix mongodb input panic on version 2.2.
|
||||||
- [#1733](https://github.com/influxdata/telegraf/issues/1733): Fix statsd scientific notation parsing
|
- [#1733](https://github.com/influxdata/telegraf/issues/1733): Fix statsd scientific notation parsing
|
||||||
|
|
|
@ -440,7 +440,8 @@
|
||||||
# separator = " "
|
# separator = " "
|
||||||
# ## set measurement name as a Riemann tag instead of prepending it to the Riemann service name
|
# ## set measurement name as a Riemann tag instead of prepending it to the Riemann service name
|
||||||
# measurement_as_tag = false
|
# measurement_as_tag = false
|
||||||
|
# ## list of Riemann tags, if specified use these instead of any Telegraf tags
|
||||||
|
# tags = ["telegraf","custom_tag"]
|
||||||
|
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
|
@ -16,6 +16,7 @@ type Riemann struct {
|
||||||
Transport string
|
Transport string
|
||||||
Separator string
|
Separator string
|
||||||
MeasurementAsTag bool
|
MeasurementAsTag bool
|
||||||
|
Tags []string
|
||||||
|
|
||||||
client *raidman.Client
|
client *raidman.Client
|
||||||
}
|
}
|
||||||
|
@ -29,6 +30,8 @@ var sampleConfig = `
|
||||||
separator = " "
|
separator = " "
|
||||||
## set measurement name as a Riemann tag instead of prepending it to the Riemann service name
|
## set measurement name as a Riemann tag instead of prepending it to the Riemann service name
|
||||||
measurement_as_tag = false
|
measurement_as_tag = false
|
||||||
|
## list of Riemann tags, if specified use these instead of any Telegraf tags
|
||||||
|
tags = ["telegraf","custom_tag"]
|
||||||
`
|
`
|
||||||
|
|
||||||
func (r *Riemann) Connect() error {
|
func (r *Riemann) Connect() error {
|
||||||
|
@ -107,7 +110,7 @@ func (r *Riemann) buildEvents(p telegraf.Metric) []*raidman.Event {
|
||||||
Host: host,
|
Host: host,
|
||||||
Service: r.service(p.Name(), fieldName),
|
Service: r.service(p.Name(), fieldName),
|
||||||
Tags: r.tags(p.Name(), p.Tags()),
|
Tags: r.tags(p.Name(), p.Tags()),
|
||||||
Attributes: p.Tags(),
|
Attributes: r.attributes(p.Name(), p.Tags()),
|
||||||
Time: p.Time().Unix(),
|
Time: p.Time().Unix(),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,7 +128,18 @@ func (r *Riemann) buildEvents(p telegraf.Metric) []*raidman.Event {
|
||||||
return events
|
return events
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r *Riemann) attributes(name string, tags map[string]string) map[string]string {
|
||||||
|
if r.MeasurementAsTag {
|
||||||
|
tags["measurement"] = name
|
||||||
|
}
|
||||||
|
return tags
|
||||||
|
}
|
||||||
|
|
||||||
func (r *Riemann) tags(name string, tags map[string]string) []string {
|
func (r *Riemann) tags(name string, tags map[string]string) []string {
|
||||||
|
if len(r.Tags) > 0 {
|
||||||
|
return r.Tags
|
||||||
|
}
|
||||||
|
|
||||||
var tagNames, tagValues []string
|
var tagNames, tagValues []string
|
||||||
|
|
||||||
for tagName := range tags {
|
for tagName := range tags {
|
||||||
|
|
Loading…
Reference in New Issue