> For the complete documentation index, see [llms.txt](https://docs.cortex.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.cortex.io/guides/operational-readiness/tracking-cloud-costs.md).

# Tracking cloud costs

Bring cloud spend into Cortex so infrastructure cost lives alongside the rest of your engineering health data (deployment frequency, reliability, scorecard compliance) instead of sitting in a separate FinOps tool that engineers never open.&#x20;

This guide walks through surfacing actuals, budgets, and forecasts at the team level, displaying them on entity pages, and wiring cost into your scorecards. By the end, your engineering managers will be able to answer, ***How much is my team spending, and are we on track against budget?***, without leaving Cortex.

<div align="left" data-with-frame="true"><figure><img src="/files/0caQrMkbpdFYL3wGPmTk" alt="A custom &#x27;Cloud cost&#x27; dashboard in Cortex."><figcaption></figcaption></figure></div>

## Prerequisites

1. The `Configure Eng Intelligence custom metrics` permission to create and publish metric definitions.
2. An [API key](/configure/settings/api-keys.md#create-api-key) with the same permission if you plan to push data programmatically (most cloud cost setups do).&#x20;
3. Cost data you can export on a schedule from your cost management platform (AWS Cost Explorer, Azure Cost Management, Databricks, New Relic, etc.), or a CQL-computable source already in Cortex.

### **Custom metrics or custom data?**&#x20;

Use [custom metrics](#step-2-creating-custom-metrics) for anything that changes over time, e.g. monthly spend, budget targets, and forecasts. Cost dollars are a time series, so they belong in custom metrics. See [Custom metrics](/improve/eng-intelligence/custom-metrics.md) to learn more.

Use [custom data](#step-5-tagging-entities-for-cost-attribution-custom-data) for slowly-changing tags like a cost-center or cost-attribution override. Refer to [Custom data](/ingesting-data-into-cortex/entities-overview/entities/custom-data.md) for more information.

## Step 1: Modeling your cost metrics

Cloud cost is most actionable at the team level where a budget owner can actually do something about it. Attach your metrics to team-type entities rather than individual services, at least to start.

A complete picture has three dimensions. A typical setup uses one metric per provider, per dimension:

**Actuals** *(what was spent)*:

* Total cloud cost
* AWS cost
* Azure cost
* Databricks cost
* New Relic cost
* AWS Marketplace cost

**Budgets** *(planned spend targets)*:

* Budgeted AWS
* Budgeted Databricks
* Budgeted New Relic

**Forecasts** *(projected spend for the period)*:

* Forecast AWS
* Forecast Databricks
* Forecast New Relic

You don't need every provider in every dimension. It's common for actuals to flow for more teams than budgets and forecasts, since budget planning is usually formalized for a smaller subset. Start with actuals everywhere, then layer in budgets and forecasts where the planning data exists.

<div align="left" data-with-frame="true"><figure><img src="/files/fvUAl3YaKtcEyA8MTuAS" alt=""><figcaption></figcaption></figure></div>

## Step 2: Creating custom metrics

Add custom metrics in Cortex via [CQL](/improve/eng-intelligence/custom-metrics.md#creating-a-custom-metric-via-cql) or [API](/improve/eng-intelligence/custom-metrics.md#creating-a-custom-metric-via-api). Refer to the table below for field definitions.

<table><thead><tr><th width="122.98828125">Field</th><th>Definition</th></tr></thead><tbody><tr><td><strong>Ingestion method</strong></td><td>Choose API for cost data exported from an external platform (the common case), or CQL if the underlying numbers already exist in Cortex.<br><br>If you choose CQL, Cortex evaluates the expression every 12 hours and the result must resolve to a number, or it fails validation.</td></tr><tr><td><strong>Name</strong></td><td>The name of the custom metric. This is how it appears in <a href="/spaces/JW7pYRxS4dHS3Hv6wxve/pages/nZOyOBWYHpwwuH9q8HVF">Eng Intelligence</a>, e.g. <code>AWS Cost</code>.</td></tr><tr><td><strong>Key</strong></td><td><p>A unique identifier of letters, digits, and hyphens, e.g. <code>aws-cost</code>. </p><p></p><p><strong>Tip</strong>: Keep a consistent prefix scheme like <code>cost-actual-aws</code>, <code>cost-budget-aws</code>, <code>cost-forecast-aws</code> so the three dimensions group cleanly later.</p></td></tr><tr><td><strong>Trend color indicator</strong></td><td>Determine if an upward or downward trend is positive.</td></tr><tr><td><strong>Draft</strong></td><td>Toggle off once you've validated the data, to make it visible to everyone with Eng Intelligence access.</td></tr></tbody></table>

<div align="left" data-with-frame="true"><figure><img src="/files/VYujTVMhyYc5paRhTCQP" alt=""><figcaption></figcaption></figure></div>

## Step 3: Pushing your cost data

For externally-sourced cost data, post to each metric via the API on a regular cadence (a daily or monthly job, depending on how often your platform closes the books).

* Add points to a single entity, or bulk-add multiple points using `createBulkCustomMetricData` to load many teams at once.
* You can backfill up to two years, so load historical spend on first setup to get trends immediately rather than waiting months for them to accumulate.
* All API requests need an `Authorization: Bearer <token>` header.

A few operational notes:

* Cortex lags custom metric results until the end of the previous day, so today's posted data won't render until tomorrow.
* Bulk metric creation via the API is rate-limited. If you're loading dozens of teams, batch your requests and handle `429` responses with a retry-after delay rather than hammering the endpoint.
* Custom metric data is retained for 24 months.

## Step 4: Surfacing cost on team pages with a plugin

Eng Intelligence and [Data Explorer](/improve/eng-intelligence/data-explorer.md) show your cost metrics out of the box, but a dedicated custom plugin gives budget owners a purpose-built view on their team page.

Build a plugin that displays:

* Cloud cost trends across providers
* Budget vs. actuals comparison
* A unified spend view across AWS, Azure, Databricks, and New Relic

Scope the plugin to team-type entities only, so it appears where cost is actionable and stays off individual service pages where it would just be noise. The plugin reads your metric data through the Cortex API, so it stays in sync with whatever cadence you're posting on.

<div align="left" data-with-frame="true"><figure><img src="/files/EuSGJixJIhd7lCqYfIcr" alt=""><figcaption></figcaption></figure></div>

## Step 5: Tagging entities for cost attribution (custom data)

If you need to attribute or override how individual services and resources roll up to a cost center, use a custom data field rather than a metric (this is the slowly-changing-metadata case). A field like operational-cost-override applied across your catalog lets your cost platform (or your own CQL) map services back to the right team or product.

This is what makes accurate chargeback and showback possible: the metrics tell you how much, the custom data tells you whose.

## Step 6: Putting cost to work in Scorecards and reports

Once cost is flowing, it stops being a dashboard and starts being a control:

* **Scorecard rules** - Flag teams whose actual spend exceeds forecast by more than a threshold, or whose spend has grown month-over-month beyond a set percentage. Cost becomes a standard you can drive, not just a number you observe. See [Scorecard rule filters](/standardize/scorecards/scorecard-filters.md)
* **CQL reports** - Build a tabular, cross-team cost comparison so leadership can rank spend without manually aggregating from a finance export. See [Using CQL reports](/standardize/cql/cql-reports.md)
* **Service-level cost** - Once team-level patterns are solid, extend attribution down to individual services using your cost-attribution custom data, so you can answer, ***Which service is driving this team's bill?***

<div align="left" data-with-frame="true"><figure><img src="/files/8eU24VpwYqJRBIIERx6X" alt=""><figcaption></figcaption></figure></div>

## What you end up with

Cost data living where engineering decisions are made—closing the loop between the teams writing the code and the teams accountable for the bill—scoped to the level where someone can act on it, and tied into the same scorecards and reports that govern everything else in your catalog.
