APT and RPM repositories at repositories.timber.io will be decommissioned on February 28th Migration instructions

Route

Split a stream of events into multiple sub-streams based on user-supplied conditions

status: stable egress: stream state: stateless
Splits a stream of events into multiple sub-streams based on a set of conditions.

Configuration

Example configurations

{
  "transforms": {
    "my_transform_id": {
      "type": "route",
      "inputs": [
        "my-source-or-transform-id"
      ]
    }
  }
}
[transforms.my_transform_id]
type = "route"
inputs = [ "my-source-or-transform-id" ]
transforms:
  my_transform_id:
    type: route
    inputs:
      - my-source-or-transform-id
{
  "transforms": {
    "my_transform_id": {
      "type": "route",
      "inputs": [
        "my-source-or-transform-id"
      ],
      "reroute_unmatched": true
    }
  }
}
[transforms.my_transform_id]
type = "route"
inputs = [ "my-source-or-transform-id" ]
reroute_unmatched = true
transforms:
  my_transform_id:
    type: route
    inputs:
      - my-source-or-transform-id
    reroute_unmatched: true

inputs

required [string]

A list of upstream source or transform IDs.

Wildcards (*) are supported.

See configuration for more info.

Array string literal
Examples
[
  "my-source-or-transform-id",
  "prefix-*"
]

reroute_unmatched

optional bool

Reroutes unmatched events to a named output instead of silently discarding them.

Normally, if an event doesn’t match any defined route, it is sent to the <transform_name>._unmatched output for further processing. In some cases, you may want to simply discard unmatched events and not process them any further.

In these cases, reroute_unmatched can be set to false to disable the <transform_name>._unmatched output and instead silently discard any unmatched events.

default: true

route

optional object

A table of route identifiers to logical conditions representing the filter of the route.

Each route can then be referenced as an input by other components with the name <transform_name>.<route_id>. If an event doesn’t match any route, and if reroute_unmatched is set to true (the default), it is sent to the <transform_name>._unmatched output. Otherwise, the unmatched event is instead silently discarded.

Both _unmatched, as well as _default, are reserved output names and thus cannot be used as a route name.

route.*

required condition
An individual route.

*.source

The text of the condition. The syntax of the condition depends on the value of type.

*.type

The type of condition to supply. See Available syntaxes below for a list of available types for this transform.

Available syntaxes

SyntaxDescriptionExample
vrlA Vector Remap Language (VRL) Boolean expression..status_code != 200 && !includes(["info", "debug"], .severity)
datadog_searchA Datadog Search query string.*stack
is_logWhether the incoming event is a log.
is_metricWhether the incoming event is a metric.
is_traceWhether the incoming event is a trace.

Shorthand for VRL

If you opt for the vrl syntax for this condition, you can set the condition as a string via the condition parameter, without needing to specify both a source and a type. The table below shows some examples:

Config formatExample
YAMLcondition: .status == 200
TOMLcondition = ".status == 200"
JSON"condition": ".status == 200"

Condition config examples

Standard VRL

*:
  type: "vrl"
  source: ".status == 500"
* = { type = "vrl", source = ".status == 500" }
"*": {
  "type": "vrl",
  "source": ".status == 500"
}
*:
  type: "datadog_search"
  source: "*stack"
* = { type = "datadog_search", source = "*stack" }
"*": {
  "type": "datadog_search",
  "source": "*stack"
}

VRL shorthand

*: ".status == 500"
* = ".status == 500"
"*": ".status == 500"

Outputs

<route_id>

Each route can be referenced as an input by other components with the name <transform_name>.<route_id>.

Telemetry

Metrics

link

component_discarded_events_total

counter
The number of events dropped by this component.
component_id
The Vector component ID.
component_kind
The Vector component kind.
component_type
The Vector component type.
host optional
The hostname of the system Vector is running on.
intentional
True if the events were discarded intentionally, like a filter transform, or false if due to an error.
pid optional
The process ID of the Vector instance.

component_errors_total

counter
The total number of errors encountered by this component.
component_id
The Vector component ID.
component_kind
The Vector component kind.
component_type
The Vector component type.
error_type
The type of the error
host optional
The hostname of the system Vector is running on.
pid optional
The process ID of the Vector instance.
stage
The stage within the component at which the error occurred.

component_received_event_bytes_total

counter
The number of event bytes accepted by this component either from tagged origins like file and uri, or cumulatively from other origins.
component_id
The Vector component ID.
component_kind
The Vector component kind.
component_type
The Vector component type.
container_name optional
The name of the container from which the data originated.
file optional
The file from which the data originated.
host optional
The hostname of the system Vector is running on.
mode optional
The connection mode used by the component.
peer_addr optional
The IP from which the data originated.
peer_path optional
The pathname from which the data originated.
pid optional
The process ID of the Vector instance.
pod_name optional
The name of the pod from which the data originated.
uri optional
The sanitized URI from which the data originated.

component_received_events_count

histogram

A histogram of the number of events passed in each internal batch in Vector’s internal topology.

Note that this is separate than sink-level batching. It is mostly useful for low level debugging performance issues in Vector due to small internal batches.

component_id
The Vector component ID.
component_kind
The Vector component kind.
component_type
The Vector component type.
container_name optional
The name of the container from which the data originated.
file optional
The file from which the data originated.
host optional
The hostname of the system Vector is running on.
mode optional
The connection mode used by the component.
peer_addr optional
The IP from which the data originated.
peer_path optional
The pathname from which the data originated.
pid optional
The process ID of the Vector instance.
pod_name optional
The name of the pod from which the data originated.
uri optional
The sanitized URI from which the data originated.

component_received_events_total

counter
The number of events accepted by this component either from tagged origins like file and uri, or cumulatively from other origins.
component_id
The Vector component ID.
component_kind
The Vector component kind.
component_type
The Vector component type.
container_name optional
The name of the container from which the data originated.
file optional
The file from which the data originated.
host optional
The hostname of the system Vector is running on.
mode optional
The connection mode used by the component.
peer_addr optional
The IP from which the data originated.
peer_path optional
The pathname from which the data originated.
pid optional
The process ID of the Vector instance.
pod_name optional
The name of the pod from which the data originated.
uri optional
The sanitized URI from which the data originated.

component_sent_event_bytes_total

counter
The total number of event bytes emitted by this component.
component_id
The Vector component ID.
component_kind
The Vector component kind.
component_type
The Vector component type.
host optional
The hostname of the system Vector is running on.
output optional
The specific output of the component.
pid optional
The process ID of the Vector instance.

component_sent_events_total

counter
The total number of events emitted by this component.
component_id
The Vector component ID.
component_kind
The Vector component kind.
component_type
The Vector component type.
host optional
The hostname of the system Vector is running on.
output optional
The specific output of the component.
pid optional
The process ID of the Vector instance.

utilization

gauge
A ratio from 0 to 1 of the load on a component. A value of 0 would indicate a completely idle component that is simply waiting for input. A value of 1 would indicate a that is never idle. This value is updated every 5 seconds.
component_id
The Vector component ID.
component_kind
The Vector component kind.
component_type
The Vector component type.
host optional
The hostname of the system Vector is running on.
pid optional
The process ID of the Vector instance.

Examples

Split by log level

Given this event...
{
  "log": {
    "level": "info"
  }
}
...and this configuration...
transforms:
  my_transform_id:
    type: route
    inputs:
      - my-source-or-transform-id
    route:
      debug: .level == "debug"
      info: .level == "info"
      warn: .level == "warn"
      error: .level == "error"
[transforms.my_transform_id]
type = "route"
inputs = [ "my-source-or-transform-id" ]

  [transforms.my_transform_id.route]
  debug = '.level == "debug"'
  info = '.level == "info"'
  warn = '.level == "warn"'
  error = '.level == "error"'
{
  "transforms": {
    "my_transform_id": {
      "type": "route",
      "inputs": [
        "my-source-or-transform-id"
      ],
      "route": {
        "debug": ".level == \"debug\"",
        "info": ".level == \"info\"",
        "warn": ".level == \"warn\"",
        "error": ".level == \"error\""
      }
    }
  }
}
...this Vector event is produced:
{
  "level": "info"
}

Split by metric namespace

Given this event...
{
  "metric": {
    "counter": {
      "value": 10000
    },
    "kind": "absolute",
    "name": "memory_available_bytes",
    "namespace": "host",
    "tags": {}
  }
}
...and this configuration...
transforms:
  my_transform_id:
    type: route
    inputs:
      - my-source-or-transform-id
    route:
      app: .namespace == "app"
      host: .namespace == "host"
[transforms.my_transform_id]
type = "route"
inputs = [ "my-source-or-transform-id" ]

  [transforms.my_transform_id.route]
  app = '.namespace == "app"'
  host = '.namespace == "host"'
{
  "transforms": {
    "my_transform_id": {
      "type": "route",
      "inputs": [
        "my-source-or-transform-id"
      ],
      "route": {
        "app": ".namespace == \"app\"",
        "host": ".namespace == \"host\""
      }
    }
  }
}
...this Vector event is produced:
{
  "counter": {
    "value": 10000
  },
  "kind": "absolute",
  "name": "memory_available_bytes",
  "namespace": "host",
  "tags": {}
}

How it works

State

This component is stateless, meaning its behavior is consistent across each input.