Configure multiple emails for Alertmanager notifications

Configure multiple emails for Alertmanager notificationsΒΆ

By default, you can set only one email for notifications through Alertmanager during the deployment model creation. However, you can configure Alertmanager to send notifications to multiple emails as required.

To configure multiple emails for Alertmanager notifications:

  1. Open your Git project repository with Reclass model on the cluster level.

  2. In the classes/cluster/cluster_name/stacklight/server.yml file, specify the emails as required, for example, by splitting the alerts by severity as shown below.

    Example:

    parameters:
      prometheus:
        alertmanager:
          enabled: true
          config:
            route:
              routes:
                email-common:
                  receiver: SMTP-common
                  continue: true
                email-critical:
                  receiver: SMTP-critical
                  match_re:
                    - label: severity
                      value: critical
                  continue: true
            receiver:
              SMTP-common:
                enabled: true
                email_configs:
                  smtp_server:
                    to: common@email.com
                    from: ${_param:alertmanager_notification_email_from}
                    auth_username: ${_param:alertmanager_notification_email_username}
                    auth_password: ${_param:alertmanager_notification_email_password}
                    smarthost: ${_param:alertmanager_notification_email_host}
                    require_tls: ${_param:alertmanager_notification_email_require_tls}
                    send_resolved: true
              SMTP-critical:
                enabled: true
                email_configs:
                  smtp_server:
                    to: critical@email.com
                    from: ${_param:alertmanager_notification_email_from}
                    auth_username: ${_param:alertmanager_notification_email_username}
                    auth_password: ${_param:alertmanager_notification_email_password}
                    smarthost: ${_param:alertmanager_notification_email_host}
                    require_tls: ${_param:alertmanager_notification_email_require_tls}
                    send_resolved: true
    
  3. Log in to the Salt Master node.

  4. Apply the following state:

    salt -C 'I@docker:swarm and I@prometheus:server' state.sls prometheus.alertmanager -b 1