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
gefragt vor 3 Monaten1396 Aufrufe
2 Antworten
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
EXPERTE
beantwortet vor 3 Monaten
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
beantwortet vor 2 Monaten

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen