You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: pkg/api/transform_filter.go
+72-11Lines changed: 72 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -17,14 +17,23 @@
17
17
18
18
package api
19
19
20
+
import (
21
+
"errors"
22
+
"regexp"
23
+
)
24
+
20
25
typeTransformFilterstruct {
21
26
Rules []TransformFilterRule`yaml:"rules,omitempty" json:"rules,omitempty" doc:"list of filter rules, each includes:"`
22
27
}
23
28
24
-
func (tf*TransformFilter) Preprocess() {
29
+
func (tf*TransformFilter) Preprocess() error {
30
+
varerrs []error
25
31
fori:=rangetf.Rules {
26
-
tf.Rules[i].preprocess()
32
+
iferr:=tf.Rules[i].preprocess(); err!=nil {
33
+
errs=append(errs, err)
34
+
}
27
35
}
36
+
returnerrors.Join(errs...)
28
37
}
29
38
30
39
typeTransformFilterEnumstring
@@ -37,6 +46,7 @@ const (
37
46
RemoveEntryIfEqualTransformFilterEnum="remove_entry_if_equal"// removes the entry if the field value equals specified value
38
47
RemoveEntryIfNotEqualTransformFilterEnum="remove_entry_if_not_equal"// removes the entry if the field value does not equal specified value
39
48
RemoveEntryAllSatisfiedTransformFilterEnum="remove_entry_all_satisfied"// removes the entry if all of the defined rules are satisfied
49
+
KeepEntryTransformFilterEnum="keep_entry"// keeps the entry if the set of rules are all satisfied
40
50
AddFieldTransformFilterEnum="add_field"// adds (input) field to the entry; overrides previous value if present (key=input, value=value)
41
51
AddFieldIfDoesntExistTransformFilterEnum="add_field_if_doesnt_exist"// adds a field to the entry if the field does not exist
42
52
AddFieldIfTransformFilterEnum="add_field_if"// add output field set to assignee if input field satisfies criteria from parameters field
@@ -55,11 +65,24 @@ const (
55
65
RemoveEntryIfNotEqualDTransformFilterRemoveEntryEnum="remove_entry_if_not_equal"// removes the entry if the field value does not equal specified value
56
66
)
57
67
68
+
typeTransformFilterKeepEntryEnumstring
69
+
70
+
const (
71
+
KeepEntryIfExistsTransformFilterKeepEntryEnum="keep_entry_if_exists"// keeps the entry if the field exists
72
+
KeepEntryIfDoesntExistTransformFilterKeepEntryEnum="keep_entry_if_doesnt_exist"// keeps the entry if the field does not exist
73
+
KeepEntryIfEqualTransformFilterKeepEntryEnum="keep_entry_if_equal"// keeps the entry if the field value equals specified value
74
+
KeepEntryIfNotEqualTransformFilterKeepEntryEnum="keep_entry_if_not_equal"// keeps the entry if the field value does not equal specified value
75
+
KeepEntryIfRegexMatchTransformFilterKeepEntryEnum="keep_entry_if_regex_match"// keeps the entry if the field value matches the specified regex
76
+
KeepEntryIfNotRegexMatchTransformFilterKeepEntryEnum="keep_entry_if_not_regex_match"// keeps the entry if the field value does not match the specified regex
77
+
)
78
+
58
79
typeTransformFilterRulestruct {
59
80
TypeTransformFilterEnum`yaml:"type,omitempty" json:"type,omitempty" doc:"(enum) one of the following:"`
60
81
RemoveField*TransformFilterGenericRule`yaml:"removeField,omitempty" json:"removeField,omitempty" doc:"configuration for remove_field rule"`
61
82
RemoveEntry*TransformFilterGenericRule`yaml:"removeEntry,omitempty" json:"removeEntry,omitempty" doc:"configuration for remove_entry_* rules"`
62
83
RemoveEntryAllSatisfied []*RemoveEntryRule`yaml:"removeEntryAllSatisfied,omitempty" json:"removeEntryAllSatisfied,omitempty" doc:"configuration for remove_entry_all_satisfied rule"`
84
+
KeepEntryAllSatisfied []*KeepEntryRule`yaml:"keepEntryAllSatisfied,omitempty" json:"keepEntryAllSatisfied,omitempty" doc:"configuration for keep_entry rule"`
85
+
KeepEntrySamplinguint16`yaml:"keepEntrySampling,omitempty" json:"keepEntrySampling,omitempty" doc:"sampling value for keep_entry type: 1 flow on <sampling> is kept"`
63
86
AddField*TransformFilterGenericRule`yaml:"addField,omitempty" json:"addField,omitempty" doc:"configuration for add_field rule"`
64
87
AddFieldIfDoesntExist*TransformFilterGenericRule`yaml:"addFieldIfDoesntExist,omitempty" json:"addFieldIfDoesntExist,omitempty" doc:"configuration for add_field_if_doesnt_exist rule"`
65
88
AddFieldIf*TransformFilterRuleWithAssignee`yaml:"addFieldIf,omitempty" json:"addFieldIf,omitempty" doc:"configuration for add_field_if rule"`
@@ -69,19 +92,35 @@ type TransformFilterRule struct {
0 commit comments