Regex Filter
Synopsis
Filters out events based on regular expression matches.
Schema
regex_filter:
- field: <ident>
- regex: <string>
- regexes: <string[]>
- description: <text>
- if: <script>
- ignore_failure: <boolean>
- ignore_missing: <boolean>
- on_failure: <processor[]>
- on_success: <processor[]>
- tag: <string>
Configuration
Field | Required | Default | Description |
---|---|---|---|
field | Y | - | Field to match against patterns |
regex | N | - | Single regex pattern to match |
regexes | N | - | Additional patterns to match |
description | N | - | Explanatory note |
if | N | - | Condition to run |
ignore_failure | N | false | Continue if matching fails |
ignore_missing | N | false | Continue if source field doesn't exist |
on_failure | N | - | See Handling Failures |
on_success | N | - | See Handling Success |
tag | N | - | Identifier |
Details
The processor uses Golang regular expressions to match field content.
If either the primary regex
or any pattern in regexes
matches, the event is dropped from the pipeline. This is useful for filtering out unwanted events.
Multiple patterns can be specified, and any match will trigger the filter.
Complex regular expressions may impact performance.
The processor can be nicely dove-tailed with conditional execution, field value validation, and error handling and success/failure processors.
If no patterns are specified, all events pass through. Empty field content is treated as non-matching. Matching success triggers event dropping.
Invalid regex patterns and non-string field values will cause errors unless ignore_failure
is set. Missing fields can be skipped by setting ignore_missing
.
Examples
Basic
Messages containing errors... |
|
are dropped when the event matches: |
|
Multi-Pattern
Filtering out both errors and warnings... |
|
drops both the warning and the event: |
|
Non-Matching Event
Allowing non-matching messages through... |
|
lets the event to continue: |
|
Conditionals
Filtering only when a condition is met... |
|
skips the event upon match: |
|
Missing Fields
Handling missing fields gracefully... |
|
continues the execution: |
|
Non-String Fields
Handling non-string field values... |
|
skips filtering upon invalid types: |
|