Setting the file. One moment.
Subchapter 13.19
cost-query/examples.mdMarkdown2 KBView on GitHub
Common query patterns with request bodies. Use the SKILL.md workflow to construct and execute the az rest command.
{
"type": "ActualCost",
"timeframe": "MonthToDate",
"dataset": {
"granularity": "None",
"aggregation": {
"totalCost": { "name": "Cost", "function": "Sum" }
},
"grouping": [
{ "type": "Dimension", "name": "ServiceName" }
],
"sorting": [
{ "direction": "Descending", "name": "Cost" }
]
}
}{
"type": "ActualCost",
"timeframe": "Custom",
"timePeriod": {
"from": "2024-01-01T00:00:00Z",
"to": "2024-01-31T23:59:59Z"
},
"dataset": {
"granularity": "Daily",
"aggregation": {
"totalCost": { "name": "Cost", "function": "Sum" }
}
}
}⚠️ Warning: Daily granularity supports a maximum of 31 days.
{
"type": "ActualCost",
"timeframe": "MonthToDate",
"dataset": {
"granularity": "None",
"aggregation": {
"totalCost": { "name": "Cost", "function": "Sum" }
},
"grouping": [
{ "type": "Dimension", "name": "ResourceGroupName" }
],
"filter": {
"tags": {
"name": "Environment",
"operator": "In",
"values": ["production", "staging"]
}
},
"sorting": [
{ "direction": "Descending", "name": "Cost" }
]
}
}{
"type": "AmortizedCost",
"timeframe": "TheLastMonth",
"dataset": {
"granularity": "None",
"aggregation": {
"totalCost": { "name": "Cost", "function": "Sum" }
},
"grouping": [
{ "type": "Dimension", "name": "BenefitName" }
],
"sorting": [
{ "direction": "Descending", "name": "Cost" }
]
}
}💡 Tip:
AmortizedCostspreads reservation purchases across the term for accurate daily/monthly effective cost.
{
"type": "ActualCost",
"timeframe": "MonthToDate",
"dataset": {
"granularity": "None",
"aggregation": {
"totalCost": { "name": "Cost", "function": "Sum" }
},
"grouping": [
{ "type": "Dimension", "name": "ResourceId" }
],
"sorting": [
{ "direction": "Descending", "name": "Cost" }
]
}
}💡 Tip: Append
&$top=10to the URL to limit results:...query?api-version=2023-11-01&$top=10