-
Notifications
You must be signed in to change notification settings - Fork 541
conditional: add conditional processing documentation #1598
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
851584f
docs(processors): add conditional processing documentation
3ff857e
SUMMARY.md: Add conditional processing doc to sidebar
alexakreizinger bd0e5fe
Update pipeline/processors/README.md
0ef1c4b
Update pipeline/processors/README.md
082d425
Update pipeline/processors/README.md
554c72d
Update pipeline/processors/README.md
96eab58
Update pipeline/processors/README.md
69636d5
Update pipeline/processors/README.md
e1ca58f
Update pipeline/processors/README.md
c524d9e
Update pipeline/processors/README.md
0644fb7
Update pipeline/processors/conditional-processing.md
d4bb233
Update pipeline/processors/conditional-processing.md
25e6278
Update pipeline/processors/conditional-processing.md
b5d19a1
Update pipeline/processors/conditional-processing.md
a8f17d6
Update pipeline/processors/conditional-processing.md
a82cc24
Update pipeline/processors/conditional-processing.md
ba34a28
Update pipeline/processors/conditional-processing.md
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,17 @@ | ||
| # Processors | ||
|
|
||
| Processors are components that can modify, transform, or enhance data records as they flow through the Fluent Bit pipeline. | ||
niedbalski marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ## Available processors | ||
|
|
||
| Fluent Bit offers the following processors: | ||
lecaros marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| - [Content Modifier](content-modifier.md): Manipulate message content, metadata/attributes for logs and traces | ||
niedbalski marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| - [Labels](labels.md): Add, update or delete labels in records | ||
niedbalski marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| - [Metrics Selector](metrics-selector.md): Select specific metrics | ||
niedbalski marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| - [OpenTelemetry Envelope](opentelemetry-envelope.md): Convert logs to OpenTelemetry format | ||
niedbalski marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| - [SQL](sql.md): Process records using SQL queries | ||
niedbalski marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ## Features | ||
|
|
||
niedbalski marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| - [Conditional Processing](conditional-processing.md): Apply processors only to records that meet specific conditions | ||
niedbalski marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,207 @@ | ||
| # Conditional processing | ||
|
|
||
| Conditional processing allows you to selectively apply processors to log records based on field values. This feature enables you to create processing pipelines that apply processors only to records that match specific criteria. | ||
niedbalski marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
niedbalski marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ## Configuration format | ||
|
|
||
| Conditional processing is available for processors in the YAML configuration format. To apply a processor conditionally, you add a `condition` block to the processor configuration: | ||
|
|
||
| ```yaml | ||
| - name: processor_name | ||
| # Regular processor configuration... | ||
| condition: | ||
| op: and|or | ||
| rules: | ||
| - field: "$field_name" | ||
| op: comparison_operator | ||
niedbalski marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| value: comparison_value | ||
| # Additional rules... | ||
| ``` | ||
|
|
||
| ### Condition operators | ||
|
|
||
| The `op` field in the condition block specifies the logical operator to apply across all rules: | ||
|
|
||
| | Operator | Description | | ||
| | --- | --- | | ||
| | `and` | All rules must evaluate to true for the condition to be true | | ||
| | `or` | At least one rule must evaluate to true for the condition to be true | | ||
|
|
||
| ### Rules | ||
|
|
||
| Each rule consists of: | ||
|
|
||
| - `field`: The field to evaluate (must use [record accessor syntax](/administration/configuring-fluent-bit/classic-mode/record-accessor.md) with `$` prefix) | ||
| - `op`: The comparison operator | ||
| - `value`: The value to compare against | ||
|
|
||
| ### Comparison operators | ||
|
|
||
| The following comparison operators are supported: | ||
|
|
||
| | Operator | Description | | ||
| | --- | --- | | ||
| | `eq` | Equal to | | ||
| | `neq` | Not equal to | | ||
| | `gt` | Greater than | | ||
| | `lt` | Less than | | ||
| | `gte` | Greater than or equal to | | ||
| | `lte` | Less than or equal to | | ||
| | `regex` | Matches regular expression | | ||
| | `not_regex` | Does not match regular expression | | ||
| | `in` | Value is in the specified array | | ||
| | `not_in` | Value is not in the specified array | | ||
|
|
||
| ### Field access | ||
|
|
||
| You can access record fields using [record accessor syntax](/administration/configuring-fluent-bit/classic-mode/record-accessor.md): | ||
|
|
||
| - Simple fields: `$field` | ||
| - Nested fields: `$parent['child']['subchild']` | ||
niedbalski marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ## Examples | ||
|
|
||
| ### Simple condition | ||
|
|
||
| Process records only when the HTTP method is POST: | ||
niedbalski marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ```yaml | ||
| pipeline: | ||
| inputs: | ||
| - name: dummy | ||
| dummy: '{"request": {"method": "GET", "path": "/api/v1/resource"}}' | ||
| tag: request.log | ||
| processors: | ||
| logs: | ||
| - name: content_modifier | ||
| action: insert | ||
| key: modified_if_post | ||
| value: true | ||
| condition: | ||
| op: and | ||
| rules: | ||
| - field: "$request['method']" | ||
| op: eq | ||
| value: "POST" | ||
| ``` | ||
| ### Multiple conditions with AND | ||
| Apply a processor only when both conditions are met: | ||
niedbalski marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ```yaml | ||
| pipeline: | ||
| inputs: | ||
| - name: dummy | ||
| dummy: '{"request": {"method": "POST", "path": "/api/v1/sensitive-data"}}' | ||
| tag: request.log | ||
| processors: | ||
| logs: | ||
| - name: content_modifier | ||
| action: insert | ||
| key: requires_audit | ||
| value: true | ||
| condition: | ||
| op: and | ||
| rules: | ||
| - field: "$request['method']" | ||
| op: eq | ||
| value: "POST" | ||
| - field: "$request['path']" | ||
| op: regex | ||
| value: "\/sensitive-.*" | ||
| ``` | ||
| ### OR condition example | ||
| Flag records that meet any of multiple criteria: | ||
niedbalski marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ```yaml | ||
| pipeline: | ||
| inputs: | ||
| - name: dummy | ||
| dummy: '{"request": {"method": "GET", "path": "/api/v1/resource", "status_code": 200, "response_time": 150}}' | ||
| tag: request.log | ||
| processors: | ||
| logs: | ||
| - name: content_modifier | ||
| action: insert | ||
| key: requires_performance_check | ||
| value: true | ||
| condition: | ||
| op: or | ||
| rules: | ||
| - field: "$request['response_time']" | ||
| op: gt | ||
| value: 100 | ||
| - field: "$request['status_code']" | ||
| op: gte | ||
| value: 400 | ||
| ``` | ||
| ### Using IN operator | ||
| Apply a processor when a value matches one of multiple options: | ||
niedbalski marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ```yaml | ||
| pipeline: | ||
| inputs: | ||
| - name: dummy | ||
| dummy: '{"request": {"method": "GET", "path": "/api/v1/resource"}}' | ||
| tag: request.log | ||
| processors: | ||
| logs: | ||
| - name: content_modifier | ||
| action: insert | ||
| key: high_priority_method | ||
| value: true | ||
| condition: | ||
| op: and | ||
| rules: | ||
| - field: "$request['method']" | ||
| op: in | ||
| value: ["POST", "PUT", "DELETE"] | ||
| ``` | ||
| ## Multiple processors with conditions | ||
| You can chain multiple conditional processors to create advanced processing pipelines: | ||
niedbalski marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ```yaml | ||
| pipeline: | ||
| inputs: | ||
| - name: dummy | ||
| dummy: '{"log": "Error: Connection refused", "level": "error", "service": "api-gateway"}' | ||
| tag: app.log | ||
| processors: | ||
| logs: | ||
| - name: content_modifier | ||
| action: insert | ||
| key: alert | ||
| value: true | ||
| condition: | ||
| op: and | ||
| rules: | ||
| - field: "$level" | ||
| op: eq | ||
| value: "error" | ||
| - field: "$service" | ||
| op: in | ||
| value: ["api-gateway", "authentication", "database"] | ||
|
|
||
| - name: content_modifier | ||
| action: insert | ||
| key: paging_required | ||
| value: true | ||
| condition: | ||
| op: and | ||
| rules: | ||
| - field: "$log" | ||
| op: regex | ||
| value: "(?i)(connection refused|timeout|crash)" | ||
| - field: "$level" | ||
| op: in | ||
| value: ["error", "fatal"] | ||
| ``` | ||
| This configuration would add the `alert` field to error logs from critical services, and add the `paging_required` field to errors containing specific critical patterns. | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.