@@ -76,6 +76,7 @@ type fluentBitConfig struct {
7676 DisableKubernetesFilter bool
7777 KubernetesFilter map [string ]string
7878 AwsFilter map [string ]string
79+ FluentdFilterGrep * FluentdFilterGrep
7980 BufferStorage map [string ]string
8081 FilterModify []v1beta1.FilterModify
8182 FluentForwardOutput * fluentForwardOutputConfig
@@ -85,6 +86,13 @@ type fluentBitConfig struct {
8586 HealthCheck * v1beta1.HealthCheck
8687}
8788
89+ type FluentdFilterGrep struct {
90+ Match string
91+ Regex []string
92+ Exclude []string
93+ Logical_Op string
94+ }
95+
8896type fluentForwardOutputConfig struct {
8997 Network FluentbitNetwork
9098 Options map [string ]string
@@ -317,6 +325,14 @@ func (r *Reconciler) configSecret() (runtime.Object, reconciler.DesiredState, er
317325 }
318326 input .Input .Values = fluentbitInputValues
319327
328+ if r .fluentbitSpec .FilterGrep != nil {
329+ input .FluentdFilterGrep , err = toFluentdFilterGrep (r .fluentbitSpec .FilterGrep )
330+
331+ if err != nil {
332+ return nil , reconciler .StatePresent , err
333+ }
334+ }
335+
320336 input .KubernetesFilter , err = mapper .StringsMap (r .fluentbitSpec .FilterKubernetes )
321337 if err != nil {
322338 return nil , reconciler .StatePresent , errors .WrapIf (err , "failed to map kubernetes filter for fluentbit" )
@@ -458,6 +474,21 @@ func (r *Reconciler) configSecret() (runtime.Object, reconciler.DesiredState, er
458474 }, reconciler .StatePresent , nil
459475}
460476
477+ func toFluentdFilterGrep (filterGrep * v1beta1.FilterGrep ) (* FluentdFilterGrep , error ) {
478+ if filterGrep .Logical_Op != "legacy" && len (filterGrep .Regex ) > 0 && len (filterGrep .Exclude ) > 0 {
479+ return nil , errors .New ("failed to parse grep filter for fluentbit, Logical_Op is set, it's not posible to set both Regex and Exclude" )
480+ }
481+
482+ fluentdFilterGrep := & FluentdFilterGrep {
483+ Match : filterGrep .Match ,
484+ Regex : filterGrep .Regex ,
485+ Exclude : filterGrep .Exclude ,
486+ Logical_Op : filterGrep .Logical_Op ,
487+ }
488+
489+ return fluentdFilterGrep , nil
490+ }
491+
461492func (r * Reconciler ) applyNetworkSettings (input fluentBitConfig ) {
462493 if r .fluentbitSpec .Network != nil {
463494 if input .FluentForwardOutput != nil {
0 commit comments