Skip to content

Commit 44e807c

Browse files
Add docs for modes
Signed-off-by: George Robinson <george.robinson@grafana.com>
1 parent 572d9d5 commit 44e807c

File tree

1 file changed

+42
-7
lines changed

1 file changed

+42
-7
lines changed

docs/configuration.md

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -419,22 +419,57 @@ source_matchers:
419419

420420
Label matchers match alerts to routes, silences, and inhibition rules.
421421

422-
**Important**: Prometheus is adding support for UTF-8 in the metric name and labels. Alertmanager versions <version> and newer have a new parser for label matchers that has backwards incompatible changes. While most matchers will be forward-compatible, some will not. Alertmanager is operating a transition period where it supports both UTF-8 and classic matchers, and has provided a number of tools to help you prepare for the transition.
422+
**Important**: Prometheus is adding support for UTF-8 in the metric name and labels. Alertmanager versions <version> and newer have a new parser for label matchers that has a number of backwards incompatible changes. While most matchers will be forward-compatible, some will not. Alertmanager is operating a transition period where it supports both UTF-8 and classic parsers, and has provided a number of tools to help you prepare for the transition.
423423

424-
By default, Alertmanager runs with support for both UTF-8 and classic matchers. As operators, you should not experience any difference in how your routes, silences or inhibition rules work. If your Alertmanager configuration contains matchers that are incompatible with the UTF-8 parser, Alertmanager will use the classic parser and log a warning. This warning also includes a suggestion on how to make the matcher compliant with the UTF-8 parser. For example:
424+
### Modes
425425

426-
> Alertmanager is moving to a new parser for labels and matchers, and this input is incompatible. Alertmanager has instead parsed the input using the old matchers parser as a fallback. To make this input compatible with the new parser please make sure the regular expression or value is double-quoted. If you are still seeing this message please open an issue." input="foo=!bar" err="4:5: !: expected one of '=~': expected label value" suggestion="foo=\"!bar\""
426+
#### Default behavior
427427

428-
If you need to disable the new parser you can do so with the following feature flag:
428+
By default, Alertmanager runs in a special mode called fallback mode where configurations are first parsed with the UTF-8 parser, and if incompatible, fallback to the classic parser. As operators, you should not experience any difference in how your routes, silences or inhibition rules work.
429+
430+
If your Alertmanager configuration contains matchers that are incompatible with the UTF-8 parser, Alertmanager will use the classic parser and log a warning. This warning also includes a suggestion on how to make the matcher compliant with the UTF-8 parser. For example:
431+
432+
> Alertmanager is moving to a new parser for labels and matchers, and this input is incompatible. Alertmanager has instead parsed the input using the old matchers parser as a fallback. To make this input compatible with the new parser please make sure the regular expression or value is double-quoted. If you are still seeing this message please open an issue." input="foo=" origin=config err="end of input: expected label value" suggestion="foo=\"\""
433+
434+
In rare cases, a configuration can cause disagreement between the UTF-8 and classic parser. This happens when a matcher is valid in both parsers, but due to added support for UTF-8, results in different parsings depending on which parser is used. An example of this would be a matcher such as `baz="\xf0\x9f\x99\x82"`. This causes disagreement because `\xf0\x9f\x99\x82` is the byte sequence for the 🙂 emoji which is interpreted as a 🙂 emoji in the UTF-8 parser but as a literal `\xf0\x9f\x99\x82` in the classic parser.
435+
436+
If your Alertmanager configuration has disagreement, Alertmanager will use the classic parser and log a warning. For example:
429437

430438
```
431-
./alertmanager --config.file=config.yml --enable-feature="classic-mode"
439+
Matchers input has disagreement input="baz=\"\\xf0\\x9f\\x99\\x82\""
440+
```
441+
442+
#### Alternate modes
443+
444+
Alertmanger also supports two additional modes. These are called classic mode and UTF-8 strict mode. In classic mode, Alertmanager disables the UTF-8 parser and uses the classic parser. Classic mode is equivalent to Alertmanager versions 0.26.0 and older. You can enable this mode with the following feature flag:
445+
432446
```
447+
alertmanager --config.file=config.yml --enable-feature="classic-mode"
448+
```
449+
450+
In UTF-8 strict mode, Alertmanager disables the classic parser and uses the UTF-8 parser:
451+
452+
```
453+
alertmanager --config.file=config.yml --enable-feature="utf8-strict-mode"
454+
```
455+
456+
UTF-8 strict mode will be the default mode at the end of the transition period.
457+
458+
### Verification
433459

434-
Likewise, if you would like to disable the classic parser and use just the UTF-8 parser then you can do so too:
460+
You can use amtool to check if a configuration is incompatible or has disagreement:
435461

436462
```
437-
./alertmanager --config.file=config.yml --enable-feature="utf8-strict-mode"
463+
amtool check-config config.yml
464+
Checking 'config.yml'level=warn msg="2: Alertmanager is moving to a new parser for labels and matchers, and this input is incompatible. Alertmanager has instead parsed the input using the old matchers parser as a fallback. To make this input compatible with the new parser please make sure all regular expressions and values are double-quoted. If you are still seeing this message please open an issue." input="foo=" err="end of input: expected label value" suggestion="foo=\"\""
465+
level=warn msg="Matchers input has disagreement" input="baz=\"\\xf0\\x9f\\x99\\x82\"\n"
466+
SUCCESS
467+
Found:
468+
- global config
469+
- route
470+
- 2 inhibit rules
471+
- 2 receivers
472+
- 0 templates
438473
```
439474

440475
### `<matcher>`

0 commit comments

Comments
 (0)