What Is the Filter Processor in OpenTelemetry?
A beginner-friendly guide to the Collector component that decides which telemetry is worth keeping and which should be dropped, how its rules are written and read, and how to use it without losing anything important.
Think of the security desk at the entrance of a large office building. Hundreds of people arrive every hour, and the guard does not stop everyone for a long chat. A simple set of rules decides who is waved through and who is turned away: delivery vans without a booking, visitors without a badge, a sales flyer being handed around. The building stays calm and useful because the unwanted traffic never reaches the lifts.
Your systems also produce a stream of traffic that nobody really needs: health-check requests that arrive every second, debug messages left switched on by accident, metrics nobody has ever graphed. The OpenTelemetry Filter Processor is the guard at the door of your telemetry pipeline. In this guide you will learn what it is, how its rules are written, how it behaves for traces, metrics and logs, and how to use it safely. Every new word is explained when it first appears, and you do not need any earlier experience.
1The Problem: Too Much Telemetry
Before meeting the tool, it helps to feel the problem it solves.
Telemetry is the general name for the information a running system sends out about itself so that people can understand how it behaves. OpenTelemetry organises telemetry into signals. Traces follow a single request as it travels through many services. Metrics are numbers measured over time, such as requests per second. Logs are timestamped records of events. Each of these is useful, but each can also be produced in enormous quantities.
More data is not always better data. Every item has to be created, sent over the network, processed, stored and queried, and most monitoring services charge by volume. A large share of the telemetry in a typical system is noise: it repeats, it describes routine and harmless events, or it simply belongs to something nobody is investigating. That noise costs money, slows down searches and makes the useful signals harder to find.
Imagine searching for one important letter in a mailbox stuffed with advertising leaflets. The letter is in there, but finding it takes far longer, and you pay for a bigger mailbox. If the leaflets were removed at the gate, the mailbox would be smaller, cheaper and much easier to search.
Where the noise usually comes from
Health checks and probes
Platforms call a service every few seconds to ask if it is alive. Each call can create a trace and several log lines that say nothing new.
Debug and verbose logs
Detailed messages are helpful while developing, but if left on in production they can multiply log volume many times over.
Unused metrics
Libraries often emit dozens of metrics by default. Teams usually look at only a small handful of them.
Test and internal traffic
Load tests, synthetic checks and internal tools generate data that should not mix with real customer activity.
The earlier you remove unwanted data, the more you save. Removing it before it leaves your network saves bandwidth as well as storage, which is why filtering inside the Collector is so popular.
2So What Is the Filter Processor?
It is a Collector component that removes telemetry which matches rules you write.
The OpenTelemetry Collector is a standalone program that receives telemetry, optionally changes it, and sends it onward to one or more destinations. Inside it, data flows through pipelines. A pipeline is made of receivers that bring data in, processors that work on it in the middle, and exporters that send it out. The Filter Processor is one of the processors. Its job is simple: look at each item passing through, check it against your rules, and drop the items that match.
It can examine traces (down to individual spans and span events), metrics (down to individual metrics and data points) and logs (individual log records). It can also look at the resource and scope information attached to them, which describe the service and the library that produced the data. Because it can look so closely, it can remove very precise slices of telemetry while leaving everything else alone.
The Filter Processor is a sieve with holes you design yourself. You decide what size of stone falls through and what stays in the sieve. Everything that matches one of your rules falls out of the pipeline and is never seen again by the later stages.
flowchart LR
A["Receiver: data comes in"] --> B["Filter processor: matching items are dropped"]
B --> C["Other processors"]
C --> D["Exporter: data goes out"]
B -.-> X["Dropped items"]
What it does and what it does not do
| It does | It does not |
|---|---|
| Drop whole items that match a condition | Change the content of items it keeps |
| Work on traces, metrics and logs | Send data anywhere on its own |
| Look at attributes, names, severity, kinds and more | Choose a random percentage to keep, as sampling does |
| Use the OpenTelemetry Transformation Language for its rules | Send different data to different places, as routing does |
Many beginners think a filter keeps what matches and throws away the rest. For this processor, it is the opposite: the items that match your conditions are the ones that get dropped. We will return to this in Chapter 5 because it causes more mistakes than any other detail.
3Where It Lives: Pipelines and Components
To use a processor, you must understand how it is defined and switched on.
The Collector is controlled by a configuration file written in YAML, a plain-text format that is easy for people to read. The file has top-level sections for receivers, processors, exporters, connectors and extensions, and a final section called service. The first group is where components are defined. The service section is where components are enabled and joined into pipelines.
This matters for the Filter Processor in two ways. First, you describe its rules in the processors section. Second, nothing happens until you list the processor inside the processors list of one or more pipelines in the service section. A filter that is defined but never listed in a pipeline does nothing at all.
Define the filter
In the processors section, add the filter processor and write the conditions that describe the data you want to drop.
Add it to a pipeline
In the service section, add its name to the processors list of each pipeline that should apply the rules.
Place it in the right position
Processors run in the order listed, so decide carefully where the filter should sit relative to the others.
Restart or reload and check
Start the Collector with the new file and confirm that the unwanted data has disappeared and the wanted data remains.
One definition, several pipelines
You can use the same filter definition in several pipelines. However, a filter defined for traces cannot be applied to a metrics pipeline in any meaningful way. Each signal has its own set of conditions. A single filter definition can hold rules for traces, metrics and logs side by side, and each pipeline will use the part that matches its own signal.
The Collector lets you define several instances of the same processor type by adding a slash and a name after the type. This is useful when you want one filter for production traces and another with different rules for a test pipeline.
The most common reason a newly written filter seems to do nothing is that it was never added to a pipeline. Always check the service section after writing a new component.
4How Rules Are Written: A Gentle Look at OTTL
The conditions in the filter processor are written in a small language designed for exactly this purpose.
The OpenTelemetry Transformation Language, usually shortened to OTTL, is a compact language for describing conditions and changes on telemetry. You can think of an OTTL condition as a yes-or-no question about one item: is this span’s name equal to a certain health-check route? Does this log’s severity fall below a chosen level? Does this metric’s name start with a certain prefix? If the answer is yes, the condition is said to be true or met.
An OTTL condition is like a question on a customs form: “Does this parcel contain liquids?” The officer reads the question, looks at the parcel and answers yes or no. A filter processor is a list of such questions, and any yes means the parcel is set aside.
The building blocks of a condition
Paths
Names that point at a piece of the data, such as a span’s name, a log’s severity or an attribute attached to the item.
Comparisons
Operators such as equals, not equals, greater than or less than that compare a path with a value.
Converter functions
Helpers that do small jobs, such as checking whether text matches a pattern, or whether a value starts with certain letters.
Logical words
Words like and, or and not that combine several small questions into one larger one.
Why OTTL is a good fit
Because OTTL is shared by several Collector components, the same way of describing data works in the filter processor, the transform processor and others. Learning it once pays off many times. It is also expressive enough to handle both simple needs, such as matching an exact name, and complex ones, such as combining several attributes in one test.
| Idea in plain words | What the condition looks at |
|---|---|
| Drop the health-check requests | The span’s route or URL attribute |
| Drop debug-level log lines | The log record’s severity |
| Drop a metric nobody uses | The metric’s name |
| Drop everything from a test service | The resource’s service name attribute |
| Drop very low-value data points | The data point’s value or attributes |
Before writing any condition, say it in plain language: “Drop spans whose route is the health check.” Translating a clear sentence into a condition is far easier than inventing the condition directly.
Not every item has every attribute. A condition that looks at an attribute that is absent from some items can be false, empty or even produce an error for them, depending on how it is written. Test with data that includes items that lack the attribute.
5The Golden Rule: Drop When the Condition Is True
This single rule explains how almost every filter behaves, and how almost every filter goes wrong.
In the Filter Processor, you list one or more conditions. If any of those conditions is met for an item, the item is dropped. If none is met, the item continues down the pipeline. The conditions are combined with a logical OR: one yes is enough.
flowchart TD
A["Item arrives at the filter"] --> B{"Is any condition true?"}
B -- Yes --> C["Drop the item"]
B -- No --> D["Pass the item on"]
Imagine a bouncer with a list of reasons to refuse entry: no ticket, wrong dress code, banned from the venue. If a guest matches any one of those reasons, they are turned away. A guest who matches none of them walks in. The list describes who is refused, never who is welcomed.
Thinking in reverse
Because conditions describe what to remove, a rule meant to keep only certain data has to be written as the opposite. If you want to keep only the traces from one service, you cannot simply write “the service is checkout”. That would drop the checkout data and keep everything else. Instead, you write a condition that is true for everything except checkout, using a not-equals comparison.
| What you want | What the condition must describe |
|---|---|
| Remove health checks | Items that are health checks |
| Keep only errors | Items that are not errors |
| Keep only the checkout service | Items whose service is not checkout |
| Keep only warnings and above | Items whose severity is below warning |
Combining conditions
There are two ways to combine ideas, and they behave differently. Several separate conditions in the list are joined by OR: any one of them drops the item. Inside a single condition, the word and joins ideas so that all of them must be true together for that condition to be met.
Separate conditions: OR
Drop the item if the first condition is met, or the second, or the third. Use this to remove several unrelated kinds of data.
The word and: all must be true
Drop the item only if both parts are true. Use this to target a narrow slice, such as debug logs from one specific service.
Problem
Writing a condition that describes the data you want to keep and expecting the filter to retain it.
Why It’s Harmful
The processor drops whatever matches. A rule that describes your important data will delete exactly the data you care about, and may do so silently across an entire production system.
Correct Approach
Always phrase each condition as a description of unwanted data. When you want to keep a narrow set, describe everything outside that set, and test carefully with sample data first.
6Context Levels: How Closely the Filter Can Look
Telemetry is layered like a set of nesting boxes, and the filter can look at any layer.
Telemetry is organised in layers. At the outside is the resource, which describes the thing that produced the data, such as a service or a host. Inside it is the scope, which describes the library or component that created the data. Inside that are the actual items: spans, metrics or log records. For some signals there are even smaller pieces inside those, such as events within a span or data points within a metric. Each of these layers is called a context, and a condition is evaluated in the context that matches the data it looks at.
Think of a parcel delivery. The delivery company is the resource. The van is the scope. The boxes in the van are the items, and the objects inside each box are the finer details. You can ask a question about the company, the van, a box or an object, and each question refers to a different level.
| Signal | Layers from outside to inside |
|---|---|
| Traces | Resource, then scope, then span, then span event |
| Metrics | Resource, then scope, then metric, then data point |
| Logs | Resource, then scope, then log record |
flowchart TD
R["Resource: the service or host"] --> S["Scope: the library that produced the data"]
S --> T["Span / Metric / Log record"]
T --> F["Span event / Data point"]
Outer decisions come first
The filter evaluates the outer layers before the inner ones. If a condition at a higher level is met, the whole thing at that level is dropped, and the inner levels are never examined. For example, if a span is dropped, the filter does not bother to check the events inside that span, because they disappear along with it.
Resource conditions
Checked first. A match removes everything produced by that resource, such as an entire test service.
Scope conditions
Checked next. A match removes everything produced by one library or instrumentation component.
Item conditions
Checked for each span, metric or log record that survived the outer checks.
Fine-grained conditions
Checked last, on span events or metric data points inside the items that were kept.
Letting the processor work out the context
You rarely need to name the context yourself. The processor looks at the path your condition uses and works out which layer it belongs to. A condition that looks at a span’s attributes is understood to be a span-level condition, and one that looks at a log’s severity is understood to be a log-level condition. Naming the context explicitly is possible, but it is seldom necessary.
If you want to remove everything from a noisy test service, use a resource-level condition. It is simpler to read and cheaper to run than checking every individual item.
A condition that mixes information from different layers in a confusing way can behave in surprising ways. Keep each condition focused on one layer, and use separate conditions for separate layers.
7Filtering Traces: Spans and Span Events
Traces are the signal where filtering needs the most care, because spans belong to families.
A trace is the story of one request. It is made of spans, each representing one step, such as a database call or a call to another service. Spans are arranged in a family tree: a parent span can have children, and together they show the full path of the request. A span can also carry span events, which are small timestamped notes recorded during the span, such as an exception being thrown.
Common reasons to filter spans
Health checks and readiness probes
Platforms call a small route again and again to check that the service is alive. Dropping spans for those routes removes a steady stream of data that is almost never investigated.
Static assets and favicons
A web service might create spans for every image or icon request. If those are not relevant to your analysis, a condition on the route or file type removes them.
Internal tools and synthetic traffic
Load tests and uptime monitors can be recognised by an attribute such as a user-agent or a special header marker, and then dropped before they pollute real data.
Very short, repetitive internal spans
Some libraries create many tiny spans of little value. A condition on the span’s name or kind can remove them when you have confirmed that nobody relies on them.
The orphan problem
Dropping a span that has children creates orphaned spans: children whose parent no longer exists in the stored trace. Viewing tools then show a trace with a gap in the middle, or children that float without a visible parent. This can make traces harder to understand, and it can confuse tools that calculate things such as the critical path.
Imagine removing a page from the middle of a family tree. The grandchildren are still on the chart, but the line connecting them to their grandparents is broken. Anyone reading it has to guess how they are related.
flowchart TD
A["Parent span: dropped by the filter"] -.-> B["Child span: kept but orphaned"]
A -.-> C["Child span: kept but orphaned"]
Prefer to drop spans that are leaves, meaning they have no children, such as a health-check endpoint that does little else. If you must drop a parent, consider dropping its children under the same rule so the whole branch disappears together.
Filtering span events
Span events are finer-grained notes inside a span. You can drop specific events while keeping the span itself. This is useful when a library records many repetitive events that add bulk without adding insight. Remember that if the span itself is dropped, its events go with it, so event conditions only run on spans that survived.
If your goal is to reduce the overall volume of traces while keeping a representative picture, sampling is usually the better tool because it makes decisions per trace. Filtering is best when you can name exactly what is unwanted.
8Filtering Metrics: Metrics and Data Points
Metrics can be filtered by name, by type, or by the individual data points inside them.
A metric is a measurement tracked over time, such as the number of requests handled. A single metric usually contains many data points, each representing the value for one particular combination of attributes at one moment. For example, one request-count metric may hold separate data points for each route and status code.
Two levels, two kinds of decisions
Drop a whole metric
Conditions on the metric’s name or type remove the entire metric and all its data points. This is the most common and most effective way to cut unused metrics.
Drop selected data points
Conditions on the attributes or values of data points remove only some of them, leaving the metric itself in place for the rest.
Common reasons to filter metrics
Unused library metrics
Instrumentation libraries and host monitors can produce dozens of metrics by default. If your team only uses a few, dropping the rest by name saves a surprising amount of volume.
Noisy attribute values
Sometimes a metric is useful but certain attribute values create too many data points, such as test environments or an internal route. Data-point conditions can remove only those.
Metrics of a certain type or scope
You might drop all metrics produced by one particular instrumentation library, using a scope-level condition, when you have decided that library’s data is not needed.
A metric is like a spreadsheet, and data points are its rows. Dropping a metric is throwing away the whole spreadsheet. Dropping data points is deleting some rows while keeping the spreadsheet and its remaining rows.
If your data-point conditions remove every data point from a metric, the metric itself is dropped as well, because an empty metric carries no information. This is expected, but it can surprise people who thought the metric would remain as an empty shell.
Before dropping a metric, search your dashboards, alerts and reports for any use of it. Removing a metric that an alert depends on can make the alert go quiet, which looks like good news while actually hiding a problem.
Filtering data points by attribute can reduce the number of unique series a metric produces. If your real concern is too many attribute combinations, also consider removing the attribute itself, since filtering drops data while attribute removal merges it.
9Filtering Logs: Severity, Body and Attributes
Logs are usually the biggest source of volume, which makes them the most rewarding place to filter.
A log record is a single event written down by an application, with a timestamp, a message called the body, a severity that says how important it is, and extra attributes. Severity is the key to the most common log filter. Typical levels run from trace and debug, which are very detailed, through info, warning and error, up to fatal.
| Severity level | Typical meaning | Often kept in production? |
|---|---|---|
| Trace and debug | Very detailed developer information | Usually dropped, or kept only briefly |
| Info | Normal events worth recording | Often kept, sometimes reduced |
| Warning | Something unusual but not yet a failure | Kept |
| Error | A failure that needs attention | Kept |
| Fatal | A failure that stops the application | Kept |
Common reasons to filter logs
Dropping low-severity logs
A condition that is true when severity is below a chosen level removes debug and trace messages in production while keeping the more important ones.
Removing known noisy messages
Some messages repeat endlessly, such as a polling loop reporting that nothing has changed. A condition on the body text, for example whether it contains a certain phrase, can remove them.
Dropping logs from specific sources
Using resource or scope conditions, you can remove all logs from a test service or from one chatty library without touching the rest.
Removing logs with sensitive content
If certain log lines are known to contain data that should never leave your network, dropping them is a blunt but effective protection, although redaction is often a gentler choice.
Logs are like the notes a ship’s crew writes in a diary. The captain wants to read about storms, damage and course changes, but not an hourly note saying the sea is calm. Severity filtering is the editor who removes the calm-sea notes before the diary is printed.
The detailed logs that look wasteful on a quiet day can be exactly what you need during an outage. Consider keeping them available in a cheap storage tier, or switching the filter off temporarily, rather than deleting them forever.
Conditions that look for words inside a log message depend on the exact wording. If developers change the message, the filter silently stops working. Prefer severity or attributes when you can, and treat body matching as a last resort.
10Two Ways to Write the Configuration
The processor offers a simple style for everyday needs and a more detailed style for special cases.
The Filter Processor’s configuration has a section for each signal, and inside each section it groups conditions by the layer they apply to. There are two styles of writing these, and you can choose the one that suits the situation.
A simple list of conditions
For each layer, you provide a plain list of conditions as text. The processor works out the context from the paths used. This is short, readable and enough for most needs.
Groups with their own settings
You provide groups of conditions, each of which can state its own context explicitly and its own error behaviour. This is useful when different groups need different treatment.
| Question | Basic style | Advanced style |
|---|---|---|
| Readability | Very high | Moderate, more detail to read |
| Context | Worked out automatically | Can be stated explicitly |
| Error handling | One setting for the whole processor | Can differ per group |
| Best for | Most everyday filtering | Mixed needs and precise control |
The basic style is a shopping list: a plain line per item. The advanced style is a shopping list with notes beside each line, such as which shop to visit and what to do if the item is out of stock. Most days, the plain list is all you need.
Begin with the basic style, and move to the advanced style only when you have a specific reason, such as needing different error behaviour for different groups. Simpler configurations are easier to review and to trust.
11When Conditions Fail: Error Modes
What should the filter do when a condition cannot be evaluated?
Sometimes a condition cannot be evaluated for a particular item. It might refer to an attribute that is missing, or try to compare values of different kinds. The processor needs a policy for this situation, and that policy is controlled by a setting called error mode. It has three possible values.
Ignore
Record the problem in the Collector’s own logs and carry on with the item. Per the current documentation this is the default behaviour.
Silent
Carry on without recording anything. Useful when failures are expected and logging them would only create more noise.
Propagate
Treat the error as serious and pass it back up the pipeline, which means the affected data is dropped and the problem is reported.
| Mode | Is the problem recorded? | Does processing continue? | Best used when |
|---|---|---|---|
| Ignore | Yes, in the Collector’s logs | Yes | You want visibility without interruptions |
| Silent | No | Yes | Failures are expected and harmless |
| Propagate | Yes, as an error | No, the payload is dropped | Correctness matters more than delivery |
Imagine a factory inspector who cannot read the label on one product. In ignore mode, the inspector writes a note and lets the product continue. In silent mode, the inspector lets it pass without a word. In propagate mode, the inspector stops the whole conveyor belt and sounds an alarm.
Defaults can change between releases. Read the documentation that matches the Collector version you run, and set the error mode explicitly in your configuration so your behaviour does not change by surprise after an upgrade.
In ignore mode, errors appear only in the Collector’s own logs. Make sure someone reads them, at least when a configuration is new, so that a condition that never works does not go unnoticed for months.
12Where to Place the Filter in a Pipeline
Processors run in the order they are listed, so position is part of the design.
The Collector applies processors one after another, in exactly the order they appear in the pipeline. The output of one becomes the input of the next. For the Filter Processor, the best position is usually early, because dropping unwanted data first means that later processors do less work.
Memory protection first
A memory limiter belongs at the very start, so that the Collector can refuse data before it is overwhelmed.
Filtering early
Drop unwanted data before spending effort enriching, transforming or batching it.
Enrichment and transformation
Add context, rename or tidy attributes on the remaining data.
Batching last
Group the final data into efficient bundles just before it is exported.
flowchart LR
A["Receiver"] --> B["Memory limiter"]
B --> C["Filter processor"]
C --> D["Transform or enrich"]
D --> E["Batch"]
E --> F["Exporter"]
When filtering should come later
Sometimes a filter needs information that another processor adds. If your condition depends on an attribute that a resource-detection or transform step creates, the filter must come after that step. The rule of thumb is that a filter should come as early as possible, but never earlier than the processor that produces the data it depends on.
Imagine a factory that washes, labels and boxes vegetables. Rotten ones should be removed early, before wasting soap on them. But if the only way to tell good from bad is to read the label, then the labelling must come before the inspection.
A batch processor groups items into bundles. Placing filters after it means working on groups instead of individual items and wastes the efficiency that early dropping provides. Keep batching as the last processor.
13Filtering Compared With Its Neighbours
Several tools reduce or reshape telemetry. Picking the right one avoids a lot of trouble.
The Filter Processor is not the only way to reduce data. It helps to know how it differs from related tools so you can choose the right one for each job.
| Tool | What it does | Decision basis | Best for |
|---|---|---|---|
| Filter processor | Drops items that match rules | Content of each item | Removing known unwanted data |
| Sampling | Keeps a fraction of traces | Probability or trace-level policy | Reducing trace volume while staying representative |
| Attributes or transform processors | Add, change or remove fields inside items | Rules on the content | Tidying and redacting data you keep |
| Routing | Sends items to different pipelines | Content of each item | Sending data to different destinations |
| View in the SDK | Shapes metrics inside the application | Instrument and attribute rules | Cutting metric cost before data leaves the process |
You can name the unwanted data
Health checks, debug logs, a test service or a specific unused metric are clear targets.
You want a representative share
When every trace looks alike and you only need enough to understand behaviour, sampling avoids bias that content rules might introduce.
You want to keep but reshape
Redacting a value, renaming an attribute or trimming long text keeps the item while fixing its content.
Different data needs different homes
If some data should go to a cheaper store while the rest goes to a premium service, routing splits the stream rather than dropping any of it.
A filter is a bin for rubbish, sampling is taking a spoonful from a large pot to taste it, transform is washing and trimming vegetables, and routing is sorting the post into different bags. Each tool answers a different question about what to do with a pile of stuff.
A typical gateway uses several of these together: filter out known noise, transform to redact sensitive values, sample traces to control volume and route different signals to different backends. Each tool handles the part of the job it is best at.
14Real-World Scenarios
Five everyday situations show how filtering is used in practice.
Scenario 1: The chatty health check
A container platform calls a service’s health route every two seconds across hundreds of copies. The traces from those calls account for a large share of all stored traces and nobody ever looks at them. A span-level condition on the route removes them, and trace storage costs fall noticeably while the real request traces are untouched.
Scenario 2: Debug logs left on in production
After an incident, a team switched on debug logging and forgot to switch it off. Log volume tripled. As a quick, safe fix, the platform team adds a log condition that drops anything below info severity at the gateway while the applications are redeployed with the correct setting.
Scenario 3: A noisy library’s metrics
A web framework publishes dozens of metrics that the team has never graphed. After checking dashboards and alerts to confirm that none of them are used, the team drops the unused metrics by name and sees a visible reduction in the number of active series.
Scenario 4: The load-testing environment
A performance team runs heavy synthetic traffic against a shared environment. Their requests carry a recognisable attribute. A filter condition removes everything with that attribute from production pipelines, so tests do not distort real usage dashboards or inflate bills.
Scenario 5: Keeping only what the vendor needs
A company must send only certain services’ data to an external support vendor. At a dedicated gateway, a resource-level condition drops anything not belonging to the approved services before the vendor exporter is reached.
flowchart TD
A["Is the data clearly unwanted?"] -- Yes --> B["Can a rule name it precisely?"]
A -- No --> G["Consider sampling or leave it"]
B -- Yes --> C["Filter it, test, then roll out"]
B -- No --> D["Use sampling, transform or routing"]
15Advantages and Trade-offs
Filtering is powerful, and like every powerful tool it needs respect.
Advantages
- Reduces storage, network and backend costs
- Improves the signal-to-noise ratio of your data
- Applies the same policy to many applications from one place
- Uses a shared, expressive language for rules
- Works on traces, metrics and logs at fine granularity
- Requires no changes to application code
Trade-offs
- Dropped data cannot be recovered later
- A wrong condition can silently delete important data
- Dropping spans can leave orphaned children in traces
- Rules can drift out of date as applications change
- Evaluating many conditions adds processing work
- Dropped data still consumes network up to the Collector
Filtering is like emptying a rubbish bin: it is wonderful for tidiness, but you cannot take something back once the truck has collected it. That is why careful people look inside before they tip.
Every condition costs a little processing time for every item. A very long list of complicated conditions on a high-volume pipeline can become a measurable load. Keep rules lean, and check the Collector’s own CPU use after adding a large filter.
16Pitfalls and Anti-Patterns
These mistakes appear again and again, and every one of them is avoidable.
Problem
Deploying a new filter directly to production without testing it against realistic data.
Why It’s Harmful
A condition that matches more than intended removes valuable data immediately, and the loss may not be noticed until someone needs the data during an incident.
Correct Approach
Test in a non-production pipeline first, compare counts before and after, and roll out gradually.
Problem
Dropping parent spans while keeping their children.
Why It’s Harmful
Traces become fragmented, with children that appear to have no parent. Latency analysis and trace views become confusing.
Correct Approach
Drop leaf spans where possible, or remove whole branches together, and check how traces look after the change.
Problem
Dropping a metric without checking whether alerts or dashboards depend on it.
Why It’s Harmful
Alerts that depend on the metric go quiet, which looks like good news but actually removes a safety net.
Correct Approach
Search every dashboard, alert and report for the metric’s name before dropping it, and announce the change to the teams that might use it.
Problem
Relying on matching free-text log messages to decide what to drop.
Why It’s Harmful
Small wording changes by developers break the match without warning, so noise returns, or worse, unrelated messages that happen to contain the phrase are dropped.
Correct Approach
Prefer severity or structured attributes, and ask development teams to add a stable marker attribute to messages that should be filtered.
Problem
Writing a condition that describes the data to keep, forgetting that matching data is dropped.
Why It’s Harmful
The filter deletes exactly the data you care about and keeps the rest.
Correct Approach
Phrase every condition as a description of unwanted data, and read each one aloud as “drop items where this is true”.
Problem
Never reviewing filter rules after they are written.
Why It’s Harmful
Applications change names, routes and attributes. Old rules either stop matching or match unrelated new data.
Correct Approach
Keep a comment beside each condition explaining its purpose and owner, and review the list on a regular schedule.
17Testing and Rolling Out a Filter Safely
Because dropped data is gone for good, a careful rollout is part of the design.
The safest way to introduce a filter is to treat it like any change that can remove data: test it, measure it, and increase its reach gradually. The documentation itself advises testing configurations thoroughly against your real data patterns, because the exact shape of real telemetry is often different from what people imagine.
Say the rule in plain words
Write one clear sentence for each condition, naming what is dropped and why. Share it with the people who own the affected services.
Count before you change
Record how many items match the idea in your current data, using your backend’s search tools. This tells you what to expect.
Try it in a test pipeline
Run the filter in a non-production Collector with realistic sample data and a visible debug output, and confirm that only the intended items disappear.
Include awkward items
Test items that lack the attribute, have unusual values, or sit at different layers, because these are where conditions most often misbehave.
Roll out to a small slice first
Apply the filter to one Collector or one environment, watch the data volumes and the Collector’s own logs, then widen gradually.
Compare after the change
Check that volumes fell by the expected amount, that dashboards and alerts still work, and that important items are still arriving.
Introducing a filter is like adding a new rule at a border crossing. You do not start by applying it to every traveller on day one. You trial it at a single gate, watch who is turned away, and only then roll it out to the whole border.
The Collector reports its own metrics about items received, refused and dropped. Watching these before and after a change gives you hard evidence that the filter is doing what you meant, and an early warning if it starts removing more than expected.
Keep the previous configuration in version control so that you can restore it quickly. If a filter turns out to be too aggressive, a fast rollback limits how much useful data is lost.
18Cost, Privacy and Compliance Angles
Filtering is often introduced to save money, but it also plays a part in privacy and governance.
Controlling cost
Most monitoring services charge by the volume of data ingested, the number of active metric series, or both. A filter that removes health-check traces, debug logs and unused metrics before they leave your network cuts those charges directly. It also lowers network traffic and the load on the rest of your pipeline.
Protecting privacy
Telemetry sometimes contains information that should not travel far: names, email addresses, tokens or other personal details accidentally written into log messages or attributes. A filter can remove whole items known to contain such details, which is a simple and robust form of protection. When you want to keep the item but remove only the sensitive field, a transform or attributes processor is usually a better fit.
Removing entire risky items
Drop logs from a component known to print sensitive data, or traffic from a source that should never be exported.
Cleaning one field
Mask or delete a single attribute while keeping the rest of the item useful for debugging.
Meeting data-handling rules
Some organisations must keep certain categories of data inside a region or away from third parties. A gateway Collector with filters can enforce this by dropping the restricted data before it reaches an external exporter. Because this is a policy decision, record it clearly and have the responsible team approve the rules.
A filter only removes what its rules describe. Sensitive data in unexpected places will pass straight through. Combine filtering with careful instrumentation, redaction and review, and avoid putting sensitive information into telemetry in the first place.
19Best Practices Checklist
Keep this list beside you whenever you write or review a filter.
Do
- Describe unwanted data in each condition, reading it as “drop where this is true”
- Place the filter early, after the memory limiter and before enrichment and batching
- Use the highest layer that fits, such as resource-level for a whole service
- Prefer structured attributes and severity over free-text matching
- Set the error mode explicitly and watch the Collector’s own logs
- Check dashboards and alerts before dropping any metric
- Test with realistic data, including items that lack the attribute
- Comment each rule with its purpose and owner, and review regularly
Do Not
- Assume that matching data is kept
- Drop parent spans without considering their children
- Deploy to production without testing
- Rely on message wording that developers may change
- Use filtering when sampling is the right tool for trace volume
- Forget to add the processor to a pipeline after defining it
- Leave stale rules in place after applications change
- Treat filtering as your only privacy control
The five-second review
Before you ship a filter, ask four questions. What exactly will this drop? How do I know the amount is what I expect? Who depends on this data? And how fast can I undo this if I am wrong? If all four answers are clear, you are ready.
20Frequently Asked Questions
Quick answers to the questions beginners ask most often.
It removes telemetry that matches conditions you define. Items that match are dropped, and everything else continues down the pipeline.
Traces, metrics and logs, and in newer versions profiles as well, though the support for profiles has been described as less mature. Check the documentation for your version for the current status of each signal.
What to drop. If any condition in the list is met for an item, that item is removed. To keep only certain data, describe everything outside that set.
Separate conditions in the list are combined with OR, so any one match drops the item. Inside a single condition, the word and requires all parts to be true together.
The OpenTelemetry Transformation Language, known as OTTL, which is shared by several Collector components.
They are dropped with it. Higher-level matches prevent lower-level checks, so events are only evaluated for spans that survived.
The metric itself is dropped too, because a metric with no data points carries no information.
If you drop a parent span, its children become orphans in the stored trace, which can make traces look broken and complicate analysis. Prefer dropping leaf spans, or whole branches together.
Ignore logs the problem and continues, silent continues without logging, and propagate returns the error and drops the affected payload. Set the mode explicitly rather than relying on a default.
Usually early: after the memory limiter, before enrichment and transformation, and well before batching. The exception is when your condition needs an attribute that another processor creates.
No. Filtering removes items that match content rules. Sampling keeps a fraction of traces, based on probability or policy, to reduce volume while staying representative.
The most common cause is that the processor was defined but never added to a pipeline in the service section. Other causes are a condition that never matches, or a typo in an attribute name.
No, not from the Collector. Once an item is dropped, it is gone, which is why testing and gradual rollout matter so much.
21Summary and Key Takeaways
The Filter Processor is the guard at the door of an OpenTelemetry Collector pipeline. It checks each item of telemetry against conditions written in OTTL and drops the items that match, whether those items are spans, span events, metrics, data points or log records. Its golden rule is easy to state and easy to forget: a condition describes what to remove, not what to keep, and any single true condition is enough. Because it can look at several layers, from the whole resource down to a single data point, it can remove very precisely targeted slices of data. Used carefully, early in the pipeline, with tested rules and a safe rollout, it cuts cost, reduces noise and helps protect sensitive data, while the cautions about orphaned spans, emptied metrics and fragile text matching keep you from deleting something you will later need.
Key Takeaways
- It drops what matches — conditions describe unwanted data, and any one true condition removes the item.
- It speaks OTTL — rules are small yes-or-no questions about paths, values and attributes of each item.
- Layers matter — resource, scope, item and fine-grained levels let you target anything from a whole service to one data point.
- Mind the side effects — dropping parent spans orphans their children, and emptying a metric removes the metric itself.
- Place it early — after the memory limiter and before enrichment and batching, unless a condition needs a later attribute.
- Choose the right tool — use filtering for known noise, sampling for representative trace volume, transform for reshaping and routing for different destinations.
- Test, roll out, review — dropped data is gone for good, so verify with real data, roll out gradually and keep rules documented and current.