turbot/tailpipe-mod-azure-cost-and-usage-insights

Dashboard: Azure Cost and Usage Actual: Cost by Tag

This dashboard answers the following questions:

  • What is the total cost for selected subscriptions and tag key?
  • How many unique tag values exist?
  • How are costs distributed across different tag values?
  • How have costs for different tag values trended over time?
  • What are the top 10 most expensive tag values?
  • What is the detailed cost breakdown by tag value, subscription, and region?
This dashboard contains 2 cards, 2 inputs and 1 table.

Usage

Install the mod:

mkdir dashboards
cd dashboards
powerpipe mod init
powerpipe mod install github.com/turbot/tailpipe-mod-azure-cost-and-usage-insights

Start the Powerpipe server:

powerpipe server

Open http://localhost:9033 in your browser and select Azure Cost and Usage Actual: Cost by Tag dashboard.

You could also snapshot and share results via Turbot Pipes:

powerpipe login
powerpipe dashboard run azure_cost_and_usage_insights.dashboard.cost_and_usage_actual_cost_by_tag_dashboard --share

Queries

This dashboard uses the the following queries:
with tagged_resources as (
select
resource_id,
date_trunc('month', date) as month,
cost_in_billing_currency,
json_extract(tags, '$.' || $2) as tag_value
from
azure_cost_and_usage_actual r
where
('all' in ($1) or subscription_id in $1)
and tags is not null
and array_contains(json_keys(tags), $2)
and json_extract(tags, '$.' || $2) is not null
and json_extract(tags, '$.' || $2) <> '""'
)
select
strftime(month, '%b %Y') as "Month",
replace(tag_value, '"', '') as "Series",
round(sum(cost_in_billing_currency), 2) as "Total Cost"
from
tagged_resources
group by
month,
tag_value
having
sum(cost_in_billing_currency) > 0
order by
month,
sum(cost_in_billing_currency) desc;
{
"$1": "subscription_ids",
"$2": "tag_key"
}

Tags