config

With the config sub-command, we can consult the internal configuration of a running Alertmanager instance, which includes all configurable fields, even ones not explicitly listed in the configuration file. You can check this by issuing the following command:

vagrant@alertmanager02:~$ amtool config --alertmanager.url http://alertmanager02:9093
global:
resolve_timeout: 5m
http_config: {}
smtp_from: [email protected]
smtp_hello: localhost
smtp_smarthost: example.com:25
smtp_require_tls: true
slack_api_url: <secret>
...

Configuration fields that were not specified in the configuration file will show with their default values, and fields that deal with secrets (such as passwords and tokens) will be automatically redacted.

The config sub-command default action is shown. The equivalent command to the previous example would be amtool config show --alertmanager.url http://alertmanager02:9093.

The next sub-command action, routes, generates a text visualization of the configured routing tree. This command can be run against a running Alertmanager instance or a local configuration file. The syntax and output is as follows:

vagrant@alertmanager02:~$ amtool config routes --alertmanager.url http://alertmanager02:9093
Routing tree:
.
└── default-route receiver: operations
├── {job=~"^(?:^(?:(checkoutService|paymentService))$)$"} receiver: yellow-squad-email
│ └── {severity="pager"} receiver: yellow-squad-pager
├── {job="firewall"} receiver: purple-squad-email
│ ├── {severity="slack"} receiver: purple-squad-slack
│ └── {severity="pager"} receiver: purple-squad-pager
└── {alertname=~"^(?:^(?:(AlertmanagerDown|NodeExporterDown))$)$"} receiver: violet-squad-slack
└── {severity="pager"} receiver: violet-squad-pager

You can even validate the routing tree by providing labels to the routes test action and checking which route would be triggered. We can see this in action in the following example, where we're validating whether the triggered receiver is in fact yellow-squad-email when an alert comes in with the job="checkoutService" label:

vagrant@alertmanager02:~$ amtool config routes test 'job="checkoutService"' --config.file /etc/alertmanager/alertmanager.yml 
yellow-squad-email

Having this command-line tool around can help you streamline the development of complex routing rules and validate produced configurations without even needing an Alertmanager instance running locally.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.143.4.181