turbot/gcp_thrifty

Control: Compute disks with low usage should be reviewed

Description

Disks that are unused should be archived and deleted.

Usage

Run the control in your terminal:

powerpipe control run gcp_thrifty.control.compute_disk_low_usage

Snapshot and share results via Turbot Pipes:

powerpipe login
powerpipe control run gcp_thrifty.control.compute_disk_low_usage --share

Steampipe Tables

Params

ArgsNameDefaultDescriptionVariable
$1compute_disk_avg_read_write_ops_low
100
The number of average read/write ops required for disks to be considered infrequently used. This value should be lower than compute_disk_avg_read_write_ops_high.
$2compute_disk_avg_read_write_ops_high
500
The number of average read/write ops required for disks to be considered frequently used. This value should be higher than compute_disk_avg_read_write_ops_low.

SQL

with disk_usage as (
select
project,
location,
name,
_ctx,
round(avg(max)) as avg_max,
count(max) as days
from
(
select
project,
name,
location,
_ctx,
cast(maximum as numeric) as max
from
gcp_compute_disk_metric_read_ops_daily
where
date_part('day', now() - timestamp) <= 30
union all
select
project,
name,
location,
_ctx,
cast(maximum as numeric) as max
from
gcp_compute_disk_metric_write_ops_daily
where
date_part('day', now() - timestamp) <= 30
) as read_and_write_ops
group by
name,
project,
_ctx,
location
)
select
name as resource,
case
when avg_max <= $1 then 'alarm'
when avg_max <= $2 then 'info'
else 'ok'
end as status,
name || ' is averaging ' || avg_max || ' read and write ops over the last ' || days / 2 || ' days.' as reason
, location, project
from
disk_usage;

Tags