- Newest
- Most votes
- Most comments
I guess you are looking for cost per instance type under reserved instance and I assume you only need EC2. The easiest way is to use excel/quicksight pivot table and group by month/day. It allows you to group by reserved option. You can also easily get the weekly by week function excel or quicksight
Alternatively, if you wish to do this in CUR query, you can sacrifice displaying the reservation id and filter by DiscountedUsage or the line_item_line_item_type you defined like what Nataliya mentioned. Here is an example query and you should get the item group by instance type per region per day within Sep 1 to Oct 1. You can modify the grouping of query by taking away some filters.
SELECT
bill_payer_account_id,
line_item_usage_account_id,
DATE_FORMAT((line_item_usage_start_date),'%Y-%m-%d') AS day_line_item_usage_start_date,
CASE
WHEN line_item_line_item_type IN ('Usage') THEN 'OnDemand'
WHEN line_item_line_item_type IN ('Fee','RIFee','DiscountedUsage') THEN 'ReservedInstance'
END AS case_purchase_option,
SPLIT_PART(line_item_usage_type ,':',2) AS split_line_item_usage_type_instance_type,
SPLIT_PART(SPLIT_PART(line_item_usage_type ,':',2), '.', 1) AS split_line_item_usage_type_instance_family,
CASE product_region
WHEN NULL THEN 'Global'
WHEN '' THEN 'Global'
ELSE product_region
END AS case_product_region,
line_item_line_item_type,
SUM(TRY_CAST(line_item_usage_amount AS DOUBLE)) AS sum_line_item_usage_amount,
SUM(TRY_CAST(reservation_unused_quantity AS DOUBLE)) AS sum_reservation_unused_quantity,
SUM(TRY_CAST(line_item_normalized_usage_amount AS DOUBLE)) AS sum_line_item_normalized_usage_amount,
SUM(TRY_CAST(reservation_unused_normalized_unit_quantity AS DOUBLE)) AS sum_reservation_unused_normalized_unit_quantity,
SUM(CAST(reservation_effective_cost AS DECIMAL(16,8))) AS sum_reservation_effective_cost,
SUM(CAST(line_item_unblended_cost AS DECIMAL(16,8))) AS sum_line_item_unblended_cost
FROM
customer_all
WHERE
line_item_usage_start_date BETWEEN FROM_ISO8601_TIMESTAMP('2023-09-01T00:00:00') AND FROM_ISO8601_TIMESTAMP('2023-10-01T00:00:00')
AND product_product_name = 'Amazon Elastic Compute Cloud'
AND line_item_operation LIKE '%RunInstance%'
AND line_item_line_item_type IN ('Usage','Fee','RIFee','DiscountedUsage')
AND product_product_family NOT IN ('Data Transfer')
GROUP BY
bill_payer_account_id,
line_item_usage_account_id,
DATE_FORMAT((line_item_usage_start_date),'%Y-%m-%d'),
4, -- refers to case_purchase_option
SPLIT_PART(line_item_usage_type ,':',2),
SPLIT_PART(SPLIT_PART(line_item_usage_type ,':',2), '.', 1),
7, -- refers to case_product_region
line_item_line_item_type
ORDER BY
day_line_item_usage_start_date,
split_line_item_usage_type_instance_type,
sum_line_item_unblended_cost DESC;
You are able to get the example query from the below link. From the example above, it should give you the excel that you generated.
Could you share the SQL query you are using to pull this data from CUR? I feel like you're mixing the recurring cost for the Reserved Instance itself, with the cost for the running EC2 instances...
WHERE line_item_line_item_type = 'DiscountedUsage'
is the right filter to use if you want to find instances covered by RIs. However, in line items where you have DiscountedUsage, your Unblended Cost should be $0; which is why I'm surprised to see some values in the unblended cost column (and suspect this must be the cost for the actual RI - reservation ARN)
Thanks Nataliya. Appreciate your quick help. Sorry for delayed response. Yes, I am using the filer
WHERE line_item_line_item_type = 'DiscountedUsage'
and considering the unblended hourly rate for corresponding reservation ARN fromline_item_line_item_type = RIFee
. This gives me a complete breakdown of charges included under RIFee.
Relevant content
- Accepted Answerasked 7 months ago
- asked 2 months ago
- Accepted Answerasked 8 months ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 2 years ago
Thanks so much. Appreciate your help and sorry for the delayed response. Yes, my query looks prety much the same and I am using the filer
WHERE line_item_line_item_type = 'DiscountedUsage'
and considering the unblended hourly rate for corresponding reservation ARN fromline_item_line_item_type = RIFee
. This gives me a complete breakdown of charges included under RIFee.