turbot/steampipe-mod-gcp-compliance

Control: Ensure 'log_statement_stats' database flag for Cloud SQL PostgreSQL instance is set to 'off'

Description

The log_statement_stats flag controls the inclusion of end-to-end performance statistics of a SQL query in the PostgreSQL logs for each query. This cannot be enabled with other module statistics (log_parser_stats, log_planner_stats, log_executor_stats).

Usage

Run the control in your terminal:

powerpipe control run gcp_compliance.control.sql_instance_postgresql_log_statement_stats_database_flag_off

Snapshot and share results via Turbot Pipes:

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

Tags