Alert Webhook Templates

Prev Next

Overview

The Alert Webhook template can be used to format the contents of the alert data before it is sent to the URL configured in the Settings section of the Alert Webhook.

Every client can add three URLs for Alert Webhook by default. One can add three URLs for every division.

Implementation

To create an Alert template:

  1. Click on the API link in the settings module.
  2. In the Alert Webhook section select the radio button labeled Template.
  3. Click Add New in the template selection drop-down menu. (Existing templates can be edited in the menu by hovering over the template name and selecting the Edit/View Properties icon.)
  4. A lightbox will pop-up where you can create a name for the template and define the contents. The content should be valid JSON or XML.

Alert Macro Usage

The JSON and XML fields can be hardcoded as well as filled in dynamically with data provided from the system. This includes data like the test name, the alert severity, conditions that triggered the alert, locations of the node for which a test run caused an alert to trigger, etc.

For example, we can use the Alert Webhook template to provide the timestamp and severity level of an alert in JSON where macros are used with the following syntax, ${macroName}:

{
"ts":"${alertCreateDateUtc}",    "eventstate":"${switch("${notificationLevelId}","0","WARNING","1","CRITICAL","3","IMPROVED")}",
"service":"${testName}",
"attributes":{"department":"app_svcs_desk","skill":"Alert Applications","application":"${ProductName}"},
"text":"${testName}"
}

The XSD for the Alert Webhook can be found here

Parent & Child Macros

It is important to take caution when using parent and child macros, such as ${nodeDetails} and ${nodeMean}, as a separator character (such a space or comma) may be needed for clarity.

This is because the child ${nodeMean} macro will show data for each and every node in a conjugated manner.

For example, for two-node runs of a single test, one with a Webpage Response time of 3200ms and another with a Webpage Response time of 4500ms:

Template without a separator:

{
"text": "Webpage Response time threshold has been exceeded on ${testName} - ${nodeDetails(${nodeMean})} ms time."
}

Will result in:

Webpage Response time threshold has been exceeded on Sample Web Test - 32004500 ms time.

Template with a separator:

{
"text": "Webpage Response time threshold has been exceeded on ${testName} - ${nodeDetails(${nodeMean};)} ms time."
}

Will result in:

Webpage Response time threshold has been exceeded on Sample Web Test - 3200; 4500 ms time.

Using Template to Control Alert Flow

The Alert Templates can be used to control which urls get triggered alerts. Please note that whenever an alert is triggered Catchpoint will still attempt to post. It is best to build your template to avoid posting a poorly formatted payload and getting errors on post. Errors posting can cause delay in the alert push api. It is recommend you use the ${switch} macro to dynamically add a flag that can be filtered by your webhook consumer. The switch macro can also be used to control the url like so:

http://${Switch("${TestId}","177184","url123.com/xf1gq2xf","177185","url321.net/12050jb1")}

Alert Webhook Macro Index

For a list of alert macros, please reference the list here.