# Split cost by environment

By the end of this guide, a report splits your cost into production, staging and development, the cost with no environment has a row of its own, each environment has a saved filter that dashboards and folders read through, and non-production spend has a budget. It is for the engineering lead who wants to know what non-production costs, and for finance, who asks. The path goes from one virtual tag for the environment, through a report grouped by it, to a filter per environment and a budget on what is not production. Each step links to the page that owns the detail.

## Before you start

- A connection whose resources carry an environment tag, under any spelling. Where each environment has its own account, subscription or project instead, a report grouped by **Sub-account** already splits it; see [Explore cost data](/cost-reports/explore#group-the-cost).
- Creating the virtual tag, the saved filters and the budget needs edit access to the workspace; see [Access model](/concepts/access-model).
- Every step works on the [sample data](/quickstart#sample-data) a new organization starts with, whose `environment` tag carries `production`, `staging` and `development` on part of its cost. Nothing is sent from the sample data, so the budget in step 5 notifies the team only with a real connection.

## 1. Enable the environment template

Open **Allocation**, then **Virtual tags**, and find the `environment` card under **Templates**. "Merges:" lists the provider tag keys it reads, and "In your data:" the matching keys your cost carries, naming any it does not merge yet; add those with the edit action. Select **Preview** to see the cost per value it would show, then **Enable**. The template becomes a virtual tag like any other, which reports, filters and budgets can use. Where untagged cost still has an obvious environment, such as an account that runs only production, select **Add rule** under **Rules** on the tag and give the rule its **Value** and a condition on **Sub-account**. See [Start from a template](/allocation/virtual-tags#start-from-a-template) and [Create a virtual tag](/allocation/virtual-tags#create-a-virtual-tag).

## 2. Merge the spellings it misses

The same environment often arrives as several values, such as `prod` and `production`. Edit the `environment` virtual tag and, under **Value map**, select **Suggest spellings**: each group proposes its costliest spelling as the value, and **Accept** adds it as an entry. Add any other spelling with **Add entry**. Check the **Preview** until "Unmatched" holds only cost that carries no environment at all, then select **Save**. The sample data spells each environment one way, so it has nothing to merge. See [Merge spellings with a value map](/allocation/virtual-tags#merge-spellings-with-a-value-map).

## 3. Group a report by environment and read the rest

Select the report action on the `environment` row of **Virtual tags** to open a new report grouped by it, or on any report set **Group by** to **Virtual tag** and choose `environment`. Each environment is a row, and the cost nothing placed is the row "No environment"; on the sample data it holds the cost without an `environment` tag, its AI spend among it. Keep the report with **Save as report**, under a title such as "Cost by environment". To shrink the "No environment" row at the source, require `environment` in the workspace's tag policy, whose report names the accounts whose cost lacks the key. See [Use it in reports](/allocation/virtual-tags#use-it-in-reports) and [Set a tag policy](/allocation/tags#set-a-tag-policy).

## 4. Save a filter for each environment

Open **Reporting**, then **Saved filters**, select **New saved filter**, enter a **Title** such as "Production", and under **Conditions** select **Add filter**, choose **Virtual tag** and `environment`, and pick `production` with "is any of"; then select **Create**. Repeat for the other environments. A dashboard then shows one environment when you choose its filter under **Saved filter** above the widgets, and a folder reads every report filed in it through the filter it is given. See [Saved filters](/reporting/saved-filters#create-a-saved-filter), [Change the view for yourself](/reporting/dashboards#change-the-view-for-yourself) and [Read a folder's reports through a saved filter](/reporting/folders#read-a-folders-reports-through-a-saved-filter).

## 5. Put non-production on a budget

On the report of step 3, select **Add filter**, choose **Virtual tag** and `environment`, pick `development` and `staging` with "is any of", and keep it as its own report with **Save as new**. On that report, open **More actions** and choose **Create budget**: the form opens on the report. Select "Suggest from history" for an amount and adjust it, keep or change the thresholds under **Alert thresholds**, pick the team's email channel under **Send to**, and select "Create budget". The budget counts what the report counts, so it measures non-production alone. See [Create a budget from a report](/planning/budgets#create-a-budget-from-a-report).

## Check the result

- **Virtual tags** lists `environment` in its table, and its **Preview** shows a small "Unmatched".
- The "Cost by environment" report shows one row per environment beside the "No environment" row.
- A dashboard set to the "Production" filter under **Saved filter** shows production cost alone in its report widgets.
- **Budgets** lists the non-production budget with its state in the current period.

## Keep it true

- New spellings arrive with new teams and tools. Costfluent recommends reading the virtual tag's **Suggest spellings** and the "No environment" row at every [Run a monthly cost review](/guides/monthly-cost-review).
- A new environment, such as one for previews, needs its value added to the non-production report's filter and a saved filter of its own, or its cost stays out of the budget.

## From your assistant

With the [Costfluent MCP server](/developers/mcp) connected, your assistant answers these with `query_costs`.

```text
What did each value of the environment tag cost last month, and how much of our cost carried no environment tag?
```

```text
How did the cost tagged environment development or staging change month by month over the last three complete months?
```

## Related

- [Virtual tags](/allocation/virtual-tags), [Saved filters](/reporting/saved-filters) and [Budgets](/planning/budgets)
- [Cost per customer, feature and environment](https://costfluent.com/handbook/allocation/cost-per-customer-feature-and-environment), for the ways environments are told apart: by account, by tag or by namespace
- [Raise tag coverage and keep it up](/guides/improve-tag-coverage)
