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

Updated AlertPolicy resource to include sql condition types. #12971

Merged
merged 7 commits into from
Feb 6, 2025

Conversation

haustenirving
Copy link
Contributor

Fixes hashicorp/terraform-provider-google#21259.

Adds support for SQL condition types when creating an Alert Policy. SQL conditions are currently configurable through the UI or API directly: https://cloud.google.com/logging/docs/analyze/sql-in-alerting

Release Note Template for Downstream PRs (will be copied)

See Write release notes for guidance.

monitoring: added `condition_sql` field to `monitoring_alert_policy` resource

@github-actions github-actions bot requested a review from hao-nan-li February 5, 2025 19:45
Copy link

github-actions bot commented Feb 5, 2025

Hello! I am a robot. Tests will require approval from a repository maintainer to run.

@hao-nan-li, a repository maintainer, has been assigned to review your changes. If you have not received review feedback within 2 business days, please leave a comment on this PR asking them to take a look.

You can help make sure that review is quick by doing a self-review and by running impacted tests locally.

@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

google provider: Diff ( 4 files changed, 910 insertions(+))
google-beta provider: Diff ( 4 files changed, 910 insertions(+))
terraform-google-conversion: Diff ( 1 file changed, 265 insertions(+))

Missing test report

Your PR includes resource fields which are not covered by any test.

Resource: google_monitoring_alert_policy (9 total tests)
Please add an acceptance test which includes these fields. The test should include the following:

resource "google_monitoring_alert_policy" "primary" {
  conditions {
    condition_sql {
      boolean_test {
        column = # value needed
      }
      daily {
        execution_time {
          hours   = # value needed
          minutes = # value needed
          nanos   = # value needed
          seconds = # value needed
        }
        periodicity = # value needed
      }
      hourly {
        minute_offset = # value needed
        periodicity   = # value needed
      }
      minutes {
        periodicity = # value needed
      }
      query = # value needed
      row_count_test {
        comparison = # value needed
        threshold  = # value needed
      }
    }
  }
}

1 similar comment
@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

google provider: Diff ( 4 files changed, 910 insertions(+))
google-beta provider: Diff ( 4 files changed, 910 insertions(+))
terraform-google-conversion: Diff ( 1 file changed, 265 insertions(+))

Missing test report

Your PR includes resource fields which are not covered by any test.

Resource: google_monitoring_alert_policy (9 total tests)
Please add an acceptance test which includes these fields. The test should include the following:

resource "google_monitoring_alert_policy" "primary" {
  conditions {
    condition_sql {
      boolean_test {
        column = # value needed
      }
      daily {
        execution_time {
          hours   = # value needed
          minutes = # value needed
          nanos   = # value needed
          seconds = # value needed
        }
        periodicity = # value needed
      }
      hourly {
        minute_offset = # value needed
        periodicity   = # value needed
      }
      minutes {
        periodicity = # value needed
      }
      query = # value needed
      row_count_test {
        comparison = # value needed
        threshold  = # value needed
      }
    }
  }
}

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 56
Passed tests: 52
Skipped tests: 3
Affected tests: 1

Click here to see the affected service packages
  • monitoring

Action taken

Found 1 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
  • TestAccMonitoringAlertPolicy

Get to know how VCR tests work

@modular-magician
Copy link
Collaborator

🔴 Tests failed during RECORDING mode:
TestAccMonitoringAlertPolicy [Error message] [Debug log]

🔴 Errors occurred during RECORDING mode. Please fix them to complete your PR.

View the build log or the debug log for each test

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 56
Passed tests: 52
Skipped tests: 3
Affected tests: 1

Click here to see the affected service packages
  • monitoring

Action taken

Found 1 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
  • TestAccMonitoringAlertPolicy

Get to know how VCR tests work

@modular-magician
Copy link
Collaborator

🔴 Tests failed during RECORDING mode:
TestAccMonitoringAlertPolicy [Error message] [Debug log]

🔴 Errors occurred during RECORDING mode. Please fix them to complete your PR.

View the build log or the debug log for each test

@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

google provider: Diff ( 4 files changed, 911 insertions(+))
google-beta provider: Diff ( 4 files changed, 911 insertions(+))
terraform-google-conversion: Diff ( 1 file changed, 265 insertions(+))

Missing test report

Your PR includes resource fields which are not covered by any test.

Resource: google_monitoring_alert_policy (10 total tests)
Please add an acceptance test which includes these fields. The test should include the following:

resource "google_monitoring_alert_policy" "primary" {
  conditions {
    condition_sql {
      boolean_test {
        column = # value needed
      }
      daily {
        execution_time {
          hours   = # value needed
          minutes = # value needed
          nanos   = # value needed
          seconds = # value needed
        }
        periodicity = # value needed
      }
      hourly {
        minute_offset = # value needed
        periodicity   = # value needed
      }
    }
  }
}

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 56
Passed tests: 52
Skipped tests: 3
Affected tests: 1

Click here to see the affected service packages
  • monitoring

Action taken

Found 1 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
  • TestAccMonitoringAlertPolicy

Get to know how VCR tests work

@modular-magician
Copy link
Collaborator

🔴 Tests failed during RECORDING mode:
TestAccMonitoringAlertPolicy [Error message] [Debug log]

🔴 Errors occurred during RECORDING mode. Please fix them to complete your PR.

View the build log or the debug log for each test


condition_sql {
query = "SELECT severity, resource FROM project.global._Default._AllLogs WHERE severity IS NOT NULL"
duration = "60s"
Copy link
Contributor

@hao-nan-li hao-nan-li Feb 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this field is not expected here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah - duration isn't valid with SQL. I've updated the tests.

Copy link
Contributor

@hao-nan-li hao-nan-li left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you also add the missing fields in the test?

@github-actions github-actions bot requested a review from hao-nan-li February 6, 2025 15:57
@haustenirving
Copy link
Contributor Author

Could you also add the missing fields in the test?

done.

@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

google provider: Diff ( 4 files changed, 1121 insertions(+))
google-beta provider: Diff ( 4 files changed, 1121 insertions(+))
terraform-google-conversion: Diff ( 1 file changed, 265 insertions(+))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 56
Passed tests: 52
Skipped tests: 3
Affected tests: 1

Click here to see the affected service packages
  • monitoring

Action taken

Found 1 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
  • TestAccMonitoringAlertPolicy

Get to know how VCR tests work

@modular-magician
Copy link
Collaborator

🔴 Tests failed during RECORDING mode:
TestAccMonitoringAlertPolicy [Error message] [Debug log]

🔴 Errors occurred during RECORDING mode. Please fix them to complete your PR.

View the build log or the debug log for each test

…QL conditions require additional GCP resources to be created and billed.
@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

google provider: Diff ( 4 files changed, 1078 insertions(+))
google-beta provider: Diff ( 4 files changed, 1078 insertions(+))
terraform-google-conversion: Diff ( 1 file changed, 265 insertions(+))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 56
Passed tests: 52
Skipped tests: 3
Affected tests: 1

Click here to see the affected service packages
  • monitoring

Action taken

Found 1 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
  • TestAccMonitoringAlertPolicy

Get to know how VCR tests work

@modular-magician
Copy link
Collaborator

🔴 Tests failed during RECORDING mode:
TestAccMonitoringAlertPolicy [Error message] [Debug log]

🔴 Errors occurred during RECORDING mode. Please fix them to complete your PR.

View the build log or the debug log for each test

…QL conditions require additional GCP resources to be created and billed.
@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

google provider: Diff ( 4 files changed, 1076 insertions(+))
google-beta provider: Diff ( 4 files changed, 1076 insertions(+))
terraform-google-conversion: Diff ( 1 file changed, 265 insertions(+))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 56
Passed tests: 52
Skipped tests: 3
Affected tests: 1

Click here to see the affected service packages
  • monitoring

Action taken

Found 1 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
  • TestAccMonitoringAlertPolicy

Get to know how VCR tests work

@modular-magician
Copy link
Collaborator

🔴 Tests failed during RECORDING mode:
TestAccMonitoringAlertPolicy [Error message] [Debug log]

🔴 Errors occurred during RECORDING mode. Please fix them to complete your PR.

View the build log or the debug log for each test

@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

google provider: Diff ( 4 files changed, 1077 insertions(+))
google-beta provider: Diff ( 4 files changed, 1077 insertions(+))
terraform-google-conversion: Diff ( 1 file changed, 265 insertions(+))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 56
Passed tests: 53
Skipped tests: 3
Affected tests: 0

Click here to see the affected service packages
  • monitoring

🟢 All tests passed!

View the build log

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

google_monitoring_alert_policy doesn't support SQL condition types
3 participants