steampipe plugin install gcp

Table: gcp_billing_budget - Query GCP Billing Budgets using SQL

A Billing Budget in Google Cloud Platform is a tool that allows you to set a custom cost threshold for your Google Cloud usage. It can be associated with one or more projects and can be configured to send alerts when the usage approaches or exceeds the set budget. This helps in managing costs, avoiding overspending, and keeping track of your cloud resource consumption.

Table Usage Guide

The gcp_billing_budget table provides insights into Billing Budgets within Google Cloud Platform. As a finance or operations manager, explore budget-specific details through this table, including budget amounts, associated projects, and alert thresholds. Utilize it to manage costs, monitor spending, and ensure that resource usage is within the set budgets.

Important Notes

  • This table requires the billing.viewer permission to retrieve billing account details.

Examples

Basic info

Explore your Google Cloud Platform's budget details to gain insights into the specified amounts, including units and currency codes, for each project and location. This can help you manage your resources more effectively and keep track of your spending.

select
name,
billing_account display_name,
specified_amount ->> 'units' as units,
specified_amount ->> 'currencyCode' as currency_code,
project,
location
from
gcp_billing_budget;
select
name,
billing_account,
display_name,
json_extract(specified_amount, '$.units') as units,
json_extract(specified_amount, '$.currencyCode') as currency_code,
project,
location
from
gcp_billing_budget;

Get threshold rules to trigger alerts for each budget

Explore the budget alert rules to understand when each budget will trigger an alert based on a certain spending threshold. This is useful to manage and control spending within your budget limits.

select
name,
display_name,
((threshold_rule ->> 'thresholdPercent') :: numeric) * 100 || '%' as threshold_percent,
threshold_rule ->> 'spendBasis' as spend_basis
from
gcp_billing_budget,
jsonb_array_elements(threshold_rules) as threshold_rule;
select
name,
display_name,
(
json_extract(threshold_rule.value, '$.thresholdPercent') * 100
) || '%' as threshold_percent,
json_extract(threshold_rule.value, '$.spendBasis') as spend_basis
from
gcp_billing_budget,
json_each(threshold_rules) as threshold_rule;

Get filters limiting the scope of the cost to calculate budget

This query is useful for gaining insights into your Google Cloud Platform (GCP) billing budget. It allows you to identify the filters that limit the cost scope for budget calculations, providing a better understanding of your spending limits and how they are distributed across different projects.

select
name,
display_name,
string_agg(p, ', ') as applies_to_projects,
specified_amount ->> 'units' as units,
specified_amount ->> 'currencyCode' as currency_code,
budget_filter ->> 'calendarPeriod' as budget_calendar_period,
budget_filter ->> 'creditTypesTreatment' as budget_credit_types_treatment
from
gcp_billing_budget,
jsonb_array_elements_text(budget_filter -> 'projects') as p
group by
name,
display_name,
budget_filter,
specified_amount;
select
name,
display_name,
group_concat(p.value, ', ') as applies_to_projects,
json_extract(specified_amount, '$.units') as units,
json_extract(specified_amount, '$.currencyCode') as currency_code,
json_extract(budget_filter, '$.calendarPeriod') as budget_calendar_period,
json_extract(budget_filter, '$.creditTypesTreatment') as budget_credit_types_treatment
from
gcp_billing_budget,
json_each(json_extract(budget_filter, '$.projects')) as p
group by
name,
display_name,
budget_filter,
specified_amount;

Schema for gcp_billing_budget

NameTypeOperatorsDescription
_ctxjsonbSteampipe context in JSON form.
akasjsonbArray of globally unique identifier strings (also known as) for the resource.
billing_accounttext=The name given to the associated billing account.
budget_filterjsonbFilters that define which resources are used to compute the actual spend against the budget amount.
display_nametextThe display name given to the budget.
last_period_amountjsonbUse the last period's actual spend as the budget for the present period.
locationtextThe GCP multi-region, region, or zone in which the resource is located.
nametext=The resource name of the budget.
notifications_rulejsonbRules to apply to notifications sent based on budget spend and thresholds.
projecttext=, !=, ~~, ~~*, !~~, !~~*The GCP Project in which the resource is located.
sp_connection_nametext=, !=, ~~, ~~*, !~~, !~~*Steampipe connection name.
sp_ctxjsonbSteampipe context in JSON form.
specified_amountjsonbUse the last period's actual spend as the budget for the present period.
threshold_rulesjsonbRules that trigger alerts (notifications of thresholds being crossed) when spend exceeds the specified percentages of the budget.
titletextTitle of the resource.

Export

This table is available as a standalone Exporter CLI. Steampipe exporters are stand-alone binaries that allow you to extract data using Steampipe plugins without a database.

You can download the tarball for your platform from the Releases page, but it is simplest to install them with the steampipe_export_installer.sh script:

/bin/sh -c "$(curl -fsSL https://steampipe.io/install/export.sh)" -- gcp

You can pass the configuration to the command with the --config argument:

steampipe_export_gcp --config '<your_config>' gcp_billing_budget