> ## Documentation Index
> Fetch the complete documentation index at: https://docs.costory.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Split Shared Infrastructure Costs Across Teams

> Allocate shared cloud costs like Cloud SQL, RDS, or network to teams using usage metrics from Datadog, Amplitude, BigQuery, CloudWatch, Snowflake and more.

A shared Cloud SQL database that costs $10K/month rarely splits evenly across the teams that use it. Instead of a flat 50/50 guess, Costory allocates `$7K`to Team A and`\$3K\` to Team B based on actual database usage from Datadog. Connect any usage metric, and Costory splits the cost proportionally, with no manual percentages to maintain.

![Pie chart showing database cost split proportionally across three teams based on usage](https://mintcdn.com/costory/dHz2ISqs3xGAuo-u/use-cases/allocate_shared_cloud_sql_database/3.png?fit=max\&auto=format\&n=dHz2ISqs3xGAuo-u\&q=85\&s=0163b84b55768e10733ebaffa9e1dc5d)

Allocate a shared database cost to the teams using it, based on actual usage metrics

## Key terms

* **Shared cost allocation**: The process of distributing a shared infrastructure cost across the teams or services that consume it, proportionally based on usage.
* **Usage metric**: An external measurement (e.g., database size per schema, CPU time per user, API calls per team) used to determine each team's share of a shared cost.
* **Virtual dimension**: A rule-based cost grouping. Shared cost allocation is configured as a special type of virtual dimension rule. See [Dimensions](https://docs.costory.io/features/tagging/dimensions.md#virtual-dimensions).

See the [Glossary](https://docs.costory.io/docs/glossary.md) for a full list of terms.

## Supported metric sources

Costory can use usage metrics from several data sources to drive proportional cost allocation.

> [card] [Datadog](https://docs.costory.io/setup/usage-metrics/datadog.md)

> [card] [Datadog CI Visibility](https://docs.costory.io/setup/usage-metrics/datadog-ci.md)

> [card] [BigQuery](https://docs.costory.io/setup/usage-metrics/bigquery.md)

> [card] [Tsuga](https://docs.costory.io/setup/usage-metrics/tsuga.md)

> [card] [AWS CloudWatch](https://docs.costory.io/setup/usage-metrics/aws-cloudwatch.md)

> [card] [S3 metrics](https://docs.costory.io/setup/usage-metrics/s3-parquet.md)

> [card] [Amplitude](https://docs.costory.io/setup/usage-metrics/amplitude.md)

> [card] [Google Sheets](https://docs.costory.io/setup/usage-metrics/google-sheet.md)

> [card] [Snowflake](https://docs.costory.io/setup/usage-metrics/snowflake.md)

> [card] [Custom metrics](https://docs.costory.io/setup/usage-metrics/custom-metrics-push.md)

Connect your metric source from **Integrations** > **+ Add integration** > **External metric**. See [Metrics Correlation](https://docs.costory.io/setup/usage-metrics), then reference it in a [virtual dimension (Rule-based dimensions that map cloud resources to business groupings like teams, products, or environments.)](https://docs.costory.io/features/tagging/dimensions.md#virtual-dimensions) rule.

## How it works

**1. Connect a usage metric source**

Go to [Integrations](https://app.costory.io/integration), click **+ Add integration**, then under **External metric** connect a source from the grid above. See [Metrics Correlation](https://docs.costory.io/setup/usage-metrics) for details.&#x20;

**2. Create or edit a virtual dimension**

Open the virtual dimension where you want to add shared cost allocation, for example `Team`. See [Dimensions](https://docs.costory.io/features/tagging/dimensions.md#virtual-dimensions) if you haven't created one yet.

**3. Add a metric-based rule**

Select the usage metric you connected. Costory will use the metric's values to determine each team's proportional share of the cost.

**4. Map metric dimensions to teams**

Tell Costory how metric labels correspond to team names. Three mapping types are available (see below).

**5. Apply**

Costory reprocesses your data. The shared cost is split proportionally and appears in [Explorer](https://docs.costory.io/features/cost-explorer.md) grouped by team.

## Mapping metric labels to teams

When a usage metric has dimension labels (e.g., a `schema` label per database schema), you need to map those labels to the team names in your virtual dimension.

| Mapping type | How it works | When to use |
| - | - | - |
| **Identity** | The metric label already matches the team name exactly | Your metric labels and team names are the same (e.g., `payments` in both) |
| **Regex** | Extract the team name from the metric label using a regular expression | Labels follow a pattern like `team-payments-prod` and you need to extract `payments` |
| **Manual** | Explicitly assign each metric label to a team | Labels don't follow a pattern, or you need full control over the mapping |

## Common allocation patterns

Shared cost allocation works well for:

* Shared databases (Cloud SQL, RDS, Aurora), split by schema size, query count, or connection time per team
* Network and egress costs, split by traffic volume per namespace or service
* Shared Kubernetes clusters, split by CPU or memory usage per namespace. See [EKS cost allocation](https://docs.costory.io/use-cases/eks-cost-allocation.md) for a full example.
* Third-party API costs, split by API call count per team. See [Reallocate API Costs](https://docs.costory.io/use-cases/reallocate_api_costs.md) for a walkthrough.
* Support and licensing fees, split proportionally based on each team's share of total spend

## Automate reporting

Once costs are allocated, you can automate weekly reports per team via [Cost Reports](https://docs.costory.io/features/slack-reports.md). Each team sees their share of shared infrastructure alongside their direct costs, all in one place.

> [!NOTE]
>
> For a step-by-step walkthrough, see [Allocate a shared Cloud SQL database](https://docs.costory.io/use-cases/allocate_shared_cloud_sql_database/allocate.md).

## Next Steps

> [card] [Dimensions](https://docs.costory.io/features/tagging/dimensions.md)
>
> Build imported and rule-based dimensions

> [card] [Allocate a Shared Database](https://docs.costory.io/use-cases/allocate_shared_cloud_sql_database/allocate.md)
>
> Step-by-step: split a Cloud SQL bill across teams

> [card] [Reallocate API Costs](https://docs.costory.io/use-cases/reallocate_api_costs.md)
>
> Split shared API costs using an external usage metric

> [card] [Metrics Correlation](https://docs.costory.io/setup/usage-metrics)
>
> Connect any External metric source


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.