Send notifications to Slack and Discord
Email and the bell menu are fine for you. A team prefers a channel where everyone sees that a deployment failed or a certificate is about to expire. SrvYard can post such messages to Slack and Discord. You create a webhook address in Slack or Discord, paste it into SrvYard, choose what should be posted, and press Test.
This article covers the setup for both, what the messages contain, and where a site can have its own channel. The channel settings (events, severity, scope) are explained in depth in Notification channels; here we concentrate on getting Slack and Discord working.
Before you begin
- Permission to manage notifications in SrvYard (notifications:manage), held by owners, admins and managers.
- Permission to add an integration in Slack or Discord. In Slack you need to be allowed to add apps to the workspace. In Discord you need the Manage Webhooks permission for the channel.
- A channel to post to. A quiet, dedicated channel such as
#ops-alertsis better than a busy one. - A limit to know about. An organisation can have 20 channels. A site can have up to 10 of its own.
1. Create the webhook in Slack
In Slack you create an incoming webhook: open Apps, choose Incoming Webhooks, switch it on, add a new webhook to the workspace and pick the channel it should post to. Slack then shows a webhook address that starts with https://hooks.slack.com/. Copy it. Anyone who has this address can post to the channel, so treat it like a password.
2. Add the channel in SrvYard
In SrvYard open Settings > Notifications, find the Channels card and press Add channel.
- Type. Slack. The other choices are Discord, Telegram and Email.
- Name. A label for the list, such as
#ops-alerts. - Incoming webhook URL. Paste the address. SrvYard accepts only addresses on
hooks.slack.comhere, stores it encrypted and never shows it again; after saving you only see a short hint. - Severity. Choose Everything, Warnings and errors or Errors only. For a busy channel start with Warnings and errors and loosen it later.
Below these fields are Events (all of them, or a list you pick) and Limit to, which lets you restrict the channel to some servers, sites or tags. Both are covered in Notification channels. Press Add channel to save.
3. Do the same for Discord
In Discord open the channel's settings, choose Integrations, then Webhooks, create a webhook and copy its address (it contains discord.com).
- Type. Discord. The fields are the same as for Slack.
- Incoming webhook URL. Paste the Discord webhook address. The help text under the field reminds you where to find it: "Channel settings, Integrations, Webhooks, then copy the webhook URL (discord.com)."
Name the channel (Dev team Discord) and press Add channel.
4. Test it
A new channel appears in the table. Press Test at the end of its row.
- Test. Sends a short test message to the channel now, whatever the filters say. The result appears next to the row, and the message should show up in Slack or Discord within a second or two.
- Last message. Sent with how long ago, or Failed with the reason. A revoked webhook shows the answer from the provider here.
- On. The switch turns the channel off without deleting it. Turn it off while you test something noisy and back on afterwards.
Under the table, Recent messages lists what each channel sent and the result of each delivery for the last 30 days. Use it when a message did not arrive.
5. What the messages look like
- Slack receives a formatted message (built with Slack's Block Kit) with the event, the server or site it concerns and a link that opens it in SrvYard.
- Discord receives the same as an embed. Mentions such as
@everyoneor@herein names or error text are made harmless, so a site called@everyonecannot ping your server. - Names and errors are escaped for each platform and cut to its length limits.
- Secrets never appear. Messages carry names, links, statuses and times. Passwords, tokens and environment values are left out.
- A burst is summarised. If more than 20 messages a minute go to one channel, SrvYard combines them into a digest message.
- Retries. A message that meets a rate limit or a server error at Slack or Discord is retried up to three times.
6. A channel for one site
If one project should have its own channel, give the site one. Open the site, Settings, Notifications, and press Add channel in the site's Channels card.
- Type. A site can post to Slack, Discord, Telegram, a signed webhook or a list of emails. Only the deployment events of that site are sent there.
The two kinds do not conflict. A deployment failure can reach the organisation channel and the site channel at once.
Good habits
- Name channels after their destination, such as
#ops-alerts (Slack), so the list is readable when you have five of them. - Keep the webhook address secret. Anyone who has it can post into your Slack channel or Discord server. If it leaks, delete the webhook in Slack or Discord and create a new one, then replace the address in SrvYard with Edit.
- Test after every change. Press Test after you edit a channel, change its filters or rotate its address, so that you find a problem now and not during an incident.
- Review the list now and then. A channel that shows Failed for weeks is noise in your Recent messages log and a sign that nobody reads that room any more.
Troubleshooting
- Test says Failed with a 404 or "unknown webhook". The webhook was deleted in Slack or Discord. Create a new one and Edit the channel to paste it.
- Nothing arrives but Test works. The events, severity or scope filter excludes what happened. Open the channel and widen it.
- Slack stopped receiving messages after we changed the app. Removing the app or the channel also removes the webhook. Create a webhook again and replace the address in SrvYard.
- Two messages for one event. The organisation and the site both have a channel that posts to the same place. Remove one, or narrow the organisation channel with Limit to.
- A message is too long or cut off. Slack and Discord limit the length of a message, and SrvYard shortens names and error text to fit. Open the link in the message to read everything in SrvYard.
- I want the messages in more than one channel. Add one SrvYard channel per destination. Each can have its own filters.
Choosing what a channel should hear
Think about who reads the channel. An operations channel wants Errors only for everything in the organisation: failed deployments, failed backups, missed heartbeats, certificates that could not be renewed, monitors in alert. A project channel wants Everything for one site, including successful deployments, so the team sees a release go out. An executive channel might want only the Backup finished and certificate events. You can add as many channels as you need, up to the limit, and each has its own filters, so start small and add channels rather than making one channel do everything.
Related
- Notification channels: events, severity, scope and the member defaults.
- Outgoing webhooks and delivery history: send signed JSON to your own systems instead.
- Alert thresholds and silencing: the monitors that raise server alerts.
- A deployment failed: what to do when the message arrives.