CUR query for using split cost allocation data

0

Hi - Can you share a CUR query for how to use tags on the scad data ? I have all my resources tagged using Cost Allocation Tags, and I would like to see how to use my tags to report on containerized application costs . There are some queries in well architected labs on how to generate amortized costs based on data in the CUR; but nothing on scad

Sara
asked 13 days ago146 views
2 Answers
-1

Hi, Sara

This example assumes you want to filter and aggregate costs for a containerized application identified by a specific tag key-value pair, such as App:ContainerizedApp.

SELECT
    line_item_usage_start_date,
    line_item_usage_end_date,
    product_product_name,
    SUM(line_item_blended_cost) AS total_cost
FROM
    your_cur_table_name
WHERE
    tags['App'] = 'ContainerizedApp'
GROUP BY
    line_item_usage_start_date,
    line_item_usage_end_date,
    product_product_name
ORDER BY
    line_item_usage_start_date;

ℹ️ The example I provided is a SQL query that is specifically designed for use with Amazon Athena. SQL is the language used, and Athena is the service that allows you to run these SQL queries against data stored in Amazon S3, such as your AWS Cost and Usage Reports (CUR).

Notes

  • Make sure that the tag keys and values are correctly mentioned in the query.
  • This query provides costs aggregated by service (product name) and by each billing period. You can customize it further to include other dimensions such as regions, specific services, etc.

💡 If you require a more detailed or customized breakdown, such as by specific resource IDs or more granular tagging, you would need to adjust the query accordingly.


Additional source:

profile picture
EXPERT
answered 13 days ago
  • Hi - Thanks for the response. However, when I enable "split cost allocation data", the 'blended cost' corresponding to my containers seems to be not populated in the CUR. So, could this work?

  • Instead, consider using line_item_unblended_cost or line_item_amortized_cost in your queries to accurately reflect your containerized application costs. Line item details

    Could you please confirm if this meets your needs?

  • @Osvaldo - Thank you for the pointers. Let me explain a bit more about my setup. I have a few ec2 instances that are running my container platform. These instances host the webservers for multiple applications. (lets say I have 2 apps App1 and App2 - then these ec2 instances host the web server containers ). Additionally, each of these apps have their own DB servers and other resources . The resources that are dedicated to the apps, are tagged with the application name (example Application: app1 ; Application:app2). Similarly, I have also tagged the container tasks . So what I want to do is get the cost of App1 and App2. How do I do that ? I need to be able to add the costs of the dedicated resources, to the container task costs.

    As I see, the container task costs generated by "Split Cost Allocation Data" only contain Amortized & Net Amortized costs. But the other dedicated resources do not have any Amortized & Net Amortized costs.

    If I have to use Unblended costs, I am seeing that only dedicated resources have the unblended costs, and the container cost CUR lines, do not have the unblended costs.

    So, I am really unsure on how to get the costs per application using my cost allocation tag (Application)

  • Hi @Sara, I'll revise my previous response based on this new information.

  • Thank you! Nataliya shared a sample of the CUR data sample when 'Split Cost Allocation Data' has been enabled , to view the container costs, in this link : https://aws.amazon.com/blogs/aws-cloud-financial-management/improve-cost-visibility-of-amazon-eks-with-aws-split-cost-allocation-data/

    The sample in this published writeup, can be used as a reference. Let us say that i2345 in that example is a single host that is running the webserver containers. The cost of that host has been split into pods 1-4. Let us assume that pods 1,2 belong to my application:app1 and pods 3,4 belong to application:app2.

    As I had mentioned previously, we can assume that app1 and app2 also have some dedicated resources to run the app-server and database-servers. So I need to be able to add the costs of pods <1,2> with the other costs associated with the dedicated resources app1 uses. What costs should I use for this? what is the CUR query I need to construct for this ?

-1

Check out some sample queries from this workshop content - https://catalog.us-east-1.prod.workshops.aws/workshops/bbc63046-2f56-4d59-917b-d5ebc63bdcee/en-US/ecs-split-cost-allocation/query-ecs-data-in-cur

This was a workshop we ran at re:Invent - note that it's intended to be delivered at an AWS-hosted event, which is why at the beginning of the content it talks about the access to temporary accounts... You can skip the labs related to tagging and basic CUR setup (it seems like you have your tagging sorted, and your cost allocation tags are activated and available in CUR already).

Go to the Lab 3 that talks about SCAD for ECS. It talks a bit more about the requirements and how to query SCAD columns. Note that this one only talks about ECS, but as you might have heard, we've just launched the same for EKS - https://aws.amazon.com/blogs/aws-cloud-financial-management/improve-cost-visibility-of-amazon-eks-with-aws-split-cost-allocation-data/ - so you can use similar queries.

Additionally, you can find information about SCAD line items and some explanation about them on the CUR documentation - https://docs.aws.amazon.com/cur/latest/userguide/split-line-item-columns.html

profile pictureAWS
EXPERT
answered 12 days ago
  • And back to your question about using line_item_unblended_cost or line_item_blended_cost or the amortized (effective) cost... when querying SCAD line items, you indeed may not have any values in the unblended or blended cost columns, but that's because that cost is now reflected in the SCAD columns (unblended or amortized).

  • Further clarifications on my questions. This is my setup: (1) a cluster of 5 ec2 instances running my container platform. All the web server containers are run on this cluster. So this cluster is shared by all apps . Web server container tasks are tagged as either applications:app1 or applications:app2) (2) a cluster for my app1 resources ( app server , db server , and other resources dedicated to app1. All resources here are tagged applications:app1 (3) a cluster for my app2 dedicated resources . All resources here are tagged applications:app2

    With this setup , what’s the cur query I can write for reporting cost of applications:app1, for let’s say unblended costs ? Also net amortized costs

    Thanks!

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions