Global Configuration
The global configuration sets default parameters for the entire Alertmanager setup. Settings defined here—such as SMTP settings for email notifications—serve as defaults that individual routes and receivers can override. This structure mirrors the global configuration approach in Prometheus. Below is an example of a global configuration block with routing rules and receivers defined:- Global Settings: Define SMTP parameters and other default configurations.
- Route Section: Establishes matching rules to determine which alerts are sent to which receivers.
- Receivers Section: Contains notifier configurations (e.g., Slack, email) that manage how alerts are delivered.
Routing Section
The routing section assigns alerts to specific receivers based on matching criteria. Routes can use eithermatchers for direct label comparisons or match_re for regular expression-based matching.
Use matchers for exact label value comparisons. Leverage match_re when you require more flexible, regular expression-based matching.
Default (Fallback) Route
You can define a default or fallback route at the top level of your routing configuration. These routes catch any alerts that do not match more specific rules. In the example below, alerts that do not match any nested routes are grouped byalertname and job, then sent to the receiver named staff:
Nested Routes (Subroutes)
Alertmanager supports nested routes (subroutes) to allow for additional filtering. With nested routes, a parent route can first match alerts with a specific label (such asjob), and subroutes can further refine the selection based on additional criteria, like severity.
Consider the following configuration. Alerts with the label job: kubernetes are routed to k8s-email by default; however, if an alert also includes severity: pager, it is forwarded to k8s-pager:
- The alert is first evaluated against the parent route (matching
job: kubernetes). - If the alert has the label
severity: pager, the subroute is matched and sent to thek8s-pagerreceiver. - Alerts missing the extra
severitylabel default to the parent route’s receiver (k8s-email).
Managing Multiple Teams with Subroutes
You can further refine routing for multiple teams by using subroutes. This approach ensures that alerts reach the appropriate team’s notifiers. The following configuration demonstrates how to set up parent routes based on a team label, with subroutes handling alert severity:- Alerts for the database team default to
database-pager, unless further specifications direct them todatabase-email. - Alerts for the API team default to
api-pager, with additional subroutes managing alerts based on environment or severity.
Reloading the Alertmanager Configuration
After making changes to your alertmanager.yml file, Alertmanager does not automatically reload the updated configurations. You must take one of the following actions to apply changes:- Restart the Alertmanager process.
-
Send a SIGHUP signal. For example:
- Send an HTTP POST request to the /-/reload endpoint.
For production environments, ensure that your configuration file is validated before reloading to avoid disruptions in alert processing.
Matching Multiple Routes
By default, Alertmanager stops processing routes after the first match is found. In the example below:alert-logs), it will not be evaluated for further matches with the Kubernetes-specific rule. To allow an alert to trigger multiple receivers, use the continue property on a route. Setting continue: true instructs Alertmanager to evaluate subsequent routes even after a match.
Alert Grouping
Alert grouping consolidates multiple alerts into a single notification based on specified label values. Thegroup_by field controls how alerts are bundled, which can be particularly useful when organizing alerts by team or other criteria.
For example, grouping alerts by team ensures that alerts for the same team are sent together:
- The default route groups alerts based on the
teamlabel. - A nested route for the infrastructure team further groups alerts by
regionandenv. - Child routes inherit the grouping rules unless they define their own
group_byvalues.