Control: Which EC2 instances have very low CPU utilization?
Description
Resize or eliminate under utilized instances.
Usage
Run the control in your terminal:
powerpipe control run aws_thrifty.control.instances_with_low_utilization
Snapshot and share results via Turbot Pipes:
powerpipe loginpowerpipe control run aws_thrifty.control.instances_with_low_utilization --share
Steampipe Tables
Params
Args | Name | Default | Description | Variable |
---|---|---|---|---|
$1 | ec2_instance_avg_cpu_utilization_low |
| The average CPU utilization required for instances to be considered infrequently used. This value should be lower than ec2_instance_avg_cpu_utilization_high. | |
$2 | ec2_instance_avg_cpu_utilization_high |
| The average CPU utilization required for instances to be considered frequently used. This value should be higher than ec2_instance_avg_cpu_utilization_low. |
SQL
with ec2_instance_utilization as ( select instance_id, max(average) as avg_max, count(average) days from aws_ec2_instance_metric_cpu_utilization_daily where date_part('day', now() - timestamp) <= 30 group by instance_id)select arn as resource, case when avg_max is null then 'error' when avg_max < $1 then 'alarm' when avg_max < $2 then 'info' else 'ok' end as status, case when avg_max is null then 'CloudWatch metrics not available for ' || title || '.' else title || ' is averaging ' || avg_max || '% max utilization over the last ' || days || ' days.' end as reason , region, account_idfrom aws_ec2_instance i left join ec2_instance_utilization as u on u.instance_id = i.instance_id;