Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,29 @@ Unquoted literals can contain all UTF-8 characters other than the reserved chara

Double-quoted strings can contain all UTF-8 characters. Unlike unquoted literals, there are no reserved characters. However, literal double quotes and backslashes must be escaped with a single backslash. For example, to match the regular expression `\d+` the backslash must be escaped `"\\d+"`. This is because double-quoted strings follow the same rules as Go's [string literals](https://go.dev/ref/spec#String_literals). Double-quoted strings also support UTF-8 code points. For example, `"foo!"`, `"bar,baz"`, `"\"baz qux\""` and `"\xf0\x9f\x99\x82"`.


> **Note: YAML quoting vs. matcher token quoting**
>
> Each entry in a `matchers:` list is a single YAML value. YAML quoting applies
> to the *entire* matcher string — it does not parse or protect individual tokens
> within it. The double-quoting described above is handled by Alertmanager's own
> parser after YAML has already processed the input.
>
> - **Plain style** (no surrounding quotes): works when the matcher contains no
> YAML special characters (`{`, `}`, `[`, `]`, `,`, `#`, `|`, `>`, `:`).
> Example: `env !~ preprod`
> - **Single-quoted style** (recommended): protects against all YAML special
> characters and allows literal double quotes inside the matcher.
> Example: `'env =~ "prod|staging"'`
> - **Double-quoted style**: supports YAML escape sequences; literal double quotes
> inside the value must be escaped as `\"`.
> Example: `"env !~ \"uat\""`
>
> Writing `env =~ "prod"` without surrounding YAML quotes is valid plain-style
> YAML. The inner double quotes are stripped by Alertmanager's parser and provide
> **no** protection against YAML special characters. Always quote the entire
> matcher at the YAML level when the value may contain special characters.

#### Classic matchers

A classic matcher is a string with a syntax inspired by PromQL and OpenMetrics. The syntax of a classic matcher consists of three tokens:
Expand Down