How to trigger an e-mail notification if a job fails
Data Studio has a range of default notification options which allow you to send a custom email to defined users when certain important events occur.
One common use for this is to have Data Studio send an email when a workflow execution fails. To do this we'll be using Notifications and Event Data Items.
First, you'll need to ask you Data Studio admin to configure the SMTP Properties. Here's an example using the Gmail SMTP host (you'll need a Gmail accout). In practice you'll likely be pointing to your own organization's mail server.
Once your SMTP connection is working (there's also a test button), you're ready to configure email notifications.
In the Glossary, you'll find a Notifications. Create a new notification, and configure it as follows:
- A: Selecting "Workflow Failed" from the list of available events will ensure the notification is only triggered for this specific events
- B: Define the recipients for the email notification. This could be list of email addresses
- C: Define the subject. Here, you will use inbuilt "event data items" to define placeholders for information such as the name of the workflow that failed, and the error message. Use any keywords here that you may want to build email inbox rules on later. To view the available event data items, type @ to see a context-sensitive list:
- D: Define the email body, again using the event data items.
Now save the notification, and test it with a failing workflow. You should receive an email that looks as follows:
The final thing you probably want to do is set up different notifications (possibly with different recipients, headlines, content etc) for different workflows.
To do this, you can return to the Notification you created earlier and set trigger conditions. These use the same syntax as the event data items, and in the example below I specify that the notification is only triggered for a workflow named MyWorkflow
If workflows with different names fail, they will not trigger this notification, but can of course be set up to trigger other notifications