A Simple Mail Transfer Protocol (SMTP) notification channel in
Google Distributed Cloud (GDC) air-gapped appliance lets you send firing Prometheus alerts directly
to your team's email through an `ObservabilityPipeline` custom resource. If you
choose not to configure email notifications, you can still view alerts in
Grafana dashboards for the `infra-obs` and `platform-obs` namespaces.

## Before you begin

[Configure the device and install software](https://docs.cloud.google.com/distributed-cloud/hosted/docs/latest/appliance/admin/setup)

## Configure notification channels

Work through the following steps to configure Slack or email notification channels:

1. To create a custom alert notification channel, host the SMTP server in your network and have the SMTP configuration details (IP, username, password, receiver email) ready to create the alertmanager config. You can validate the correctness of the SMTP host IP by pinging it from [bm03](https://docs.cloud.google.com/distributed-cloud/hosted/docs/latest/appliance/admin/setup#ssh-bm03).

   > [!NOTE]
   > **Note:** Perform the following steps for both of the namespaces (`infra-obs` and `platform-obs`) and any additional namespaces created by the user.

2. Create a file `cm.yml` with the following content:

   The `smtp_smarthost` must have the IP address of the SMTP server hosted by the customer.

         apiVersion: v1
         kind: ConfigMap
         metadata:
           # The name must match the ConfigMap name specified in the ObservabilityPipeline custom resource.
           name: appl-alert-notification
           # The namespace must match the project namespace
           namespace: PROJECT_NAMESPACE
         data:
           # The file name must be alertmanager.yml
           alertmanager.yml: |
             global:
               smtp_smarthost: SMTP HOST IP ADDRESS
               smtp_from: FROM_EMAIL_ADDRESS
               # Give empty string for unsecured smtp server in username and password and false in smtp_require_tls.
               smtp_auth_username: USERNAME
               smtp_auth_password: PASSWORD
               smtp_require_tls: true
             route:
               group_by: ['alertname', 'cluster', 'service']
               group_wait: 30s
               group_interval: 5m
               repeat_interval: 3h
               receiver: team-X-mails
             receivers:
               - name: 'team-X-mails'
                 email_configs:
                   - to: **RECIEVER_EMAIL_ID**

3. Update the required fields with the correct content.

4. Run `kubectl apply -f cm.yaml`.

5. Create an `ObservabilityPipeline` custom resource with the following:

           # Configure observability pipeline
         apiVersion: observability.gdc.goog/v1
         kind: ObservabilityPipeline
         metadata:
           # Choose namespace that matches the project's namespace
           namespace: PROJECT_NAMESPACE
           name: observability-config
         spec:
           # Configure Alertmanager
           alerting:
             # Permission: PA and AO
             # The alerts configuration must be in the key "alertmanager.yml" of the configMap
             alertmanagerConfig: CUSTOMIZED_CONFIGMAP_NAME
           ...

   Replace the following:
   - <var translate="no">PROJECT_NAMESPACE</var>: The namespace of your project.
   - <var translate="no">CUSTOMIZED_CONFIGMAP_NAME</var>: The name you used for your configuration file in the `ConfigMap` object must match exactly with the name of the `ConfigMap` object. For example in step 2, if you used `appl-alert-notification` as the `ConfigMap` name, then use the same name for your configuration file in the `ObservabilityPipeline` object.

     > [!NOTE]
     > **Note:** You must create a CR for both the namespaces, `infra-obs` as well as `platform-obs`. There must be a separate configmap and `ObservabilityPipeline` for each namespace.

6. Update the namespace to the value used in the previous step.

7. Run `kubectl apply -f ob.yaml.`

8. All the alerts visible on the Grafana dashboard of the GDC trigger an email if they are in a `firing` state. Launch Grafana for the namespace which you used in the previous steps and check for alerts in a `firing` state. The alerts come to your email.

> [!NOTE]
> **Note:** Refer to [Configure notification channels for alerts](https://docs.cloud.google.com/distributed-cloud/hosted/docs/latest/appliance/admin/configure-notification-channels) for more information on configuring notification channels for the alerts you set up.

## What's next

- [Manage PKI certificates](https://docs.cloud.google.com/distributed-cloud/hosted/docs/latest/appliance/platform/pa-user/pki/web-tls-cert-config)