Enable email or Slack notifications

Enable email or Slack notifications

This section describes how to enable StackLight LMA to send notifications to email, Slack, or to both notification channels using the Alertmanager service on an existing MCP cluster. By default, StackLight LMA uses Alertmanager and the SMTP protocol or the webhook receiver to send email or Slack notifications respectively.

Note

Skip this section if you require only email notifications and have already defined the variables for Alertmanager email notifications during the deployment model creation as described in MCP Deployment Guide: Infrastructure related parameters: Alertmanager email notifications.

To enable StackLight LMA to send notifications through Alertmanager:

  1. Log in to the Salt Master node.

  2. Open the classes/cluster/cluster_name/stacklight/server.yml file of the Reclass model for editing.

  3. Add the following classes:

    • For email notifications:

      classes:
      [...]
      - system.prometheus.alertmanager.notification.email
      - system.prometheus.server.alert.labels_add.route
      
    • For Slack notifications:

      classes:
      [...]
      - system.prometheus.alertmanager.notification.slack
      - system.prometheus.server.alert.labels_add.route
      
  4. Define the following variables:

    • For email notifications:

      parameters:
        _param:
          alertmanager_notification_email_from: <email_from>
          alertmanager_notification_email_host: <smtp_server:port>
          alertmanager_notification_email_password: <email_password>
          alertmanager_notification_email_require_tls: <email_require_tls>
          alertmanager_notification_email_to: <email_to>
          alertmanager_notification_email_username: <email_username>
      

      Note

      Using the alertmanager_notification_email_host parameter, specify both the host and the port number of the SMTP server. For example, host.com:25.

    • For Slack notifications:

      parameters:
        _param:
          alertmanager_notification_slack_api_url: https://hooks.slack.com/services/<webhook/integration/token>
      
  5. Set one or multiple notification channels by using the _param:prometheus_server_alert_label_route parameter. The default value is email, which means that email notifications will be sent.

    Example:

    parameters:
      _param:
        prometheus_server_alert_label_route: email;slack;
    
  6. Apply the Salt formulas:

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