terraform-provider-dynatrace
terraform-provider-dynatrace copied to clipboard
dynatrace_alerting_profile does not work correctly
I can create an alerting profile that contains mixed Predefined and Custom event filters. Trying to do the same via Terraform HCL fails. A snippet of the Terraform HCL config that is failing:
### dynatrace_alerting_profile ###
resource "dynatrace_alerting_profile" "alerting_profile" {
display_name = "Microsites"
mz_id = local.management_zone
event_type_filters {
predefined_event_filter {
event_type = "APPLICATION_ERROR_RATE_INCREASED"
}
predefined_event_filter {
event_type = "SERVICE_ERROR_RATE_INCREASED"
}
predefined_event_filter {
event_type = "DATABASE_CONNECTION_FAILURE"
}
predefined_event_filter {
event_type = "MONITORING_UNAVAILABLE"
}
custom_event_filter {
custom_description_filter {
operator = "EQUALS"
value = "Name"
case_insensitive = false
enabled = true
}
custom_title_filter {
operator = "EQUALS"
value = "Name"
case_insensitive = false
enabled = true
}
}
}
When trying to create alerting profile via Terraform it fails with the error below:
dynatrace_alerting_profile.alerting_profile: Modifying... [id=23e073ee-8616-33ba-870e-7002d08158cb] ╷ │ Error: { │ "code": 400, │ "message": "Constraints violated.", │ "constraintViolations": [ │ { │ "parameterLocation": "PAYLOAD_BODY", │ "location": "", │ "message": "The parameters of this object are mutually exclusive. Please only provide one of the 2 filters", │ "path": "eventTypeFilters[0]" │ } │ ] │ } │ │ with dynatrace_alerting_profile.alerting_profile, │ on monitoring.tf line 29, in resource "dynatrace_alerting_profile" "alerting_profile": │ 29: resource "dynatrace_alerting_profile" "alerting_profile" {
Hello @moseskt
It looks like you've run into a limitation of the Config REST API of Dynatrace here. It doesn't accept certain combinations of filters while the WebUI allows for it.
The resource dynatrace_alerting
takes care of that. It utilizes the Settings 2.0 REST API. Here the functionality is indeed streamlined with the WebUI.
The example you've provided looks like this when using dynatrace_alerting
.
resource "dynatrace_alerting" "alerting_profile" {
name = "Microsites"
management_zone = "d4a898f9-abb4-4f20-a913-201a86f81335"
filters {
filter {
predefined {
type = "APPLICATION_ERROR_RATE_INCREASED"
}
}
filter {
predefined {
type = "SERVICE_ERROR_RATE_INCREASED"
}
}
filter {
predefined {
type = "DATABASE_CONNECTION_FAILURE"
}
}
filter {
predefined {
type = "MONITORING_UNAVAILABLE"
}
}
filter {
custom {
description {
operator = "STRING_EQUALS"
value = "Name"
case_sensitive = true
enabled = true
}
}
}
filter {
custom {
title {
operator = "STRING_EQUALS"
value = "Name"
case_sensitive = true
enabled = true
}
}
}
}
}
Let me know if that solves your difficulties.
Closing the ticket for now, please re-open it if you have any issues with the solution that @Dynatrace-Reinhard-Pilz provided. Thanks!