Compare commits

...

3 Commits

Author SHA1 Message Date
Greg Linton 71a93ed6b1 Revert regex processor to allow empty values 2018-07-05 18:02:05 -06:00
Greg Linton a7fb1c280f Assume empty field/tag value is not useful, fix test 2018-07-05 11:13:36 -06:00
Greg Linton 2e724d8d02 Prevent new tag from being overwritten
Resolves #4374
2018-07-05 10:24:00 -06:00
1 changed files with 9 additions and 3 deletions

View File

@ -67,7 +67,10 @@ func (r *Regex) Apply(in ...telegraf.Metric) []telegraf.Metric {
for _, metric := range in {
for _, converter := range r.Tags {
if value, ok := metric.GetTag(converter.Key); ok {
metric.AddTag(r.convert(converter, value))
k, v := r.convert(converter, value)
if k != "" {
metric.AddTag(k, v)
}
}
}
@ -75,11 +78,14 @@ func (r *Regex) Apply(in ...telegraf.Metric) []telegraf.Metric {
if value, ok := metric.GetField(converter.Key); ok {
switch value := value.(type) {
case string:
k, _ := r.convert(converter, value)
if k != "" {
metric.AddField(r.convert(converter, value))
}
}
}
}
}
return in
}