Metric events anomaly detection API - PUT an event
Updates the specified metric event rule.
The request consumes an application/json
payload.
This request is an Early Adopter release and may be changed in non-compatible way.
PUT |
|
Authentication
To execute this request, you need the Write configuration (WriteConfig
) permission assigned to your API token. To learn how to obtain and use it, see Tokens and authentication.
Parameters
To find all JSON models that depend on the type of the model, refer to JSON models.
Parameter | Type | Description | In | Required |
---|---|---|---|---|
id | string |
The ID of the metric event to be updated. If you also set the ID in the body, it must match this ID. |
path | required |
body | MetricEvent |
The JSON body of the request. Contains updated parameters of the metric event. |
body | optional |
Body format
The MetricEvent object
The configuration of the metric event.
Element | Type | Description | Required |
---|---|---|---|
metadata | ConfigurationMetadata | optional | |
id | string |
The ID of the metric event. |
optional |
metricId | string |
The ID of the metric evaluated by the metric event. |
required |
name | string |
The name of the metric event displayed in the UI. |
required |
description | string |
The description of the metric event. |
required |
aggregationType | string |
How the metric data points are aggregated for the evaluation. The timeseries must support this aggregation. |
optional |
severity | string |
The type of the event to trigger on the threshold violation. The |
optional |
enabled | boolean |
The metric event is enabled ( |
required |
disabledReason | string |
The reason of automatic disabling. The |
optional |
warningReason | string |
The reason of a warning set on the config. The |
optional |
alertingScope | MetricEventAlertingScope[] |
Defines the scope of the metric event. Only one filter is allowed per filter type, except for tags, where up to 3 are allowed. The filters are combined by conjunction. |
optional |
metricDimensions | MetricEventDimensions[] |
Defines the dimensions of the metric to alert on. The filters are combined by conjunction. |
optional |
monitoringStrategy | MetricEventMonitoringStrategy | required | |
primaryDimensionKey | string |
Defines which dimension key should be used for the alertingScope. |
optional |
The MetricEventMonitoringStrategy object
A monitoring strategy for a metric event config.
This is the base version of the monitoring strategy, depending on the type, the actual JSON may contain additional fields.
Element | Type | Description | Required |
---|---|---|---|
type | string |
Defines the actual set of fields depending on the value. See one of the following objects:
|
required |
The MetricEventDimensions object
A single filter for the metrics dimensions.
This is the base version of the filter, depending on the type, the actual JSON may contain additional fields.
Element | Type | Description | Required |
---|---|---|---|
filterType | string |
Defines the actual set of fields depending on the value. See one of the following objects:
|
required |
key | string |
The dimensions key on the metric. |
optional |
The MetricEventAlertingScope object
A single filter for the alerting scope.
This is the base version of the filter, depending on the type, the actual JSON may contain additional fields.
Element | Type | Description | Required |
---|---|---|---|
filterType | string |
Defines the actual set of fields depending on the value. See one of the following objects:
|
required |
The ConfigurationMetadata object
Metadata useful for debugging
Element | Type | Description | Required |
---|---|---|---|
configurationVersions | integer[] |
A Sorted list of the version numbers of the configuration. |
optional |
currentConfigurationVersions | string[] |
A Sorted list of string version numbers of the configuration. |
optional |
clusterVersion | string |
Dynatrace server version. |
optional |
This is a model of the request body, showing the possible elements. It has to be adjusted for usage in an actual request. See the Example expandable section for working sample request.
{
"metadata": {
"configurationVersions": [
4,
2
],
"clusterVersion": "Mock version"
},
"metricId": "com.dynatrace.builtin:host.disk.bytesread",
"name": "My metric event",
"description": "This is the description for my metric event.\n",
"aggregationType": "AVG",
"severity": "CUSTOM_ALERT",
"alertingScope": [
{
"filterType": "ENTITY_ID",
"entityId": "HOST-000000000001E240"
},
{
"filterType": "TAG",
"tagFilter": {
"context": "CONTEXTLESS",
"key": "someKey",
"value": "someValue"
}
}
],
"metricDimensions": [
{
"filterType": "ENTITY",
"key": "dt.entity.disk",
"nameFilter": {
"value": "diskName",
"operator": "EQUALS"
}
}
],
"enabled": true,
"disabledReason": "NONE",
"warningReason": "NONE",
"monitoringStrategy": {
"type": "STATIC_THRESHOLD",
"alertCondition": "ABOVE",
"samples": 5,
"violatingSamples": 3,
"dealertingSamples": 5,
"threshold": 80,
"unit": "KILO_BYTE_PER_SECOND"
}
}
Response
Response codes
Code | Description |
---|---|
201 | Success. The new metric event has been created. The response contains the ID of the newly created metric event |
204 | Success. The metric event has been updated. The response is empty. |
400 | Failed. The input is invalid. |
Response body
The EntityShortRepresentation object
The short representation of a Dynatrace entity.
Element | Type | Description |
---|---|---|
id | string | The ID of the Dynatrace entity. |
name | string | The name of the Dynatrace entity. |
description | string | A short description of the Dynatrace entity. |
{
"id": "6a98d7bc-abb9-44f8-ae6a-73e68e71812a",
"name": "Dynatrace entity",
"description": "Dynatrace entity for the REST API example\n"
}
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.
This request is an Early Adopter release and may be changed in non-compatible way.
POST |
|
Authentication
To execute this request, you need the Write configuration (WriteConfig
) permission assigned to your API token. To learn how to obtain and use it, see Tokens and authentication.
Response
Response codes
Code | Description |
---|---|
204 | Validated. The submitted configuration is valid. Response doesn't have a body. |
400 | Failed. The input is invalid. |
Response body
A successful request doesn't return any content.
Example
In this example, the request updates the Low disk space rule we created in the POST request example. It changes the threshold to 4% in 9 out of 10 samples. It restricts the scope of the alert to the HOST-IG-1 host, which has the Dynatrace entity ID of HOST-DE7EB04EB33F3040.
The API token is passed in the Authorization header.
You can download or copy the example request body to try it out on your own.
Curl
curl -X PUT \
https://mySampleEnv.live.dynatrace.com/api/config/v1/anomalyDetection/metricEvents/1b06b18a-82df-4e18-a4aa-d4543b227734 \
-H 'Authorization: Api-token abcdefjhij1234567890' \
-H 'Content-Type: application/json' \
-d '{
"metricId": "com.dynatrace.builtin:host.disk.freespacepercentage",
"name": "Low disk space",
"description": "The available disk space is below 4%",
"aggregationType": "AVG",
"eventType": "CUSTOM_ALERT",
"alertCondition": "BELOW",
"samples": 10,
"violatingSamples": 9,
"dealertingSamples": 10,
"threshold": 4,
"entity": "HOST-DE7EB04EB33F3040",
"enabled": true,
"tagFilters": []
}
'
Request URL
https://mySampleEnv.live.dynatrace.com/api/config/v1/anomalyDetection/metricEvents/1b06b18a-82df-4e18-a4aa-d4543b227734
Request body
{
"metricId": "com.dynatrace.builtin:host.disk.freespacepercentage",
"name": "Low disk space",
"description": "The available disk space is below 4%",
"aggregationType": "AVG",
"eventType": "CUSTOM_ALERT",
"alertCondition": "BELOW",
"samples": 10,
"violatingSamples": 9,
"dealertingSamples": 10,
"threshold": 4,
"entity": "HOST-DE7EB04EB33F3040",
"enabled": true,
"tagFilters": []
}
Response code
204
Result
The updated configuration has the following parameters: