Configure Filtering of Flow Spans
Block: filter.source/filter.destination/filter.network/filter.flow
Flow filtering allows you to include or exclude network flows based on various criteria. This reduces data volume and focuses on relevant traffic.
Mermin supports filtering flows by:
Source/destination IP addresses and ports
Network protocols and interface names
TCP flags, ICMP types
Connection states
Filter option names are derived directly from FlowSpan attribute names defined in the semantic conventions and can be referenced easily in the attributes reference. The attribute's dot notation is converted to underscores (e.g., flow.tcp.flags.tags becomes tcp_flags_tags). This 1:1 mapping ensures consistency and makes it easy to identify which attribute each filter targets.
Configuration
A full configuration example can be found in the Default Configuration.
filter.source and filter.destination blocks
filter.source and filter.destination blocksThe filters apply to the source/destination combination of the address and port in the flow span. Filter is applied at the "Flow Producer" stage (architecture), which can help reduce resource usage in subsequent stages.
addressattributeFilter by IP address.
Type: Pattern matcher object
Default:
{}Supported values: IP or CIDR notation (
10.0.0.0/8,10.0.0.1)Example: Include only RFC1918, but exclude
10.0.0.0/24, and10.0.2.1filter "source" { address = { match = ["10.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16"] not_match = ["10.0.0.0/24", "10.0.2.1"] } }portattributeFilter by port.
Type: Pattern matcher object
Default:
{}Supported values: Port or port range as a string (
443,8000-9000)Examples:
Include flows with only
443(HTTPS) destination portfilter "destination" { port = { match = ["443"] } }Include flows with only Linux ephemeral source ports
filter "source" { port = { match = ["32000-60999"] } }
Notes
The result of the filter.source/filter.destination inclusion/exclusion is combined with an "AND" condition, meaning it is very easy to accidentally exclude flows you want to observe. For example:
Matching only private subnets will filter out any flow originating from public subnets. The configuration:
Flows:
Matching the same port in the
sourceanddestinationfilters will filter out almost all flows. Although, theoretically, source and destination ports can be the same (e.g., old DNS servers), it is relatively uncommon to see the same source and destination port. The configuration:Flows:
filter.network block
filter.network blockThe filter applies to various network attributes in the flow span, such as transport protocol, interface, and others. Filter is applied at the "Flow Producer" stage (architecture), which can help reduce resource usage in subsequent stages.
transportattributeFilter by transport protocol.
Type: Pattern matcher object
Default:
{}Supported values:
tcp,udp,icmp,icmpv6(supports globs)Examples:
Include only TCP and UDP traffic:
Exclude ICMP:
typeattributeFilter by IP version.
Type: Pattern matcher object
Default:
{}Supported values:
ipv4,ipv6(supports globs)Example: Include only IPv4 traffic:
interface_nameattributeFilter by network interface name.
Type: Pattern matcher object
Default:
{}Supported values: Any valid interface name (supports globs)
Examples:
Include only interfaces matching
eth*orenp*(eth0,eth1,enp0s3,enp8s0f0):Exclude interfaces matching
docker*(docker0,docker1,docker-wec2323):
interface_indexattributeFilter by network interface index.
Type: Pattern matcher object
Default:
{}Supported values: Any valid interface index or interface index range as a string (
0,1-27)Examples:
Exclude only interface index 2:
Include only interfaces
1to27and30:
interface_macattributeFilter by network interface MAC address.
Type: Pattern matcher object
Default:
{}Supported values: Any valid MAC address (supports globs)
Example: Exclude a specific MAC address:
filter.flow block
filter.flow blockThe filter applies to various flow attributes in the flow span, such as connection state, TCP flags and others. Filter is applied at the "Flow Producer" stage (architecture), which can help reduce resource usage in subsequent stages.
connection_stateattributeFilter by TCP connection state.
Type: Pattern matcher object
Default:
{}Supported values: Any valid connection state,
established,syn_sent,syn_received,fin_wait,close_wait,closing,last_ack,time_wait,closed(supports globs)Example: Include only established connections:
tcp_flags_tagsattributeFilter by TCP flags.
Type: Pattern matcher object
Default:
{}Supported values:
SYN,ACK,FIN,RST,PSH,URG(supports globs), case insensitive.Example: Include only flows with SYN flag:
ip_dscp_nameattributeFilter flows based on the DSCP (Differentiated Services Code Point) names.
Type: Pattern matcher object
Default:
{}Supported values: Any valid DSCP name (supports globs)
Examples:
Include only low-latency data (
AF21)Exclude multimedia conferencing (
AF41,AF42,AF43)
ip_ecn_nameattributeFilter flows based on ECN (Explicit Congestion Notification) values.
Type: Pattern matcher object
Default:
{}Supported values: Any valid ECN value (supports globs)
Examples:
Include only ECN-capable transport (
ECT0,ECT1)Exclude congestion encountered (
CE)
ip_ttlattributeFilter flows based on the IP TTL (Time To Live) values.
Type: Pattern matcher object
Default:
{}Supported values: Any valid TTL or TTL range as a string (
1,64-184)Examples:
Include only packets with the TTL
1and64to128Exclude packets with the TTL
64
ip_flow_labelattributeFilter flows based on IPv6 flow labels.
Type: Pattern matcher object
Default:
{}Supported values: Any valid flow label or label range (
2145,12345-12545)Examples:
Include only flows with label 12345
Exclude flows with labels in a range
icmp_type_nameattributeFilter flows based on ICMP type names (converted to a snake case).
Type: Pattern matcher object
Default:
{}Supported values: Any valid ICMP type name (supports globs)
Examples:
Include only echo requests
Exclude destination unreachable
icmp_code_nameattributeFilter flows based on ICMP codes.
Type: Pattern matcher object
Default:
{}Supported values: Any valid ICMP code or code range as a string (
13,0-8)Examples:
Include codes from
0to8and13Exclude code
3
Object Types
Pattern Matcher Object
matchattributeInclude flows matching the pattern
Type: List of strings
Default:
[](empty list, include all)not_matchattributeExclude flows matching the pattern
Type: List of strings
Default:
[](empty list, exclude none)
Matcher value types
Although matcher patterns are strings only, there are multiple types that are supported:
IP addresses and CIDRs, used in the
addressarguments, for example:10.0.0.0/8: CIDR notation, matches the subnet10.0.0.1: IP address, equals the10.0.0.1/32subnet
Ranges, used in the
port,interface_index,ip_ttl,ip_flow_label,icmp_code_namearguments, support ranges. For example:80: Single port8000-8999: Port range0: Single interface index0-22: Interface index range64: Single TTL64-128: TTL range12345: Single Flow Label12345-12445: Flow Label range0: Single ICMP code0-8: ICMP code range
Arbitrary strings, used in more generic arguments like transport names, interface names, and others. Supports globs. For example:
tcp: Protocol namesclose_wait: Connection stateseth*: Interface names
Common Filtering Scenarios
HTTP/HTTPS Only
The following configuration captures flows with HTTP/HTTPS destination.
Example flows:
Exclude Internal Traffic
The following configuration captures flows originating from non-local addresses:
TCP Only, Established Connections
The following configuration captures flows for established TCP connections.
Best Practices
Start permissive: Begin with no filters, add as needed
Monitor impact: Check flow reduction with metrics
Test incrementally: Add one filter at a time
Document rationale: Comment why filters are applied
Use
match/not_matchcarefully: Match patterns can hide important traffic
Next Steps
Tune Flow Generation: Configure timeouts and thresholds
Set Up OTLP Export: Send filtered flows to your backend
Review Complete Configurations: Production-ready filter examples
Deployment Examples: End-to-end configurations
Need Help?
Troubleshoot Missing Flows: Diagnose over-filtering
GitHub Discussions: Share filter configurations
Last updated