diff --git a/internal/services/monitor/monitor_alert_prometheus_rule_group_resource.go b/internal/services/monitor/monitor_alert_prometheus_rule_group_resource.go index 3c13347436ddf..f76693c53c409 100644 --- a/internal/services/monitor/monitor_alert_prometheus_rule_group_resource.go +++ b/internal/services/monitor/monitor_alert_prometheus_rule_group_resource.go @@ -293,7 +293,7 @@ func (r AlertPrometheusRuleGroupResource) Create() sdk.ResourceFunc { if _, ok := metadata.ResourceData.GetOk("interval"); ok { properties.Properties.Interval = pointer.To(model.Interval) } - properties.Properties.Rules = expandPrometheusRuleModel(model.Rule) + properties.Properties.Rules = expandPrometheusRuleModel(model.Rule, *metadata.ResourceData) if _, err := client.CreateOrUpdate(ctx, id, properties); err != nil { return fmt.Errorf("creating %s: %+v", id, err) @@ -344,7 +344,7 @@ func (r AlertPrometheusRuleGroupResource) Update() sdk.ResourceFunc { properties.Properties.Interval = pointer.To(model.Interval) } if metadata.ResourceData.HasChange("rule") { - properties.Properties.Rules = expandPrometheusRuleModel(model.Rule) + properties.Properties.Rules = expandPrometheusRuleModel(model.Rule, *metadata.ResourceData) } if metadata.ResourceData.HasChange("scopes") { properties.Properties.Scopes = model.Scopes @@ -422,7 +422,7 @@ func (r AlertPrometheusRuleGroupResource) Delete() sdk.ResourceFunc { } } -func expandPrometheusRuleModel(inputList []PrometheusRuleModel) []prometheusrulegroups.PrometheusRule { +func expandPrometheusRuleModel(inputList []PrometheusRuleModel, d schema.ResourceData) []prometheusrulegroups.PrometheusRule { outputList := make([]prometheusrulegroups.PrometheusRule, 0) for _, v := range inputList { @@ -435,8 +435,8 @@ func expandPrometheusRuleModel(inputList []PrometheusRuleModel) []prometheusrule if v.Alert != "" { output.Actions = expandPrometheusRuleGroupActionModel(v.Action) output.Alert = pointer.To(v.Alert) - if v.Severity != 0 { - output.Severity = pointer.To(int64(v.Severity)) + if v, ok := d.GetOk("severity"); ok { + output.Severity = pointer.To(int64(v.(int))) } output.Annotations = pointer.To(v.Annotations) output.For = pointer.To(v.For) diff --git a/internal/services/monitor/monitor_alert_prometheus_rule_group_resource_test.go b/internal/services/monitor/monitor_alert_prometheus_rule_group_resource_test.go index 7a92781f88300..2fdc40c1e3f92 100644 --- a/internal/services/monitor/monitor_alert_prometheus_rule_group_resource_test.go +++ b/internal/services/monitor/monitor_alert_prometheus_rule_group_resource_test.go @@ -225,7 +225,7 @@ EOF histogram_quantile(0.99, sum(rate(jobs_duration_seconds_bucket{service="billing-processing"}[5m])) by (job_type)) EOF for = "PT5M" - severity = 2 + severity = 0 action { action_group_id = azurerm_monitor_action_group.test.id }