Case
Assigns values to a field based on conditional case statements, similar to switch-case logic or SQL CASE expressions.
Schema
- case:
field: <ident>
cases:
- condition: <script>
value: <any>
default: <any>
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 | - | Target field to set the result value |
cases | Y | - | Array of condition-value pairs to evaluate |
cases.condition | Y | - | Condition expression to evaluate |
cases.value | Y | - | Value to set if condition is true (supports templates) |
default | N | - | Default value if no cases match (supports templates) |
description | N | - | Explanatory note |
if | N | - | Condition to run processor |
ignore_failure | N | false | Continue if processor fails |
ignore_missing | N | false | Continue if source fields don't exist |
on_failure | N | - | Processors to run on failure |
on_success | N | - | Processors to run on success |
tag | N | - | Processor identifier |
Details
Cases are evaluated in the order they appear, with the first matching condition winning and processing stopping at that point (short-circuit evaluation). Both case values and default values support template expressions, allowing for dynamic value assignment based on other fields.
Values can be strings, numbers, booleans, or complex objects, providing flexibility in the types of data that can be assigned. If no cases match and no default is provided, the target field is not set. Conditions use the same expression syntax as other conditional processors in the system.
This processor is particularly effective for log classification, categorizing log entries based on severity, type, or content characteristics. It excels at status mapping by converting numeric codes to descriptive text and supports risk assessment by assigning risk scores based on multiple factors.
The processor is also valuable for user classification, categorizing users based on roles, departments, or permissions, and enables alert prioritization by setting alert levels based on event characteristics. Additionally, it supports data normalization by standardizing field values across different log sources, ensuring consistency in data processing pipelines.
Examples
Log Levels
Mapping log levels to severity categories... |
|
assigns appropriate severity level: |
|
Status Codes
Categorizing HTTP response codes by range... |
|
Template Values
Using template expressions in case values for dynamic messages... |
|
generates formatted alert message: |
|
Complex Logic
Multi-factor risk scoring with complex conditions... |
|
User Types
Categorizing users based on roles and attributes... |
|