Cost usage monthly report per instance

0

Hi AWS, I want to print the cost usage for individual server on monthly basis for a given Instance ID. I know Cost Explorer (previously known as CUR) is the best fit to do this task but unfortunately it prints it based on the Instance Type only. I was following this Stack overflow link https://stackoverflow.com/questions/63719507/how-can-i-find-out-cost-per-instance-per-month-on-aws and it recommends the use of cost-allocation tags in tandem with the Cost Explorer service to granularize the solution.

Can you please suggest if there is any other AWS service to accomplish this?

profile picture
已提問 3 個月前檢視次數 1511 次
2 個答案
2

Cost and Usage Reports (CUR) and Cost Explorer are different tools. Cost Explorer may show cost by resource/InstanceID for the last two weeks or so: https://aws.amazon.com/blogs/aws-cloud-financial-management/extended-history-and-more-granular-data-available-within-aws-cost-explorer/

CUR might be a better solution for extended timelines. This is an example athena query -

SELECT line_item_resource_id as "Instance ID",
    SUM(line_item_unblended_cost) AS Cost
FROM cost_and_usage_report
WHERE line_item_product_code = 'AmazonEC2'
    -- AND Month = 04
    -- AND Year = 2023
    AND line_item_resource_id = '${instance_id}'
profile pictureAWS
專家
David
已回答 3 個月前
profile picture
專家
已審閱 2 個月前
1

Hi Arjun, using the Cost Explorer, you can find the resource level cost for past 14 days only, provided resource-level data is enabled from the Billing & Cost Management Preferences for Cost Explorer. Once you enable it, apply the below filters on Cost Explorer to get the cost of an instance. Resource = EC2-Instances EC2-Instances = <select or type in the instance ID that you are looking for>

Better alternative is to get the compete cost and usage data from CUR using the Athena query. you can learn about CUR query using Athena from AWS Well Architected Labs. You can find the query from this repost.

profile pictureAWS
已回答 3 個月前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南