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, JSON alerts can be sent to Slack (using custom alert 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 add http:// or https:// at the beginning of the URL.

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

Alert payload contains information about the monitor and location that triggered the error, the error details, the date and time of the last check, and other details. You can see sample alerts below.

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).

Availability Alerts

The default payload for availability alerts is as follows. For the field descriptions, see Availability Alert Fields. The payload can be customized using alert templates (see below).

{
  "source": "AlertSite",
  "notify_type": "error",
  "custid": "C12345",
  "company": "SmartBear Software",
  "device_id": "135790",
  "device_name": "Home page",
  "timestamp": "2017-05-17 14:22:08",
  "status": "7",
  "errcount": "3",
  "status_text": "HTTP error from web server",
  "location": "Fort Lauderdale, FL",
  "location_num": "10",
  "device_typecode": "w",
  "device_type": "Web Server",
  "transaction": "0",
  "url": "https://example.com",
  "http_status": "HTTP 500",
  "step_num": "",
  "step_name": "",
  "rotated_locations": [
    {
      "status": "0",
      "status_text": "Site responded normally to all tests",
      "location": "Atlanta, GA"
    },
    {
      "status": "7",
      "status_text": "HTTP error from web server",
      "location": "Fort Lauderdale, FL"
    }
  ]
}

Performance Alerts

The performance alert payload is as follows. For the field descriptions, see Performance Alert Fields.

{
  "source": "AlertSite",
  "notify_type": "perf_error",
  "custid": "C12345",
  "company": "SmartBear Software",
  "device_id": "135790",
  "device_name": "Home page",
  "timestamp": "2017-05-17 14:22:08",
  "status": "20",
  "perf_count": 2,
  "locations": [
    {
      "perf_location": "London, UK - Docklands",
      "perf_location_num": "5130",
      "perf_status": "20",
      "perf_actual": "3.503",
      "perf_threshold": "3.500"
    },
    {
      "perf_location": "Miami, Florida",
      "perf_location_num": "19",
      "perf_status": "10"
      "perf_actual": "2.361",
      "perf_threshold": "2.000"
    }
  ]
}

The format is fixed and cannot be changed. It is expected that the target server supports this format. If you need performance alerts in a different format (for example, for usage with a third-party service), you could send the alerts to your server which would then convert the alerts to the desired format and forward them to the target server.

Templates

You can customize the format of JSON availability alerts by creating custom alert templates. There are separate templates for the “error” and “clear” notifications. Use the template variables to insert monitor information into your template.

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.

Template Variables

The following variables can be used in JSON alert templates. When an alert is sent, these variables will be replaced with the corresponding data.

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 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 the $RRDETAIL_ROWS template variable. 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 alert type – error, clear, test. error
$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 The 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

The following variables are 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.

Variable Description Example
$RRDETAIL_ROWS The monitor status at all locations used during the test interval. This 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 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"
 
$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

Testing Custom Templates

You can test your custom JSON templates by sending a sample alert to a URL. To do this:

See Also

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