Synthetic monitors API - PUT a monitor

Updates the specified monitor.

The configuration of the monitor is passed via its JSON script.

You can copy the script of an existing monitor and adjust it as needed.

This request is an early adopter release and may be changed in non compatible way.

PUT
  • Managed https://{your-domain}/e/{your-environment-id}/api/v1/synthetic/monitors/{monitorId}
  • SaaS https://{your-environment-id}.live.dynatrace.com/api/v1/synthetic/monitors/{monitorId}

Parameters

Refer to JSON models to find all JSON models that depend on the type of the model.

Parameter Type Description In Required
monitorId string

The ID of the synthetic monitor to be updated.

path required
body SyntheticMonitorUpdate body optional

The SyntheticMonitorUpdate object

The synthetic monitor update. This is a base object, the exact type depends on the value of the type field:

  • BROWSER -> BrowserSyntheticMonitorUpdate
  • HTTP -> HttpSyntheticMonitorUpdate
Element Type Description Required
frequencyMin integer

The frequency of the monitor, in minutes.

You can use one of the following values: 5, 10, 15, 30, and 60.

required
anomalyDetection AnomalyDetection

The anomaly detection configuration.

optional
type string

The type of the monitor.

The type element can hold these values.
required
name string

The name of the monitor.

required
locations string[]

A list of locations from which the monitor is executed.

To specify a location, use its entity ID.

required
enabled boolean

The monitor is enabled (true) or disabled (false).

required
script object

The script of a browser or HTTP monitor.

required
tags string[]

A set of tags assigned to the monitor.

Only specify the value of the tag here. The CONTEXTLESS context will be added automatically.

required
manuallyAssignedApps string[]

A set of manually assigned applications.

required

The AnomalyDetection object

The anomaly detection configuration.

Element Type Description Required
outageHandling OutageHandlingPolicy

Outage handling configuration.

required
loadingTimeThresholds LoadingTimeThresholdsPolicyDto

Performance thresholds configuration.

required

The LoadingTimeThresholdsPolicyDto object

Performance thresholds configuration.

Element Type Description Required
enabled boolean

Performance threshold is enabled (true) or disabled (false).

required
thresholds LoadingTimeThreshold[]

The list of performance threshold rules.

required

The LoadingTimeThreshold object

The performance threshold rule.

Element Type Description Required
type string

The type of the threshold: total loading time or action loading time.

The type element can hold these values.
required
valueMs integer

Notify if monitor takes longer than X milliseconds to load.

required
requestIndex integer

Specify the request to which an ACTION threshold applies.

optional

The OutageHandlingPolicy object

Outage handling configuration.

Element Type Description Required
globalOutage boolean

When enabled (true), generate a problem and send an alert when the monitor is unavailable at all configured locations.

required
localOutage boolean

When enabled (true), generate a problem and send an alert when the monitor is unavailable for one or more consecutive runs at any location.

required
localOutagePolicy LocalOutagePolicy

Local outage handling configuration.

required

The LocalOutagePolicy object

Local outage handling configuration.

Alert if affectedLocations of locations are unable to access the web application consecutiveRuns times consecutively.

Element Type Description Required
affectedLocations integer

The number of affected locations to trigger an alert.

required
consecutiveRuns integer

The number of consecutive fails to trigger an alert.

required

Possible values

Possible values for the type element in the SyntheticMonitorUpdate object:

  • BROWSER
  • HTTP

Possible values for the type element in the LoadingTimeThreshold object:

  • ACTION
  • TOTAL

Response format

A successful request doesn't return any content.

Example

In this example, the request updates the dynatrace.com monitor from the GET monitor example, changing the list of locations from which it is executed and increasing the frequency to 10 minutes.

The API token is passed in the Authorization header.

Since the request body is lengthy, it is truncated in this example Curl section. See the full body in the Request body section. You can download or copy the example request body to try it out on your own. Before using it, make sure that the location from the example is available in your environment. You can fetch the list of available locations with the GET all synthetic locations call. If the location is not available, replace it with any location you're using.

Curl

curl -X PUT \
  https://mySampleEnv.live.dynatrace.com/api/v1/synthetic/monitors/SYNTHETIC_TEST-0000000000025434 \
  -H 'Authorization: Api-Token abcdefjhij1234567890' \
  -H 'Content-Type: application/json' \  
  -d '{<truncated - see the Request body section > }
'

Request URL

https://mySampleEnv.live.dynatrace.com/api/v1/synthetic/monitors/SYNTHETIC_TEST-0000000000025434

Request body

api-examples/synthetic/put-monitor.json
Download
{
  "frequencyMin": 10,
  "anomalyDetection": {
    "outageHandling": {
      "globalOutage": true,
      "localOutage": false,
      "localOutagePolicy": {
        "affectedLocations": 1,
        "consecutiveRuns": 3
      }
    },
    "loadingTimeThresholds": {
      "enabled": false,
      "thresholds": []
    }
  },
  "type": "browser",
  "name": "dynatrace.com",
  "locations": [
    "GEOLOCATION-0A41430434C388A9",
    "GEOLOCATION-95196F3C9A4F4215",
    "GEOLOCATION-0DF9A0E1095A5A62"
  ],
  "enabled": true,
  "script": {
    "type":"clickpath",
    "version":"1.0",
    "configuration":{
      "device":{
        "deviceName":"Desktop",
        "orientation":"landscape"
      }
    },
    "events":[
      {
        "type":"navigate",
        "description":"Loading of \"http://www.dynatrace.com\"",
        "url":"http://www.dynatrace.com",
        "wait":{
          "waitFor":"page_complete"
        }
      },
      {
        "type":"click",
        "description":"click on \"Free trial\"",
        "target":{
          "locators":[
            {
              "type":"css",
              "value":"a:contains(\"Free trial\"):eq(1)"
            },
            {
              "type":"css",
              "value":".btn:eq(1)"
            },
            {
              "type":"css",
              "value":"#content div div div div div div div p:nth-child(3) a"
            },
            {
              "type":"css",
              "value":"#content div.homepage-hero-wrapper div.gallery div.flickity-viewport div.flickity-slider div.gallery-cell div.section div.column p.cta--row a.btn:eq(0)"
            }
          ]
        },
        "button":0,
        "wait":{
          "waitFor":"page_complete"
        }
      },
      {
        "type":"click",
        "description":"click on \"email\"",
        "target":{
          "locators":[
            {
              "type":"css",
              "value":"input[type=\"email\"][name=\"email\"]:eq(0)"
            },
            {
              "type":"dom",
              "value":"document.forms[0][\"email\"]"
            },
            {
              "type":"css",
              "value":".inputfield:eq(0)"
            },
            {
              "type":"css",
              "value":"#content div div:nth-child(2) form:nth-child(9) input:nth-child(3)"
            },
            {
              "type":"css",
              "value":"#content div.section div.tile form.cta input.inputfield:eq(0)"
            }
          ]
        },
        "button":0
      },
      {
        "type":"keystrokes",
        "description":"keystrokes on \"email\"",
        "target":{
          "locators":[
            {
              "type":"css",
              "value":"input[type=\"email\"][name=\"email\"]:eq(0)"
            },
            {
              "type":"dom",
              "value":"document.forms[0][\"email\"]"
            },
            {
              "type":"css",
              "value":".inputfield:eq(0)"
            },
            {
              "type":"css",
              "value":"#content div div:nth-child(2) form:nth-child(9) input:nth-child(3)"
            },
            {
              "type":"css",
              "value":"#content div.section div.tile form.cta input.inputfield:eq(0)"
            }
          ]
        },
        "textValue":"sample@sample.com",
        "masked":false,
        "simulateBlurEvent":true
      },
      {
        "type":"click",
        "description":"click on \"Start free trial\"",
        "target":{
          "locators":[
            {
              "type":"css",
              "value":"input[type=\"submit\"]:eq(0)"
            },
            {
              "type":"dom",
              "value":"document.forms[0][19]"
            },
            {
              "type":"css",
              "value":".btn:eq(1)"
            },
            {
              "type":"css",
              "value":"#content div div:nth-child(2) form:nth-child(9) div:nth-child(22) input"
            },
            {
              "type":"css",
              "value":"#content div.section div.tile form.cta div.cta__formgroup input.btn:eq(0)"
            }
          ]
        },
        "button":0,
        "wait":{
          "waitFor":"page_complete"
        }
      }
    ]
  },
  "tags": []
}

Response code

204