> For the complete documentation index, see [llms.txt](https://docs.perfectscale.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.perfectscale.io/customize-workflow/communication-and-messaging/slack-integration.md).

# Slack Integration

Streamline alerts management with Slack integration

Integrating Slack streamlines the management of **`Alerts`** in clusters, allowing users to receive timely notifications in the defined Slack channel when alerts are detected.

## Configuring Slack integration with the profile

### :tools: **How to create Slack Profile**

There are two options for creating a Profile: [from the Settings](#from-the-settings-tab) tab or directly [from the Overview](#from-the-overview-tab).

#### From the **Settings** tab

Go to the **`Settings`** tab on the left panel -> select **`Integrations`** -> click the **`+Add Integration`** button and select **`Slack`** from the drop-down -> insert the required data.

<figure><img src="https://1573387604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FABMqnYtsOO44JmQTVSnn%2Fuploads%2FUYC9ZFOXxXs2NEV3T4h9%2Fslack_settings.gif?alt=media&amp;token=c0a8ff48-5951-4f3b-a9a8-8ab4cdeb65f8" alt=""><figcaption><p>Slack profile from settings</p></figcaption></figure>

#### From the **Overview** tab

Go to the **`Overview`** tab on the left panel -> find the cluster to which you want to apply the **`Profile`** and click **`gear`** button -> go to **`Customizations`** -> find **`Integrations`** and click the **`Communication & Messaging`** drop-down list -> click the **`Add New Profile`** button and select **`Slack`** -> configure the profile.

<figure><img src="https://1573387604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FABMqnYtsOO44JmQTVSnn%2Fuploads%2FgZ5ilK7GQdTcyRwKGGrA%2Fslack_overview.gif?alt=media&amp;token=2107d262-8922-4922-85a3-921b70770d88" alt=""><figcaption><p>Slack profile from overview</p></figcaption></figure>

#### Slack profile configuration

<figure><img src="https://1573387604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FABMqnYtsOO44JmQTVSnn%2Fuploads%2FxaFLAjAeuigNmWcLFy7w%2FGroup%201000001881.png?alt=media&amp;token=bb496dcc-c439-4a3a-b0bd-0172b4e75123" alt=""><figcaption></figcaption></figure>

1. Name the profile.
2. Configure the profile:
   * It is important to include relevant data in the **`slack_token`** field as it is a **mandatory** one. \
     Learn how to configure [slack\_token here](/customize-workflow/communication-and-messaging/slack-integration/how-to-configure-slack_token.md).&#x20;
   * Indicate the name of the Slack channel where you want to receive the alerts. This field is **mandatory,** and the indicated channel will be the default channel if Advanced Alert Routing fails. To specify the Slack channel, enter its name in the **`channel`** field.&#x20;
   * Set up [Advanced Alert Routings](#advanced-alerts-routing) to send alerts to different Slack channels for various workloads within a cluster.

{% hint style="warning" %}
The channel\_id is deprecated. Please use the channel name instead.
{% endhint %}

{% hint style="success" %}
You can create as many as needed Slack Integration Profiles with only one [slack\_token](/customize-workflow/communication-and-messaging/slack-integration/how-to-configure-slack_token.md) by changing the channel name.&#x20;
{% endhint %}

3. Use **`Set as default`** checkbox to automatically assign the profile to the clusters.\
   \
   :bulb: **NOTE**: The manually assigned profile takes priority over the default one.
4. Verify if your Slack is configured properly with the [**`Test Integration`**](#slack-integration-verification) button.&#x20;
5. Click **`Save`** button

### :tools: **How to apply** **Slack Profile**

#### Apply to a single cluster

To apply **`Slack Profile`** to the cluster, go to the **`Overview`** tab on the left panel -> find the cluster to which you want to apply the **`Slack Profile`** and click **`gear`** button -> go to **`Customizations`** -> select the needed profile in the **`Communication & Messaging`** drop-down list.&#x20;

<figure><img src="https://1573387604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FABMqnYtsOO44JmQTVSnn%2Fuploads%2FUh4XXJS4XvCyQzyEbKgr%2Fr4FDGjdbuK.gif?alt=media&amp;token=c765dbb5-99bf-41d2-9aee-b5b2b39663e3" alt=""><figcaption><p>Applying Slack profile to a single cluster</p></figcaption></figure>

#### Apply to multiple clusters

To apply the profile to **multiple clusters** from a single view, use the **`Manage Assignments`** feature.&#x20;

Go to the **`Settings`** tab on the left panel -> select the **`Integrations`** -> click the **`Manage Assignments`** button -> go to **`Communication & Messaging`** section and apply the profiles for the needed clusters -> click the **`Save Changes`** button.

<figure><img src="https://1573387604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FABMqnYtsOO44JmQTVSnn%2Fuploads%2F3u4GOGIpF3j20cJfYKYV%2FOWAIGY193i.gif?alt=media&amp;token=e960730b-e682-49f8-8c1b-19fd142e3a1e" alt=""><figcaption><p>Applying Slack profile to multiple clusters</p></figcaption></figure>

## Advanced Alerts Routing

If you need to configure routing for Slack alerts in a more advanced way, PerfectScale provides an option for setting it up with labels.&#x20;

This approach enables sending alerts to different Slack channels for various workloads within a cluster.&#x20;

Learn [how to configure routings here](/customize-workflow/communication-and-messaging/slack-integration/how-to-configure-routings.md).

{% hint style="info" %}
If the value of a label with key `label_key` is wrong or empty, PerfectScale will send Alerts to the default Slack channel specified in the `channel` row.
{% endhint %}

## Configuring Slack integration with CR

To enable Slack alerts, you need to define and apply a Custom Resource (CR) with the required parameters. This approach allows you to manage Slack alerting directly through Kubernetes manifests.&#x20;

{% hint style="warning" %}
The Custom Resource (CR) must be created in the `perfectscale` namespace.
{% endhint %}

### Setup instructions

1. Create the app at <https://api.slack.com/apps>.
2. Go to the **OAuth & Permissions** tab and specify the following scope:
   * chat:write.public
   * chat:write
   * channels:read
3. Click the **Install to Workspace** button.
4. Copy the **Bot User OAuth Token** (you will need it for the **Slack token secret** in the next steps).

Apply the **Slack token secret** first:

```yaml
apiVersion: v1
kind: Secret
metadata:
  name: slack-credentials
  namespace: perfectscale
type: Opaque
stringData:
  bot-token: "xoxb-your-slack-bot-token-here"
```

{% hint style="info" %}
Ensure that the secret is created in the same namespace as the exporter -  `perfectscale`.
{% endhint %}

Configure the CR:

```yaml
apiVersion: perfectscale.io/v1
kind: ClusterSettings
metadata:
  name: cluster-settings-main
  namespace: perfectscale
spec:
  profiles:
    integrations:
      - type: slack
        name: team-slack-alerts
        assigned: true
        value:
          channel: "perfectscale-alerts"
          slack_token_from:
            secretKeyRef:
              name: slack-credentials
              key: bot-token
          #Optional: Advanced alert routing
          #routings:
            #- label_alert
            #- resiliency_alert
```

⚙️ **CR parameters:**

<table><thead><tr><th width="251.94921875">Parameter</th><th>Description</th></tr></thead><tbody><tr><td><strong><code>channel</code></strong></td><td>Slack channel name that indicates where to receive PerfectScale alerts.</td></tr><tr><td><strong><code>slack_token_from</code></strong></td><td>A secret that permits PerfectScale to interact with your Slack. Learn how to configure <a href="/customize-workflow/communication-and-messaging/slack-integration/how-to-configure-slack_token.md">slack_token here</a>. </td></tr><tr><td><strong><code>routings</code></strong></td><td>Advanced alerts routing that enables sending alerts to different Slack channels for various workloads within a cluster based on labels. Learn more <a href="/customize-workflow/communication-and-messaging/slack-integration/how-to-configure-routings.md">here</a>.</td></tr></tbody></table>

## Slack Integration Verification

To verify the accuracy of your Slack configuration, simply click on the **`Test Integration`** button. When the configuration is correct, you will see the message **`Slack Configured Correctly`** . In case of **`Slack Configured Wrongly`** response, check and ensure the correctness of the data.&#x20;

{% hint style="warning" %}
**`channel`** and **`slack_token`** are mandatory. Verification will fail if **`channel`** and/or **`slack_token`** are missing or incorrect.
{% endhint %}

<figure><img src="https://1573387604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FABMqnYtsOO44JmQTVSnn%2Fuploads%2FMT1WMaqYoTYqlZZV0Qov%2Fslack%20test.gif?alt=media&amp;token=580b51e1-2ff1-4b4e-9d1f-9ad5e5036647" alt=""><figcaption><p>Slack integration verification</p></figcaption></figure>
