Try it free

Set up Cost Allocation for OneAgent deployments

  • Latest Dynatrace
  • How-to guide
  • 5-min read

You can use Cost Allocation to allocate your Dynatrace DPS usage on OneAgent deployments to the cost centers and products that you define.

You can allocate data that comes from hosts monitored with Foundation & Discovery, Infrastructure Monitoring, or Full-Stack Monitoring, such as:

  • Logs: Log data that is ingested by OneAgent on these hosts, see Log Analytics.
  • Metrics: Custom metrics that come from these hosts, see Metrics powered by Grail.
  • Traces: Traces that are ingested as extended trace ingestion, and also OTel traces, see Traces powered by Grail.

Allocating costs in this way provides a transparent and detailed account of the Dynatrace expenditures that originate from each cost center or product, which in turn helps your organization optimize its budgets.

No matter your use case or tag strategy, you can easily implement Cost Allocation for OneAgent.

On this page, you'll learn how to set up Cost Allocation in One Agent deployments.

Overview

We recommend setting up Cost Allocation along organizational lines and deployment scopes. Suitable concepts include host groups and host names. These attributes are typically available for all the telemetry data that you ingest.

Generally, to add Cost Allocation information to your OneAgent data, you'll enrich your signals with the dt.cost.costcenter and dt.cost.product Grail attributes. Dynatrace automatically propagates these attributes value from spans to the service entity for span data.

Depending on your tagging strategy and requirements, there are different ways to do this. If you only need to allocate costs at the host/host group (deployment) level of granularity, we recommend setting up Cost Allocation in OpenPipeline. This lets you use your existing host groups and host names without any changes to your setup. If you need more granularity, you can use OneAgent to add host tags with Cost Allocation metadata.

Map primary Grail fields with OpenPipeline

If you only need to allocate costs at the deployment level of granularity (host/host group), we recommend setting up Cost Allocation in OpenPipeline. This allows you to use your already-defined organizational lines or deployment scopes to set up Cost Allocation, and you don't need to make any changes to your existing deployment.

First, identify the primary Grail fields that you want to base your allocation on. For OneAgent, these could be dt.host_group.id or host.name.

Next, use OpenPipeline to map these to dt.cost.costcenter or dt.cost.product. OpenPipeline has a specific Cost allocation stage where you can do this, which is available at Settings Settings > Process and contextualize > OpenPipeline > Logs > Pipelines > [Select a pipeline] > Cost allocation. For more information, see Processing.

For more information about primary Grail fields, see Global field reference.

Set up at the host level

If you require a more sophisticated way to set up Cost Allocation, you can configure OneAgent to add specific Cost Allocation metadata at the host level. The metadata you create can represent your own cost center architecture, and can even be hierarchical by encoding it into a string such as department-A/department-AB/team-C.

The sections below show you how to add, modify, and remove OneAgent host tags. You can do this either during or after OneAgent installation.

Add Cost Allocation metadata

OneAgent version 1.291+

You can configure Cost Allocation when you install OneAgent.

For information on OneAgent installation, see Install OneAgent on a server.

  1. On the Install OneAgent page, go to Optional parameters > Tags.

  2. Select Add tag.

    1. Enter the Key and Value as appropriate:

      • The key is either dt.cost.costcenter or dt.cost.product.
      • The value is the name of the cost center or product. You've already defined cost centers and hosts in Identify allowed cost centers and products.
    2. Select Add.

  3. Continue to install OneAgent.

OneAgent version 1.291+

OneAgent configuration via command-line interface is a Dynatrace script that performs post-installation OneAgent configuration at the individual host level. You can use it to configure Cost Allocation for OneAgent, even if you've already installed OneAgent on a host.

For usage details, see OneAgent configuration via command-line interface.

  1. Define the cost center and/or product. To do this, execute oneagentctl with the --set-host-tag option.

    This option has two forms:

    • To set the cost center: --set-host-tag=dt.cost.costcenter=<cost_center>
    • To set the product: --set-host-tag=dt.cost.product=<product>

    Modify the placeholder values of <cost_center> and <product> as appropriate. You've already defined cost centers and hosts in Identify allowed cost centers and products.

  2. Verify that you have set the metadata correctly. Execute oneagentctl with --get-host-tags and --get-host-properties and review the output.

  3. Restart OneAgent. Execute oneagentctl with --restart-service.

OneAgent version 1.291+

You can use the Dynatrace web UI to configure Cost Allocation for OneAgent, even if you've already installed OneAgent on a host. To do this, go to Deployment Status Deployment Status > OneAgents.

  1. Select all OneAgent deployments that you want to configure with the same Cost Allocation metadata.

  2. Select the modify host properties action from the list in the lower-left corner. The Modify host properties page opens:

    1. Select Specify host properties to be added or Specify host properties to be removed, as appropriate.
    2. Add or modify the relevant dt.cost.costcenter or dt.cost.product. You've already defined cost centers and hosts in Identify allowed cost centers and products.
    3. Select Next.
    4. Select Apply changes.

Once the changes are applied, the relevant OneAgent deployment is automatically triggered to restart.

OneAgent version 1.291+

You can create a script to automatically configure Cost Allocation for OneAgent, even if you've already installed OneAgent on a host.

The code blocks below provide the script for Linux and Windows OS.

  • Linux:

    COSTCENTER=<cost_center>
    PRODUCT=<product>
    /opt/dynatrace/oneagent/agent/tools/oneagentctl --set-host-tag=dt.cost.costcenter="${COSTCENTER}" --set-host-tag=dt.cost.product="${PRODUCT}" --restart-service
  • Windows:

    COSTCENTER=<cost_center>
    PRODUCT=<product>
    %PROGRAMFILES%\dynatrace\oneagent\agent\tools\oneagentctl.exe --set-host-tag=dt.cost.costcenter="${COSTCENTER}" --set-host-tag=dt.cost.product="${PRODUCT}" --restart-service

To use this script:

  1. Save the contents to a script file on the host where you've deployed OneAgent.

  2. Modify the placeholder values of <cost_center> and <product> as appropriate. You've already defined cost centers and hosts in Identify allowed cost centers and products.

  3. On the host, execute the script with administrator (root) privileges.

  4. Restart OneAgent.

OneAgent version 1.291+

You can configure Cost Allocation for OneAgent via the API after it has been installed on a host.

For more information on these API calls, see OneAgent remote configuration management API - POST a configuration job.

Specifically for Cost Allocation, an API call consists of two parameters:

  • body: Provide the JSON body of the request:

    • Attribute: Use hostTag.

    • operation: Use set.

    • value:

      • Use dt.cost.costcenter=<cost_center> to add a cost center.
      • Use dt.cost.product=<product> to add a product.

      Modify the placeholder values of <cost_center> and <product> as appropriate. You've already defined cost centers and hosts in Identify allowed cost centers and products.

  • restart: Instruct the OneAgent to restart. Set the value to true.

For examples of the JSON file, see Request body JSON model.

Modify Cost Allocation metadata

Past tracked consumption can't be changed or reassigned. If you modify Cost Allocation metadata, you'll lose all data about already-recorded costs (related to that metadata on that host).

Before you reassign a dt.cost.costcenter or dt.cost.product, you might want to export the data via the Dynatrace Platform Subscription API - GET cost allocation.

Before you change the values for dt.cost.costcenter or dt.cost.product, add or remove target values in the Cost Allocation allow lists. This will ensure that no usage values are unassigned in the transition.

Updates to the allow list will take a couple of minutes to take effect.

OneAgent version 1.291+

To modify Cost Allocation metadata, follow the steps in Add Cost Allocation metadata. The new values will overwrite the current values. All changes are irreversible.

Remove Cost Allocation metadata

If you remove Cost Allocation metadata, you'll lose all data about already-recorded costs (related to that metadata on that host). All changes are irreversible.

Related topics

  • Allocate your DPS costs
  • Set up Grail permissions for OneAgent
Related tags
Dynatrace Platform