首页 > 解决方案 > 未在 AWS boto3 costExplorer get_cost_and_usage() 函数中获取总成本

问题描述

我正在使用以下请求调用 boto3 get_cost_and_usage 函数来获取按服务和“名称”标签分组的每日成本:

result = client.get_cost_and_usage(
    TimePeriod = {
        'Start': '2020-10-31',
        'End': '2020-11-02'
    },
    Granularity = 'DAILY',
    Metrics = ["BlendedCost"],
    GroupBy = [
        {
            'Type': 'DIMENSION',
            'Key': 'SERVICE'
        },
        {
            'Type': 'TAG',
            'Key': 'Name'
        }
    ]
)

在响应中,我得到了每天每项服务和名称标签的所有费用,但是每天的总费用为空 [ "Total": {} ]:

"ResultsByTime": [
    {
        "Estimated": true,
        "Groups": [
            {
             ...
            }
        "TimePeriod": {
            "End": "2020-11-01",
            "Start": "2020-10-31"
        },
        "Total": {}
    },
    ...
]

请告诉我这里有什么问题吗?我还尝试在 Metrics 中使用“UnblendedCost”、“AmortizedCost”并仅按服务分组,但这是同样的问题,即总成本不会到来。

请在这里帮助我。

标签: amazon-web-servicesboto3cost-management

解决方案


推荐阅读