if command: Examples
The following are examples for using the SPL2 if command. To learn more about the if command, see How the SPL2 if command works.
1. Prioritize events by severity level
This example assigns a priority number to each event based on its severity level.
...
| if (level == "critical") [eval priority=1]
elseif (level == "high") [eval priority=2]
else [eval priority=3]
2. Label and route events by status code
This pipeline example does the following:
-
Updates events that have
statuscodes greater than500with aseverity=criticalfield-value pair.
-
Updates all other events with a
severity=normalfield-value pair. -
Routes all events to an Amazon S3 bucket.
$pipeline = from $source
| if (status > 500) [eval severity="critical"]
else [eval severity="normal"]
| into $aws_s3_destination
See also
if command
Pipelines
Edge Processor pipeline syntax in the Use Edge Processors manual
Ingest Processor pipeline syntax in the Use Ingest Processors manual