From eec9e9a6a92b6b382b7bb7127528a8a442e7050a Mon Sep 17 00:00:00 2001 From: The Magician Date: Tue, 8 Aug 2023 09:33:08 -0700 Subject: [PATCH] Make condition_prometheus_query_language.evaluation_interval optional (#8564) (#6028) * Add support for retriggering notifications in AlertPolicy * Add support for forecast options in AlertPolicy * Move tests for forecast alerts into the handwritten file * Add support for PromQL condition type in AlertPolicy * Added test for promql alerts into the handwritten file * Add test for condition_prometheus_query_language.labels * Remove trailing whitespace * Update mmv1/products/monitoring/AlertPolicy.yaml * Make condition_prometheus_query_language.evaluation_interval optional * Remove test for condition_prometheus_query_language.evaluation_interval --------- Signed-off-by: Modular Magician Co-authored-by: James Edouard Co-authored-by: Cameron Thornton --- .changelog/8564.txt | 3 +++ .../resource_monitoring_alert_policy_test.go | 1 - .../resource_monitoring_alert_policy.go | 18 +++++++++--------- .../r/monitoring_alert_policy.html.markdown | 2 +- 4 files changed, 13 insertions(+), 11 deletions(-) create mode 100644 .changelog/8564.txt diff --git a/.changelog/8564.txt b/.changelog/8564.txt new file mode 100644 index 0000000000..f960aa5b2c --- /dev/null +++ b/.changelog/8564.txt @@ -0,0 +1,3 @@ +```release-note:bug +monitoring: updated `evaluation_interval` on `condition_prometheus_query_language` to be optional +``` diff --git a/google-beta/resource_monitoring_alert_policy_test.go b/google-beta/resource_monitoring_alert_policy_test.go index 56dcce1166..ed0272c2ac 100644 --- a/google-beta/resource_monitoring_alert_policy_test.go +++ b/google-beta/resource_monitoring_alert_policy_test.go @@ -432,7 +432,6 @@ resource "google_monitoring_alert_policy" "promql" { condition_prometheus_query_language { query = "vector(1)" duration = "60s" - evaluation_interval = "60s" labels = { "severity" = "page" } diff --git a/google-beta/services/monitoring/resource_monitoring_alert_policy.go b/google-beta/services/monitoring/resource_monitoring_alert_policy.go index b210145283..ffd59bfb4c 100644 --- a/google-beta/services/monitoring/resource_monitoring_alert_policy.go +++ b/google-beta/services/monitoring/resource_monitoring_alert_policy.go @@ -370,15 +370,6 @@ from a Prometheus alerting rule and its associated rule group.`, MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "evaluation_interval": { - Type: schema.TypeString, - Required: true, - Description: `How often this rule should be evaluated. Must be a positive multiple -of 30 seconds or missing. The default value is 30 seconds. If this -PrometheusQueryLanguageCondition was generated from a Prometheus -alerting rule, then this value should be taken from the enclosing -rule group.`, - }, "query": { Type: schema.TypeString, Required: true, @@ -408,6 +399,15 @@ valid Prometheus label name.`, to be "true" for this long. Alerts whose PromQL expression was not evaluated to be "true" for long enough are considered pending. The default value is zero. Must be zero or positive.`, + }, + "evaluation_interval": { + Type: schema.TypeString, + Optional: true, + Description: `How often this rule should be evaluated. Must be a positive multiple +of 30 seconds or missing. The default value is 30 seconds. If this +PrometheusQueryLanguageCondition was generated from a Prometheus +alerting rule, then this value should be taken from the enclosing +rule group.`, }, "labels": { Type: schema.TypeMap, diff --git a/website/docs/r/monitoring_alert_policy.html.markdown b/website/docs/r/monitoring_alert_policy.html.markdown index 4ba7b00190..04177f0a97 100644 --- a/website/docs/r/monitoring_alert_policy.html.markdown +++ b/website/docs/r/monitoring_alert_policy.html.markdown @@ -773,7 +773,7 @@ The following arguments are supported: default value is zero. Must be zero or positive. * `evaluation_interval` - - (Required) + (Optional) How often this rule should be evaluated. Must be a positive multiple of 30 seconds or missing. The default value is 30 seconds. If this PrometheusQueryLanguageCondition was generated from a Prometheus