---
layout: ""
page_title: "dynatrace_metric_events Resource - terraform-provider-dynatrace"
subcategory: "Anomaly Detection"
description: |-
The resource `dynatrace_metric_events` covers configuration for custom metric events
---
# dynatrace_metric_events (Resource)
-> This resource requires the API token scopes **Read settings** (`settings.read`) and **Write settings** (`settings.write`)
## Dynatrace Documentation
- Metric events for alerting - https://www.dynatrace.com/support/help/how-to-use-dynatrace/problem-detection-and-analysis/problem-detection/metric-events-for-alerting
- Settings API - https://www.dynatrace.com/support/help/dynatrace-api/environment-api/settings (schemaId: `builtin:anomaly-detection.metric-events`)
## Export Example Usage
- `terraform-provider-dynatrace -export dynatrace_metric_events` downloads all existing custom metric event configuration
The full documentation of the export feature is available [here](https://dt-url.net/h203qmc).
## Resource Example Usage
```terraform
resource "dynatrace_metric_events" "#name#" {
enabled = true
event_entity_dimension_key = "dt.entity.host"
summary = "sample_name"
event_template {
description = "some description"
davis_merge = false
event_type = "CUSTOM_ALERT"
title = "sample_name"
}
model_properties {
type = "STATIC_THRESHOLD"
alert_condition = "ABOVE"
alert_on_no_data = false
dealerting_samples = 5
samples = 5
threshold = 1
violating_samples = 3
}
query_definition {
type = "METRIC_KEY"
aggregation = "AVG"
metric_key = "builtin:host.disk.usedPct"
dimension_filter {
filter {
dimension_key = "dt.entity.host"
dimension_value = "HOST-9DDF1200A29EFAC9"
}
filter {
dimension_key = "dt.entity.disk.name"
dimension_value = "/local"
}
filter {
dimension_key = "dt.entity.disk"
dimension_value = "DISK-3DC3FC42FBB07595"
}
}
entity_filter {
dimension_key = "dt.entity.host"
conditions {
condition {
type = "NAME"
operator = "EQUALS"
value = "HOST-80FF882B3215BF1A"
}
condition {
type = "ENTITY_ID"
operator = "EQUALS"
value = "HOST-32D0DB4904B28FB3"
}
condition {
type = "MANAGEMENT_ZONE"
operator = "EQUALS"
value = "-189204438944455158"
}
condition {
type = "HOST_GROUP_NAME"
operator = "EQUALS"
value = "HOST-42FDD00356069724"
}
}
}
}
}
```
## Schema
### Required
- `enabled` (Boolean) This setting is enabled (`true`) or disabled (`false`)
- `event_template` (Block List, Min: 1, Max: 1) Event template (see [below for nested schema](#nestedblock--event_template))
- `model_properties` (Block List, Min: 1, Max: 1) Monitoring strategy (see [below for nested schema](#nestedblock--model_properties))
- `query_definition` (Block List, Min: 1, Max: 1) Query definition (see [below for nested schema](#nestedblock--query_definition))
- `summary` (String) The textual summary of the metric event entry
### Optional
- `event_entity_dimension_key` (String) Controls the preferred entity type used for triggered events.
- `legacy_id` (String) Config id
### Read-Only
- `id` (String) The ID of this resource.
### Nested Schema for `event_template`
Required:
- `description` (String) The description of the event to trigger.
- `event_type` (String) The event type to trigger. Possible values: `AVAILABILITY`, `CUSTOM_ALERT`, `CUSTOM_ANNOTATION`, `CUSTOM_CONFIGURATION`, `CUSTOM_DEPLOYMENT`, `ERROR`, `INFO`, `MARKED_FOR_TERMINATION`, `RESOURCE`, `SLOWDOWN`, `WARNING`
- `title` (String) The title of the event to trigger.
Optional:
- `davis_merge` (Boolean) DavisĀ® AI will try to merge this event into existing problems, otherwise a new problem will always be created.
- `metadata` (Block Set) Set of additional key-value properties to be attached to the triggered event. You can retrieve the available property keys using the [Events API v2](https://dt-url.net/9622g1w). (see [below for nested schema](#nestedblock--event_template--metadata))
### Nested Schema for `event_template.metadata`
Required:
- `metadata_key` (String) Type 'dt.' for key hints.
- `metadata_value` (String) No documentation available
### Nested Schema for `model_properties`
Required:
- `alert_condition` (String) Alert condition. Possible values: `ABOVE`, `BELOW`, `OUTSIDE`
- `alert_on_no_data` (Boolean) The ability to set an alert on missing data in a metric. When enabled, missing data samples will be treated as violating samples defined in the advanced model properties. When disabled, missing data is not treated as a violation but will still contribute to dealerting. We recommend disabling alerting on missing data for sparse timeseries to avoid false alerts. To learn more, visit [anomaly detection configuration](https://dt-url.net/lz02mwi).
- `dealerting_samples` (Number) The number of one-minute samples within the evaluation window that must go back to normal to close the event.
- `samples` (Number) The number of one-minute samples that form the sliding evaluation window.
- `type` (String) Metric-key-based query definitions only support static thresholds. Possible values: `AUTO_ADAPTIVE_THRESHOLD`, `SEASONAL_BASELINE`, `STATIC_THRESHOLD`
- `violating_samples` (Number) The number of one-minute samples within the evaluation window that must violate to trigger an event.
Optional:
- `signal_fluctuation` (Number) Controls how many times the signal fluctuation is added to the baseline to produce the actual threshold for alerting
- `threshold` (Number) Raise an event if this value is violated
- `tolerance` (Number) Controls the width of the confidence band and larger values lead to a less sensitive model
### Nested Schema for `query_definition`
Required:
- `type` (String) Possible values: `METRIC_KEY`, `METRIC_SELECTOR`
Optional:
- `aggregation` (String) Possible values: `AVG`, `COUNT`, `MAX`, `MEDIAN`, `MIN`, `PERCENTILE90`, `SUM`, `VALUE`
- `dimension_filter` (Block List, Max: 1) Dimension filter (see [below for nested schema](#nestedblock--query_definition--dimension_filter))
- `entity_filter` (Block List, Max: 1) Use rule-based filters to define the scope this event monitors. (see [below for nested schema](#nestedblock--query_definition--entity_filter))
- `management_zone` (String) The `legacy_id` of a Management Zone (as provided by the resource `dynatrace_management_zone_v2` or the data source `dynatrace_management_zone`)
- `metric_key` (String) Metric key
- `metric_selector` (String) To learn more, visit [Metric Selector](https://dt-url.net/metselad)
- `query_offset` (Number) Minute offset of sliding evaluation window for metrics with latency
### Nested Schema for `query_definition.dimension_filter`
Required:
- `filter` (Block Set, Min: 1) (see [below for nested schema](#nestedblock--query_definition--dimension_filter--filter))
### Nested Schema for `query_definition.dimension_filter.filter`
Required:
- `dimension_key` (String) Dimension key
- `dimension_value` (String) Dimension value
Optional:
- `operator` (String) Possible values: `CONTAINS_CASE_SENSITIVE`, `DOES_NOT_CONTAIN_CASE_SENSITIVE`, `DOES_NOT_EQUAL`, `DOES_NOT_START_WITH`, `EQUALS`, `STARTS_WITH`
### Nested Schema for `query_definition.entity_filter`
Optional:
- `conditions` (Block List, Max: 1) No documentation available (see [below for nested schema](#nestedblock--query_definition--entity_filter--conditions))
- `dimension_key` (String) Dimension key of entity type to filter
### Nested Schema for `query_definition.entity_filter.conditions`
Required:
- `condition` (Block Set, Min: 1) (see [below for nested schema](#nestedblock--query_definition--entity_filter--conditions--condition))
### Nested Schema for `query_definition.entity_filter.conditions.condition`
Required:
- `operator` (String) Possible values: `CONTAINS_CASE_INSENSITIVE`, `CONTAINS_CASE_SENSITIVE`, `DOES_NOT_CONTAIN_CASE_INSENSITIVE`, `DOES_NOT_CONTAIN_CASE_SENSITIVE`, `DOES_NOT_EQUAL`, `DOES_NOT_START_WITH`, `EQUALS`, `STARTS_WITH`
- `type` (String) Filter type. Possible values: `CUSTOM_DEVICE_GROUP_NAME`, `ENTITY_ID`, `HOST_GROUP_NAME`, `HOST_NAME`, `MANAGEMENT_ZONE`, `NAME`, `PROCESS_GROUP_ID`, `PROCESS_GROUP_NAME`, `TAG`
- `value` (String) No documentation available