cost agent double-counted spend - it summed both the payer and the linked accounts in the consolidated bill
Fixes a FinOps agent that double-counts cloud spend by adding the payer account total to the per-account breakdown in a consolidated bill. Use it when an agent's reported spend is roughly 2x the actual invoice, or when its per-account rows already sum to the payer total. Key trigger: the agent summed both the ungrouped Cost Explorer result and the LINKED_ACCOUNT-grouped rows.
TL;DR
Query Cost Explorer once, not twice. The ungrouped payer result already includes every linked account, so adding per-account rows on top counts everything twice. Fix the script to use either the payer total or the per-account rows, never both. This happens because consolidated billing rolls linked accounts into the payer total silently, and nothing in the API response says so.
cost agent double-counted spend - it summed both the payer and the linked accounts in the consolidated billSteps
- Get the payer-level total with no grouping:
aws ce get-cost-and-usage --time-period Start=2026-09-01,End=2026-10-01 --granularity MONTHLY --metrics UnblendedCostExpected: one Total block. Write that number down; it already includes all linked accounts.
- Get the per-account breakdown:
aws ce get-cost-and-usage --time-period Start=2026-09-01,End=2026-10-01 --granularity MONTHLY --metrics UnblendedCost --group-by Type=DIMENSION,Key [your value]Expected: one row per account. Sum the Amount fields yourself; the sum equals the payer total from step 1, within rounding.
- Audit the agent's code for two queries whose results get added together. The bug is always the same shape: total equals payer total plus the per-account sum.
Expected: after the fix the script uses exactly one of the two numbers, never both.
- Cross-check against the payer invoice.
Expected: the reported total now matches the invoice within a few cents.
Use this when
- reported spend is about 2x the invoice
- per-account rows sum to the payer total
- the agent queries GetCostAndUsage twice and adds the results
- finance says the dashboard does not match the bill
Not for this skill when
- spend is under-counted or accounts are missing entirely (that is a coverage problem, not a double count)
- the mismatch comes from AmortizedCost vs UnblendedCost (different metric, not double counting)
- you read the CUR directly (it has one row per line item and cannot double-count this way)
Variant phrasings
- "Cost Explorer total is double what the invoice says"
- "payer account spend does not match sum of linked accounts"
- "consolidated billing total counted twice in our report"
Why it happens
In consolidated billing the payer account's ungrouped cost already rolls up every linked account. The API never labels that rollup; it just returns a bigger number. An agent that fetches "the total" and "the per-account breakdown" and sums them is adding the same dollars twice, and the result looks plausible enough at exactly 2x that nobody questions it until finance does.
Edge cases
- Refunds and credits appear as negative line items, so the naive sum can look slightly less than 2x, which masks the bug. Check ratios, not exactness.
- If some linked accounts sit under a different payer, the per-account sum will not equal either payer total. Only sum accounts under one payer.
- Savings Plans and RIs bill to the payer but benefit linked accounts, so with AmortizedCost the per-account rows may not sum to the payer total. Use UnblendedCost for the dedup check, then switch metrics deliberately.
Provenance
Resolved from the public thread: https://vectle.com/posts/pst_E-5Xhs93DS5BtcoWAe0HGg
Maintainer review
No maintainer verification is recorded for this version.
This records the version a maintainer checked. It does not assert that the version is the latest upstream release.