> ## 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.

# Unit Economics

> Build cloud unit economics in Costory Explorer by combining cloud cost metrics, usage metrics, and formulas such as cost per user, cost per API call, or ROI.

Unit economics (Financial metrics expressed on a per-unit basis: cost per customer, cost per API call, cost per transaction.) turns cloud spend into efficiency metrics. Use it when total cost is rising and you need to know whether cost per user, transaction, request, or workload is improving.

![Dashboard showing total cloud spend increasing while cost per client decreases](https://mintcdn.com/costory/RpRZ9xA1sDfxexAj/images/unit-economics-dashboard.png?fit=max\&auto=format\&n=RpRZ9xA1sDfxexAj\&q=85\&s=eadd133322463f6b3948f5530a1089d0)

Total cloud spend increased while cost per client decreased, making infrastructure efficiency visible

## Overview

Costory Explorer lets you combine cost metrics, usage metrics, and formulas in the same chart. Instead of stopping at "compute spend increased", you can track "cost per active user decreased" or "cost per transaction crossed our target".

Use unit economics when you need to:

* Explain cloud cost increases in the context of business growth
* Track cost per customer, API call, transaction, build minute, or container-hour
* Compare efficiency by team, service, region, or product
* Report engineering improvements in the same terms finance and leadership use

## What you can build

* Track infrastructure ratios such as cost per GB transferred, build minute, or container-hour by dividing cloud spend by usage metrics from your billing data or Datadog.
* Track application ratios such as cost per API call, daily active user, or transaction by connecting an [external metric](https://docs.costory.io/setup/usage-metrics) from Datadog, Datadog CI Visibility, Amplitude, BigQuery, [Cloud Monitoring](https://docs.costory.io/setup/usage-metrics/gcp-cloud-monitoring.md), Google Sheets, Tsuga, CloudWatch, S3, Snowflake, or [Custom metrics](https://docs.costory.io/setup/usage-metrics/custom-metrics-push.md).
* Compare the cost of a new service against the service it replaced by grouping formulas by service tag.
* Track realized savings from Savings Plans (AWS's flexible commitment-based pricing. You commit to a consistent amount of compute usage for 1 or 3 years and get discounted rates.) or CUDs by computing `list_cost - total_cost`.
* Build custom KPIs for commitment utilization, coverage, and ROI.

You can apply these patterns to [hourly granularity for bursty workloads](https://docs.costory.io/use-cases/hourly-cost-granularity.md), [BigQuery cost visibility with dbt](https://docs.costory.io/use-cases/dbt_bigquery_visibility/increase_visibility.md), [BigQuery jobs](https://docs.costory.io/setup/usage-metrics/bigquery-jobs.md) (beta: cost per query with slots reallocated to the user), or [allocating shared database costs](https://docs.costory.io/use-cases/allocate_shared_cloud_sql_database/allocate.md).

## Metric types

Costory's query bar supports the metric types you need for formulas.

> [tab] Cost metrics
>
> Built-in billing metrics from your connected cloud providers. These include total cost, Contracted Cost (A stable cost metric that removes Savings Plan fluctuation noise. Shows what each resource would cost at its effective discounted rate.), list cost, and usage quantity.

> [tab] Usage metrics
>
> Cloud provider usage metrics such as GB-Hours, ReadCapacityUnit-Hrs, and vCPU-Hours. These come from your billing data and describe how much of a resource you consumed.
>
> ![Selecting GB-Hours as a usage metric to calculate per-unit storage cost in Explorer](https://mintcdn.com/costory/0WD1AAdc_uIVll5h/images/list-usage-metrics.png?fit=max\&auto=format\&n=0WD1AAdc_uIVll5h\&q=85\&s=89215cba9049b857a95de57cc6d2d56b)
>
> Usage metrics available in the query builder, sourced from cloud billing data

> [tab] External metrics
>
> Metrics from sources you connect under **Integrations** > **+ Add integration** > **External metric**: Datadog, Datadog CI Visibility, Amplitude, BigQuery, Google Sheets, Tsuga, CloudWatch, S3, Snowflake, or [Custom metrics](https://docs.costory.io/setup/usage-metrics/custom-metrics-push.md). These describe business or application activity that you correlate with cloud cost. Query them in **Advanced Explorer** only. Classic greys out non-cost metrics.
>
> ![Advanced Explorer metric picker open on Cost, with integrations listing Tsuga and BigQuery](https://mintcdn.com/costory/7N_qRRx_7ACcj7QT/images/external-metrics/explorer-metric-picker.png?fit=max\&auto=format\&n=7N_qRRx_7ACcj7QT\&q=85\&s=83a364e7392e46a8df87ec385843e3f9)
>
> Metric picker chips: cost, usage, metric, budget, and integrations

## Prerequisites

To build formulas from business or application activity, connect at least one [external metrics source](https://docs.costory.io/setup/usage-metrics) from **Integrations** > **+ Add integration** > **External metric**. Supported sources include:

* [Datadog](https://docs.costory.io/setup/usage-metrics/datadog.md) for infrastructure and application metrics
* [Datadog CI Visibility](https://docs.costory.io/setup/usage-metrics/datadog-ci.md) for pipeline metrics
* [Amplitude](https://docs.costory.io/setup/usage-metrics/amplitude.md) for product analytics such as DAU, MAU, and sessions
* [BigQuery](https://docs.costory.io/setup/usage-metrics/bigquery.md) for warehouse-native metrics
* [Google Sheets](https://docs.costory.io/setup/usage-metrics/google-sheet.md) for numeric columns from a spreadsheet
* [Tsuga](https://docs.costory.io/setup/usage-metrics/tsuga.md) for live cluster metrics, logs, and traces
* [AWS CloudWatch](https://docs.costory.io/setup/usage-metrics/aws-cloudwatch.md) for CloudWatch metrics
* [S3 metrics](https://docs.costory.io/setup/usage-metrics/s3-parquet.md) for Parquet files in S3
* [Snowflake](https://docs.costory.io/setup/usage-metrics/snowflake.md) for tables in a granted database
* [Custom metrics](https://docs.costory.io/setup/usage-metrics/custom-metrics-push.md) for hourly points you POST yourself

> [!NOTE]
>
> You can still use formulas without external metrics. Combine cost fields with usage metrics from billing data, such as cost per GB-Hour, without connecting another source.

## Create a unit economics formula

**1. Open Advanced Explorer**

Click **Explore your data**, switch **Classic** to **Advanced**, and configure the cost query you want to analyze. Classic greys out non-cost metrics. See [Explorer](https://docs.costory.io/features/cost-explorer.md).

**2. Add metrics**

Click **+ Add Metric** in the query bar to add a cost metric, usage metric, or external metric. Use the **integrations** chip for sources you connected under **External metric**. Each metric gets a letter label that you reference in formulas.

**3. Add a formula**

Click **+ Add Formula** and write your formula with the metric labels.

Examples:

* If metric **a** is total cost and metric **b** is GB-Hours, `a / b` gives you cost per GB-Hour.
* If metric **a** is total cost and metric **b** is Daily Active Users, `a / b` gives you cost per DAU.

![Formula editor combining total cost divided by usage metric to produce cost per unit over time](https://mintcdn.com/costory/eYn3vPzyhd5sQYvV/images/example_formula_reallocation.png?fit=max\&auto=format\&n=eYn3vPzyhd5sQYvV\&q=85\&s=1f0d4c4895450206b96fd67229a67b55)

The formula editor combines multiple metrics and cost queries with letter references

> [!NOTE]
>
> Formulas support `+`, `-`, `*`, `/`, and parentheses. For rolling averages or conditional logic, pre-compute the metric in your source system before you connect it.

**4. Visualize the result**

The chart updates to show the formula over time. Switch chart types and toggle between raw metrics and the formula output.

![Cost per DAU trending down while total cloud spend increases](https://mintcdn.com/costory/bKbzMBnmQFL25JnQ/images/Prod%20Cost%20per%20Daily%20Active%20Users.png?fit=max\&auto=format\&n=bKbzMBnmQFL25JnQ\&q=85\&s=f8b815eec2c5e9cc5e5cd8c7bc4e84f3)

Cost per DAU plotted over time alongside total cloud spend

**5. Save and share**

Save the query as a [dashboard widget](https://docs.costory.io/features/dashboards/create-dashboard.md) so you can revisit it, [share it](https://docs.costory.io/features/sharing.md), or schedule it as a [Cost Report](https://docs.costory.io/features/slack-reports.md).

> [!TIP]
>
> Formulas respect your group-by dimensions. If you group by team and define `cost / daily_active_users`, Costory returns a separate cost-per-DAU value for each team.

> [!TIP]
>
> You can ask the [Costory MCP](https://docs.costory.io/features/mcp.md) to build the ratio for you: *"show cost per active user this quarter, broken down by service."* It picks the right usage metric and returns the result you can save as a widget.

> [!TIP]
>
> You can set threshold alerts on any formula. If cost per request exceeds your target, Costory sends a notification through Slack or email. Configure thresholds in [cloud cost alerts](https://docs.costory.io/features/alerts.md).

## Frequently asked questions

> [accordion] How do I track cloud cost per user or per transaction?
>
> Connect a usage metric such as DAU from Amplitude or transactions from your database. In Explorer, create a formula that divides cloud spend by that metric. For a full walkthrough, see [cost per active user with Amplitude](https://docs.costory.io/use-cases/amplitude/cost_per_active_users.md).

> [accordion] Do formulas work with group-by dimensions?
>
> Yes. If you group by a dimension such as team or service, the formula is applied per group. This lets you compare unit economics across teams, services, or products.

> [accordion] What operators can I use in formulas?
>
> Formulas support arithmetic operators (`+`, `-`, `*`, `/`) and parentheses. Each metric is referenced by its letter label. Formulas operate on the aggregated value per time bucket.

> [accordion] Can I alert on a unit economics metric?
>
> Yes. Save the formula and create an alert from it. Use this for targets such as cost per request, cost per active user, or cost per build minute.

## Related links

> [card] [Explorer](https://docs.costory.io/features/cost-explorer.md)
>
> Build the base cost queries for unit economics.

> [card] [Metrics Correlation](https://docs.costory.io/setup/usage-metrics)
>
> Connect external metrics from Integrations.

> [card] [Events](https://docs.costory.io/features/events.md)
>
> Add timeline context to cost changes.

> [card] [Cost per active user](https://docs.costory.io/use-cases/amplitude/cost_per_active_users.md)
>
> Follow a worked example with Amplitude.


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