Filter

Filter events based on a set of conditions

status: stable egress: stream state: stateless

Configuration

Example configurations

{
  "transforms": {
    "my_transform_id": {
      "type": "filter",
      "inputs": [
        "my-source-or-transform-id"
      ],
      "condition": ".status_code != 200 && !includes([\"info\", \"debug\"], .severity)"
    }
  }
}
[transforms.my_transform_id]
type = "filter"
inputs = [ "my-source-or-transform-id" ]
condition = '.status_code != 200 && !includes(["info", "debug"], .severity)'
---
transforms:
  my_transform_id:
    type: filter
    inputs:
      - my-source-or-transform-id
    condition: .status_code != 200 && !includes(["info", "debug"], .severity)
{
  "transforms": {
    "my_transform_id": {
      "type": "filter",
      "inputs": [
        "my-source-or-transform-id"
      ],
      "condition": ".status_code != 200 && !includes([\"info\", \"debug\"], .severity)"
    }
  }
}
[transforms.my_transform_id]
type = "filter"
inputs = [ "my-source-or-transform-id" ]
condition = '.status_code != 200 && !includes(["info", "debug"], .severity)'
---
transforms:
  my_transform_id:
    type: filter
    inputs:
      - my-source-or-transform-id
    condition: .status_code != 200 && !includes(["info", "debug"], .severity)

condition

required string
The condition to be matched against every input event. Only messages that pass the condition will be forwarded.

inputs

required [string]

A list of upstream source or transform IDs. Wildcards (*) are supported but must be the last character in the ID.

See configuration for more info.

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

Telemetry

Metrics

link

events_discarded_total

counter
The total number of events discarded by this component.

events_in_total

counter
The number of events accepted by this component either from tagged origin like file and uri, or cumulatively from other origins.
component_kind required
The Vector component kind.
component_name required
The Vector component name.
component_type required
The Vector component type.
container_name optional
The name of the container from which the event originates.
file optional
The file from which the event originates.
mode optional
The connection mode used by the component.
peer_addr optional
The IP from which the event originates.
peer_path optional
The pathname from which the event originates.
pod_name optional
The name of the pod from which the event originates.
uri optional
The sanitized URI from which the event originates.

events_out_total

counter
The total number of events emitted by this component.
component_kind required
The Vector component kind.
component_name required
The Vector component name.
component_type required
The Vector component type.

processed_bytes_total

counter
The number of bytes processed by the component.
component_kind required
The Vector component kind.
component_name required
The Vector component name.
component_type required
The Vector component type.
container_name optional
The name of the container from which the bytes originate.
file optional
The file from which the bytes originate.
mode optional
The connection mode used by the component.
peer_addr optional
The IP from which the bytes originate.
peer_path optional
The pathname from which the bytes originate.
pod_name optional
The name of the pod from which the bytes originate.
uri optional
The sanitized URI from which the bytes originate.

processed_events_total

counter
The total number of events processed by this component. This metric is deprecated in place of using events_in_total and events_out_total metrics.
component_kind required
The Vector component kind.
component_name required
The Vector component name.
component_type required
The Vector component type.

Examples

Drop debug logs

Given this event...
[
  {
    "log": {
      "level": "debug",
      "message": "I'm a noisy debug log"
    }
  },
  {
    "log": {
      "level": "info",
      "message": "I'm a normal info log"
    }
  }
]
...and this configuration...
[transforms.my_transform_id]
type = "filter"
inputs = [ "my-source-or-transform-id" ]
condition = '.level == "debug"'
---
transforms:
  my_transform_id:
    type: filter
    inputs:
      - my-source-or-transform-id
    condition: .level == "debug"
{
  "transforms": {
    "my_transform_id": {
      "type": "filter",
      "inputs": [
        "my-source-or-transform-id"
      ],
      "condition": ".level == \"debug\""
    }
  }
}
...this Vector event is produced:
[
  {
    "log": {
      "level": "info",
      "message": "I'm a normal info log"
    }
  }
]

How it works

State

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