add riemann_tag_keys option to specify which tags to send
Signed-off-by: Fabio Berchtold <fabio.berchtold@swisscom.com>
This commit is contained in:
parent
8c555661eb
commit
c36eb4788c
|
@ -440,8 +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
|
# ## list of tag keys to specify, whose values get sent as Riemann tags. If empty, all Telegraf tag values will be sent to Riemann as tags.
|
||||||
# tags = ["telegraf","custom_tag"]
|
# # riemann_tag_keys = ["telegraf","custom_tag"]
|
||||||
|
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
|
@ -16,7 +16,7 @@ type Riemann struct {
|
||||||
Transport string
|
Transport string
|
||||||
Separator string
|
Separator string
|
||||||
MeasurementAsTag bool
|
MeasurementAsTag bool
|
||||||
Tags []string
|
RiemannTagKeys []string
|
||||||
|
|
||||||
client *raidman.Client
|
client *raidman.Client
|
||||||
}
|
}
|
||||||
|
@ -30,8 +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
|
## list of tag keys to specify, whose values get sent as Riemann tags. If empty, all Telegraf tag values will be sent to Riemann as tags.
|
||||||
tags = ["telegraf","custom_tag"]
|
# riemann_tag_keys = ["telegraf","custom_tag"]
|
||||||
`
|
`
|
||||||
|
|
||||||
func (r *Riemann) Connect() error {
|
func (r *Riemann) Connect() error {
|
||||||
|
@ -136,21 +136,27 @@ func (r *Riemann) attributes(name string, tags map[string]string) map[string]str
|
||||||
}
|
}
|
||||||
|
|
||||||
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 {
|
var tagNames, tagValues []string
|
||||||
return r.Tags
|
|
||||||
|
if r.MeasurementAsTag {
|
||||||
|
tagValues = append(tagValues, name)
|
||||||
}
|
}
|
||||||
|
|
||||||
var tagNames, tagValues []string
|
if len(r.RiemannTagKeys) > 0 {
|
||||||
|
for _, tagName := range r.RiemannTagKeys {
|
||||||
|
tagValue, ok := tags[tagName]
|
||||||
|
if ok {
|
||||||
|
tagValues = append(tagValues, tagValue)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return tagValues
|
||||||
|
}
|
||||||
|
|
||||||
for tagName := range tags {
|
for tagName := range tags {
|
||||||
tagNames = append(tagNames, tagName)
|
tagNames = append(tagNames, tagName)
|
||||||
}
|
}
|
||||||
sort.Strings(tagNames)
|
sort.Strings(tagNames)
|
||||||
|
|
||||||
if r.MeasurementAsTag {
|
|
||||||
tagValues = append(tagValues, name)
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, tagName := range tagNames {
|
for _, tagName := range tagNames {
|
||||||
if tagName != "host" { // we'll skip the 'host' tag
|
if tagName != "host" { // we'll skip the 'host' tag
|
||||||
tagValues = append(tagValues, tags[tagName])
|
tagValues = append(tagValues, tags[tagName])
|
||||||
|
|
Loading…
Reference in New Issue