Grep Filter 🔗︎

Overview 🔗︎

The grep filter plugin “greps” events by the values of specified fields.

Configuration 🔗︎

GrepConfig 🔗︎

Variable Name Type Required Default Description
regexp []RegexpSection No - Regexp Directive
exclude []ExcludeSection No - Exclude Directive
or []OrSection No - Or Directive
and []AndSection No - And Directive

Regexp Directive 🔗︎

Specify filtering rule. This directive contains two parameters. 🔗︎

Variable Name Type Required Default Description
key string Yes - Specify field name in the record to parse.
pattern string Yes - Pattern expression to evaluate

Example Regexp filter configurations 🔗︎

apiVersion: logging.banzaicloud.io/v1beta1
kind: Flow
metadata:
 name: demo-flow
spec:
 filters:
   - grep:
       regexp:
       - key: first
         pattern: /^5\d\d$/
 selectors: {}
 outputRefs:
   - demo-output

Fluentd Config Result 🔗︎

 <filter **>
   @type grep
   @id demo-flow_1_grep
   <regexp>
     key first
     pattern /^5\d\d$/
   </regexp>
 </filter>

Exclude Directive 🔗︎

Specify filtering rule to reject events. This directive contains two parameters. 🔗︎

Variable Name Type Required Default Description
key string Yes - Specify field name in the record to parse.
pattern string Yes - Pattern expression to evaluate

Example Exclude filter configurations 🔗︎

apiVersion: logging.banzaicloud.io/v1beta1
kind: Flow
metadata:
 name: demo-flow
spec:
 filters:
   - grep:
       exclude:
       - key: first
         pattern: /^5\d\d$/
 selectors: {}
 outputRefs:
   - demo-output

Fluentd Config Result 🔗︎

 <filter **>
   @type grep
   @id demo-flow_0_grep
   <exclude>
     key first
     pattern /^5\d\d$/
   </exclude>
 </filter>

Or Directive 🔗︎

Specify filtering rule. This directive contains either regexp or exclude directive. 🔗︎

Variable Name Type Required Default Description
regexp []RegexpSection No - Regexp Directive
exclude []ExcludeSection No - Exclude Directive

Example Or filter configurations 🔗︎

apiVersion: logging.banzaicloud.io/v1beta1
kind: Flow
metadata:
 name: demo-flow
spec:
 filters:
   - grep:
       or:
         - exclude:
           - key: first
             pattern: /^5\d\d$/
           - key: second
             pattern: /\.css$/

 selectors: {}
 outputRefs:
   - demo-output

Fluentd Config Result 🔗︎

   <or>
     <exclude>
       key first
       pattern /^5\d\d$/
     </exclude>
     <exclude>
       key second
       pattern /\.css$/
     </exclude>
   </or>

And Directive 🔗︎

Specify filtering rule. This directive contains either regexp or exclude directive. 🔗︎

Variable Name Type Required Default Description
regexp []RegexpSection No - Regexp Directive
exclude []ExcludeSection No - Exclude Directive

Example And filter configurations 🔗︎

apiVersion: logging.banzaicloud.io/v1beta1
kind: Flow
metadata:
 name: demo-flow
spec:
 filters:
   - grep:
       and:
         - regexp:
           - key: first
             pattern: /^5\d\d$/
           - key: second
             pattern: /\.css$/

 selectors: {}
 outputRefs:
   - demo-output

Fluentd Config Result 🔗︎

   <and>
     <regexp>
       key first
       pattern /^5\d\d$/
     </regexp>
     <regexp>
       key second
       pattern /\.css$/
     </regexp>
   </and>