JSON Alerts

AlertSite can send alerts in the JSON format to an external URL via an HTTP POST request. This is known as outgoing webhooks. You can use this to send alerts to your web servers or third-party services that accept incoming JSON data. For example, Slack integration uses JSON alerts with custom templates.

In This Topic

Considerations

Creating a JSON POST Recipient

In AlertSite UXM, go to Alerts > Alert Recipients and create a recipient of the POST JSON request to web server type.

Specify the target URL in the Recipient field. This URL must be available on the public Internet. Make sure to include http:// or https:// at the beginning of the URL.

If the target URL is protected with Basic authentication, specify the User and Password.

Creating a JSON alert recipient

Once you create the recipient, edit it and choose whether it will receive availability alerts, performance alerts or both. For a description of the available settings, see Editing Recipients.

Alert Data

Alerts contain information about the monitor and location that triggered the error, the error details, the date and time of the last check, and other details. By default, JSON alerts have the following format (see Alert Data Fields for the field descriptions).

Alerts are sent directly from AlertSite locations. You can see our IPs here.

The User-Agent in requests has the ipd/ prefix, for example, ipd/1.0 (ipd; IPD 1.0; AlertSite).

Templates

You can change the field names and structure of JSON alerts by creating custom alert templates. There are separate templates for the “error” and “clear” alerts, availability and performance alerts. The templates use variables to insert the monitor information into the alert.

Note: In order for custom templates to have effect, you need to either make these templates the default ones, or create a recipient group that combines the desired monitors, recipients and custom templates.

For examples of using custom templates, see Slack Integration and VictorOps Integration.

Availability Template Variables

The following variables are used in the Site Error and Site Clear templates.

Variable Description Example
$ALERT_NOTE Custom alert notes specified in the monitor settings. Maintenance is scheduled for this weekend.
$CERRORS The number of consecutive errors. 3
$COMPANY The AlertSite customer name, as seen on the Profile > Account screen. SmartBear Software
$CUSTID The AlertSite customer ID, as seen on the Profile > Account screen. C12345
$DESCRIP The monitor name. Home page
$DEVICE_ID The monitor ID. 13570
$DT_STATUS The date and time when the monitor was last checked, in the format YYYY-MM-DD hh:mm:ss. The timestamps in alerts use the time zone specified in your AlertSite settings. 2017-05-18 13:33:06
$FULLIP The IP address the monitored server resolved to. 93.184.216.34
$GROUP_MEMBERS If the alert was sent to a recipient group, this is a semicolon-delimited list of recipients in this group. Each recipient is in the format:
[Recipient Name - ]Recipient

The text in square brackets [ ] is optional and is included only if the recipient name is defined.

development@example.com; Operations - operations@example.com
$GROUP_NAME If the alert was sent to a recipient group, this is the name of the recipient group that triggered the current alert. Otherwise, an empty string. DevOps
$HTTP_STATUS The HTTP status of the monitor or of the failed step. HTTP/1.1 503 Service Unavailable
$ISTXN 1 for DéjàClick, SoapUI, Selenium and Perfecto Mobile monitors. 0 for other monitor types. 1
$LOC ID of the $LOCDESC location. 10
$LOCDESC The name of the AlertSite location that sent the alert. Note that depending on the monitoring mode, this may be not the same location that actually had the error. If rotated locations are used, those locations and their statuses are included in $RRDETAIL_ROWS. Fort Lauderdale, FL
$LOGIN The AlertSite login email of the account’s admin user. demo@example.com
$MSG The description of the AlertSite status code. HTTP error from web server
$NAME The name of the failed step in a multi-step monitor (DéjàClick, Selenium, SoapUI or Perfecto Mobile). An empty string otherwise.

Note: This variable is used in error templates only.

Customer Login
$NOTIFY_TYPE The message type: error, clear, test. error
$RRDETAIL_ROWS This variable is specific to monitors that use rotated locations or were configured with the monitoring mode set to SLA (MultiPOP) or Round Robin. In other cases, the value of $RRDETAIL_ROWS will be empty.

$RRDETAIL_ROWS contains the monitor status at all locations used during the test interval. It is an array variable, which means the variable is replaced with the contents of the $RRDETAIL_ROWS template for each location. Multiple items are separated by commas.

The default $RRDETAIL_ROWS template is:

{
   "status" : "$RROBJ_ERRNO",
   "status_text" : "$RROBJ_ERRMSG",
   "location" : "$RROBJ_LOC"
}

which expands to:

{
   "status" : "7",
   "status_text" : "HTTP error from web server",
   "location" : "Fort Lauderdale, FL"
},
{
   "status" : "0",
   "status_text" : "Site responded normally to all tests",
   "location" : "Atlanta, GA"
},
{
   ...
}

As another example, the following template:

"$RROBJ_LOC: $RROBJ_ERRNO - $RROBJ_ERRMSG"

expands to:

"Fort Lauderdale, FL: 7 - HTTP error from web server",
"Atlanta, GA: 0 - Site responded normally to all tests"

Note: The $RRDETAIL_ROWS variable is used in error templates only.

 
$SEQNO The step number (from 1) of the failed step in a multi-step monitor. An empty string otherwise.

Note: This variable is used in error templates only.

3
$STATUS AlertSite status code. 0 means no errors. 7
$STATUS_LINK Link to the run results in AlertSite.

Note: This variable is used in error templates only.

https://www.alertsite.com/cgi-bin/goevent?obj_devlog=12345678
$TYPE The monitor type as a one-letter code. See device_typecode for possible values. w
$TYPEPORT The monitor type. See device_type for possible values. Web Server
$URLLINE The monitored URL in web URL and API endpoint monitors. https://example.com
Variables used in the $RRDETAIL_ROWS template
$RROBJ_ERRMSG The description of the monitor status at this location. HTTP error from web server
$RROBJ_ERRNO The monitor status at this location. 7
$RROBJ_LOC The AlertSite location name. Fort Lauderdale, FL

Performance Template Variables

The following variables can be used in the Performance Error and Performance Clear templates. The Performance Error template applies to both performance errors and warnings.

Note that the $NOTIFY_TYPE, $MSG and $STATUS variables mean the same thing (message type), just use different values for that.

Variable Description Example
$COMPANY The AlertSite customer name, as seen on the Profile > Account screen. SmartBear Software
$CUSTID The AlertSite customer ID, as seen on the Profile > Account screen. C12345
$DESCRIP The monitor name. Home page
$DEVICE_ID The monitor ID. 13570
$DT_STATUS The date and time the performance alert was triggered, in the YYYY-MM-DD hh:mm:ss format. The timestamps in alerts use the time zone specified in your AlertSite settings. 2017-05-18 13:33:06
$MSG The message type – ERROR, WARN or CLEAR. ERROR
$NAME If step-level performance alerts are configured for the monitor, this is the name of the step that triggered this performance alert. An empty string otherwise. Customer Login
$NOTIFY_TYPE The message type: perf_error, perf_warning, perf_clear. perf_error
$RRDETAIL_COUNT The number of locations per interval used by this monitor. Individual locations are included in $RRDETAIL_ROWS.

Note: This variable is used in error templates only.

2
$RRDETAIL_ROWS

This variable contains the response time measurement for all locations used during the test interval. It is an array variable, meaning the variable is replaced with the contents of the $RRDETAIL_ROWS template for each location. Multiple locations are separated by commas.

The default template is:

{
  "perf_status" : "$RROBJ_ERRNO",
  "perf_actual" : "$RROBJ_ACTUAL",
  "perf_threshold": "$RROBJ_THRESHOLD",
  "perf_location" : "$RROBJ_LOC",
  "perf_location_num" : "$RROBJ_LOC_ID"
}

which expands to:

{
  "perf_status" : "20",
  "perf_actual" : "5.234",
  "perf_threshold": "4.500",
  "perf_location" : "Austin, Texas",
  "perf_location_num" : "63"
},							
{
  "perf_status" : "10",
  "perf_actual" : "3.417",
  "perf_threshold": "2.500",
  "perf_location" : "Dublin, Ireland",
  "perf_location_num" : "5040"
},
{
  ...
}

Note: The $RRDETAIL_ROWS variable is used in error templates only.

 
$SEQNO If step-level performance alerts are configured for the monitor, this is the step number (from 1) of the step that triggered the performance alert.

In monitor-level alerts, this is 0.

3
$STATUS The message type:
  • 20 – error
  • 10 – warning
  • 0 – clear
 
$STATUS_LINK The link to the Performance Alert Report that visualizes the response time at each location compared to the error and warning thresholds.

Note: This variable is used in error templates only.

https://www.alertsite.com/rd/12345678
Variables used in the $RRDETAIL_ROWS template
$RROBJ_ACTUAL Current average response time at this location, in seconds. 4.706
$RROBJ_ERRMSG The performance condition that this location observes:
  • ERROR
  • WARN
  • CLEAR (response time is within limits)
This value is not necessarily the same as $MSG.
WARN
$RROBJ_ERRNO The performance condition that this location observes:
  • 20 – error
  • 10 – warning
  • 0 – no error (the response time is below the thresholds)
This value is not necessarily the same as $STATUS.
10
$RROBJ_LOC AlertSite location name. Fort Lauderdale, FL
$RROBJ_LOC_ID AlertSite location ID. See Monitoring Locations for possible values. 10
$RROBJ_THRESHOLD The response time threshold, in seconds, that is specified in the monitor settings. If $RROBJ_ERRNO is 20, this is the error threshold; otherwise, this is the warning threshold. 2.500

Testing Custom Templates

Templates can be tested by sending a sample alert to a URL. You can use http://requestb.in to create temporary URLs for testing and to inspect the data that comes in.

To test a template:

See Also

© 2017 SmartBear Software. All rights reserved.      Terms of Use · Privacy Policy