Table of Contents

The AWS Cost and Usage Report (CUR) is the most detailed and comprehensive source for AWS cost and usage data. CUR provides insights into every aspect of resource utilization and the corresponding charges across different AWS services. However, accessing and analyzing the large volume of CUR data can be challenging when stored in an Amazon S3 bucket as a raw file.

By integrating CUR with Amazon Athena, you can easily query this data using standard SQL without setting up any infrastructure. Athena allows you to interactively explore and gain insights into your AWS costs and usage, making the AWS cost analysis process much more convenient and accessible.


What is the AWS Cost and Usage Report (CUR)?

The AWS Cost and Usage Report (CUR) is the most comprehensive billing data source in AWS. It provides detailed information on your cloud usage, including line-item-level data for every service used, resource consumed, and corresponding costs. This detailed granularity helps organizations break down expenses by various dimensions such as service type, region, and tags.

The CUR is delivered in a format optimized for analytics, and it’s typically stored in an Amazon Simple Storage Service (S3) bucket. This raw data, while rich in detail, requires processing to transform it into actionable insights.

AWS CUR console, Cost and Usage report, cost allocation tags, data analysis
Source: AWS

What is AWS Athena?

AWS Athena is an interactive query service that allows us to analyze data directly in Amazon S3 using standard SQL. As a serverless solution, Athena provides high scalability and cost-effectiveness, allowing organizations to perform queries on large datasets without needing to manage complex infrastructure.

aws athena, how amazon athena works, integrate aws cur with amazon athena
Source: AWS

By utilizing Athena to query the AWS CUR, users can analyze their cloud spending patterns, identify cost-saving opportunities, and make data-driven decisions with minimal overhead. The Athena-CUR integration, therefore, empowers companies to have deeper cost visibility into their cloud infrastructure and aids in better cloud cost management.


Setting Up CUR for AWS Athena Integration

Step 1: Enabling the Cost and Usage Report

  • Access Billing Console
    To set up CUR, navigate to the AWS Billing and Cost Management console. Locate the “Cost and Usage Reports” section under the “Billing” menu.
  • Create a Cost and Usage Report
    Click on “Create report.” Provide a name for the report, e.g., “AthenaCUR.” Make sure to select the following options:
    • Include resource IDs for more granular details.
    • Choose Amazon S3 as the delivery destination.
  • Set Delivery Preferences
    Select or create an S3 bucket to store your CUR data. It is recommended to use a bucket dedicated solely for CUR data to avoid confusion and facilitate better management of storage costs.
  • Data Format and Report Granularity
    Choose the report format as “Apache Parquet” for optimized querying. Also, select “Daily” report granularity for the most up-to-date insights.
  • IAM Permissions
    Grant the appropriate permissions to the S3 bucket to allow AWS CUR to deliver data. AWS provides a policy template to simplify this process.

Step 2: Preparing Athena to Query CUR Data

  • Define the Athena Database and Table
    Access the AWS Athena console and create a database where CUR tables will be stored. In the Query Editor, execute the following SQL statement to create a database:
  • Set Up the S3 Bucket Structure
    Athena needs a properly formatted S3 bucket to perform queries. CUR delivers data in a nested folder structure (/year/month/day/) for each report. Ensure the bucket follows this structure without modifications.
CREATE DATABASE IF NOT EXISTS cost_usage_reports;
  • Next, define the table schema to reflect the structure of the CUR data. A sample SQL statement is provided by AWS when you enable CUR, which you can execute in the Athena console. Update the S3 location in the SQL statement to match the bucket where CUR data is stored.

Step 3: Running Queries on CUR with Athena

With the CUR data set up in Athena, you can now run SQL queries to extract insights.

  • Total Monthly Costs by Service
    To get a breakdown of monthly costs by service, use the following query:
SELECT
line_item_product_code AS service,
SUM(line_item_blended_cost) AS total_cost
FROM
cost_usage_reports.athenacur
WHERE
year = '2024' AND month = '09'
GROUP BY
line_item_product_code
ORDER BY
total_cost DESC;

Identify Unused Resources
This query helps to identify resources with zero usage to locate wasteful expenditures:

SELECT
line_item_resource_id AS resource,
SUM(line_item_usage_amount) AS usage_amount
FROM
cost_usage_reports.athenacur
WHERE
line_item_usage_amount = 0
GROUP BY
line_item_resource_id
ORDER BY
usage_amount ASC;

Advanced Use Cases for CUR and Athena Integration

AWS Athena and the Cost and Usage Report (CUR) offer powerful capabilities for deep cost analysis, cost optimization, and efficient resource utilization. Beyond basic cost monitoring, there are numerous advanced use cases that uses Athena’s interactive query capabilities that help to implement automation for resource management, and proactively manage cloud costs.

1. Cost Attribution by Business Unit or Project

One advanced use case of CUR and Athena is attributing cloud costs to individual projects or teams within an organization. By analyzing the resource tags defined in AWS, organizations can accurately calculate which departments or projects are responsible for specific costs.

  • Use Athena queries to break down costs by specific tags, such as department, project_id, or environment. This helps attribute expenses to the right cost centers and aids in financial planning.
  • Athena can be used to create custom rules for allocating shared costs like network or data storage across multiple teams or projects. By setting up predefined allocation ratios, the query can distribute shared costs proportionally based on usage or team size.

2. Identifying Cost Anomalies and Root Cause Analysis

Cost anomalies are unexpected spikes or dips in cloud expenses, often indicating potential misconfigurations, misuse, or unplanned changes in resource usage.

  • CUR and Athena can be used to detect these cost anomalies and perform a root cause analysis by using SQL queries to compare current costs against historical baselines. By calculating averages and standard deviations for each service, you can set thresholds that indicate unusual spending patterns.
  • Once an anomaly is detected, you can further analyze which accounts, regions, or resource types are contributing to the spike. This involves drilling down into CUR data using filters to understand the cause of the unusual cost patterns, such as unexpected usage in a particular region or an unplanned resource scaling event.

3. Forecasting Cloud Costs Using Trend Analysis

AWS CUR provides rich historical data, which can be leveraged to forecast future cloud expenses. Athena’s ability to perform complex time-series analysis helps in predicting future spending trends.

  • Analyzing historical CUR data can reveal seasonal patterns in cloud spending, such as increased activity during certain times of the year. For instance, e-commerce platforms may experience spikes in costs during holiday seasons, while businesses in specific industries may notice regular cost changes around quarterly reports or project deadlines.

4. Provide Targeted Reports for Different Teams

Different teams within an organization need customized views of cost data that are relevant to them. Using Athena, you can create custom reports and dashboards.

  • You can segment cost data by department, team, or environment. For instance, create separate dashboards for the development and operations teams, showing only the services and resources they are responsible for.
  • Use environment tags (e.g., production, staging, development) in Athena to create dashboards that show costs incurred in different environments. This helps engineering and finance teams distinguish between experimental projects and critical production workloads.

5. Cost Optimization by Tagging

Proper tagging helps in isolating costs for specific projects, teams, or environments. AWS offers extensive capabilities to categorize and allocate cloud resources using tags. Using Athena, you can group spending by tags to identify which teams are responsible for the most significant expenses.

  • AWS tags are metadata that provide additional information about AWS resources, such as department, project, environment, or owner. For example, by tagging all resources associated with a specific project, you can easily determine the total cost incurred by that project.
  • Using tags to categorize resources helps identify underutilized or unused resources that could be optimized or decommissioned to reduce costs.

Best Practices for CUR and Athena Integration

Integrating AWS Athena with the AWS Cost and Usage Report (CUR) offers a powerful way to analyze your cloud expenditures and discover opportunities for optimization. To maximize the benefits and achieve accurate, cost-effective results, it is essential to follow certain best practices when implementing this integration.

1. Use Partitioning for Efficient Queries: Athena charges are based on the amount of data scanned. To minimize costs, partition your CUR data by year, month, and other relevant columns. This ensures that your queries only scan the required partitions, reducing processing time and costs.

2. Leverage Parquet for Optimal Performance: AWS CUR offers the option to deliver reports in Apache Parquet format. Parquet is a columnar storage format that enables faster and cheaper querying, especially for large datasets. When creating the Athena table, ensure that the format is set to Parquet for maximum efficiency.

3. Set Up Scheduled Queries for Automation: Scheduling recurring queries in Athena allows for ongoing monitoring of your cloud expenditures. Automate commonly used queries to run daily or weekly, and export the results to Amazon QuickSight or an S3 bucket for further visualization and reporting.

4. Security Considerations: Ensure the permissions to the S3 bucket storing the CUR are correctly configured. Least-privilege access should be applied, allowing only authorized services and users to access sensitive billing data.

5. Make CUR Data Actionable with Visual Analytics: By integrating AWS Athena with Amazon QuickSight, you can create interactive dashboards and reports that present your cloud spending data in a user-friendly format.


Improve Your Cost Efficiency with Economize

Managing costs with AWS CUR and Athena requires significant effort, from creating custom queries to analyzing the vast data generated. While this approach can offer detailed cost data, it often requires manual setup, ongoing management, and a deep understanding of AWS services. This method also lacks the ability to provide real-time insights without constant updates. For businesses looking for a more intuitive, hands-off solution, Economize provides a smarter, simpler, and more efficient way to monitor, manage, and optimize cloud spending.

Economize not only eliminates the complexities of manual reporting but also provides a centralized platform to monitor your cloud spending in real-time, offering a seamless experience right out of the box. Here’s how:

Comprehensive Organization-Wide Insights:

  • Organization View provides a clear breakdown of spending across different teams, projects, or departments. It enables granular visibility into resource usage, which is often difficult to achieve with CUR and Athena without custom queries.

Incident Reports & Real-Time Alerts:

  • With Economize, you get real-time alerts for any unexpected cost spikes or anomalies in your AWS spending. It also offers incident reports that explain the causes of these spikes, enabling you to take proactive measures and avoid budget overruns.

Smart Cost-Saving Suggestions:

  • Economize uses intelligent algorithms to provide personalized recommendations for cost optimization. These smart suggestions identify underutilized resources, suggest ways to optimize your usage, and help reduce unnecessary expenses without needing manual input or deep knowledge of AWS services.

Root Cause Analysis:

  • One of the standout features of Economize is its Root Cause Analysis tool, which automatically identifies the source of cost anomalies. Whether it’s a misconfigured resource or a sudden usage spike, this feature helps you quickly resolve issues that could otherwise go unnoticed with AWS CUR and Athena.

Customizable Dashboards & Reports:

  • Get tailored reports and dashboards that are built for your specific business needs. With Economize, you can create custom views to monitor your costs in ways that make sense for your organization, something that would require extensive manual configuration with AWS CUR and Athena.

Seamless Integration with Other Tools:

  • Economize integrates easily with popular tools like Slack and Datadog, enabling automated notifications and monitoring without switching platforms. This integration is especially useful for teams already using these tools for operational monitoring and collaboration.

Conclusion

Integrating AWS Athena with the Cost and Usage Report is a powerful strategy for gaining visibility into cloud expenditures. By leveraging the scalability and flexibility of Athena, organizations can transform raw CUR data into actionable insights and easily detect cost spikes and cost anomalies to drive cost optimization. From tracking monthly spending patterns to identifying underutilized resources, the combination of CUR and Athena provides an unparalleled approach to cloud cost management.

On the other hand, Economize offers a comprehensive and automated approach to AWS cost management. With features like auto-taggingroot cause analysissmart suggestions, and real-time monitoring, Economize allows businesses to gain better control over their cloud spending while saving both time and resources.


FAQs

Q: How do I find out how much I spent on AWS?
A: You can track and analyze your AWS spending using the AWS Billing and Cost Management Dashboard or AWS Cost Explorer. For more granular cost analysis and improved cloud cost management, consider using cloud cost optimization tools like Economize.

Q: What is the Athena query cost?
A: Amazon Athena charges based on the amount of data scanned per query, at $5 per terabyte scanned.

Q: What is the difference between S3 and Athena?
A: Amazon S3 is a storage service for data, while Amazon Athena is a query service that allows you to run SQL queries on data stored in S3.

Q: Is AWS Athena a data warehouse?
A: No, AWS Athena is a serverless interactive query service, not a data warehouse; it allows querying data directly from Amazon S3.

Q: Which AWS service can be used to store AWS Cost and Usage Report files?
A: Amazon S3 is the primary service for storing AWS Cost and Usage Report (CUR) files, and AWS does not offer an alternative service specifically for storing CUR files directly. However, you can transfer or export data to other storage or database services like Amazon Redshift for further analysis.


Looking to Optimize your Cloud Costs?

Ready to transform your cloud economics? Don’t let runaway costs hold your business back. With Economize, you can effortlessly slash your cloud expenditures by up to 30%. Book a free demo with us today and discover how we can help you start saving in as little as 10 minutes.

Heera Ravindran

Content Marketer at Economize. An avid writer and a zealous reader who specializes in technical content and has a passion for all things Cloud and FinOps.

Related Articles

How to Use Azure Tags: Best Practices for Cost Management

How to Use Azure Tags: Best Practices for Cost Management

10 Best Azure Kubernetes Cost Optimization Strategies,

10 Best Azure Kubernetes Cost Optimization Strategies

AKS Costs Explained: Pricing Models & Best Practices

AKS Costs Explained: Pricing Models & Best Practices