To configure Grafana to send alerts to Slack, you need to set up a notification channel in Grafana and configure it to use the Slack integration. Here are the steps to configure Grafana to contact Slack:
Create a Slack Workspace:
If you don't already have one, create a Slack workspace where you want to receive Grafana alerts. You can sign up for Slack at https://slack.com/.
Set Up an Incoming Webhook:
To allow Grafana to send messages to Slack, you'll need to create an Incoming Webhook integration in your Slack workspace. Here's how:
Go to your Slack workspace.
Click on your workspace name in the top-left corner and select "Settings & administration" > "Manage apps."
In the "Custom Integrations" section, click on "Incoming Webhooks."
Activate incoming webhooks if they are not already enabled.
Scroll down and click on "Add New Webhook to Workspace."
Select a channel where you want to receive Grafana alerts.
Click "Authorize."
You'll be provided with a Webhook URL. This URL is required for Grafana to send messages to Slack.
Configure a Notification Channel in Grafana:
Log in to your Grafana instance.
Click on the gear icon (⚙️) in the left sidebar to open the "Configuration" menu.
Click on "Notification channels" under the "Alerting" section.
Click on "New Channel" to create a new notification channel.
Configure the channel settings:
Name: Give your channel a descriptive name (e.g., "Slack Alerts").
Type: Select "Slack" from the dropdown menu.
Send reminders: Enable this option if you want to send reminders for unresolved alerts.
Include image: Enable this option to include an image in your alerts (optional).
API URL: Paste the Slack Webhook URL you obtained in step 2 here.
Username: Set the username that will appear in Slack notifications.
Channel: Enter the Slack channel or user where you want to send alerts (e.g., "#general").
Click "Save."
Test the Notification Channel:
After creating the notification channel, you can test it to ensure that alerts are successfully sent to Slack. Click on the "Send Test" button in the notification channel settings to send a test message to Slack. If everything is set up correctly, you should see a message in your Slack channel.
Set Up Alerts in Grafana:
To send alerts to the Slack notification channel, you need to configure alert rules in Grafana. Create or edit a dashboard, add an alert panel, and configure the alert conditions as needed. Then, select the Slack notification channel you created as the "Send to" option for the alert.
Now, when the alert conditions are met, Grafana will send notifications to your specified Slack channel using the configured notification channel.