turbot/gcp_insights

Query: compute_instance_by_cpu_utilization_category

Usage

powerpipe query gcp_insights.query.compute_instance_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,
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
gcp_compute_instance_metric_cpu_utilization_daily
where
date_part('day', now() - timestamp) <= 30
group by
name
)
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: