diff --git a/.changelog/6720.txt b/.changelog/6720.txt new file mode 100644 index 00000000000..4fb4975dec2 --- /dev/null +++ b/.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 +``` diff --git a/google/resource_sql_database_instance.go b/google/resource_sql_database_instance.go index fb0d6cbc825..02d179fc5d1 100644 --- a/google/resource_sql_database_instance.go +++ b/google/resource_sql_database_instance.go @@ -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", } ) @@ -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.`, @@ -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)), } } @@ -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} diff --git a/google/resource_sql_database_instance_test.go b/google/resource_sql_database_instance_test.go index c9fc45a7ed4..18d915b5924 100644 --- a/google/resource_sql_database_instance_test.go +++ b/google/resource_sql_database_instance_test.go @@ -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 } } } diff --git a/website/docs/r/sql_database_instance.html.markdown b/website/docs/r/sql_database_instance.html.markdown index 316a7c04002..9071e445634 100644 --- a/website/docs/r/sql_database_instance.html.markdown +++ b/website/docs/r/sql_database_instance.html.markdown @@ -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.