Classic Webhooks for Alert Notifications
In this article, we'll describe the configuration of alerts to use classic webhooks (henceforth, simply "webhooks"). Additionally, for those unfamiliar with webhooks or who will benefit from constructing a quick example, we provide information to set up a test web service using Heroku. For reference, we've also included example POST body data at the end of this article.
Configuring Webhook Notifications
To configure notifications to a webhook server, you'll need to define a webhook in Alerts > Alert Rules. Expand an alert rule and select the Notifications tab. Under the Webhooks section, click the Configure Webhooks link. If you already have configured webhooks, click the Edit webhooks link:
Click Add New Webhook, then complete the New Webhook dialog:
Enter the Name of your Webhook, and the target URL (note that HTTP redirects are not accepted, so be sure to provide the final URL). Configure required authentication if required, and click Test to check your configuration:
NOTE: Encoded HTML URLs are currently not supported for webhook configuration. Enter the URL in decoded form. If the test succeeds, a Webhook test completed successfully message displays:
Once you have tested your webhook server successfully, click Add New Webhook, and select your webhook from the list of configured webhooks. You can add any number of custom, static key-value pairs to the webhook payload. These custom payloads can be used on any Cloud or Enterprise Agent alert type and are specific to the selected alert rule.
To add these elements, navigate to an individual alert rule, select a webhook, and click Add Custom Payload (1). A key-value pair (2) field appears that allows you to enter any static key-value pair. You can add or remove these payloads using the - and + buttons (3).
Additionally, this change adds two new fields to the webhook payload: testLabels, which includes test label name and ID, as well as testTargetsDescription, which includes the description of the test target as defined in the test configuration.
Webhook Authentication
The webhook interface supports the use of a token, OAuth, and basic HTTP authentication. This is an optional configuration step and can be configured for a webhook service if the target server requires authentication.
Basic
A Username and corresponding Password are necessary to configure Basic HTTP Authentication:
Token
The Token Auth Type uses a Bearer Token to authenticate with the webhook server:
OAuth
Webhook Server-Side Configuration
Create a new OAuth endpoint for ThousandEyes Alerts with https://app.thousandeyes.com/webhooks-oauth-callback/ as redirect/call back URL. Grab the newly created Client ID and Authorization Endpoint URL (Auth URL) for the webhook server to configure ThousandEyes-side authentication. Below is an example Client OAuth configuration from ServiceNow:
NOTICE: Ensure that the token has a sufficient lifespan to avoid manual regeneration on timeout.
ThousandEyes-Side Configuration
Configure the webhook Name and URL as explained in the Configuring Webhook Notifications section. Click OAuth in Auth Type. Fill out the Auth URL and Client ID according to the Webhook Server-Side Configuration section above. Click Get Token:
A new tab opens, requesting consent to authorize ThousandEyes. Below is a snippet from ServiceNow application that we are using in this guide as an example:
Once the authorization is complete, a Token retrieved successfully message is displayed, as shown in the following figure:
Now click Test to verify the operability of your new webhook:
Setting Up a Webhook Server
If you visit Heroku, you can deploy a free web application. If you're new to Heroku, it's worth running through their instructional tutorials to understand how the deployment process works. Follow these instructions to deploy a simple version of your web service.
Install the Heroku command line interface (CLI). Go to https://devcenter.heroku.com/articles/getting-started-with-nodejs#set-up, and follow the instructions to download the Heroku CLI for your operating system.
Clone your git repository.
Create a Heroku remote in your git repository.
Push your content to the Heroku remote. This will build the application.
Open the site to confirm the target location. This opens a web browser in the context of your Heroku application.
Open a console to review the logs of the target server. In this window, you'll see POST requests hitting your server.
Webhook POST Content
Webhooks use events to signify activity. Our system is configured today to support the following types of events:
WEBHOOK_TEST - sent when a user clicks the Test Webhook link in ThousandEyes webhook configuration.
ALERT_NOTIFICATION_TRIGGER - sent when an alert is triggered
ALERT_NOTIFICATION_CLEAR - sent when an alert is cleared, the alert rule is deleted, or the alert rule is removed from a test while in an active alerting status.
Note: All eventIds
are unique. To correlate two events (for example, an alert trigger and clear) reference the alertId
, which is unique per generated alert.
Agent Webhook Notifications
Notifications sent by agents use the same eventType
as regular notifications. See the payload examples for agent notifications in the Sample Webhook Event Payloads section below.
ALERT_NOTIFICATION_TRIGGER - sent when an agent notification triggers - may be related to clock offset, version number, or agent online status
ALERT_NOTIFICATION_CLEAR - sent when the agent notification clears
Note: All eventIds
are unique. To correlate two events (for example, an alert trigger and clear) reference the alertId
, which is unique per generated alert.
Sample Webhook Event Payloads
Each event type shown below contains a sample JSON payload, which is posted to the target server. The Alert notification data corresponds to alerting data from the ThousandEyes API, wrapped in an event wrapper. See the ThousandEyes Developer site for more information on data returned via the API.
WEBHOOK_TEST
ALERT_NOTIFICATION_TRIGGER
ALERT_NOTIFICATION_CLEAR
Agent Notifications
ALERT_NOTIFICATION_TRIGGER
ALERT_NOTIFICATION_CLEAR
Allowlist Requirements
If your web server only allows requests from allowlisted senders, you will need to allow requests from ThousandEyes web servers. You can find the list of allowed IP addresses at Firewall Exception Requirements.
Related Articles
For a guide on creating your own alert rules, see Creating and Editing Alert Rules.
Last updated