Sub topic 9
Breaking down spend by tag
This chapter assumes you know how to apply tags to resources, that you have activated cost allocation tags (covered in the previous chapters), and that you can set time range, granularity, grouping and filters in Cost Explorer. Here you use tags to attribute spend to projects, teams or environments, and you learn why the numbers sometimes don't look the way you expect.
What a tag report shows
A tag report is a normal Cost Explorer report with one change. You group or filter by a cost allocation tag key instead of by a dimension such as Service or Linked account. Cost Explorer finds every line of billing data that carries that key and sums the cost for each tag value.
Two parts of the model explain most surprises:
- Only activated tag keys appear. A tag that exists on a resource but was never activated is invisible to Cost Explorer.
- Tags are applied to usage from the point of activation onward. Activation is not retroactive by default, so a report for a period before activation shows nothing under the tag. You can ask AWS to backfill up to 12 months of data with a backfill request. Do this before you build reports for earlier months.
Grouping by a tag in the console
Follow these steps to see spend per project.
- Open Cost Explorer and choose a report, for example the monthly costs by service report.
- Set the date range and granularity. Use monthly granularity for a first pass.
- In the group-by control, choose Tag, then choose the key, for example Project.
- Read the chart and the table below it. Each tag value (checkout, search, and so on) becomes one series.
One row is labelled "No tag key: Project" (the console wording may vary slightly). It holds all spend that has no value for that key. This row is your untagged spend, and the next chapter treats it in detail. For now, treat its size as a quality measure for your tagging.
Grouping by tag from the CLI
The same query from the AWS CLI groups by the Project tag.
aws ce get-cost-and-usage \
--time-period Start=2026-10-01,End=2026-11-01 \
--granularity MONTHLY \
--metrics UnblendedCost \
--group-by Type=TAG,Key=ProjectThe End date is exclusive, so this covers 1 October through 31 October. Each group key in the response has the form Project$checkout. Spend with no Project tag is returned in a group whose key is Project$, with an empty value after the dollar sign. Scripts that parse the response must handle that empty value, or they will drop your untagged spend.
Filtering by a tag
Grouping splits a report. Filtering narrows it. You can do both at once. For example, you might want only production compute spend, split by project.
Save this expression as filter.json. It combines a service dimension with a tag condition.
{
"And": [
{ "Dimensions": { "Key": "SERVICE", "Values": ["Amazon Elastic Compute Cloud - Compute"] } },
{ "Tags": { "Key": "Environment", "Values": ["prod"] } }
]
}Then pass it to the CLI together with a tag grouping:
aws ce get-cost-and-usage \
--time-period Start=2026-10-01,End=2026-11-01 \
--granularity MONTHLY \
--metrics UnblendedCost \
--filter file://filter.json \
--group-by Type=TAG,Key=ProjectThe result lists EC2 compute cost for resources tagged Environment=prod, divided by the value of Project. In the console you reach the same result by adding a Tag filter on Environment and a Service filter, then grouping by the Project tag.
Choosing grouping versus filtering
| Goal | Use | Example |
|---|---|---|
| Compare all values of one key | Group by tag | Spend per Project |
| Look at one value only | Filter by tag | Only Environment=prod |
| Drill into one value, split another way | Filter by tag, group by something else | Environment=prod, grouped by Service |
| Two keys together | Filter on one, group by the other | prod spend split by Project |
A single query can group by at most two dimensions or tag keys. If you need a three-way split, run several queries with filters, or use Cost and Usage Reports, which are covered at the end of the tutorial.
Common errors and surprises
The tag does not appear in the group-by list
The key is not activated, or it was activated recently. Confirm activation with the CLI:
aws ce list-cost-allocation-tags --status ActiveIf the key is listed and still missing, wait. After you apply a tag or activate a key, it can take up to 24 hours before the data appears in Cost Explorer.
Everything is under "no tag"
Several causes produce this result:
- The tags were applied to resources after the period you are viewing, so the earlier usage carries no tag.
- The key is spelled differently on the resources. Tag keys are case sensitive, so
projectandProjectare separate keys, and only the activated spelling is reported. - The resource type does not support cost allocation by tag, or the cost belongs to a charge that cannot be tagged. Data transfer, support fees and some taxes often fall into this group.
Tag values look duplicated
Values are also case sensitive. prod, Prod and PROD appear as three separate groups. A report shows what is on the resources, so fix the values at the source. Cost Explorer does not merge them. In the short term you can add all spellings as Values in a filter, or merge them with a Cost Category (covered later).
Totals differ between views
If the sum of your tag groups does not match the account total, check that the untagged group is included. A filter such as Environment=prod removes everything else, so its total is lower than the account total by design.
Resource tags changed mid-month
Cost Explorer uses the tags that were on the resource when the usage occurred. If you retag an instance on the 15th, the first half of the month stays under the old value. Plan tag changes at the start of a billing period when you can.
Tags and cost metrics
Tag reports respect whichever metric you choose. A project tagged on Savings Plans-covered instances shows very different numbers under unblended and amortized cost. Unblended cost shows the upfront or recurring Savings Plans fee as it was charged. Amortized cost spreads it across the usage period. When you present spend by project to the teams that own it, amortized cost usually gives the fairer picture. Pick one metric per report and state it in the title so readers don't compare numbers from different metrics.
A working routine
- Group the last full month by the main tag key (such as Project) and note the size of the no-tag group.
- Filter to the largest services and group by tag again to see which services carry the untagged spend.
- Switch the metric to amortized and compare the two views for any team that uses commitments.
- Save the report so the team can open the same view next month.
Exercise
You run a query grouped by the Project tag for October 2026. It returns the groups Project$checkout, Project$search and Project$. A colleague wants to remove the last group from a script because "it has no name". What does that group contain, and why should it stay?
Show answer
Project$ is the group for spend that has no value for the Project tag. It is your untagged spend, so it shows how much of the bill cannot be attributed to a project. Removing it makes the groups add up to less than the true total and hides the size of the tagging gap.
Exercise
You activated the Environment tag key today, but a report for last quarter shows all spend under "no tag". Give two possible fixes or explanations.
Show answer
Activation applies to usage from the activation point forward, so earlier usage carries no tag data until you request a backfill, which can cover up to 12 months. Another cause is that the resources were not tagged at the time the usage occurred. Retagging now does not change data already billed.