githubEdit

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

circle-info

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 Configurationarrow-up-right.

filter.source and filter.destination blocks

The 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.

  • address attribute

    Filter 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 RFC1918arrow-up-right, but exclude 10.0.0.0/24, and 10.0.2.1

    filter "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"]
      }
    }
  • port attribute

    Filter 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 port

      filter "destination" {
        port = {
          match = ["443"]
        }
      }
    • Include flows with only Linux ephemeralarrow-up-right 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 source and destination filters 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

The 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.

  • transport attribute

    Filter by transport protocol.

    Type: Pattern matcher object

    Default: {}

    Supported values: tcp, udp, icmp, icmpv6 (supports globsarrow-up-right)

    Examples:

    • Include only TCP and UDP traffic:

    • Exclude ICMP:

  • type attribute

    Filter by IP version.

    Type: Pattern matcher object

    Default: {}

    Supported values: ipv4, ipv6 (supports globsarrow-up-right)

    Example: Include only IPv4 traffic:

  • interface_name attribute

    Filter by network interface name.

    Type: Pattern matcher object

    Default: {}

    Supported values: Any valid interface name (supports globsarrow-up-right)

    Examples:

    • Include only interfaces matching eth* or enp* (eth0, eth1, enp0s3, enp8s0f0):

    • Exclude interfaces matching docker* (docker0, docker1, docker-wec2323):

  • interface_index attribute

    Filter 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 1 to 27 and 30:

  • interface_mac attribute

    Filter by network interface MAC address.

    Type: Pattern matcher object

    Default: {}

    Supported values: Any valid MAC address (supports globsarrow-up-right)

    Example: Exclude a specific MAC address:

filter.flow block

The 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.

Object Types

Pattern Matcher Object

  • match attribute

    Include flows matching the pattern

    Type: List of strings

    Default: [] (empty list, include all)

  • not_match attribute

    Exclude 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 address arguments, for example:

    • 10.0.0.0/8: CIDR notation, matches the subnet

    • 10.0.0.1: IP address, equals the 10.0.0.1/32 subnet

  • Ranges, used in the port, interface_index, ip_ttl, ip_flow_label, icmp_code_name arguments, support ranges. For example:

    • 80: Single port

    • 8000-8999: Port range

    • 0: Single interface index

    • 0-22: Interface index range

    • 64: Single TTL

    • 64-128: TTL range

    • 12345: Single Flow Label

    • 12345-12445: Flow Label range

    • 0: Single ICMP code

    • 0-8: ICMP code range

  • Arbitrary strings, used in more generic arguments like transport names, interface names, and others. Supports globsarrow-up-right. For example:

    • tcp: Protocol names

    • close_wait: Connection states

    • eth*: 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

  1. Start permissive: Begin with no filters, add as needed

  2. Monitor impact: Check flow reduction with metrics

  3. Test incrementally: Add one filter at a time

  4. Document rationale: Comment why filters are applied

  5. Use match/not_match carefully: Match patterns can hide important traffic

Next Steps

  1. Tune Flow Generation: Configure timeouts and thresholds

  2. Set Up OTLP Export: Send filtered flows to your backend

Need Help?

Last updated