Return
Synopsis
Exits early from the current processor block (group, pipeline, or foreach), similar to a return statement in programming languages.
Schema
- return:
description: <text>
if: <script>
ignore_failure: <boolean>
on_failure: <processor[]>
on_success: <processor[]>
tag: <string>
Configuration
The following fields are used to define the processor:
| Field | Required | Default | Description |
|---|---|---|---|
description | N | - | Explanatory note |
if | N | - | Condition to run |
ignore_failure | N | false | Continue processing if operation fails |
on_failure | N | - | See Handling Failures |
on_success | N | - | See Handling Success |
tag | N | - | Identifier |
Details
The return processor exits early from the current execution block, halting any remaining processors within that scope. It behaves like a return statement in typical programming languages, allowing you to exit a function or block early based on conditions.
Scope Behavior:
- Inside a foreach processor: Exits the current item's processing and moves to the next item
- Inside a group processor: Exits the group and continues with the next processor after the group
- Inside a pipeline processor: Exits the nested pipeline and returns to the parent pipeline
- At the top level: Completes processing of the current event and continues to the next event
The processor executes any on_success handlers before exiting, allowing for cleanup operations, logging, or metrics collection.
return exits the current block entirely, while continue (in foreach contexts) skips to the next iteration. Use return for early exit logic and continue for iteration control.
- Skip expensive processing for events that don't need it
- Exit early after successful completion of a task
- Implement conditional processing paths
- Optimize performance by avoiding unnecessary operations
Examples
Early Exit from Group
Exiting a processing group early... | |
exits the group early, skips expensive operations: | |
Conditional Processing Path
Implementing conditional logic with return... | |
skips validation steps when not needed: | |
Exit from Nested Pipeline
Exiting a nested pipeline early... | |
exits nested pipeline for US events: | |
Performance Optimization
Skipping expensive processing for filtered events... | |
bypasses expensive operations for debug logs: | |