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

Add query_plans_per_minute to query insights #12951

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/6720.txt
@@ -0,0 +1,3 @@
```release-note:enhancement
sql: added `query_plan_per_minute` field to `insights_config` in `google_sql_database_instance` resource
```
11 changes: 11 additions & 0 deletions google/resource_sql_database_instance.go
Expand Up @@ -81,6 +81,7 @@ var (
"settings.0.insights_config.0.query_string_length",
"settings.0.insights_config.0.record_application_tags",
"settings.0.insights_config.0.record_client_address",
"settings.0.insights_config.0.query_plans_per_minute",
}
)

Expand Down Expand Up @@ -466,6 +467,14 @@ is set to true. Defaults to ZONAL.`,
AtLeastOneOf: insightsConfigKeys,
Description: `True if Query Insights will record client address when enabled.`,
},
"query_plans_per_minute": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
ValidateFunc: validation.IntBetween(0, 20),
AtLeastOneOf: insightsConfigKeys,
Description: `Number of query execution plans captured by Insights per minute for all queries combined. Between 0 and 20. Default to 5.`,
},
},
},
Description: `Configuration of Query Insights.`,
Expand Down Expand Up @@ -1253,6 +1262,7 @@ func expandInsightsConfig(configured []interface{}) *sqladmin.InsightsConfig {
QueryStringLength: int64(_insightsConfig["query_string_length"].(int)),
RecordApplicationTags: _insightsConfig["record_application_tags"].(bool),
RecordClientAddress: _insightsConfig["record_client_address"].(bool),
QueryPlansPerMinute: int64(_insightsConfig["query_plans_per_minute"].(int)),
}
}

Expand Down Expand Up @@ -1806,6 +1816,7 @@ func flattenInsightsConfig(insightsConfig *sqladmin.InsightsConfig) interface{}
"query_string_length": insightsConfig.QueryStringLength,
"record_application_tags": insightsConfig.RecordApplicationTags,
"record_client_address": insightsConfig.RecordClientAddress,
"query_plans_per_minute": insightsConfig.QueryPlansPerMinute,
}

return []map[string]interface{}{data}
Expand Down
1 change: 1 addition & 0 deletions google/resource_sql_database_instance_test.go
Expand Up @@ -2212,6 +2212,7 @@ resource "google_sql_database_instance" "instance" {
query_string_length = 256
record_application_tags = true
record_client_address = true
query_plans_per_minute = 10
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/sql_database_instance.html.markdown
Expand Up @@ -353,6 +353,8 @@ The optional `settings.insights_config` subblock for instances declares [Query I

* `record_client_address` - True if Query Insights will record client address when enabled.

* `query_plans_per_minute` - Number of query execution plans captured by Insights per minute for all queries combined. Between 0 and 20. Default to 5.

The optional `settings.password_validation_policy` subblock for instances declares [Password Validation Policy](https://cloud.google.com/sql/docs/postgres/built-in-authentication) configuration. It contains:

* `min_length` - Specifies the minimum number of characters that the password must have.
Expand Down