github.com/observiq/carbon@v0.9.11-0.20200820160507-1b872e368a5e/docs/operators/router.md (about) 1 ## `router` operator 2 3 The `router` operator allows logs to be routed dynamically based on their content. 4 5 The operator is configured with a list of routes, where each route has an associated expression. 6 An entry sent to the router operator is forwarded to the first route in the list whose associated 7 expression returns `true`. 8 9 An entry that does not match any of the routes is dropped and not processed further. 10 11 ### Configuration Fields 12 13 | Field | Default | Description | 14 | --- | --- | --- | 15 | `id` | `router` | A unique identifier for the operator | 16 | `routes` | required | A list of routes. See below for details | 17 18 #### Route configuration 19 20 | Field | Default | Description | 21 | --- | --- | --- | 22 | `output` | required | The connected operator(s) that will receive all outbound entries for this route | 23 | `expr` | required | An [expression](/docs/types/expression.md) that returns a boolean. The record of the routed entry is available as `$` | 24 | `labels` | {} | A map of `key: value` labels to add to an entry that matches the route | 25 26 27 ### Examples 28 29 #### Forward entries to different parsers based on content 30 31 ```yaml 32 - type: router 33 routes: 34 - output: my_json_parser 35 expr: '$.format == "json"' 36 - output: my_syslog_parser 37 expr: '$.format == "syslog"' 38 ``` 39 40 #### Drop entries based on content 41 42 ```yaml 43 - type: router 44 routes: 45 - output: my_output 46 expr: '$.message matches "^LOG: .* END$"' 47 ``` 48 49 #### Route with a default 50 51 ```yaml 52 - type: router 53 routes: 54 - output: my_json_parser 55 expr: '$.format == "json"' 56 - output: catchall 57 expr: 'true' 58 ```