Skip to content

feat(logging): Add Cloud Logging Saved Query resource#16182

Merged
roaks3 merged 6 commits intoGoogleCloudPlatform:mainfrom
kvanzuijlen:add-cloud-logging-saved-query
Jan 28, 2026
Merged

feat(logging): Add Cloud Logging Saved Query resource#16182
roaks3 merged 6 commits intoGoogleCloudPlatform:mainfrom
kvanzuijlen:add-cloud-logging-saved-query

Conversation

@kvanzuijlen
Copy link
Copy Markdown
Contributor

This PR adds a resource for Cloud Logging Saved Queries, which can be used for both Logging Saved Queries and Log Analytics Saved Queries.

Fixes hashicorp/terraform-provider-google#18023

Release Note Template for Downstream PRs (will be copied)

See Write release notes for guidance.

`google_logging_saved_query`

@modular-magician modular-magician added the awaiting-approval Pull requests that need reviewer's approval to run presubmit tests label Jan 21, 2026
@kvanzuijlen kvanzuijlen marked this pull request as ready for review January 21, 2026 15:11
@github-actions github-actions Bot requested a review from roaks3 January 21, 2026 15:12
@github-actions
Copy link
Copy Markdown

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

Googlers: For automatic test runs see go/terraform-auto-test-runs.

@roaks3, 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.

Copy link
Copy Markdown
Contributor

@ramonvermeulen ramonvermeulen left a comment

Choose a reason for hiding this comment

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

LGTM, nice work!

Ran tests locally:

sh -c "'/Users/ramon/go/src/github.com/hashicorp/terraform-provider-google/scripts/gofmtcheck.sh'"
==> Checking that code complies with gofmt requirements...
go vet
TF_ACC_REFRESH_AFTER_APPLY=1 TF_ACC=1 TF_SCHEMA_PANIC_ON_ERROR=1 go test ./google/services/logging -v -run=TestAccLoggingSavedQuery_ -timeout 240m -ldflags="-X=github.com/hashicorp/terraform-provider-google/version.ProviderVersion=acc"                    
=== RUN   TestAccLoggingSavedQuery_loggingSavedQueryBasicExample
=== PAUSE TestAccLoggingSavedQuery_loggingSavedQueryBasicExample
=== RUN   TestAccLoggingSavedQuery_loggingSavedQueryPrivateExample
=== PAUSE TestAccLoggingSavedQuery_loggingSavedQueryPrivateExample
=== RUN   TestAccLoggingSavedQuery_loggingSavedQuerySummaryFieldsExample
=== PAUSE TestAccLoggingSavedQuery_loggingSavedQuerySummaryFieldsExample
=== RUN   TestAccLoggingSavedQuery_loggingSavedQuerySqlBasicExample
=== PAUSE TestAccLoggingSavedQuery_loggingSavedQuerySqlBasicExample
=== RUN   TestAccLoggingSavedQuery_update
=== PAUSE TestAccLoggingSavedQuery_update
=== CONT  TestAccLoggingSavedQuery_loggingSavedQueryBasicExample
=== CONT  TestAccLoggingSavedQuery_loggingSavedQuerySqlBasicExample
=== CONT  TestAccLoggingSavedQuery_loggingSavedQuerySummaryFieldsExample
=== CONT  TestAccLoggingSavedQuery_update
=== CONT  TestAccLoggingSavedQuery_loggingSavedQueryPrivateExample
--- PASS: TestAccLoggingSavedQuery_loggingSavedQuerySummaryFieldsExample (7.36s)
--- PASS: TestAccLoggingSavedQuery_loggingSavedQueryBasicExample (7.87s)
--- PASS: TestAccLoggingSavedQuery_loggingSavedQueryPrivateExample (8.01s)
--- PASS: TestAccLoggingSavedQuery_loggingSavedQuerySqlBasicExample (8.17s)
--- PASS: TestAccLoggingSavedQuery_update (12.32s)
PASS
ok      github.com/hashicorp/terraform-provider-google/google/services/logging  13.990s

Comment thread mmv1/third_party/terraform/services/logging/resource_logging_saved_query_test.go Outdated
@kvanzuijlen kvanzuijlen changed the title feat: Add Cloud Logging Saved Query resource feat(logging): Add Cloud Logging Saved Query resource Jan 21, 2026
@github-actions
Copy link
Copy Markdown

@roaks3 This PR has been waiting for review for 3 weekdays. Please take a look! Use the label disable-review-reminders to disable these notifications.

Copy link
Copy Markdown
Contributor

@roaks3 roaks3 left a comment

Choose a reason for hiding this comment

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

Sorry for the delay. I found some very minor things to comment on, but overall LGTM

Comment thread mmv1/products/logging/SavedQuery.yaml Outdated
- name: 'logging_saved_query_private'
primary_resource_id: 'saved_query'
vars:
logging_saved_query_name: 'my-saved-query'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: It can be helpful to name these in a way that correlates to the test, particularly if they ever have issues being cleaned up (ie. my-saved-query-private, etc.).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done, thanks!

Comment thread mmv1/products/logging/SavedQuery.yaml Outdated
description: |
Characters will be counted from the start of the string.
conflicts:
- 'summaryFieldEnd'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do you know if this works? I believe, at least at one point, that this needed to be an absolute name, like loggingQuery.0.summaryFieldEnd.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

You are correct. I now fixed this. Tested it locally as well:
image

"google.golang.org/api/googleapi"
)

var (
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hmm, you might be able to remove this block? I haven't seen it before, but guessing this is generated now to support imports that may or may not be used (and for handwritten tests I'd assume you don't need it).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done, thanks. Is indeed part of the generated tests.

display_name = "My Saved Query"
parent = "projects/%{project}"
location = "global"
description = "A saved query"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: Could remove description from one of these tests, to test it's optionality. It looks like it is specified in all tests currently.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Created a new test in SavedQuery.yaml that creates it without a description. I hope that's ok.

@github-actions github-actions Bot requested a review from roaks3 January 27, 2026 00:45
@kvanzuijlen
Copy link
Copy Markdown
Contributor Author

@roaks3 I implemented your feedback. Should be ready for re-review now.

Copy link
Copy Markdown
Contributor

@roaks3 roaks3 left a comment

Choose a reason for hiding this comment

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

One last item I missed, otherwise LGTM and we should be able to merge.

I'll wait to re-run tests until the copyright is added.

@@ -0,0 +1,158 @@
---
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Sorry, missed this before. I think you need to include the Google copyright that can be found in most other yaml files.

@github-actions github-actions Bot requested a review from roaks3 January 28, 2026 11:49
@kvanzuijlen
Copy link
Copy Markdown
Contributor Author

Hi @roaks3,

Thanks for the review. I've added the copyright as an exact copy from 1 of the other yaml files. I did notice, however, that the copyright year is 2024, so it might make sense if this is updated to 2026 at some point?

@modular-magician modular-magician added service/logging and removed awaiting-approval Pull requests that need reviewer's approval to run presubmit tests labels Jan 28, 2026
@modular-magician
Copy link
Copy Markdown
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 ( 6 files changed, 1441 insertions(+), 2 deletions(-))
google-beta provider: Diff ( 6 files changed, 1441 insertions(+), 2 deletions(-))
terraform-google-conversion: Diff ( 1 file changed, 267 insertions(+))

Missing test report

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

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

resource "google_logging_saved_query" "primary" {
  logging_query {
    summary_field_end = # value needed
  }
}

@modular-magician
Copy link
Copy Markdown
Collaborator

Tests analytics

Total tests: 83
Passed tests: 75
Skipped tests: 2
Affected tests: 6

Click here to see the affected service packages
  • logging

Action taken

Found 6 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
  • TestAccLoggingSavedQuery_loggingSavedQueryBasicExample
  • TestAccLoggingSavedQuery_loggingSavedQueryNoDescriptionExample
  • TestAccLoggingSavedQuery_loggingSavedQueryPrivateExample
  • TestAccLoggingSavedQuery_loggingSavedQuerySqlBasicExample
  • TestAccLoggingSavedQuery_loggingSavedQuerySummaryFieldsExample
  • TestAccLoggingSavedQuery_update

Get to know how VCR tests work

@modular-magician
Copy link
Copy Markdown
Collaborator

🟢 Tests passed during RECORDING mode:
TestAccLoggingSavedQuery_loggingSavedQueryBasicExample [Debug log]
TestAccLoggingSavedQuery_loggingSavedQueryNoDescriptionExample [Debug log]
TestAccLoggingSavedQuery_loggingSavedQueryPrivateExample [Debug log]
TestAccLoggingSavedQuery_loggingSavedQuerySqlBasicExample [Debug log]
TestAccLoggingSavedQuery_loggingSavedQuerySummaryFieldsExample [Debug log]
TestAccLoggingSavedQuery_update [Debug log]

🟢 No issues found for passed tests after REPLAYING rerun.


🟢 All tests passed!

View the build log or the debug log for each test

@roaks3 roaks3 added this pull request to the merge queue Jan 28, 2026
Merged via the queue into GoogleCloudPlatform:main with commit c790ddb Jan 28, 2026
31 checks passed
SirGitsalot pushed a commit that referenced this pull request Jan 28, 2026
@kvanzuijlen kvanzuijlen deleted the add-cloud-logging-saved-query branch January 29, 2026 09:57
wuchris-g pushed a commit to wuchris-g/magic-modules that referenced this pull request Feb 5, 2026
JianweiQ pushed a commit to JianweiQ/magic-modules that referenced this pull request Feb 20, 2026
aditikumarii-google pushed a commit to aditikumarii-google/magic-modules that referenced this pull request Mar 10, 2026
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.

Resource for Cloud Logging saved queries?

4 participants