• Home
  • Dynatrace API
  • Environment
  • Synthetic v1
  • Monitors
  • POST a monitor

Synthetic monitors API - POST a monitor

Creates a new synthetic monitor.

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

POSTManagedDynatrace for Governmenthttps://{your-domain}/e/{your-environment-id}/api/v1/synthetic/monitors
SaaShttps://{your-environment-id}.live.dynatrace.com/api/v1/synthetic/monitors
Environment ActiveGatehttps://{your-activegate-domain}/e/{your-environment-id}/api/v1/synthetic/monitors

Authentication

To execute this request, you need an access token with ExternalSyntheticIntegration scope.

To learn how to obtain and use it, see Tokens and authentication.

Parameters

To find all model variations that depend on the type of the model, see JSON models.

ParameterTypeDescriptionInRequired
bodySyntheticMonitorUpdate

The JSON body of the request, containing parameters of the new synthetic monitor.

bodyoptional

Request body objects

The SyntheticMonitorUpdate object

The synthetic monitor update.

The actual set of fields depends the type of the monitor. Find the list of actual objects in the description of the type field or see Synthetic monitors API - JSON models.

ElementTypeDescriptionRequired
frequencyMininteger

The frequency of the monitor, in minutes.

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

required
anomalyDetectionAnomalyDetection

The anomaly detection configuration.

optional
typestring

Defines the actual set of fields depending on the value. See one of the following objects:

  • BROWSER -> BrowserSyntheticMonitorUpdate
  • HTTP -> HttpSyntheticMonitorUpdate
The element can hold these values
  • BROWSER
  • HTTP
required
namestring

The name of the monitor.

required
locationsstring[]

A list of locations from which the monitor is executed.

To specify a location, use its entity ID.

required
enabledboolean

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

required
scriptobject

The script of a browser or HTTP monitor.

required
tagsTagWithSourceInfo[]

A set of tags assigned to the monitor.

You can specify only the value of the tag here and the CONTEXTLESS context and source 'USER' will be added automatically. But preferred option is usage of TagWithSourceDto model.

required
manuallyAssignedAppsstring[]

A set of manually assigned applications.

required

The AnomalyDetection object

The anomaly detection configuration.

ElementTypeDescriptionRequired
outageHandlingOutageHandlingPolicy

Outage handling configuration.

required
loadingTimeThresholdsLoadingTimeThresholdsPolicyDto

Performance thresholds configuration.

required

The OutageHandlingPolicy object

Outage handling configuration.

ElementTypeDescriptionRequired
globalOutageboolean

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

required
globalOutagePolicyGlobalOutagePolicy

Global outage handling configuration.

optional
localOutageboolean

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
localOutagePolicyLocalOutagePolicy

Local outage handling configuration.

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

required
retryOnErrorboolean

Schedule retry if browser monitor execution results in a fail. For HTTP monitors this property is ignored.

optional

The GlobalOutagePolicy object

Global outage handling configuration.

ElementTypeDescriptionRequired
consecutiveRunsinteger

Alert if all locations are unable to access the web application X times consecutively.

required

The LocalOutagePolicy object

Local outage handling configuration.

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

ElementTypeDescriptionRequired
affectedLocationsinteger

The number of affected locations to trigger an alert.

required
consecutiveRunsinteger

The number of consecutive fails to trigger an alert.

required

The LoadingTimeThresholdsPolicyDto object

Performance thresholds configuration.

ElementTypeDescriptionRequired
enabledboolean

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

required
thresholdsLoadingTimeThreshold[]

The list of performance threshold rules.

required

The LoadingTimeThreshold object

The performance threshold rule.

ElementTypeDescriptionRequired
typestring

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

The element can hold these values
  • ACTION
  • TOTAL
required
valueMsinteger

Notify if monitor takes longer than X milliseconds to load.

required
requestIndexinteger

Specify the request to which an ACTION threshold applies.

optional
eventIndexinteger

Specify the event to which an ACTION threshold applies.

optional

The TagWithSourceInfo object

Tag with source of a Dynatrace entity.

ElementTypeDescriptionRequired
sourcestring

The source of the tag, such as USER, RULE_BASED or AUTO

The element can hold these values
  • AUTO
  • RULE_BASED
  • USER
optional
contextstring

The origin of the tag, such as AWS or Cloud Foundry.

Custom tags use the CONTEXTLESS value.

The element can hold these values
  • AWS
  • AWS_GENERIC
  • AZURE
  • CLOUD_FOUNDRY
  • CONTEXTLESS
  • ENVIRONMENT
  • GOOGLE_CLOUD
  • KUBERNETES
required
keystring

The key of the tag.

Custom tags have the tag value here.

required
valuestring

The value of the tag.

Not applicable to custom tags.

optional

Request body JSON model

This is a model of the request body, showing the possible elements. It has to be adjusted for usage in an actual request.

json
{ "frequencyMin": 5, "anomalyDetection": { "outageHandling": { "globalOutage": true, "localOutage": true, "localOutagePolicy": { "affectedLocations": 1, "consecutiveRuns": 3 } }, "loadingTimeThresholds": { "enabled": true, "thresholds": [ { "type": "TOTAL", "valueMs": 100, "requestIndex": 1 } ] } }, "type": "BROWSER", "name": "Browser Monitor Example", "locations": [ "GEOLOCATION-9999453BE4BDB3CD" ], "enabled": true, "script": { "type": "availability", "version": "1.0", "configuration": { "device": { "deviceName": "Desktop", "orientation": "landscape" } }, "events": [ { "type": "navigate", "description": "Loading of \"example.com\"", "url": "http://example.com", "wait": { "waitFor": "page_complete" } } ] }, "keyPerformanceMetrics": { "loadActionKpm": "VISUALLY_COMPLETE", "xhrActionKpm": "VISUALLY_COMPLETE" }, "tags": [ "example" ], "manuallyAssignedApps": [ "APPLICATION-4ADF0EF407C7C545" ], "events": [] }

Response

Response codes

CodeTypeDescription
200EntityIdDto

Success. The new synthetic monitor has been created. The response contains the Dynatrace entity ID of the new monitor.

Response body objects

The EntityIdDto object

A DTO for entity ID.

ElementTypeDescription
entityIdstring

Entity ID to be transferred

Response body JSON model

json
{ "entityId": "string" }

Example

In this example, the request creates a simple browser monitor that navigates to dynatrace.com.

The monitor is executed every 10 minutes from one location, which has the ID of GEOLOCATION-0A41430434C388A9. A problem will be raised if the website is unavailable for three consecutive runs. A notification is sent if the website takes longer than 500 milliseconds to load.

The API token is passed in the Authorization header.

The response contains the entity ID of the newly created monitor.

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

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

Request URL

plaintext
https://mySampleEnv.live.dynatrace.com/api/v1/synthetic/monitors

Request body

json
{ "frequencyMin": 10, "anomalyDetection": { "outageHandling": { "globalOutage": true, "localOutage": false, "localOutagePolicy": { "affectedLocations": 1, "consecutiveRuns": 3 } }, "loadingTimeThresholds": { "enabled": true, "thresholds": [ { "type": "total", "valueMs": 500 } ] } }, "type": "BROWSER", "name": "restExample", "locations": ["GEOLOCATION-0A41430434C388A9"], "enabled": true, "script": { "configuration": { "device": { "orientation": "landscape", "deviceName": "Desktop" } }, "type": "clickpath", "version": "1.0", "events": [ { "type": "navigate", "wait": { "waitFor": "page_complete" }, "description": "navigate to main page ", "url": "https://www.dynatrace.com" } ] }, "tags": ["restExample"] }

Response body

json
{ "entityId": "SYNTHETIC_TEST-00000000000254E2" }

Response code

200

Related topics
  • Synthetic Monitoring

    Learn about Synthetic Monitoring and how to create a single-URL browser monitor, a browser clickpath, or an HTTP monitor.

  • Script mode for browser monitor configuration

    Create or edit your browser monitors in JSON format.

  • Script mode for HTTP monitor configuration

    Create or edit your HTTP monitors in JSON format.