Pattern
Synopsis
Extracts structured patterns from log messages, identifying key components and normalizing variable content.
Schema
pattern:
- field: <ident>
- target_field: <ident>
- description: <text>
- if: <script>
- custom_patterns: <map[string]string>
- tokenize_all: <boolean>
- ignore_failure: <boolean>
- ignore_missing: <boolean>
- on_failure: <processor[]>
- on_success: <processor[]>
- tag: <string>
Configuration
Field | Required | Default | Description |
---|---|---|---|
field | Y | - | Field containing the message to analyze |
target_field | N | field | Field to store pattern information |
description | N | - | Documentation note |
custom_patterns | N | - | Map of custom regex patterns to use |
tokenize_all | N | false | Use all built-in patterns for tokenization |
if | N | - | Condition to run |
ignore_failure | N | false | See Handling Failures |
ignore_missing | N | false | If true , skip if field doesn't exist |
on_failure | N | - | See Handling Failures |
on_success | N | - | See Handling Success |
tag | N | - | Identifier |
Details
The processor extracts a normalized representation of log messages by first removing numeric or other identifiable values, and then replacing the standard patterns with tokens in order to generate a consistent pattern representation. It uses the following patterns:
EMAIL | Email address format |
IP | IP address detection |
NUMBER | Numeric values |
PATH | File system paths |
TIMESTAMP | Date and time formats |
URL | Web URLs |
For each processed message, the processor generates a pattern string, a unique hash, and an identifier. It limits the pattern to 100 words, and requires words to be at least 2 characters long.
The processor may modify the input message to create a generalized pattern.
Long messages are truncated, and specific identifiers are replaced with generic tokens.
Examples
Basic
Extracting a pattern from a log message... |
|
creates a normalized one: |
|
Custom
Adding a custom pattern for error codes... |
|
applies it: |
|
Tokenizing
Using all built-in patterns... |
|
replaces all the known patterns: |
|
Error Handling
Handling non-string inputs... |
|
adds an error tag and continues execution: |
|