【问题标题】:How can I get the daily costs using the AWS CLI如何使用 AWS CLI 获取每日费用
【发布时间】:2021-07-09 06:47:23
【问题描述】:

是否可以使用 AWS CLI 工具获取每日费用?

我正在寻找类似于通过 AWS Web 控制台中的 Cost Explorer 提供的信息的输出。我需要一种简单的方法来快速查看我的 AWS 账户中过去几天的费用。

【问题讨论】:

    标签: amazon-web-services command-line-interface cost-management


    【解决方案1】:

    可以使用aws ce子命令获取最近几天的日常开支:

    aws ce get-cost-and-usage \
     --time-period Start=$(date +"%Y-%m-%d" --date="-240 hours"),End=$(date +"%Y-%m-%d") \
     --granularity=DAILY \
     --metrics BlendedCost \
     --query "ResultsByTime[].[TimePeriod.Start, Total.BlendedCost.[Amount][0], Total.BlendedCost.[Unit][0]]" \
     --output text
    

    输出:

    2021-07-11  1.9959926052    USD
    2021-07-12  2.0098551581    USD
    2021-07-13  1.9654925302    USD
    2021-07-14  1.9829672821    USD
    2021-07-15  1.996039161     USD
    2021-07-16  2.0303596042    USD
    2021-07-17  2.0193637439    USD
    2021-07-18  2.0282529061    USD
    2021-07-19  3.1817841617    USD
    2021-07-20  5.0995626964    USD
    

    【讨论】:

      猜你喜欢
      • 2018-09-22
      • 2016-12-08
      • 2020-02-14
      • 1970-01-01
      • 2019-05-19
      • 2016-01-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多