Alerting status updates in Discord
Get status updates in your Discord channel.
Overview of steps
- Set up webhooks for Discord
- Update Mage project settings
Set up webhooks for Discord
Follow these instructions on Discord to setup incoming webhooks for your workspace.
Update Mage project settings
Once you’ve set up webhooks for Discord, you should have a webhook URL that Discord provides.
Here is an example webhook (yours may vary):
https://discordapp.com/api/webhooks/XXX3514XXXXX/MHhahaduwa183-ccgfxcgv88kladJkjBJKB78CHCfds
Follow these steps to add that webhook URL to your project settings:
-
Open the Mage tool in your browser (e.g. http://localhost:6789/).
-
Open a pipeline and start editing it (e.g. http://localhost:6789/pipelines/example_pipeline/edit).
-
In your left sidebar in the file browser, scroll all the way down and click on a file named
metadata.yaml
. -
In the
metadata.yaml
file, add a section with the following configuration or update the existingnotification_config
section:notification_config: alert_on: - trigger_failure - trigger_passed_sla
If you omit the
alert_on
section it will default totrigger_failure
andtrigger_passed_sla
.Options:
trigger_failure
: alert when a run of a trigger failstrigger_success
: alert when a run of a trigger succeedstrigger_passed_sla
: alert when a SLA is missed.- In this context, SLA (Service Level Agreement) is an expected amount of time for the pipeline to complete.
- If the pipeline runs longer than the SLA, an alert will be sent.
-
In the
metadata.yaml
file, add the following values:notification_config: alert_on: ... discord_config: webhook_url: ...
Change the
webhook_url
value to be the webhook URL you created from Discord.
Customize message templates
You can customize message templates in notification_config
. Here is an example config:
notification_config:
alert_on:
...
discord_config:
...
message_templates:
failure:
title: 'Failed to execute pipeline {pipeline_uuid} at {execution_time}'
summary: >
Failed to execute pipeline {pipeline_run_url}.
Pipeline uuid: {pipeline_uuid}. Trigger name: {pipeline_schedule_name}.
Test custom message.
success:
title: ...
summary: ...
passed_sla:
title: ...
summary: ...
You can customize the message template for success
, failure
, passed_sla
scenarios. For each message template,
you can specify the sentence on summary
and the title
.
To interpolate variables in the message template, you can use {variable_name}
syntax.
Here are the supported variables:
execution_time
pipeline_run_url
pipeline_schedule_id
pipeline_schedule_name
pipeline_schedule_description
pipeline_uuid
error
- available only for the
failure
message template
- available only for the
stacktrace
- available only for the
failure
message template
- available only for the
For pipeline_run_url
, the default host is http://localhost:6789
. You can specify MAGE_PUBLIC_HOST
to be
the host url you want to use in the notification messages.
What next?
Whenever a pipeline run is successfully completed or fails, a Discord Channel message will appear in the channel you configured the webhook URL for.
Here is an example of what that message could look like: