Azure Cost Query
azure_cost_queryQuery Azure actual or amortized costs for any scope, with grouping by service, tags, or resource group, and time-based filtering to support cost optimization and chargeback.
Instructions
Queries actual or amortized costs for an Azure scope with grouping and time filtering. WAF Cost Optimization: identify top-spending services and resource groups, track daily trends, and perform chargeback/showback using tag-based grouping. CAF: use management group scope for cross-subscription cost reports aligned to landing zones.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| to | No | ISO 8601 end date for Custom timeframe (e.g., 2024-01-31). | |
| top | No | Maximum number of result rows to return. | |
| from | No | ISO 8601 start date for Custom timeframe (e.g., 2024-01-01). | |
| type | No | Cost type. ActualCost: pay-as-you-go charges as billed. AmortizedCost: includes amortized reservation and savings plan costs (recommended for showback). | ActualCost |
| scope | Yes | Azure scope. Formats: full path (/subscriptions/{id} | /subscriptions/{id}/resourceGroups/{name}), UUID subscription ID, sub:{id}, sub:{id}/rg:{name}, rg:{name}, mg:{managementGroupId}, ba:{billingAccountId}. CAF tip: use mg: scope for enterprise-wide analysis across landing zones. | |
| groupBy | No | Dimensions to group by. Common values: ResourceGroup, ServiceName, ResourceType, Location, SubscriptionName, MeterCategory, MeterSubCategory, ChargeType. For tags prefix with 'tag:' (e.g., 'tag:CostCenter', 'tag:Environment', 'tag:Application'). WAF tagging strategy: group by tag:CostCenter and tag:Environment for chargeback/showback. | |
| timeframe | No | Billing window. Use Custom with from/to for historical queries. | MonthToDate |
| granularity | No | Aggregation granularity. None=single total, Daily=trend analysis, Monthly=billing period summary. | None |