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

Monitoring alert policies: Unexpected diff when filter contains line breaks #7425

Closed
MajorBreakfast opened this issue Oct 5, 2020 · 4 comments
Assignees
Labels

Comments

@MajorBreakfast
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

0.12.26

Affected Resource(s)

  • google_monitoring_alert_policy

Terraform Configuration Files

resource "google_monitoring_alert_policy" "postgres" {
  project               = var.project
  display_name          = "${var.name}: Postgres"
  notification_channels = [data.google_monitoring_notification_channel.main.name]

  combiner = "OR"
  conditions {
    display_name = "Assert that utilization of disk is under 80%"
    condition_threshold {
      filter          = <<-EOF
        metric.type = "cloudsql.googleapis.com/database/disk/utilization"
        resource.type = "cloudsql_database"
        resource.label.database_id = ${jsonencode("${var.project}:${var.postgres_instance_name}")}
        EOF
      duration        = "60s"
      comparison      = "COMPARISON_GT"
      threshold_value = 0.8
    }
  }
}

Debug Output

n/a

Panic Output

n/a

Expected Behavior

The provider shows an unexpected diff for all alert policies. This diff should ideally not be there.

Actual Behavior

My filter contains line breaks. These line breaks seem to get removed at some point and consequently produce an artificial diff.

  ~ resource "google_monitoring_alert_policy" "postgres" {
        ...
      ~ conditions {
            ...
          ~ condition_threshold {
                comparison      = "COMPARISON_GT"
                duration        = "60s"
              ~ filter          = <<~EOT
                  - metric.type="cloudsql.googleapis.com/database/disk/utilization" resource.type="cloudsql_database" resource.label.database_id="my-project:my-db"
                  + metric.type = "cloudsql.googleapis.com/database/disk/utilization"
                  + resource.type = "cloudsql_database"
                  + resource.label.database_id = "my-project:my-db"
                EOT
                ...
            }
        }
    }

Steps to Reproduce

  1. terraform plan

Important Factoids

Using a heredoc to to define the filter. The filter string is a bit long. The heredoc

References

n/a

@ghost ghost added the bug label Oct 5, 2020
@michael-bernards-db
Copy link

👍

@edwardmedia
Copy link
Contributor

edwardmedia commented Oct 5, 2020

@MajorBreakfast to my test, below two got same results. Staying same code, tf plan does not show difference for each case. I can't repro your issue. Please note: filter is a string field. Changing any characters could lead to a difference.

filter     = "metric.type=\"compute.googleapis.com/instance/disk/write_bytes_count\" AND resource.type=\"gce_instance\""
      filter     = <<-EOF
        metric.type="compute.googleapis.com/instance/disk/write_bytes_count" 
        resource.type="gce_instance"
       EOF

@MajorBreakfast
Copy link
Author

Weirdly enough I too don't see it anymore today and I don't know what changed compared to what I saw yesterday and during the past few weeks. I'm going to close this issue and reopen a more precise one if I encounter it again. Thank you for having a look!

Note: The people voting thumbs up are people on my team who saw the diffs in our ci

@ghost ghost removed the waiting-response label Oct 6, 2020
@ghost
Copy link

ghost commented Nov 5, 2020

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 as resolved and limited conversation to collaborators Nov 5, 2020
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