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

<Tooltip tip="Financial metrics expressed on a per-unit basis: cost per customer, cost per API call, cost per transaction." cta="See Glossary" href="/docs/glossary#unit-economics">Unit economics</Tooltip> 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.

<Frame caption="Total cloud spend increased while cost per client decreased, making infrastructure efficiency visible">
  <img src="https://mintcdn.com/costory/RpRZ9xA1sDfxexAj/images/unit-economics-dashboard.png?fit=max&auto=format&n=RpRZ9xA1sDfxexAj&q=85&s=eadd133322463f6b3948f5530a1089d0" alt="Dashboard showing total cloud spend increasing while cost per client decreases" width="662" height="514" data-path="images/unit-economics-dashboard.png" />
</Frame>

## 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 external metrics from Amplitude, BigQuery, CSV, or Google Sheets.
* Compare the cost of a new service against the service it replaced by grouping formulas by service tag.
* Track realized savings from <Tooltip tip="AWS's flexible commitment-based pricing. You commit to a consistent amount of compute usage for 1 or 3 years and get discounted rates." cta="See Glossary" href="/docs/glossary#savings-plans">Savings Plans</Tooltip> 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](/use-cases/hourly-cost-granularity), [BigQuery cost visibility with dbt](/use-cases/dbt_bigquery_visibility/increase_visibility), or [allocating shared database costs](/use-cases/allocate_shared_cloud_sql_database/allocate).

## Metric types

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

<Tabs>
  <Tab title="Cost metrics">
    Built-in billing metrics from your connected cloud providers. These include total cost, <Tooltip tip="A stable cost metric that removes Savings Plan fluctuation noise. Shows what each resource would cost at its effective discounted rate." cta="See Glossary" href="/docs/glossary#contracted-cost">Contracted Cost</Tooltip>, list cost, and usage quantity.
  </Tab>

  <Tab title="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.

    <Frame caption="Usage metrics available in the query builder, sourced from cloud billing data">
      <img src="https://mintcdn.com/costory/0WD1AAdc_uIVll5h/images/list-usage-metrics.png?fit=max&auto=format&n=0WD1AAdc_uIVll5h&q=85&s=89215cba9049b857a95de57cc6d2d56b" alt="Selecting GB-Hours as a usage metric to calculate per-unit storage cost in Explorer" width="2940" height="1662" data-path="images/list-usage-metrics.png" />
    </Frame>
  </Tab>

  <Tab title="External metrics">
    Metrics from sources such as Datadog, Amplitude, BigQuery, CSV, or Google Sheets. These describe business or application activity that you correlate with cloud cost.

    <Frame caption="External metrics from connected sources such as Amplitude, Datadog, or BigQuery">
      <img src="https://mintcdn.com/costory/0WD1AAdc_uIVll5h/images/list-metrics.png?fit=max&auto=format&n=0WD1AAdc_uIVll5h&q=85&s=cdb5f5569f92a8cf310bce70c2f19be1" alt="Choosing Daily Active Users from Amplitude as an external metric for a cost per DAU formula" width="2940" height="1662" data-path="images/list-metrics.png" />
    </Frame>
  </Tab>
</Tabs>

## Prerequisites

To build formulas from business or application activity, connect at least one [usage metrics source](/setup/usage-metrics). Supported sources include:

* [Datadog](/setup/usage-metrics/datadog) for infrastructure and application metrics
* [Amplitude](/setup/usage-metrics/amplitude) for product analytics such as DAU, MAU, and sessions
* [BigQuery](/setup/usage-metrics/bigquery) for warehouse-native metrics
* [CSV](/setup/usage-metrics/csv) or [Google Sheets](/setup/usage-metrics/google-sheet) for manual imports

<Info>
  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.
</Info>

## Create a unit economics formula

<Steps>
  <Step title="Open Explorer">
    Navigate to [Explorer](/features/cost-explorer) and configure the cost query you want to analyze.
  </Step>

  <Step title="Add metrics">
    Click **+ Add Metric** in the query bar to add a cost metric, usage metric, or external metric. Each metric gets a letter label that you reference in formulas.
  </Step>

  <Step title="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.

    <Frame caption="The formula editor combines multiple metrics and cost queries with letter references">
      <img src="https://mintcdn.com/costory/eYn3vPzyhd5sQYvV/images/example_formula_reallocation.png?fit=max&auto=format&n=eYn3vPzyhd5sQYvV&q=85&s=1f0d4c4895450206b96fd67229a67b55" alt="Formula editor combining total cost divided by usage metric to produce cost per unit over time" width="1697" height="362" data-path="images/example_formula_reallocation.png" />
    </Frame>

    <Note>
      Formulas support `+`, `-`, `*`, `/`, and parentheses. For rolling averages or conditional logic, pre-compute the metric in your source system before importing it.
    </Note>
  </Step>

  <Step title="Visualize the result">
    The chart updates to show the formula over time. Switch chart types and toggle between raw metrics and the formula output.

    <Frame caption="Cost per DAU plotted over time alongside total cloud spend">
      <img src="https://mintcdn.com/costory/bKbzMBnmQFL25JnQ/images/Prod%20Cost%20per%20Daily%20Active%20Users.png?fit=max&auto=format&n=bKbzMBnmQFL25JnQ&q=85&s=f8b815eec2c5e9cc5e5cd8c7bc4e84f3" alt="Cost per DAU trending down while total cloud spend increases" width="2868" height="1540" data-path="images/Prod Cost per Daily Active Users.png" />
    </Frame>
  </Step>

  <Step title="Save and share">
    Save the query as a [dashboard widget](/features/dashboards/create-dashboard) so you can revisit it, share it with [Quick Share](/features/dashboards/quickshare), or schedule it as a [Cost Report](/features/slack-reports).
  </Step>
</Steps>

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

<Tip>
  You can ask the [Costory MCP](/features/mcp) 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>

<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](/features/alerts).
</Tip>

## Frequently asked questions

<AccordionGroup>
  <Accordion title="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](/use-cases/amplitude/cost_per_active_users).
  </Accordion>

  <Accordion title="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>

  <Accordion title="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>

  <Accordion title="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.
  </Accordion>
</AccordionGroup>

## Related links

<CardGroup cols={2}>
  <Card title="Explorer" icon="magnifying-glass" href="/features/cost-explorer">
    Build the base cost queries for unit economics.
  </Card>

  <Card title="Usage metrics setup" icon="chart-line" href="/setup/usage-metrics">
    Connect business and application metrics.
  </Card>

  <Card title="Events" icon="calendar-days" href="/features/events">
    Add timeline context to cost changes.
  </Card>

  <Card title="Cost per active user" icon="users" href="/use-cases/amplitude/cost_per_active_users">
    Follow a worked example with Amplitude.
  </Card>
</CardGroup>
