terraform-provider-newrelic
terraform-provider-newrelic copied to clipboard
Detect error condition during plan: Term duration must be a multiple of the aggregation window
Feature Description
In newrelic_nrql_alert_condition the terms[] (Critical/Warning) threshold_duration must be a multiple of the aggregation_window. This could be detected during the plan stage. Presently only alerts during apply.
This resource block
resource "newrelic_nrql_alert_condition" "my_critical_alert" {
policy_id = newrelic_alert_policy.my_alert_policy.id
name = "My Critical Alert"
type = "static"
expiration_duration = 900
aggregation_window = 120
aggregation_method = "event_flow"
aggregation_delay = 120
critical {
threshold_duration = 300
operator = "below"
threshold = 99.9
threshold_occurrences = "all"
}
nrql {
query = <<-EOF
SELECT ...
EOF
}
}
Would result in error
Error: Validation Error: BAD_USER_INPUT
│
│ with newrelic_nrql_alert_condition.my_critical_alert,
│ on alerts_critical.tf line 370, in resource "newrelic_nrql_alert_condition" "my_critical_alert":
│ 370: resource "newrelic_nrql_alert_condition" "my_critical_alert" {
│
│ terms[].thresholdDuration: Term duration must be a multiple of the aggregation window (120 seconds) but was 300 seconds
Describe Alternatives
Detect if terms[].threshold_duration is not a multiple of aggregation_window during terraform plan phase.
Additional context
Hi @xero-grant-young, thanks or raising the issue. We will prioritise it.
Hi @xero-grant-young this is a deliberate choice. The validation was changing too quickly in the Alerts API for the Terraform Provider to keep up so we're just handling validation through the API.