Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update filter_ex processor #159

Merged
merged 1 commit into from
Oct 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading