The router
operator allows logs to be routed dynamically based on their content.
The operator is configured with a list of routes, where each route has an associated expression.
An entry sent to the router operator is forwarded to the first route in the list whose associated
expression returns true
.
An entry that does not match any of the routes is dropped and not processed further.
Field | Default | Description |
---|---|---|
id |
router |
A unique identifier for the operator |
routes |
required | A list of routes. See below for details |
default |
The operator(s) that will receive any entries not matched by any of the routes |
Field | Default | Description |
---|---|---|
output |
required | The connected operator(s) that will receive all outbound entries for this route |
expr |
required | An expression that returns a boolean. The record of the routed entry is available as $ |
labels |
{} | A map of key: value labels to add to an entry that matches the route |
- type: router
routes:
- output: my_json_parser
expr: '$.format == "json"'
- output: my_syslog_parser
expr: '$.format == "syslog"'
- type: router
routes:
- output: my_output
expr: '$.message matches "^LOG: .* END$"'
- type: router
routes:
- output: my_json_parser
expr: '$.format == "json"'
- output: catchall
expr: 'true'