Filter Processor
core, contrib, k8s
Maintainers: @TylerHelmuth, @evan-bradley, @edmocosta, @bogdandrutu
Source: opentelemetry-collector-contrib
Supported Telemetry
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
- 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.
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:
resource → scope → log
Metrics: resource → scope → metric → datapoint
Traces: resource → scope → span → spanevent
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.
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. propagate is the default mode.
| error_mode | description |
|---|---|
| ignore | The processor ignores errors returned by conditions, logs them, and continues on to the next condition. This is the recommended mode. |
| silent | The processor ignores errors returned by conditions, does not log them, and continues on to the next condition. |
| propagate | The processor returns the error up the pipeline. This will result in the payload being dropped from the collector. |
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: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:
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:
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:
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 functionsHasAttrKeyOnDatapoint
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.
| Deprecated Config | Migrate To |
|---|---|
traces.resource | trace_conditions with resource. prefix |
traces.span | trace_conditions with span. prefix |
traces.spanevent | trace_conditions with spanevent. prefix |
metrics.resource | metric_conditions with resource. prefix |
metrics.metric | metric_conditions with metric. prefix |
metrics.datapoint | metric_conditions with datapoint. prefix |
logs.resource | log_conditions with resource. prefix |
logs.log_record | log_conditions with log. prefix |
profiles.resource | profile_conditions with resource. prefix |
profiles.profile | profile_conditions with profile. prefix |
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.
Last generated: 2026-04-13