turbot/oci_insights

Query: compute_instance_by_creation_month

Usage

powerpipe query oci_insights.query.compute_instance_by_creation_month

Steampipe Tables

SQL

with instances as (
select
title,
time_created,
to_char(time_created,
'YYYY-MM') as creation_month
from
oci_core_instance
where
lifecycle_state <> 'TERMINATED'
),
months as (
select
to_char(d,
'YYYY-MM') as month
from
generate_series(date_trunc('month',
(
select
min(time_created)
from instances)),
date_trunc('month',
current_date),
interval '1 month') as d
),
instances_by_month as (
select
creation_month,
count(*)
from
instances
group by
creation_month
)
select
months.month,
-- instances_by_month.count
coalesce(instances_by_month.count, 0)
from
months
left join instances_by_month on months.month = instances_by_month.creation_month
order by
months.month desc;

Dashboards

The query is used in the dashboards: