Vail/Discord Alerts

Discord Alerts

Post status updates to a Discord channel through a webhook.

Vail can post embeds to a Discord channel through a webhook. It does not post on its own when a service goes down. You send each update to Vail's /api/notify endpoint, by hand or from a script, and Vail forwards it to Discord.

Set Up the Webhook

  1. In Discord, open the channel's settings, go to Integrations > Webhooks and click New Webhook.
  2. Copy the webhook URL.
  3. Add it to settings.json:
settings.json
{
  "discord": {
    "enabled": true,
    "webhookUrl": "https://discord.com/api/webhooks/...",
    "apiKey": "a-long-random-string",
    "username": "Vail Status",
    "avatarUrl": "https://status.example.com/logo.png"
  }
}
SettingWhat it does
enabledTurns alerts on.
webhookUrlThe Discord webhook URL.
apiKeyThe key callers must send to /api/notify. The endpoint is off while this is empty.
usernameOptional. The name the webhook posts as.
avatarUrlOptional. The picture the webhook posts with.

Send an Update

curl -X POST https://status.example.com/api/notify \
  -H "Authorization: Bearer a-long-random-string" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "API Degraded",
    "message": "Requests are slower than usual. We are looking into it.",
    "status": "degraded",
    "url": "https://status.example.com"
  }'
FieldRequiredWhat it does
titleYesThe embed title.
messageYesThe embed text.
statusoperational, degraded, outage or maintenance. Sets the colour.
typeinfo, warning or error. Sets the colour when there is no status.
urlMakes the title a link.

Vail answers { "success": true }, or an error with the reason.

StatusMeaning
401The Authorization header is missing or the key is wrong.
403apiKey is empty in settings.json.
400title or message is missing, or alerts are turned off.

Generate a key with openssl rand -hex 32 and keep it out of anything public, such as a GitHub repository.

ColourUsed for
Greenoperational
Yellowdegraded, warning
Redoutage, error
Bluemaintenance, info

Ideas

  • Call it from an uptime checker, such as a cron job that runs curl when a service stops answering.
  • Post the same text you add to incidents in settings.json, so the page and Discord match.