如何按实例类型和日期获取 AWS EC2/Sagemaker 实例使用时间?

How to get AWS EC2/Sagemaker instance used time by instance type and day?

我想在 EC2 和 Sagemaker 服务中按实例类型和日期获取实例使用时间,

但在 AWSCUR 中似乎没有实例值 运行 time(hour/minute/second),

如何获取实例实际使用时间?

您可以按实例类型查看每日(如果您选择加入,甚至每小时)成本和使用情况:
aws ce get-cost-and-usage --time-period Start=2021-10-26,End=2021-10-27 --granularity DAILY --metrics "UsageQuantity" "BlendedCost" --group-by Type=DIMENSION,Key=INSTANCE_TYPE
请注意,SageMaker 实例类型名称以:ml.*

开头

要以最高分辨率查看内容,您需要生成详细的账单报告 (DBR):https://docs.aws.amazon.com/cur/latest/userguide/detailed-billing.html
它将在 S3 中生成 CSV 报告,您可以使用 SQL: https://docs.aws.amazon.com/cur/latest/userguide/cur-query-athena.html

通过 Athena 查询