• Home
  • Dynatrace API
  • Configuration
  • Calculated metrics
  • Synthetic
  • POST a metric

Synthetic metrics API - POST a metric

Creates a new calculated synthetic metric.

The request consumes and produces an application/json payload.

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

Authentication

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

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

Parameters

ParameterTypeDescriptionInRequired
bodyCalculatedSyntheticMetric

The JSON body of the request. Contains definition of the new calculated synthetic metric.

bodyoptional

Request body objects

The CalculatedSyntheticMetric object

Definition of the calculated synthetic metric.

ElementTypeDescriptionRequired
monitorIdentifierstring

The Dynatrace entity ID of the synthetic monitor to which the metric belongs.

required
namestring

The name of the metric, displayed in the UI.

required
metricKeystring

The unique key of the metric.

The key must have the calc:synthetic prefix.

required
enabledboolean

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

required
metricstring

The type of the synthetic metric.

The element can hold these values
  • ApplicationCache
  • Callback
  • CumulativeLayoutShift
  • DNSLookup
  • DOMComplete
  • DOMContentLoaded
  • DOMInteractive
  • FailedRequestsResources
  • FirstContentfulPaint
  • FirstInputDelay
  • FirstInputStart
  • FirstPaint
  • HTMLDownloaded
  • HttpErrors
  • JavaScriptErrors
  • LargestContentfulPaint
  • LoadEventEnd
  • LoadEventStart
  • LongTasks
  • NavigationStart
  • OnDOMContentLoaded
  • OnLoad
  • Processing
  • RedirectTime
  • Request
  • RequestStart
  • ResourceCount
  • Response
  • SecureConnect
  • SpeedIndex
  • TCPConnect
  • TimeToFirstByte
  • TotalDuration
  • TransferSize
  • UserActionDuration
  • VisuallyComplete
required
dimensionsSyntheticMetricDimension[]

A list of metric dimensions.

optional
filterSyntheticMetricFilter

Filter of the calculated synthetic metric.

optional

The SyntheticMetricDimension object

Dimension of the calculated synthetic metric.

ElementTypeDescriptionRequired
topXinteger

The number of top values to be calculated.

optional
dimensionstring

The dimension of the metric.

The element can hold these values
  • Event
  • Location
  • ResourceOrigin
required

The SyntheticMetricFilter object

Filter of the calculated synthetic metric.

ElementTypeDescriptionRequired
actionTypestring

Only user actions of the specified type are included in the metric calculation.

The element can hold these values
  • Custom
  • Load
  • Xhr
optional
hasErrorboolean

The execution status of the monitors to be included in the metric calculation:

  • true: Only failed executions are included.

  • false: All executions are included.

optional
errorCodeinteger

Only executions finished with the specified error code are included in the metric calculation.

optional
eventstring

Only the specified browser clickpath event is included in the metric calculation.

Specify the Dynatrace entity ID of the event here. You can fetch the list of clickpath events of the monitor with the GET a synthetic monitor request from the Environment API

optional
locationstring

Only executions from the specified location are included in the metric calculation.

Specify the Dynatrace entity ID of the location here. You can fetch the list of locations the monitor is running from with the GET a synthetic monitor request from the Environment API.

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
{ "enabled": true, "name": "MyMetric", "metricKey": "calc:synthetic.browser.mymetric", "metric": "UserActionDuration", "monitorIdentifier": "SYNTHETIC_TEST-1234", "filter": { "event": "SYNTHETIC_TEST_STEP-1234", "hasError": true }, "dimensions": [ { "dimension": "Location" } ] }

Response

Response codes

CodeTypeDescription
201EntityShortRepresentation

Success. The calculated synthetic metric has been created. Response contains its key and name.

400ErrorEnvelope

Failed. The input is invalid

Response body objects

The EntityShortRepresentation object

The short representation of a Dynatrace entity.

ElementTypeDescription
idstring

The ID of the Dynatrace entity.

namestring

The name of the Dynatrace entity.

descriptionstring

A short description of the Dynatrace entity.

Response body JSON model

json
{ "id": "6a98d7bc-abb9-44f8-ae6a-73e68e71812a", "name": "Dynatrace entity", "description": "Dynatrace entity for the REST API example" }

Validate payload

We recommend that you validate the payload before submitting it with an actual request. A response code of 204 indicates a valid payload.

The request consumes an application/json payload.

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

Authentication

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

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

Response

Response codes

CodeTypeDescription
204

Validated. The submitted calculated synthetic metric is valid. The response doesn't have a body.

400ErrorEnvelope

Failed. The input is invalid.

Related topics
  • Synthetic Monitoring

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