How to automatically send workflow errors as webhooks to a monitoring system
Learn how to automatically send workflow errors as webhooks
Exivity offers the possibility to create notifications for workflows. Users can get notified when a workflow has finished successfully or when it has failed. In some scenarios, you may want to get informed by a Monitoring System about any Failed Workflow alerts. This is possible through webhooks.
Webhooks are automated messages sent from one app to another when something happens.
In simple words: A webhook URL is provided by the receiving application (in this case, the Monitoring System), and acts like a phone number that the other application (in this case, Exivity) can "call" when an event happens. The data about the event is sent to the webhook URL in either JSON or XML format and it is known as the Payload. As seen in the diagrams above, there is no need to have continuous polling between the Monitoring system and Exivity when using webhooks.
The Monitoring System, receiving the notification through the chosen URL, not only knows an event occurred on another system, but it can also react to it.
In a real case scenario, you would have a webhook endpoint provided by your Monitoring System of choice. For the purpose of this tutorial, we are going to simulate that by using a mock endpoint.
One powerful tool that can get you started with the configuration of a webhook channel is Hookdeck. Hookdeck is a platform that helps you manage your webhooks and create mock endpoints for testing purposes.
After you have created your connection, it should look similar to this one:
Example of connection between Exivity and Hookdeck
2. Provide a Channel name for your channel and select the Channel type as Webhook.
Copy the Webhook URL
4. Fill in the Webhook URL with the URL provided by Hookdeck:
Creating a Webhook Channel
5. Click the Create button.
Also, make sure you fill in a suggestive Name, Title and Description, since you want to identify the Error status easily in your Monitoring System (or in this case, in the Hookdeck events Dashboard):
Example of notification for a workflow that fails
Now that you have created a webhook channel and a notification for your workflow using that channel, you can test it to see that your Hookdeck mock endpoint catches your notifications successfully. 1. Ideally, none of your workflows would fail, but for testing purposes, we are going to make one of them fail. Select one of your workflows, and add a faulty step. For example, add an Execute type of step and fill in the following command:
Example of a command that fails in your workflow
2. Click Update to add the new step, then you may also click the Run Now button if you don't want to wait until your Workflow is scheduled to execute.
3. You should immediately see a new event in the Hookdeck events section in the Dashboard:
Hookdeck events for your Connection
4. Select the most recent event (which is at the top of the list) and on the right side of your screen, you will see a window containing the Response/Payload in a JSON format. In the
bodysection you can see the message from the notification you created to let you know when your workflow has failed:
The notification message got sent successfully to the Hookdeck endpoint
Analogously, the same steps you have seen in this how-to guide will apply to sending your failed workflow notifications to a Monitoring System, except you will not use the mock endpoint provided by Hookdeck, but the webhook URL provided by your Monitoring System.