turbot/azure_thrifty
Loading controls...

Control: Long running virtual machines should be reviewed

Description

Virtual machines should ideally be ephemeral and rehydrated frequently, check why these virtual machines have been running for so long.

Usage

Run the control in your terminal:

powerpipe control run azure_thrifty.control.compute_virtual_machine_long_running

Snapshot and share results via Turbot Pipes:

powerpipe login
powerpipe control run azure_thrifty.control.compute_virtual_machine_long_running --share

Steampipe Tables

Params

ArgsNameDefaultDescriptionVariable
$1compute_running_vm_age_max_days
90
The maximum number of days virtual machines are allowed to run.

SQL

select
vm.id as resource,
case
when date_part('day', now() - (s ->> 'time') :: timestamptz) > $1 then 'alarm'
else 'ok'
end as status,
vm.title || ' has been running for ' || date_part('day', now() - (s ->> 'time') :: timestamptz) || ' days.' as reason,
vm.resource_group,
display_name as subscription
from
azure_compute_virtual_machine as vm,
jsonb_array_elements(statuses) as s,
azure_subscription as sub
where
sub.subscription_id = vm.subscription_id
and vm.power_state in ('running', 'starting')
and s ->> 'time' is not null;

Tags