# Alert notifications

> Send alerts to a Microsoft Teams channel, email or a webhook, with the notification service's own configuration, secrets kept apart and encrypted.

## What decides where an alert goes

When an alert fires, it shows on the **Alerts** page. Whether it is also sent somewhere, to a Microsoft Teams channel, a mailbox or a webhook, is decided by the notification service's configuration, under **Alerts → Notifications**. Until you change it, the configuration sends nothing: every alert goes to a receiver called `blackhole`.

The notification service is Prometheus Alertmanager 0.28, and the page edits its configuration in its own format. Every receiver type and every setting it documents works here, see the [configuration reference](https://prometheus.io/docs/alerting/0.28/configuration/).

The page edits three things:

- **The configuration**: routes and receivers. Every account that can read settings can read it.
- **The secrets**: webhook URLs, passwords and API keys, as `NAME=value` lines. They are stored encrypted, and only an account with the permission `alert-notification-secrets:reveal` (the Administrator role) can show or change them. Every time they are shown is recorded in the audit log.
- **The templates** (optional): the text of each notification, such as a Teams card's title.

The configuration refers to a secret as `${NAME}`. The control plane fills in the value when it hands the configuration to the notification service. Write `$$` for a literal `$`.

## Send alerts to a Microsoft Teams channel

1. In Teams, open the channel, choose **Workflows**, and create a workflow from the template **Post to a channel when a webhook request is received**. Copy the URL it shows.
2. Under **Alerts → Notifications**, choose **Edit secrets** and add a line:

   ```
   TEAMS_WEBHOOK_URL=https://...the URL you copied...
   ```

   Save. The control plane refuses the save when a line cannot be read, and names the line.
3. Replace the configuration with one that routes alerts to Teams, and save:

   ```yaml
   route:
     receiver: teams
     group_by: ["alertname"]
     group_wait: 30s
     group_interval: 5m
     repeat_interval: 4h
     routes:
       # The Watchdog alert fires always, by design; keep it out of the channel.
       - matchers: ['alertname="Watchdog"']
         receiver: blackhole

   receivers:
     - name: blackhole
     - name: teams
       msteamsv2_configs:
         - webhook_url: ${TEAMS_WEBHOOK_URL}
   ```

4. Choose **Send test notification**. Show where it goes, then **Send**. A message arrives in the channel, and a second one five minutes later when the test alert resolves.

## Send alerts by email

Add the mail server's password under **Edit secrets** (`SMTP_PASSWORD=...`), then a receiver:

```yaml
receivers:
  - name: operations-mail
    email_configs:
      - to: operations@example.com
        from: alerts@example.com
        smarthost: 192.0.2.25:587
        auth_username: alerts@example.com
        auth_password: ${SMTP_PASSWORD}
```

Route to it the way the Teams example does. To send only critical alerts by email and everything to Teams, add a route with `matchers: ['severity="critical"']`, `receiver: operations-mail` and `continue: true` before the others.

## When a save is refused

Before the control plane stores a change, it checks it with the notification service's own checker. A refused save names the reason and stores nothing; the notification service keeps the configuration it runs. The common reasons:

- **The configuration refers to `${NAME}`, and the secrets do not define it.** Add it under **Edit secrets**, or remove the reference.
- **Alertmanager would not load this configuration**, followed by its reason: an unknown field, a route to a receiver that does not exist, a template that does not parse. A secret's value never appears in the reason; its `${NAME}` does.
- **The configuration has a templates key.** Edit templates under **Edit templates**; the control plane lists them in the configuration itself.
- **The configuration changed after you opened it.** Someone else saved in between. Reload the page, apply your change again, and save.

**Validate** runs the same check and stores nothing.

## Applied or not

Beside the title, the page says whether the notification service runs the stored configuration:

- **Applied**: it runs what is stored.
- **Not applied**, with the reason: the notification service is not running (it loads the configuration when it starts; check the alerting services on the **Status** page), or the change is still on its way from another control plane machine, or loading it failed. A failure to load a configuration that passed the check is a defect: the reason names an error report, which you can open and send to support.

When a notification cannot be delivered (the Teams workflow was deleted, the mail server refuses the password), the alert **AlertNotificationDeliveryFailures** fires on the **Alerts** page and names the kind of receiver. Check its address and secret, then send a test notification.

## Over the API and MCP

Everything on the page is a command of the API and of the MCP endpoint (`alert_notifications_read`, `alert_notifications_change`): `config/get` and `config/update`, `templates/get` and `templates/update`, `secrets/reveal` and `secrets/update`, and `send-test-notification`. Each update replaces the whole value, names the SHA-256 of the value it started from, and accepts `dry_run` to check without storing. A control plane API key reaches the secrets only when its scopes name `alert-notification-secrets:reveal`.
