Add configurable separator for metrics and fields in opentsdb output (#3106)
This commit is contained in:
parent
9bddd50a64
commit
f85db90780
|
@ -33,6 +33,8 @@ type OpenTSDB struct {
|
|||
HttpBatchSize int
|
||||
|
||||
Debug bool
|
||||
|
||||
Separator string
|
||||
}
|
||||
|
||||
var sampleConfig = `
|
||||
|
@ -53,6 +55,9 @@ var sampleConfig = `
|
|||
|
||||
## Debug true - Prints OpenTSDB communication
|
||||
debug = false
|
||||
|
||||
## Separator separates measurements
|
||||
separator = "."
|
||||
`
|
||||
|
||||
func ToLineFormat(tags map[string]string) string {
|
||||
|
@ -133,7 +138,8 @@ func (o *OpenTSDB) WriteHttp(metrics []telegraf.Metric, u *url.URL) error {
|
|||
}
|
||||
|
||||
metric := &HttpMetric{
|
||||
Metric: sanitize(fmt.Sprintf("%s%s_%s", o.Prefix, m.Name(), fieldName)),
|
||||
Metric: sanitize(fmt.Sprintf("%s%s%s%s",
|
||||
o.Prefix, m.Name(), o.Separator, fieldName)),
|
||||
Tags: tags,
|
||||
Timestamp: now,
|
||||
Value: value,
|
||||
|
@ -183,7 +189,7 @@ func (o *OpenTSDB) WriteTelnet(metrics []telegraf.Metric, u *url.URL) error {
|
|||
}
|
||||
|
||||
messageLine := fmt.Sprintf("put %s %v %s %s\n",
|
||||
sanitize(fmt.Sprintf("%s%s_%s", o.Prefix, m.Name(), fieldName)),
|
||||
sanitize(fmt.Sprintf("%s%s%s%s", o.Prefix, m.Name(), o.Separator, fieldName)),
|
||||
now, metricValue, tags)
|
||||
|
||||
_, err := connection.Write([]byte(messageLine))
|
||||
|
|
Loading…
Reference in New Issue