From a0b5666893fa3dd46e1fcd4c101c5fd511261400 Mon Sep 17 00:00:00 2001 From: Vladislav Radin Date: Tue, 1 Oct 2024 16:02:01 +0300 Subject: [PATCH] update filter_ex processor --- plugins/processors/filter_ex/filter_ex.go | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/plugins/processors/filter_ex/filter_ex.go b/plugins/processors/filter_ex/filter_ex.go index 768b5c720a1fb..858abfd4e6ea6 100644 --- a/plugins/processors/filter_ex/filter_ex.go +++ b/plugins/processors/filter_ex/filter_ex.go @@ -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" @@ -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)