Skip to content

Split cost allocation data shows 0 values if a task runs beyond the top of an hour

1

We are using ECS split cost allocation data to track task-level costs for ECS tasks (launched by Batch).

If the start and end time of a task span the top of an hour (for example if a task starts at 11:55 and finishes at 12:05) the task is recorded as two lines in the cost and usage report and the second line doesn't include any split cost allocation data (when it should probably include the split cost usage between 12:00 and 12:05).

We aggregate cost data from all tasks, grouped by customer, and this missing data is causing a discrepancy between the information we can query from cost and usage reports and our actual bill.

Here is a redacted example of lines from the cost and usage report showing that a single task is split across two lines, one of which is missing data.

identity_line_item_id,identity_time_interval,bill_invoice_id,bill_invoicing_entity,bill_billing_entity,bill_bill_type,bill_payer_account_id,bill_billing_period_start_date,bill_billing_period_end_date,line_item_usage_account_id,line_item_line_item_type,line_item_usage_start_date,line_item_usage_end_date,line_item_product_code,line_item_usage_type,line_item_operation,line_item_availability_zone,line_item_resource_id,line_item_usage_amount,line_item_normalization_factor,line_item_normalized_usage_amount,line_item_currency_code,line_item_unblended_rate,line_item_unblended_cost,line_item_blended_rate,line_item_blended_cost,line_item_line_item_description,line_item_tax_type,line_item_legal_entity,product_product_name,product_datatransferout,product_description,product_instance_type,product_location,product_location_type,product_platostoragetype,product_product_family,product_region,product_region_code,product_routing_target,product_routing_type,product_servicecode,product_servicename,product_sku,product_storage,product_storage_type,product_usagetype,pricing_rate_code,pricing_rate_id,pricing_currency,pricing_public_on_demand_cost,pricing_public_on_demand_rate,pricing_term,pricing_unit,reservation_amortized_upfront_cost_for_usage,reservation_amortized_upfront_fee_for_billing_period,reservation_effective_cost,reservation_end_time,reservation_modification_status,reservation_normalized_units_per_reservation,reservation_number_of_reservations,reservation_recurring_fee_for_usage,reservation_start_time,reservation_subscription_id,reservation_total_reserved_normalized_units,reservation_total_reserved_units,reservation_units_per_reservation,reservation_unused_amortized_upfront_fee_for_billing_period,reservation_unused_normalized_unit_quantity,reservation_unused_quantity,reservation_unused_recurring_fee,reservation_upfront_value,savings_plan_total_commitment_to_date,savings_plan_savings_plan_a_r_n,savings_plan_savings_plan_rate,savings_plan_used_commitment,savings_plan_savings_plan_effective_cost,savings_plan_amortized_upfront_commitment_for_billing_period,savings_plan_recurring_commitment_for_billing_period,product_availability,product_durability,product_from_location,product_from_location_type,product_from_region_code,product_group,product_group_description,product_logs_destination,product_message_delivery_frequency,product_message_delivery_order,product_operation,product_queue_type,product_storage_class,product_storage_media,product_to_location,product_to_location_type,product_to_region_code,product_transfer_type,product_version,product_volume_type,product_with_active_users,product_size_flex,product_alarm_type,product_availability_zone,product_capacitystatus,product_classicnetworkingsupport,product_clock_speed,product_cputype,product_current_generation,product_database_engine,product_dedicated_ebs_throughput,product_deployment_option,product_ecu,product_endpoint_type,product_engine_code,product_enhanced_networking_supported,product_event_type,product_free_query_types,product_gpu,product_gpu_memory,product_instance_family,product_instance_type_family,product_intel_avx2_available,product_intel_avx_available,product_intel_turbo_available,product_invocation,product_license_model,product_marketoption,product_max_iops_burst_performance,product_max_iopsvolume,product_max_throughputvolume,product_max_volume_size,product_memory,product_memorytype,product_min_volume_size,product_network_performance,product_normalization_size_factor,product_operating_system,product_physical_processor,product_platousagetype,product_platovolumetype,product_pre_installed_sw,product_processor_architecture,product_processor_features,product_request_count,product_request_description,product_request_duration,product_request_type,product_tenancy,product_time_window,product_type,product_type_description,product_vcpu,product_volume_api_name,product_vpcnetworkingsupport,split_line_item_parent_resource_id,split_line_item_reserved_usage,split_line_item_actual_usage,split_line_item_split_usage,split_line_item_split_usage_ratio,split_line_item_split_cost,split_line_item_unused_cost,split_line_item_public_on_demand_split_cost,split_line_item_public_on_demand_unused_cost,product_product_type,product_fee_code,product_fee_description,product_instance,product_abd_instance_class,product_access_type,product_content_type,product_equivalentondemandsku,product_origin,product_pricingplan,product_provider,product_provisioned,product_recipient,product_subservice,product_tiertype,resource_tags_user_environment,product_steps,product_cloudformationresource_provider,year,month
htie7hnpkw33lytqljnf26ofnjak55mexgavyvpbkn2flfdg27da,2024-10-01T00:00:00Z/2024-10-01T01:00:00Z,,"Amazon Web Services, Inc.",AWS,Anniversary,,2024-10-01 0:00:00,2024-11-01 0:00:00,,Usage,2024-10-01 0:00:00,2024-10-01 1:00:00,AmazonECS,USE1-ECS-EC2-GB-Hours,ECSTask-EC2,,,1.997288889,0,0,USD,0,0,0,0,USD 0.0 per GB-Hours for ECS-EC2-GB-Hours in US East (N. Virginia),,"Amazon Web Services, Inc.",Amazon Elastic Container Service,,,,US East (N. Virginia),AWS Region,,Compute Metering,us-east-1,us-east-1,,,AmazonECS,Amazon Elastic Container Service,74HXSAMY4YHFPXQQ,,,USE1-ECS-EC2-GB-Hours,74HXSAMY4YHFPXQQ.JRTCKXETXF.6YS6EN2CT7,95213016959,USD,0,0,OnDemand,GB-Hours,0,0,0,,,,,0,,,,,,0,0,0,0,0,0,,0,0,0,0,0,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,perGB,,,,,,,,,,,,,,,,,,,,,,i-0507c34b242af5f43,1.997288889,0.001783045411,1.997288889,0.02634172888,0.007681880342,0.09055728219,0.007681880342,0.09055728219,,,,,,,,,,,,,,,,,,,2024,10
qv2vfzk4jb5twbw35ip6fwij7cbg2g6lwwevbeu533eywzzgiamq,2024-10-01T00:00:00Z/2024-10-01T01:00:00Z,,"Amazon Web Services, Inc.",AWS,Anniversary,,2024-10-01 0:00:00,2024-11-01 0:00:00,,Usage,2024-10-01 0:00:00,2024-10-01 1:00:00,AmazonECS,USE1-ECS-EC2-vCPU-Hours,ECSTask-EC2,,,1.497966667,0,0,USD,0,0,0,0,USD 0.0 per vCPU-Hours for ECS-EC2-vCPU-Hours in US East (N. Virginia),,"Amazon Web Services, Inc.",Amazon Elastic Container Service,,,,US East (N. Virginia),AWS Region,,Compute Metering,us-east-1,us-east-1,,,AmazonECS,Amazon Elastic Container Service,DQ8NT47B7YY2CGC5,,,USE1-ECS-EC2-vCPU-Hours,DQ8NT47B7YY2CGC5.JRTCKXETXF.6YS6EN2CT7,95213016850,USD,0,0,OnDemand,vCPU-Hours,0,0,0,,,,,0,,,,,,0,0,0,0,0,0,,0,0,0,0,0,,,,,,,,,,,,,,,,,,,,,,,,,,,,perCPU,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,i-0507c34b242af5f43,1.497966667,1.83E-04,1.497966667,0.07902518663,0.05185269231,0.1691854234,0.05185269231,0.1691854234,,,,,,,,,,,,,,,,,,,2024,10
htie7hnpkw33lytqljnf26ofnjak55mexgavyvpbkn2flfdg27da,2024-10-01T01:00:00Z/2024-10-01T02:00:00Z,,"Amazon Web Services, Inc.",AWS,Anniversary,,2024-10-01 0:00:00,2024-11-01 0:00:00,,Usage,2024-10-01 1:00:00,2024-10-01 2:00:00,AmazonECS,USE1-ECS-EC2-GB-Hours,ECSTask-EC2,,,0.1404888889,0,0,USD,0,0,0,0,USD 0.0 per GB-Hours for ECS-EC2-GB-Hours in US East (N. Virginia),,"Amazon Web Services, Inc.",Amazon Elastic Container Service,,,,US East (N. Virginia),AWS Region,,Compute Metering,us-east-1,us-east-1,,,AmazonECS,Amazon Elastic Container Service,74HXSAMY4YHFPXQQ,,,USE1-ECS-EC2-GB-Hours,74HXSAMY4YHFPXQQ.JRTCKXETXF.6YS6EN2CT7,95213016959,USD,0,0,OnDemand,GB-Hours,0,0,0,,,,,0,,,,,,0,0,0,0,0,0,,0,0,0,0,0,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,perGB,,,,,,,,,,,,,,,,,,,,,,,0,0,0,0,0,0,0,0,,,,,,,,,,,,,,,,,,,2024,10
qv2vfzk4jb5twbw35ip6fwij7cbg2g6lwwevbeu533eywzzgiamq,2024-10-01T01:00:00Z/2024-10-01T02:00:00Z,,"Amazon Web Services, Inc.",AWS,Anniversary,,2024-10-01 0:00:00,2024-11-01 0:00:00,,Usage,2024-10-01 1:00:00,2024-10-01 2:00:00,AmazonECS,USE1-ECS-EC2-vCPU-Hours,ECSTask-EC2,,,0.1053666667,0,0,USD,0,0,0,0,USD 0.0 per vCPU-Hours for ECS-EC2-vCPU-Hours in US East (N. Virginia),,"Amazon Web Services, Inc.",Amazon Elastic Container Service,,,,US East (N. Virginia),AWS Region,,Compute Metering,us-east-1,us-east-1,,,AmazonECS,Amazon Elastic Container Service,DQ8NT47B7YY2CGC5,,,USE1-ECS-EC2-vCPU-Hours,DQ8NT47B7YY2CGC5.JRTCKXETXF.6YS6EN2CT7,95213016850,USD,0,0,OnDemand,vCPU-Hours,0,0,0,,,,,0,,,,,,0,0,0,0,0,0,,0,0,0,0,0,,,,,,,,,,,,,,,,,,,,,,,,,,,,perCPU,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,0,0,0,0,0,0,0,0,,,,,,,,,,,,,,,,,,,2024,10
asked a year ago96 views
1 Answer
0

Greeting

Hi Ben,

Thanks for sharing your detailed example and experience! The way you've described the issue makes it clear that you're thorough and dedicated to resolving these discrepancies. Let’s build on your observations to ensure your ECS split cost allocation data is accurate and reliable. 😊


Clarifying the Issue

You’ve noticed that when an ECS task spans the top of an hour, the Cost and Usage Report (CUR) splits the task data into two lines. While this division correctly represents usage across two hourly intervals, the second line is missing split cost allocation data for the subsequent period. This results in incomplete or missing costs (e.g., from 12:00 to 12:05 in your example).

This gap creates challenges in aggregating customer-specific costs, as the absence of split usage values leads to discrepancies between CUR data and the actual bill. Addressing this issue is essential to maintaining accurate cost attribution and transparent reporting.


Why This Matters

Precise cost allocation enables better visibility into task-level expenses, especially when attributing costs to individual customers or projects. Missing data can lead to billing discrepancies, affect profitability analysis, and create potential trust issues with stakeholders. By resolving this, you can achieve confidence in your billing systems and ensure accurate tracking of resource utilization.


Key Terms

  • ECS: Amazon Elastic Container Service, a managed service for running containerized applications.
  • Split Cost Allocation Data: Detailed cost breakdowns assigned to specific ECS tasks, instances, or resources.
  • Cost and Usage Report (CUR): A comprehensive AWS billing report containing granular data on resource usage and associated costs.
  • AWS Cost Explorer: A tool for visualizing and analyzing AWS usage and costs interactively.

The Solution (Our Recipe)

Steps at a Glance:

  1. Confirm CUR configuration for split cost allocation data.
  2. Verify ECS task metadata and resource utilization details.
  3. Implement a data cleanup or reconciliation process for missing values.
  4. Explore AWS Cost Explorer for supplementary analysis.

Step-by-Step Guide:

  1. Verify CUR Configuration
    Start by ensuring that split cost allocation is correctly enabled in the Cost and Usage Report settings. This feature needs to be activated to provide task-level cost granularity.

    • Navigate to Billing and Cost Management in the AWS Console.
    • Under Preferences, confirm that "Split Cost Allocation Data" is checked.
    • Verify that your CUR is configured to deliver reports to an S3 bucket.

    Example CLI command to retrieve CUR details:

    aws ce get-cost-and-usage \
    --time-period Start=2024-10-01,End=2024-10-02 \
    --granularity HOURLY \
    --metrics "UsageQuantity" \
    --group-by Type=TAG,Key=ECS_TaskID

  1. Check ECS Task Metadata
    Use the AWS CLI or SDK to retrieve detailed ECS task metadata and ensure all relevant fields are populated. Missing fields like startedAt or stoppedAt could result in incomplete cost allocation.

    Example CLI command:

    aws ecs describe-tasks \
    --cluster <your-cluster-name> \
    --tasks <task-id>

    Look for the following details:

    • Start and end times (startedAt, stoppedAt).
    • Resource utilization (e.g., CPU, memory).

  1. Apply Data Cleanup for Missing Values
    If gaps persist, implement a post-processing script to reconcile missing values. For instance, prorate costs for intervals with missing data based on task duration.

    Example Python script for filling missing split usage data:

    import pandas as pd
    
    # Load your CUR data
    df = pd.read_csv("cost_usage_report.csv")
    
    # Identify rows with missing split usage data
    missing_rows = df[df['split_line_item_split_usage'].isnull()]
    
    # Fill gaps by prorating usage (example logic)
    for index, row in missing_rows.iterrows():
        if row['line_item_usage_start_date'] and row['line_item_usage_end_date']:
            usage_seconds = (
                pd.to_datetime(row['line_item_usage_end_date']) -
                pd.to_datetime(row['line_item_usage_start_date'])
            ).total_seconds()
            row['split_line_item_split_usage'] = row['line_item_usage_amount'] / usage_seconds
            df.loc[index] = row
    
    # Save the updated CUR data
    df.to_csv("updated_cost_usage_report.csv", index=False)

  1. Explore AWS Cost Explorer
    Use AWS Cost Explorer to analyze usage trends and verify task-level costs. This tool provides visual insights that may help identify patterns or anomalies in split cost allocations.

    Example:

    aws ce get-cost-and-usage \
    --time-period Start=2024-10-01,End=2024-10-02 \
    --granularity HOURLY \
    --metrics "BlendedCost" "UnblendedCost" \
    --group-by Type=DIMENSION,Key=SERVICE

Closing Thoughts

Resolving this issue ensures accurate task-level cost tracking, which is essential for customer-specific billing and internal financial analysis. If AWS CUR data gaps persist despite these steps, consider raising a support case with AWS for further investigation.

For additional resources:


Farewell

I hope these steps help you resolve the discrepancies in your CUR data, Ben! If you have further questions or need deeper insights, feel free to reach out. Good luck with your ECS tasks and cost tracking. 🚀😊


Cheers,

Aaron 😊

answered 10 months ago

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.