我尝试使用Azure Cost Management - Query Usage API来获取给定订阅的所有成本的详细信息(某些列)。我用于请求的主体是
{
"type": "Usage",
"timeframe": " BillingMonthToDate ",
"dataset": {
"granularity": "Daily",
"configuration": {
"columns": [
"MeterCategory",
"CostInBillingCurrency",
"ResourceGroup"
]
}
}但我得到的回应是:
{
"id": "xxxx",
"name": "xxxx",
"type": "Microsoft.CostManagement/query",
"location": null,
"sku": null,
"eTag": null,
"properties": {
"nextLink": null,
"columns": [
{
"name": "UsageDate",
"type": "Number"
},
{
"name": "Currency",
"type": "String"
} ],
"rows": [
[
20201101,
"EUR"
],
[
20201102,
"EUR"
],
[
20201103,
"EUR"
],
...
]
}JSON继续列出该货币的所有日期。
当我在JSON中使用dataset.aggregation或dataset.grouping子句时,我确实在JSON中得到了返回的成本,但是我没有得到我想要的详细列信息。当然,不可能将这两个子句与dataset.columns子句结合使用。有人知道我做错了什么吗?
发布于 2020-11-11 00:14:05
我找到了一个不使用dataset.columns子句的解决方案(这可能只是一个错误的子句?)。通过根据我想要的列对数据进行分组,我还可以获得这些列值的数据:
{
"type": "Usage",
"timeframe": "BillingMonthToDate",
"dataset": {
"granularity": "Daily",
"aggregation": {
"totalCost": {
"name": "PreTaxCost",
"function": "Sum"
}
},
"grouping": [
{
"type": "Dimension",
"name": "SubscriptionName"
},
{
"type": "Dimension",
"name": "ResourceGroupName"
}
,
{
"type": "Dimension",
"name": "meterSubCategory"
}
,
{
"type": "Dimension",
"name": "MeterCategory"
}
]}
https://stackoverflow.com/questions/64769203
复制相似问题