Skip to content

Commit

Permalink
Merge pull request #159 from devopsext/5745
Browse files Browse the repository at this point in the history
update filter_ex processor
  • Loading branch information
colixxx authored Oct 1, 2024
2 parents 3d6fa43 + a0b5666 commit f1577a7
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions plugins/processors/filter_ex/filter_ex.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@ type FilterIf struct {
}

type Filter struct {
Ifs []*FilterIf `toml:"if"`
Fields []string `toml:"fields,omitempty"`
Tags map[string]string `toml:"tags,omitempty"`
Log telegraf.Logger `toml:"-"`
rAll *regexp.Regexp
DropOriginal bool `toml:"drop_original"`
Ifs []*FilterIf `toml:"if"`
Fields []string `toml:"fields,omitempty"`
Tags map[string]string `toml:"tags,omitempty"`
Log telegraf.Logger `toml:"-"`
rAll *regexp.Regexp
}

var description = "Advanced filtering for metrics based on tags"
Expand Down Expand Up @@ -158,7 +159,11 @@ func (f *Filter) Apply(metrics ...telegraf.Metric) []telegraf.Metric {
}
}

if len(valids) == 0 {
if len(valids) == 0 && f.DropOriginal {

metric.Drop()

} else if len(valids) == 0 {

only = append(only, metric)

Expand Down

0 comments on commit f1577a7

Please sign in to comment.