Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

google_monitoring_alert_policy: labels not working #3493

Closed
wilkmaia opened this issue Apr 25, 2019 · 3 comments
Closed

google_monitoring_alert_policy: labels not working #3493

wilkmaia opened this issue Apr 25, 2019 · 3 comments
Assignees
Labels

Comments

@wilkmaia
Copy link

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 an 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 an issue is assigned to a user, that user is claiming responsibility for the issue. If an issue is assigned to "hashibot", a community member has claimed the issue already.

Terraform Version

Terraform v0.11.13 (latest)

Affected Resource(s)

  • google_monitoring_alert_policy

Terraform Configuration Files

resource "google_monitoring_notification_channel" "email" {
  display_name = "Sample Email"
  type         = "email"

  labels = {
    email_address = "sample@email.com"
  }
}

resource "google_monitoring_alert_policy" "alert" {
  display_name = "alert-policy"
  combiner     = "OR"

  enabled = true

  notification_channels = ["${google_monitoring_notification_channel.email.name}"]

  conditions = [
    {
      display_name = "Origin Unhealthy"

      condition_threshold {
        filter     = "metric.type=\"monitoring.googleapis.com/uptime_check/check_passed\" AND resource.type=\"uptime_url\" AND metric.label.check_id=\"origin\""
        duration   = "300s"
        comparison = "COMPARISON_GT"

        threshold_value = 2

        aggregations = [
          {
            alignment_period     = "300s"
            per_series_aligner   = "ALIGN_NEXT_OLDER"
            cross_series_reducer = "REDUCE_COUNT_FALSE"
          },
        ]
      }
    },
  ]

  labels = [
    "{ \"Key1\": \"Value1\"}",
    "{ \"Key2\": \"Value2\"}",
  ]
}

Debug Output

https://gist.github.com/wilkmaia/bfd4793810bb2dde49de0b50be35b21b

Panic Output

Expected Behavior

Successful execution.

Actual Behavior

Error on GCP api call. The error is caused because GCP's AlertPolicy API has no labels field. The field name is userLabels.

Error is at https://github.com/terraform-providers/terraform-provider-google/blob/master/google/resource_monitoring_alert_policy.go#L345. Replacing that with obj["userLabels"] should be enough. Or maybe renaming the labels prop to user_labels.

Steps to Reproduce

  1. terraform init
  2. terraform apply

Important Factoids

References

@slevenick
Copy link
Collaborator

This is fixed with #3494

The field is renamed to user_labels to match the API. This will be available with the next release

@wilkmaia
Copy link
Author

Thanks for fixing it, @slevenick. Should I close the issue?

@ghost
Copy link

ghost commented May 26, 2019

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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 hashibot-feedback@hashicorp.com. Thanks!

@ghost ghost locked and limited conversation to collaborators May 26, 2019
@github-actions github-actions bot added service/monitoring-alerting forward/review In review; remove label to forward labels Jan 15, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants