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
The following fields are used to define the processor:
| Field | Required | Default | Description |
|---|---|---|---|
field | Y | - | Field to match against patterns |
regex | Y | - | 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. This does not mean "keep filtering and ignore errors" — see the warning below. |
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 |
disabled | N | false | When true, the processor is skipped and the event continues to the next one. Lets you take a processor out of the path without removing its configuration |
ignore_failure: true silently turns this processor off. The drop is signalled to the pipeline as an error value, and the ignore_failure check runs before that value is inspected — so a matched event is kept instead of dropped, no error is logged, and the pipeline reports success. The processor appears to run normally while filtering nothing.
Use it only if you genuinely want a pass-through. To tolerate real errors without losing the filtering, leave ignore_failure unset and handle the failure with on_failure instead.
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.
Regular Expression Semantics
Patterns compile with Go's RE2 engine. A pattern RE2 rejects — one using a lookaround or a backreference — is retried on a .NET-compatible backtracking engine, so both syntaxes are accepted. Every match made by that fallback engine is bounded by a 100ms timeout: a pattern that exceeds it fails the record with an error, and the rest of the pipeline continues.
Matching is unanchored and case-sensitive. A plain string matches anywhere in the field — anchor with ^ and $, and prefix the expression with (?i) for case-insensitive matching.
A pattern is rejected before it compiles when it:
- exceeds 1000 characters,
- uses more than 100 quantifiers (
*,+,{n,m}), - nests groups more than 10 levels deep, or
- takes longer than 100ms to compile.
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: | |