Loading controls...
Control: SQL DB instances with a low number connections per day should be reviewed
Description
DB instances having less usage in last 30 days should be reviewed.
Usage
Run the control in your terminal:
steampipe check gcp_thrifty.control.sql_db_instance_low_connection_count
Snapshot and share results via Steampipe Cloud:
steampipe loginsteampipe check --share gcp_thrifty.control.sql_db_instance_low_connection_count
Plugins & Tables
Params
Args | Name | Default | Description | Variable |
---|---|---|---|---|
$1 | sql_db_instance_avg_connections |
| The minimum number of average connections per day required for DB instances to be considered in-use. |
SQL
with sql_db_instance_usage as ( select instance_id, round(sum(maximum) / count(maximum)) as avg_max, count(maximum) as days from gcp_sql_database_instance_metric_connections_daily where date_part('day', now() - timestamp) <= 30 group by instance_id)select i.self_link as resource, case when avg_max is null then 'error' when avg_max = 0 then 'alarm' when avg_max < $1 then 'info' else 'ok' end as status, case when avg_max is null then 'Logging metrics not available for ' || title || '.' when avg_max = 0 then title || ' has not been connected to in the last ' || days || ' days.' else title || ' is averaging ' || avg_max || ' max connections/day in the last ' || days || ' days.' end as reason, location, projectfrom gcp_sql_database_instance as i left join sql_db_instance_usage as u on i.project || ':' || i.name = u.instance_id;