Match
The Match filter’s job is to provide a mechanism to change behaviour based
on dynamic metadata. This filter behaves similarly to the match expression
in Rust or switch statements in other languages.
Filter name
quilkin.filters.match.v1alpha1.Match
Configuration Examples
#![allow(unused)]
fn main() {
let yaml = "
version: v1alpha1
clusters:
- endpoints:
- address: 127.0.0.1:26000
- address: 127.0.0.1:26001
filters:
- name: quilkin.filters.capture.v1alpha1.Capture
config:
metadataKey: myapp.com/token
prefix:
size: 3
remove: false
- name: quilkin.filters.match.v1alpha1.Match
config:
on_read:
metadataKey: myapp.com/token
branches:
- value: abc
name: quilkin.filters.pass.v1alpha1.Pass
fallthrough:
name: quilkin.filters.drop.v1alpha1.Drop
";
let config = quilkin::config::Config::from_reader(yaml.as_bytes()).unwrap();
assert_eq!(config.filters.load().len(), 2);
}
Configuration Options (Rust Doc)
$schema: https://json-schema.org/draft/2020-12/schema
title: Config
description: Configuration for [`Match`][super::Match].
type: object
properties:
on_read:
description: Configuration for [`Filter::read`][crate::filters::Filter::read].
anyOf:
- $ref: '#/$defs/DirectionalConfig'
- type: 'null'
on_write:
description: Configuration for [`Filter::write`][crate::filters::Filter::write].
anyOf:
- $ref: '#/$defs/DirectionalConfig'
- type: 'null'
additionalProperties: false
$defs:
Branch:
description: |-
A specific match branch. The filter is run when `value` matches the value
defined in `metadata_key`.
type: object
properties:
config: true
label:
type:
- string
- 'null'
name:
type: string
value:
description: The value to compare against the dynamic metadata.
$ref: '#/$defs/Value'
required:
- value
- name
Bytes:
type:
- array
- string
items:
type: integer
format: uint8
maximum: 255
minimum: 0
DirectionalConfig:
description: Configuration for a specific direction.
type: object
properties:
branches:
description: List of filters to compare and potentially run if any match.
type: array
items:
$ref: '#/$defs/Branch'
fallthrough:
description: The behaviour for when none of the `branches` match.
$ref: '#/$defs/Fallthrough'
default:
config: null
label: null
name: quilkin.filters.drop.v1alpha1.Drop
metadataKey:
description: The key for the metadata to compare against.
$ref: '#/$defs/Key'
required:
- metadataKey
- branches
Fallthrough:
description: The behaviour when the none of branches match. Defaults to dropping packets.
$ref: '#/$defs/Filter'
Filter:
description: Filter is the configuration for a single filter
type: object
properties:
config: true
label:
type:
- string
- 'null'
name:
type: string
additionalProperties: false
required:
- name
Key:
description: A key in the metadata table.
type: string
Value:
anyOf:
- type: boolean
- type: integer
format: uint64
minimum: 0
- type: array
items:
$ref: '#/$defs/Value'
- type: string
- $ref: '#/$defs/Bytes'
View the Match filter documentation for more details.
Metrics
quilkin_filter_int_counter{label="packets_matched_total"}A counter of the total number of packets where the dynamic metadata matches a branch value.quilkin_filter_int_counter{label="packets_fallthrough_total"}A counter of the total number of packets that are processed by the fallthrough configuration.