turbot/steampipe-mod-gcp-compliance

Control: Ensure 'log_duration' database flag for Cloud SQL PostgreSQL instance is set to 'on'

Description

Enabling the log_duration setting causes the duration of each completed statement to be logged. This does not logs the text of the query and thus behaves different from the log_min_duration_statement flag. This parameter cannot be changed after session start.

Usage

Run the control in your terminal:

powerpipe control run gcp_compliance.control.sql_instance_postgresql_log_duration_database_flag_on

Snapshot and share results via Turbot Pipes:

powerpipe login
powerpipe control run gcp_compliance.control.sql_instance_postgresql_log_duration_database_flag_on --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_duration","value":"on"}]' 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_duration"}]')
then title || ' ''log_duration'' database flag not set.'
when database_flags @> '[{"name":"log_duration","value":"on"}]'
then title || ' ''log_duration'' database flag set to ''on''.'
else title || ' ''log_duration'' database flag set to ''off''.'
end as reason
, location as location, project as project
from
gcp_sql_database_instance;

Tags