This API is deprecated. Use the Settings API instead. Look for the Metric events (builtin:anomaly-detection.metric-events
) schema.
Creates a new metric event rule.
The request consumes and produces an application/json
payload.
POST | ManagedDynatrace for Government | https://{your-domain}/e/{your-environment-id}/api/config/v1/anomalyDetection/metricEvents |
Environment ActiveGate | https://{your-activegate-domain}/e/{your-environment-id}/api/config/v1/anomalyDetection/metricEvents |
To execute this request, you need an access token with WriteConfig
scope.
To learn how to obtain and use it, see Tokens and authentication.
To find all JSON models that depend on the type of the model, refer to JSON models.
Parameter | Type | Description | In | Required |
---|---|---|---|---|
body | Metric | The JSON body of the request. Contains parameters of the new metric event. | body | optional |
MetricEvent
objectThe configuration of the metric event.
Element | Type | Description | Required |
---|---|---|---|
aggregationType | string | How the metric data points are aggregated for the evaluation. The timeseries must support this aggregation.
| optional |
alertingScope | Metric | 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 |
description | string | The description of the metric event. | required |
disabledReason | string | The reason of automatic disabling. The
| optional |
enabled | boolean | The metric event is enabled ( | required |
id | string | The ID of the metric event. | optional |
metadata | Configuration | Metadata useful for debugging | optional |
metricDimensions | Metric | Defines the dimensions of the metric to alert on. The filters are combined by conjunction. | optional |
metricId | string | The ID of the metric evaluated by the metric event. | optional |
metricSelector | string | The metric selector that should be executed. | optional |
monitoringStrategy | Metric | 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. | required |
name | string | The name of the metric event displayed in the UI. | required |
primaryDimensionKey | string | Defines which dimension key should be used for the alertingScope. | optional |
queryOffset | integer | Defines the query offset to adapt the evaluation timeframe for known metric latency. | optional |
severity | string | The type of the event to trigger on the threshold violation. The
| optional |
warningReason | string | The reason of a warning set on the config. The
| optional |
MetricEventAlertingScope
objectA single filter for the alerting scope.
The actual set of fields depends on type of the filter. Find the list of actual objects in the description of the filterType field or see Metric events anomaly detection API - JSON models.
Element | Type | Description | Required |
---|---|---|---|
filterType | string | Defines the actual set of fields depending on the value. See one of the following objects:
| required |
ConfigurationMetadata
objectMetadata useful for debugging
Element | Type | Description | Required |
---|---|---|---|
clusterVersion | string | Dynatrace version. | optional |
configurationVersions | integer[] | A sorted list of the version numbers of the configuration. | optional |
currentConfigurationVersions | string[] | A sorted list of version numbers of the configuration. | optional |
MetricEventDimensions
objectA single filter for the metrics dimensions.
The actual set of fields depends on type of the filter. Find the list of actual objects in the description of the filterType field or see Metric events anomaly detection API - JSON models.
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 |
MetricEventMonitoringStrategy
objectA 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 |
This is a model of the request body, showing the possible elements. It has to be adjusted for usage in an actual request.
{"aggregationType": "AVG","alertingScope": [{"entityId": "HOST-000000000001E240","filterType": "ENTITY_ID"},{"filterType": "TAG","tagFilter": {"context": "CONTEXTLESS","key": "someKey","value": "someValue"}}],"description": "This is the description for my metric event.","disabledReason": "NONE","enabled": true,"metadata": {"clusterVersion": "Mock version","configurationVersions": [4,2]},"metricDimensions": [{"filterType": "ENTITY","key": "dt.entity.disk","nameFilter": {"operator": "EQUALS","value": "diskName"}}],"metricId": "com.dynatrace.builtin:host.disk.bytesread","monitoringStrategy": {"alertCondition": "ABOVE","dealertingSamples": 5,"samples": 5,"threshold": 80,"type": "STATIC_THRESHOLD","unit": "KILO_BYTE_PER_SECOND","violatingSamples": 3},"name": "My metric event","severity": "CUSTOM_ALERT","warningReason": "NONE"}
Code | Type | Description |
---|---|---|
201 | Entity | Success. The metric event has been created. The response contains the ID and name of the newly created metric event |
400 | Error | Failed. The input is invalid. |
EntityShortRepresentation
objectThe short representation of a Dynatrace entity.
Element | Type | Description |
---|---|---|
description | string | A short description of the Dynatrace entity. |
id | string | The ID of the Dynatrace entity. |
name | string | The name of the Dynatrace entity. |
{"description": "Dynatrace entity for the REST API example","id": "6a98d7bc-abb9-44f8-ae6a-73e68e71812a","name": "Dynatrace entity"}
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.
POST | ManagedDynatrace for Government | https://{your-domain}/e/{your-environment-id}/api/config/v1/anomalyDetection/metricEvents/validator |
Environment ActiveGate | https://{your-activegate-domain}/e/{your-environment-id}/api/config/v1/anomalyDetection/metricEvents/validator |
To execute this request, you need an access token with WriteConfig
scope.
To learn how to obtain and use it, see Tokens and authentication.
Code | Type | Description |
---|---|---|
204 | - | Validated. The submitted configuration is valid. Response doesn't have a body. |
400 | Error | Failed. The input is invalid. |
In this example, the request creates a custom alert that triggers if free disk space drops below 3% in 3 out of 5 samples. The scope of the alert is all hosts.
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 -X POST \https://mySampleEnv.live.dynatrace.com/api/config/v1/anomalyDetection/metricEvents \-H 'Authorization: Api-Token dt0c01.abc123.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 3%","aggregationType": "AVG","eventType": "CUSTOM_ALERT","alertCondition": "BELOW","samples": 5,"violatingSamples": 3,"dealertingSamples": 5,"threshold": 3,"enabled": true,"tagFilters": []}'
https://mySampleEnv.live.dynatrace.com/api/config/v1/anomalyDetection/metricEvents
{"metricId": "com.dynatrace.builtin:host.disk.freespacepercentage","name": "Low disk space","description": "The available disk space is below 3%","aggregationType": "AVG","eventType": "CUSTOM_ALERT","alertCondition": "BELOW","samples": 5,"violatingSamples": 3,"dealertingSamples": 5,"threshold": 3,"enabled": true,"tagFilters": []}
{"id": "1b06b18a-82df-4e18-a4aa-d4543b227734","name": "Low disk space","description": "The available disk space is below 3%"}
204
The new rule looks like this in the UI: