Webhooks¶
Webhooks are defined as HTTP callbacks that can be configured to automatically push information from a server-side application to a client-side application whenever certain events occur.
For example, your deployed Mayhem instance can utilize webhooks to send a notification to client-side applications such as Slack or Google Chat whenever a Mayhem run has failed or completed. Webhooks in Mayhem can be subscribed to events for runs from a particular User, Project, or Organization.
Configuring a New Webhook¶
Webhooks in Mayhem can be accessed and configured in the following ways:
- A User can configure webhooks for their projects on the User Settings page.
- A Project Contributor with Admin permission can configure webhooks for a Project on the Project Settings page.
- An Organization Owner can configure webhooks for an Organization on the Organization Settings page.
- A Mayhem Admin can configure all webhooks cluster-wide from the Webhooks section of the Admin Settings page.
Your webhook configuration page should look similar to the following:
Webhook Name¶
This is a free-form name so you can keep track of your webhooks.
Subscription¶
Webhooks can subscribe to events for a User, an Organization or a Project. Mayhem Admins can use this field to search for and select the subscription for a new webhook. Users, Organization Owners, and Project Contributors with Admin permission will find this field pre-populated based on which User, Organization or Project's settings page they started on.
Webhook URL¶
This is the URL to which Mayhem will send events. The URL used for the webhook must resolve to a public IP address that is routable from the Mayhem cluster. Attempting to use a URL that resolves to a private IP address (e.g., 192.168.1.1) will result in an error.
Since webhook URLs may contain tokens or other authentication information, only the scheme and domain portions are shown in the webhook list. The full URL is only visible in the Edit Webhook form. For example, https://example.com/mysecretlocation/webhook
will be displayed in the webhook list as https://example.com
.
Tip
Check out the official documentation for Slack and Google Chat on how to generate webhook URLs.
Format¶
There are currently two webhook formats implemented:
-
JSON v1 sends structured, machine-readable JSON for consumption by custom services.
{ "message":"test", "triggered_at":"1970-01-01T00:00:00" }
-
Text (Slack) sends messages that can be used with an "incoming webhook" to post events to a Slack channel.
{ "blocks": [ { "type": "section", "text": { "type": "mrkdwn", "text": ">:microscope: Test Message 1\n>:microscope: Test Message 2" } }, { "type": "context", "elements": [ { "type": "plain_text", "text": "Test Webhook from cURL\nWebhook: Name not defined" } ] } ] }
Event-Driven Webhooks¶
The following webhook notification types send a webhook event immediately when the event happens on the Mayhem cluster:
- Run Started: Is sent whenever a run begins.
- Run Completed: Is sent whenever a run ends, and includes information about why the run ended, e.g., because it ended successfully, because it was stopped, or because it failed.
"Rollup" Webhooks¶
These webhooks send summary information about high-volume events approximately every 15 minutes. If no matching events occurred, the webhook is not sent.
- Recent Test Cases Generated: Reports how many test cases a run has generated over the interval.
- Recent Crashes Found: Reports how many crashes were found by a run over the interval.
- Recent Defects Found: Reports how many defects were found by a run over the interval.
Editing Webhooks¶
Webhooks can be edited from the webhook lists on any of the settings pages where webhooks can be created.
The name and subscription choices cannot be changed, as those are used to uniquely identify the webhook entries to Mayhem. You may, however, edit the URL, Format, and selected events of existing
webhooks. Additionally, in the Edit Webhook form, there is a sample curl
command invocation that can be used to test the webhook configuration.
Deleting Webhooks¶
Webhooks can be deleted from the webhook lists on any of the settings pages where webhooks can be created.