terraform-provider-google icon indicating copy to clipboard operation
terraform-provider-google copied to clipboard

google_monitoring_alert_policy missing notify_on_incident_closure functionality

Open rrmestl-cx opened this issue 3 years ago • 4 comments

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment. If the issue is assigned to the "modular-magician" user, it is either in the process of being autogenerated, or is planned to be autogenerated soon. If the issue is assigned to a user, that user is claiming responsibility for the issue. If the issue is assigned to "hashibot", a community member has claimed the issue already.

Description

When using the GCP console to setup a Monitoring Alerting Policy, the user is able to check mark a "Notify on Incident Closure". Similarly, I would expect the terraform resource google_monitoring_alert_policy to allow a "notify_on_incident_closure" option to publicly be modifiable, but is not. Also, the current default value of the non-public option is set to "true", which would prefer that default value to be "false".

New or Affected Resource(s)

  • google_monitoring_alert_policy

Potential Terraform Configuration

resource "google_monitoring_alert_policy" "nginx_group_monitoring_alert_policy" {
   display_name = "Nginx Group Alerts"
   conditions {
      display_name = "Nginx Group - cpu utilization"
      condition_threshold {
         aggregations {
            alignment_period = "300s"
            per_series_aligner = "ALIGN_MEAN"
         }
         comparison = "COMPARISON_GT"
         duration = "0s"
         filter = "metric.type=\"compute.googleapis.com/instance/cpu/utilization\" resource.type=\"gce_instance\" metadata.system_labels.\"instance_group\"=\"ilbnginx-grp\""
         threshold_value = 0.85
         trigger {
            count = 1
         }
      }
   }
   conditions {
      display_name = "Nginx Group - process count (nginx)"
      condition_threshold {
         comparison = "COMPARISON_LT"
         duration = "60s"
         filter = "select_process_count(\"command=nginx\",\"user=root\") resource.type=\"gce_instance\" group.id=\"2072154648184892149\""
         threshold_value = 1
         trigger {
            count = 1
         }
      }
   }
   conditions {
      display_name = "Nginx Group - allocated ports"
      condition_threshold {
         aggregations {
            alignment_period = "300s"
            per_series_aligner = "ALIGN_MEAN"
         }
         comparison = "COMPARISON_GT"
         duration = "0s"
         filter = "metric.type=\"compute.googleapis.com/nat/allocated_ports\" resource.type=\"gce_instance\" metadata.system_labels.\"instance_group\"=\"ilbnginx-grp\""
         threshold_value = 65
         trigger {
            count = 1
         }
      }
   }
   combiner = "OR"
   enabled = false
   documentation {
     content = "One or more ILB Nginx Group resources has triggered an alert.\nDetermine what is going on in the GCP environment and why."
     mime_type = "text/markdown"
   }
   notification_channels = [
      google_monitoring_notification_channel.gcp_mosaic_alerts_notif_chan.name,
      google_monitoring_notification_channel.snow_incident_notif_chan.name
   ]
   notify_on_incident_close = false
   user_labels = {
      name = "nginx-group"
   }

}

References

rrmestl-cx avatar Aug 03 '21 15:08 rrmestl-cx

for me it says this Error: Unsupported argument │ │ on main.tf line 37, in resource "google_monitoring_alert_policy" "alert_policy": │ 37: notify_on_incident_close = false │ │ An argument named "notify_on_incident_close" is not expected here.

richaslab avatar Dec 27 '21 08:12 richaslab

This option is called "notificationPrompts" when you export alert policy to JSON. For example: "alertStrategy": { "autoClose": "604800s", "notificationPrompts": [ "OPENED", "CLOSED" ] },

Unfortunately the API does not expose such flag at the moment. https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.alertPolicies#alertstrategy

The good thing is that if you disable this option manually, terraform will not overwrite it during next run.

mwink avatar Feb 07 '22 13:02 mwink

Hi all, I am also facing this issue. I cant able to uncheck the notify on incident close checkbox through terraform. How soon we can expect this to be available through terraform?

shaikhreza43 avatar May 06 '22 11:05 shaikhreza43

marking this as upstream to indicate that it's not supported by the API.

melinath avatar Sep 15 '22 23:09 melinath

(https://issuetracker.google.com/issues/218288184)

philip-harvey avatar Sep 23 '22 17:09 philip-harvey

closing as a duplicate of https://github.com/hashicorp/terraform-provider-google/issues/8470

melinath avatar Apr 13 '23 22:04 melinath

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

github-actions[bot] avatar May 14 '23 02:05 github-actions[bot]