Control: Compute virtual machines with low CPU utilization should be reviewed
Description
Resize or eliminate under utilized virtual machines.
Usage
Run the control in your terminal:
powerpipe control run azure_thrifty.control.compute_virtual_machine_low_utilization
Snapshot and share results via Turbot Pipes:
powerpipe loginpowerpipe control run azure_thrifty.control.compute_virtual_machine_low_utilization --share
Steampipe Tables
Params
Args | Name | Default | Description | Variable |
---|---|---|---|---|
$1 | compute_vm_avg_cpu_utilization_low |
| The average CPU utilization required for virtual machines to be considered infrequently used. This value should be lower than compute_vm_avg_cpu_utilization_high. | |
$2 | compute_vm_avg_cpu_utilization_high |
| The average CPU utilization required for virtual machines to be considered frequently used. This value should be higher than compute_vm_avg_cpu_utilization_low. |
SQL
with compute_virtual_machine_utilization as ( select name, round(cast(sum(maximum)/count(maximum) as numeric), 1) as avg_max, count(maximum) as days from azure_compute_virtual_machine_metric_cpu_utilization_daily where date_part('day', now() - timestamp) <=30 group by name)select v.id 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 'Monitor metrics not available for ' || v.title || '.' else v.title || ' averaging ' || avg_max || '% max utilization over the last ' || days || ' days.' end as reason , v.resource_group , display_name as subscriptionfrom azure_compute_virtual_machine as v left join compute_virtual_machine_utilization as u on u.name = v.name left join azure_subscription as sub on sub.subscription_id = v.subscription_id;