Skip to main content

Filter Processor

Status Available in: core, contrib, k8s Maintainers: @TylerHelmuth, @evan-bradley, @edmocosta, @bogdandrutu Source: opentelemetry-collector-contrib

Supported Telemetry

Logs Metrics Traces

Overview

[!NOTE] This documentation applies only to version 0.146.0 and later. Configuration from previous version is still supported, but no longer documented in this README. For information on earlier versions, please refer to the previous documentation.

Configuration

The Filter Processor utilizes the OpenTelemetry Transformation Language to create conditions that determine when telemetry should be dropped. If any condition is met, the telemetry is dropped (each condition is ORed together).

General Config

The Filter Processor’s primary configuration is broken down by signal (traces, metrics, logs, and profiles) and allows you to configure a list of conditions for the processor to evaluate. The list can be made of:
  • OTTL conditions. This option will meet most user’s needs. See Basic Config for more details.
  • Objects, which allows users to apply configuration options to a specific list of conditions. See Advanced Config for more details.
The OTTL allows the use of and, or, and () in conditions. See OTTL Boolean Expressions for more details.

Context

Within each <signal>_conditions list, only certain OTTL Contexts can be used. Each context provides access to different telemetry fields. Click the context name for detailed documentation. Telemetry is evaluated hierarchically, from higher to lower levels. The hierarchy may vary by signal type; examples include: Logs: resourcescopelog Metrics: resourcescopemetricdatapoint Traces: resourcescopespanspanevent For conditions that apply to the same signal, such as spans and span events, if the “higher” level telemetry matches a condition and is dropped, the “lower” level condition will not be checked. This means that if a span is dropped but a span event condition was defined, the span event condition will not be checked for that span. The same relationship applies to other signals. If all span events for a span are dropped, the span will be left intact. If all datapoints for a metric are dropped, the metric will also be dropped. Note that when a single condition contains paths from different contexts, resource and spanevent for example, the condition is evaluated in the lower context spanevent.
This condition translates to: For each span event, check whether its parent span’s resource attribute host.name is localhost or whether the span event’s name is grpc.timeout. Drop the span event if either condition is true.

Error Modes

The filter processor also allows configuring an optional field, error_mode, which will determine how the processor reacts to errors that occur while processing an OTTL condition. ignore is the default mode.

Feature Gate

processor.filter.defaultErrorModeIgnore
The processor.filter.defaultErrorModeIgnore feature gate changes the default error_mode of the filter processor from propagate to ignore. This gate is currently in stable (always enabled). The default error_mode is ignore and can no longer be reverted via this gate. The gate will be removed in v0.159.0.

Basic Config

The basic configuration style allows you to configure OTTL conditions as a flat, OR-ed list, without worrying about extra configurations. This is the simplest way to configure the Filter Processor. If you need explicit context specification or specific error modes, see Advanced Config. Format:
Example:

Advanced Config

For more complex use cases you may need to use the Filter Processor’s advanced configuration style to explicitly specify the context and apply additional settings to a group of conditions. Format:
context: specifies the OTTL context for the conditions. See the Context table for valid values per signal type. Note: In most cases, you should not set this field manually. The processor’s context inferrer will automatically determine the correct context based on the paths used in your conditions. Only set this field if you have a specific need to set the context. error_mode: allows overriding the top-level error_mode for this specific group of conditions. Valid values are ignore, silent, and propagate. See the Error Modes table for more details. conditions: a list of OTTL conditions. If any condition is met, the telemetry is dropped (conditions are OR-ed together). Example:

Context Inference

[!NOTE] This is an advanced topic and is not necessary to get started using the Filter Processor. Read on if you’re interested in how the Filter Processor parses your OTTL conditions.
An OTTL Context defines which Paths, functions, and enums are available when parsing the condition. The Filter Processor automatically infers the OTTL Context based on the paths defined in a condition. This inference is based on the Path names, functions, and enums present in the condition. The inference happens automatically because Path names are prefixed with the context name. For example:
In this configuration, the inferred context value is spanevent, as it is the only context that supports parsing both spanevent and span Paths. In Filter processor, each condition in a list is parsed individually and grouped by its inferred context. Conditions are executed by context group in hierarchical order (resource → scope → signal-specific). For example:
Resource condition is executed first, followed by scope, span, and finally spanevent conditions. The primary benefit of context inference is that it enhances the efficiency of data filtering by linking them to the most suitable context. This optimization ensures that the processing are both accurate and performant, leveraging the hierarchical structure of contexts to avoid unnecessary iterations and improve overall processing efficiency. All of this happens automatically, leaving you to write OTTL conditions without worrying about context. In some situations a combination of Paths, functions, or enums is not allowed. For example:
This condition fails because IsRootSpan() is only available in the span context, not span events, while the spanevent Path prefix requires the condition to evaluate in the span event context. The solution is to split into separate span and span event conditions:
The advanced configuration is required for IsRootSpan() because there is no Path prefix in the condition, so the context must be set explicitly to span.

Examples

Dropping data based on a resource attribute

Dropping metrics with invalid type

Dropping specific metric and value

Dropping non-HTTP spans

Dropping HTTP spans

Dropping non-error spans with a duration of less than 1 second

OTTL Functions

The filter processor has access to all OTTL Converter functions In addition, the processor defines a few of its own functions: Metrics only functions

HasAttrKeyOnDatapoint

HasAttrKeyOnDatapoint(key) Returns true if the given key appears in the attribute map of any datapoint on a metric. key must be a string. You must use the metrics.metric context. Examples:
  • HasAttrKeyOnDatapoint("http.method")

HasAttrOnDatapoint

HasAttrOnDatapoint(key, value) Returns true if the given key and value appears in the attribute map of any datapoint on a metric. key and value must both be strings. If the value of the attribute on the datapoint is not a string, value will be compared to "". You must use the metrics.metric context. Examples:
  • HasAttrOnDatapoint("http.method", "GET")

Legacy Configuration

The following configuration options are deprecated and will be removed in a future release. Please migrate to the new *_conditions format.

Troubleshooting

When using OTTL you can enable debug logging in the collector to print out useful information, such as if the condition matched and the TransformContext used in the condition, to help you troubleshoot why a condition is not behaving as you expect. This feature is very verbose, but provides you an accurate view into how OTTL views the underlying data.

Warnings

In general, understand your data before using the filter processor.
  • When using the Filter Processor make sure you understand the look of your incoming data and test the configuration thoroughly. In general, use as specific a configuration as possible to lower the risk of the wrong data being dropped.
  • Orphaned Telemetry: The processor allows dropping spans. Dropping a span may lead to orphaned spans if the dropped span is a parent. Dropping a span may lead to orphaned logs if the log references the dropped span.

Available Benchmarks

The filter processor is tested as part of the project’s load tests, with the results being publicly available on the benchmarks page. There you can find the CPU and memory usage of the processor evaluating a representative set of OTTL conditions against each signal at 10,000 items/second: Refer to the test for more information about the setup.
Last generated: 2026-08-24