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

# Automated env allocation

> How to easily allocate your costs per environment using all the metadatas available in your billing data

## Prerequisites:

* If you have an AWS provider connected to Costory, you enabled in [Cost Allocation tags](https://console.aws.amazon.com/billing/home#/tags) AWS UI all the tags available.
* If you're using the same Kubernetes cluster for all your environments, you have a way to identify the environment of the pod using a namespace / or a label attached to the pod.
* You identified which marketplace purchases are required for your production environment.

## Output:

* You can compute your cost per environment either using only labels, or using a virtual dimension.
* You can schedule monthly reports to share with your team to monitor the cost of each environment.
* Your Digest will surface the cost changes for each environment.

## Steps:

<Steps>
  <Step title="Step 1: Ingest the env-related labels in your billing data">
    When you connect your billing data, Costory analyzes every available label and finds the ones tied to environments.

    <img src="https://mintcdn.com/costory/yF_njTV234PMuZMt/use-cases/automated_env_allocation/feature_engineering_env.gif?s=18297aee74b7806ef7824d312aa9e4ef" alt="Auto Ingest" width="2042" height="1660" data-path="use-cases/automated_env_allocation/feature_engineering_env.gif" />

    Automatic feature engineering includes:

    * Merge columns from multiple sources into a single label: `k8s_label_env` with `env` and `environment`, `environnment`...
    * Rename values to standardize naming across providers: `stg`-> `staging`, `dev`-> `development`, `prod`-> `production`...
          <img src="https://mintcdn.com/costory/JTLkQHaf9vGcEfO3/use-cases/automated_env_allocation/image.png?fit=max&auto=format&n=JTLkQHaf9vGcEfO3&q=85&s=3421030a742aed5d0014fa3259e969b6" alt="Auto Ingest" width="2234" height="1450" data-path="use-cases/automated_env_allocation/image.png" />
  </Step>

  <Step title="Step 2: Create a virtual dimension to allocate the leftover costs">
    Some of your costs might not be allocated using those labels:

    * either because they can't (network costs, Datadog, etc.)
    * or because they would require an additional split (for example a marketplace purchase used in both prod and staging) that you need to share.

    To fill this gap, you can create a virtual dimension to allocate those costs:

    <img src="https://mintcdn.com/costory/JTLkQHaf9vGcEfO3/use-cases/automated_env_allocation/vdim_env.gif?s=86a412b493450467c0f474aee3548d0c" alt="Virtual Dimension" width="1818" height="702" data-path="use-cases/automated_env_allocation/vdim_env.gif" />
  </Step>

  <Step title="Step 3: Create a report to visualize the cost allocation">
    Once costs are allocated per environment, you can:

    * [Share a report with your exec team](/use-cases/what_your_exec_team_wants/value)
    * [Calculate marginal cost of your prod app using an external metric](/use-cases/amplitude/cost_per_active_users)

          <img src="https://mintcdn.com/costory/JTLkQHaf9vGcEfO3/use-cases/automated_env_allocation/load_test.gif?s=75c341747236534ede0ab0a651290faf" alt="Examples" width="1696" height="788" data-path="use-cases/automated_env_allocation/load_test.gif" />
  </Step>
</Steps>
