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

Add alertStrategy to google_monitoring_alert_policy

Open laurensknoll opened this issue 3 years ago • 5 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

The alertStrategy field is missing on the resource. Therefore it's not possible to configure an auto-close period using the Terraform provider.

New or Affected Resource(s)

  • google_monitoring_alert_policy

Potential Terraform Configuration

# Propose what you think the configuration to take advantage of this feature should look like.
# We may not use it verbatim, but it's helpful in understanding your intent.
resource "google_monitoring_alert_policy" "example" {
  project      = "my_project"
  display_name = "Example using alert strategy"

  alert_strategy {
    auto_close = "1800s"
  }
}

References

  • Monitoring API v3 https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.alertPolicies#AlertStrategy
  • Internal tracking issue: http://b/219098650

laurensknoll avatar Nov 30 '21 19:11 laurensknoll

Hi team, anyone knows when this enhancement will be feasible? Because we need this a lot. Thank you!

Ubaldo-Brea avatar Jan 10 '22 17:01 Ubaldo-Brea

As I noticed, latest release 4.7.0 include alert_strategy with auto_close. Next step could be great to add option to enable or not auto_close, using notificationPrompts "alertStrategy": { "autoClose": "604800s", "notificationPrompts": [ "OPENED" ] },

fredprod avatar Jan 20 '22 16:01 fredprod

Thank you Frederic!

Best Regards

Ubaldo Brea

Frederic Perrouin @.***> escreveu em qui., 20/01/2022 às 16:34 :

As I noticed, latest release 4.7.0 include alert_strategy with auto_close. Next step could be great to add option to enable or not auto_close, using notificationPrompts "alertStrategy": { "autoClose": "604800s", "notificationPrompts": [ "OPENED" ] },

— Reply to this email directly, view it on GitHub https://github.com/hashicorp/terraform-provider-google/issues/10655#issuecomment-1017691706, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMSRC26LQDBMJU46FYCEEDDUXA2PZANCNFSM5JCUGZ6A . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you commented.Message ID: @.***>

-- Ubaldo Brea

Google Cloud Engineer +351 966235297 <+351+966235297> @.*** gcloud.devoteam.com [image: facebook] https://www.facebook.com/devoteam.gcloud.benelux [image: twitter] https://twitter.com/gcloud_benelux [image: linkedin] https://www.linkedin.com/company/devoteam-g-cloud/ [image: instagram] https://www.instagram.com/Devoteam_gcloud_benelux/ Create Your Own Free Signature https://www.hubspot.com/email-signature-generator?utm_source=create-signature

Ubaldo-Brea avatar Jan 20 '22 21:01 Ubaldo-Brea

Was there any progress on this? I see the code and "alert_strategy" option in the documentation but its not working. Auto close is a very useful feature.

harshalpatani avatar Feb 10 '22 15:02 harshalpatani

yeah, I'm waiting for it too, @harshalpatani you might have seen that in the auto generated code, not the one that will allow you to access that. (I was mislead too)

shivaharikumar avatar Feb 17 '22 15:02 shivaharikumar

This was resolved by https://github.com/GoogleCloudPlatform/magic-modules/pull/5565

melinath avatar Aug 16 '22 15:08 melinath

ah, reopening since there were reports of it not working since that PR was merged

melinath avatar Aug 16 '22 15:08 melinath

My Findings are as per given below :

"mode": "managed",
"type": "google_monitoring_alert_policy",
"name": "example",
"provider": "provider[\"google.com/googleprovider/google\"]",
"instances": [
{
    "schema_version": 0,
    "attributes": {
    "alert_strategy": [
        {
        "auto_close": "604800s",
        "notification_rate_limit": [
            {
            "period": "3600s"
            }
        ]
        }
    ],

(this is the reference of tfstate file)
So as we can see that in alert_strategy block, all the attributes that provided in api is supported by the GA provider. But in comment (https://github.com/hashicorp/terraform-provider-google/issues/10655#issuecomment-1017691706) The required attribute is not supported in GA and Beta as well so @melinath you can close this issue for now. Reference : (https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.alertPolicies#alertstrategy)

AarshDhokai avatar Sep 02 '22 10:09 AarshDhokai

Here's the link to the provider docs for these fields: https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/monitoring_alert_policy#nested_alert_strategy

If there are any issues with the field, please open a bug ticket describing the behavior you're seeing (or not seeing!) If there are any other fields you'd like supported that are in the API, please open a new enhancement ticket

melinath avatar Sep 02 '22 16:09 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 Oct 04 '22 02:10 github-actions[bot]