turbot/azure_insights

Query: compute_virtual_machine_by_cpu_utilization_category

Usage

powerpipe query azure_insights.query.compute_virtual_machine_by_cpu_utilization_category

SQL

with cpu_buckets as (
select
unnest(array ['Unused (<1%)','Underutilized (1-10%)','Right-sized (10-90%)', 'Overutilized (>90%)' ]) as cpu_bucket
),
max_averages as (
select
name,
resource_group,
case
when max(average) <= 1 then 'Unused (<1%)'
when max(average) between 1 and 10 then 'Underutilized (1-10%)'
when max(average) between 10 and 90 then 'Right-sized (10-90%)'
when max(average) > 90 then 'Overutilized (>90%)'
end as cpu_bucket,
max(average) as max_avg
from
azure_compute_virtual_machine_metric_cpu_utilization_daily
where
date_part('day', now() - timestamp) <= 30
group by
name, resource_group
)
select
b.cpu_bucket as "CPU Utilization",
count(a.*)
from
cpu_buckets as b
left join max_averages as a on b.cpu_bucket = a.cpu_bucket
group by
b.cpu_bucket;

Dashboards

The query is used in the dashboards: