Skip to main content

Module filter_pattern

Module filter_pattern 

Source
Expand description

CloudWatch Logs filter pattern evaluator used by metric filters.

Supports the documented variants:

  • Empty pattern matches everything.
  • Quoted phrase: substring match of the literal text inside the quotes.
  • Plain string (single token): substring match.
  • Space-separated terms: AND match (all terms must appear in the message).
  • JSON pattern { <expr> }: parses the message as JSON, evaluates a boolean expression with =, !=, >, <, >=, <=, &&, ||.

Independent from the simpler matches_filter_pattern helper in service/mod.rs; metric filters need || plus JSON-path value extraction for MetricValue = $.field, which the older helper doesn’t expose.

Array-style patterns ([a, b, c]) match positionally against whitespace-separated tokens in the message. Each comma-separated field is either a bare name (always matches that slot), a quoted string, a literal value for equality, or a comparison =v, !=v, >=v, <=v, >v, <v. ... is a wildcard that skips any number of tokens.

IS NULL and free-form regex are out of scope and fail closed.

Functions§

matches
Returns true when message matches the given filter pattern.
resolve_metric_value
Resolve the literal MetricValue from a metric filter transformation.