Skip to content

Costs appears to be excluding of Publisher account costs #30

@thetombombadil

Description

@thetombombadil

Hi again!

From my experimentation it appears that when using a centralised account (as the publisher) with linked accounts, the central account(publisher) costs aren't included by aws-cost-explorer. This is desirable for us as we have a single billing account which has linked costs from all our child accounts, so we can access our aws costs for all accounts in one place.

Tested using Unblendedcost& opensourceelectrolux/aws-cost-exporter:v1.0.10.

From /metrics:

# HELP aws_daily_cost_usd Daily cost of an AWS account in USD
# TYPE aws_daily_cost_usd gauge
aws_daily_cost_usd{ChargeType="Usage",Publisher=<root-account-id-goes-here>} 1958.44886696

Metrics portion of config:

metrics:
  - metric_name: aws_daily_cost_usd
    group_by:
      enabled: false
    metric_type: UnblendedCost

Roughly equivalent aws-cli command from what I can gather, with root profile being the publisher account:

aws ce get-cost-and-usage --time-period '{"Start": "2025-03-13", "End": "2025-03-14"}' --granularity DAILY --metrics UnblendedCost --profile root --output text
RESULTSBYTIME   True
TIMEPERIOD      2025-03-14      2025-03-13
UNBLENDEDCOST   2864.44886696   USD

As you can see, 1958.44886696 != 2864.44886696.

So I experimented with filtering out the root account (which is the publisher), which brings the awscli result within $1 of the metric reported by cost explorer. It's not quite lined up, but it's much closer.

aws ce get-cost-and-usage --time-period '{"Start": "2025-03-13", "End": "2025-03-14"}' --granularity DAILY --metrics UnblendedCost --profile root --output text --filter '{"Not": {"Dimensions": {"Key": "LINKED_ACCOUNT", "Values": ["root-account-id-goes-here"]}}}'
RESULTSBYTIME   True
TIMEPERIOD      2025-03-14      2025-03-13
UNBLENDEDCOST   1957.7170637458 USD

I can also confirm I can't see the AccountName="<root-account-id-goes-here>" label for any of the aws_daily_cost_by_region_by_account metrics under /metrics, which adds weight that the publisher account metrics aren't being included. Using the following config:

  - metric_name: aws_daily_cost_by_region_by_account
    group_by:
      enabled: true
      groups:
        - type: DIMENSION
          key: REGION
          label_name: Region
        - type: DIMENSION
          key: LINKED_ACCOUNT
          label_name: AccountName
      merge_minor_cost:
        enabled: true
        threshold: 10
        tag_value: Other
    metric_type: UnblendedCost

Strangely I could see the AccountName="<root-account-id-goes-here>" label for the aws_daily_cost_by_service_by_account metric however, using this config:

  - metric_name: aws_daily_cost_by_service_by_account
    group_by:
      enabled: true
      groups:
        - type: DIMENSION
          key: SERVICE
          label_name: ServiceName
        - type: DIMENSION
          key: LINKED_ACCOUNT
          label_name: AccountName
      merge_minor_cost:
        enabled: false
        threshold: 10
        tag_value: Other
    metric_type: UnblendedCost

Appreciate your time, thanks again!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions