Skip to content

Commit

Permalink
Add query_plans_per_minute to query insights (#6720) (#12951)
Browse files Browse the repository at this point in the history
Signed-off-by: Modular Magician <magic-modules@google.com>

Signed-off-by: Modular Magician <magic-modules@google.com>
  • Loading branch information
modular-magician committed Nov 4, 2022
1 parent d2a3e31 commit d837a16
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 0 deletions.
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

0 comments on commit d837a16

Please sign in to comment.