sanitize known issue characters from graphite tag name
This commit is contained in:
parent
22073042a9
commit
e940f99646
|
@ -7,7 +7,6 @@ import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
"github.com/influxdata/telegraf/internal"
|
"github.com/influxdata/telegraf/internal"
|
||||||
|
@ -156,13 +155,7 @@ func (l *Librato) Description() string {
|
||||||
func (l *Librato) buildGaugeName(m telegraf.Metric, fieldName string) string {
|
func (l *Librato) buildGaugeName(m telegraf.Metric, fieldName string) string {
|
||||||
// Use the GraphiteSerializer
|
// Use the GraphiteSerializer
|
||||||
graphiteSerializer := graphite.GraphiteSerializer{}
|
graphiteSerializer := graphite.GraphiteSerializer{}
|
||||||
serializedMetric := graphiteSerializer.SerializeBucketName(m, fieldName)
|
return graphiteSerializer.SerializeBucketName(m, fieldName)
|
||||||
|
|
||||||
// Deal with slash characters:
|
|
||||||
replacedString := strings.Replace(serializedMetric, "/", "-", -1)
|
|
||||||
// Deal with @ characters:
|
|
||||||
replacedString = strings.Replace(replacedString, "@", "-", -1)
|
|
||||||
return replacedString
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *Librato) buildGauges(m telegraf.Metric) ([]*Gauge, error) {
|
func (l *Librato) buildGauges(m telegraf.Metric) ([]*Gauge, error) {
|
||||||
|
|
|
@ -12,6 +12,8 @@ type GraphiteSerializer struct {
|
||||||
Prefix string
|
Prefix string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var sanitizedChars = strings.NewReplacer("/", "-", "@", "-", " ", "_")
|
||||||
|
|
||||||
func (s *GraphiteSerializer) Serialize(metric telegraf.Metric) ([]string, error) {
|
func (s *GraphiteSerializer) Serialize(metric telegraf.Metric) ([]string, error) {
|
||||||
out := []string{}
|
out := []string{}
|
||||||
|
|
||||||
|
@ -85,5 +87,5 @@ func buildTags(metric telegraf.Metric) string {
|
||||||
tag_str += "." + tag_value
|
tag_str += "." + tag_value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return tag_str
|
return sanitizedChars.Replace(tag_str)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue