Athena query to know a EC2 instances cost

0

Hi:

  I'm trying to get the total costs of 2 EC2 instances but getting the detail of each amount that contributs to the total, I mean how much was for storage, for network usage and for compute usage.

Do you know how I can get it?

Thanks! BR

AWS
質問済み 3ヶ月前1396ビュー
2回答
1

You can use lineItem/ResourceId to query anything that has the instance ID in it. But it won't give you the EBS volume. You would have to also query the specific EBS Volume ID. The best way to get the total cost associated with an EC2 instance is to use cost allocation tag. Without the tag, you would have to use the instance ID and the volume ID (that is attached to the instance) to query separately.

profile pictureAWS
エキスパート
回答済み 3ヶ月前
0

If you are okay to use Athena + CUR , then here's a query that you might want to try:

line_item_resource_id, bill_payer_account_id, bill_billing_period_start_date, line_item_usage_account_id, DATE_FORMAT(line_item_usage_start_date,'%Y-%m') AS month_line_item_usage_start_date, savings_plan_savings_plan_a_r_n, line_item_product_code, line_item_usage_type, SUM(line_item_usage_amount) AS sum_line_item_usage_amount, line_item_line_item_description, pricing_public_on_demand_rate, SUM(pricing_public_on_demand_cost) AS sum_pricing_public_on_demand_cost, savings_plan_savings_plan_rate, SUM(savings_plan_savings_plan_effective_cost) AS sum_savings_plan_savings_plan_effective_cost FROM "<CUR_DB>" WHERE year='<YEAR>' AND month='<MONTH>' AND line_item_resource_id='<Instance-Id>' AND line_item_line_item_type LIKE 'SavingsPlanCoveredUsage' GROUP BY line_item_resource_id, bill_payer_account_id, bill_billing_period_start_date, line_item_usage_account_id, DATE_FORMAT(line_item_usage_start_date,'%Y-%m'), savings_plan_savings_plan_a_r_n, line_item_product_code, line_item_usage_type, line_item_unblended_rate, line_item_line_item_description, pricing_public_on_demand_rate, savings_plan_savings_plan_rate ORDER BY sum_pricing_public_on_demand_cost DESC;

AWS
回答済み 2ヶ月前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ