Control: Ensure that the 'log_min_duration_statement' database flag for Cloud SQL PostgreSQL instance is set to '-1' (disabled)
Description
The log_min_duration_statement flag defines the minimum amount of execution time of a statement in milliseconds where the total duration of the statement is logged. Ensure that log_min_duration_statement is disabled, i.e., a value of -1 is set.
Usage
Run the control in your terminal:
powerpipe control run gcp_compliance.control.sql_instance_postgresql_log_min_duration_statement_database_flag_disabled
Snapshot and share results via Turbot Pipes:
powerpipe loginpowerpipe control run gcp_compliance.control.sql_instance_postgresql_log_min_duration_statement_database_flag_disabled --share
SQL
This control uses a named query:
select self_link resource, case when database_version not like 'POSTGRES%' then 'skip' when database_flags @> '[{"name":"log_min_duration_statement","value":"-1"}]' then 'ok' else 'alarm' end as status, case when database_version not like 'POSTGRES%' then title || ' not a PostgreSQL database.' when database_flags is null or not (database_flags @> '[{"name":"log_min_duration_statement"}]') then title || ' ''log_min_duration_statement'' database flag not set.' when database_flags @> '[{"name":"log_min_duration_statement","value":"-1"}]' then title || ' ''log_min_duration_statement'' database flag disabled.' else title || ' ''log_min_duration_statement'' database flag enabled.' end as reason , location as location, project as projectfrom gcp_sql_database_instance;