Overview
Thefilter transform filters events based on a set of conditions. Events that match the condition are forwarded to the next component. Events that don’t match are dropped.
This is one of the simplest and most commonly used transforms in Vector, ideal for:
- Dropping unwanted log lines
- Sampling events
- Routing specific event types
- Reducing data volume
- High performance (function transform)
- Supports all event types (logs, metrics, traces)
- VRL-based conditions
- Built-in metrics for dropped events
Configuration
The condition that every input event is matched against.If an event matches the condition, it is forwarded. Otherwise, the event is dropped.Conditions can be specified using VRL expressions or structured condition types.
Inputs
List of upstream component IDs.
Outputs
The filter transform has a single default output that emits only events that match the condition. Dropped events are counted in thefilter_events_dropped_total internal metric.
Examples
Filter by Log Level
Filter by Field Existence
Filter with Multiple Conditions
Filter by Message Content
Filter Metrics by Tag
Regex-based Filtering
Numeric Comparisons
Complex VRL Conditions
Filter by Timestamp
Sampling with Filter
Type-based Filtering
Structured Condition Types
Vector supports structured condition configuration:Negating Conditions
Multiple Field Checks
Condition Syntax
Thecondition field accepts VRL expressions that return a boolean value:
Comparison Operators
==- Equal to!=- Not equal to>- Greater than<- Less than>=- Greater than or equal<=- Less than or equal
Logical Operators
&&- Logical AND||- Logical OR!- Logical NOT
Common Functions
contains(field, substring)- Check if string contains substringmatch(field, regex)- Match against regex patternexists(field)- Check if field existsstarts_with(field, prefix)- Check if string starts with prefixends_with(field, suffix)- Check if string ends with suffixis_nullish(field)- Check if field is null or doesn’t exist
Use Cases
Security Event Filtering
Cost Optimization
Multi-tenant Filtering
Data Quality
Performance Considerations
Efficiency
The filter transform is a function transform, meaning it processes events synchronously with minimal overhead. It’s one of the fastest transforms in Vector.Placement in Pipeline
For optimal performance, place filters early in your pipeline to reduce the number of events processed by downstream components:Condition Complexity
Simple conditions are faster than complex ones:Metrics
The filter transform emits the following internal metrics:component_received_events_total- Total events receivedcomponent_sent_events_total- Total events forwarded (matched condition)filter_events_dropped_total- Total events dropped (didn’t match)
Alternatives
Using Remap for Filtering
For more complex logic, consider usingremap with conditional abort:
Using Route for Multiple Outputs
If you need to send events to different destinations based on conditions, use theroute transform instead:
Troubleshooting
No Events Passing Through
If no events are being forwarded:- Check that the condition syntax is valid VRL
- Test the condition with sample data using
vector vrl - Temporarily simplify the condition to isolate the issue
- Check that field names match exactly (case-sensitive)
All Events Passing Through
If all events pass through (none are filtered):- Verify the condition returns
falsefor events you want to drop - Check for typos in field names
- Ensure field values match expected types and formats
Unexpected Drops
If events are being dropped unexpectedly:- Check metrics:
filter_events_dropped_total - Log the condition evaluation:
See Also
- Remap Transform - More powerful data transformation
- Route Transform - Send events to multiple outputs
- VRL Conditions - VRL language reference
- Conditions Reference - Condition types