Script mode for HTTP monitor configuration

In addition to the configuration in the UI (Visual mode), you can use Script mode to configure your HTTP monitors. In this mode, you can access the underlying JSON script of your monitor. If you're a Synthetic Monitoring power user, this will make your life a lot easier and allow you to speed up monitor creation and management. Use the script editor to quickly find specific events (steps) or adapt locators across the entire script.

You aren't limited to just one mode—you can switch between the UI and script modes by selecting the Visual mode/Script mode.

Access the script

To edit your HTTP monitor in script mode:

  1. Go to the Synthetic monitors page and opt to view it in list mode.
  2. Select the check box next to the monitor that you want to edit > select Edit in the lower-left corner.
  3. Select the HTTP Requests tab of Monitor settings on the left.
  4. Select Script mode at the top.

Edit the script

You can download the script (Download script as .json) or just copy it from the editor and edit it in a text editor of your choice. However, you can also edit the script directly in the browser. This provides the following benefits:

  • Autocomplete—just press Ctrl+Spacebar to see a list of suggestions.
  • Syntax highlighting makes it easier for you to write script code.
  • Instant error validation—the editor instantly shows a warning for any error in the script. Hover over the error to see what's wrong and a suggestion for how to fix it. You cannot save changes until the code is error free.

Script structure

Main script object

Contains the monitor script.

Element Type Description Required
version string Script version—use the 1.0 value here. required
requests

Array of:
request

A list of HTTP requests to be performed by the monitor

The requests are executed in the order in which they appear in the script.

required

The request object

Contains the parameters of an HTTP request.

Element Type Description Required
description string A short description of the event to appear in the web UI optional
url string The URL to check required
method string The HTTP method of the request required
requestBody string

The body of the HTTP request—you need to escape all JSON characters.

Is set to null if the request method is GET, HEAD, or OPTIONS.

optional
validation requestValidation

The validation configuration of the request

Validation helps you verify that your HTTP monitor loads the expected content.

optional
configuration requestConfiguration The setup of the monitor optional
preProcessingScript string

The script executed before the request

You must escape all JSON characters and break lines with /n.

optional
postProcessingScript string

The script executed after the request

You must escape all JSON characters and break lines with /n.

optional

The requestValidation object

Contains the validation configuration for the request.

Element Type Description Required
rules

Array of:
validationRule

A list of validation rules optional
rulesChaining string

The logical operator that applies to rules is or.

optional

The validationRule object

Contains a validation rule.

Element Type Description Required
type string

The type of rule—possible values are:

  • patternConstraint—performs a simple content match.
  • regexConstraint—interprets the content match as a regular expression.
  • httpStatusesList—validates a list of HTTP status codes.
  • certificateExpiryDateConstraint—checks if certificate expiry is within a specified number of days.
required
passIfFound boolean

The validation condition:

  • true—validation succeeds if the specified content/element is found.
  • false—validation fails if the specified content/element is found.

Always specify false for certificateExpiryDateConstraint to fail the monitor if SSL certificate expiry is within the specified number of days.

required
value string The content to look for required

The requestConfiguration object

Contains the setup of the monitor.

Element Type Description Required
userAgent string The User agent of the request optional
acceptAnyCertificate boolean

Accept any (true) or only a trusted (false) SSL certificate.

If set to false, then the monitor fails with invalid SSL certificates.

If not set, the false option is used.

optional
followRedirects boolean

Follow (true) or don't follow (false) redirects.

If set to false, redirects are reported as successful requests with response code 3xx.

If not set, the false option is used.

optional
requestHeaders

Array of:
requestHeader

A list of additional headers for the request

By default, only the User-Agent header is set.

You can't set or modify this header here. Use the userAgent field for that.

optional

The requestHeader object

Contains an HTTP header of the request.

Element Type Description Required
name string The key of the header required
value string The value of the header required