Lesson 4 of 4 Observability, Reliability and Cost Monitoring

Monitoring Cost and Allocating It Across Teams

This lesson covers a cost strategy for agent solutions, whose costs grow quickly and are often shared across teams: measuring usage, managing quotas and allocations, attributing cost through chargebacks, and controlling spending with budgets and alerts.

Learning outcomes

After completing this lesson, you will be able to:

  • Measure usage at the deployment, agent and request levels.
  • Divide quota through allocations.
  • Choose an attribution mechanism for chargeback or showback.
  • Track unit economics such as cost per completed task.

Measuring usage

Usage is measured at several levels. Azure Monitor metrics report tokens per deployment. Trace spans report tokens per agent, step and run, with custom attributes for feature, team and tenant. The API Management AI gateway's token metric policy emits token counts with dimensions such as subscription (consumer), API and custom values, which is the most practical source for per-consumer usage. Microsoft Cost Management reports actual charges by subscription, resource group, resource and tag.

Match the pairs

Sources of usage data

Exam skills 3.3.4

Match each usage source with the level of detail it reports.

Log in to try this activity Interactive activities are free with an account.

Quotas and allocations

Model quota is assigned per subscription, region and model as TPM, and each deployment receives part of it. Allocations divide the quota between deployments and teams deliberately, so that one workload cannot starve another. At the gateway, the token limit policy enforces per-consumer TPM and longer-period token quotas (hourly, daily, monthly), turning allocations into enforced limits. Provisioned throughput reservations give predictable cost for steady workloads.

True or false

Quota and allocation

Exam skills 3.3.4

Check how model quota is assigned and enforced.

Log in to try this activity Interactive activities are free with an account.

Chargebacks, budgets and anomalies

Chargeback bills each business unit for its consumption; showback reports it without billing. Attribution mechanisms are compared in the following table.

MechanismGranularityNotes
Separate subscriptions or resource groupsPer teamSimple; duplicates resources
Resource tagsPer resourceCannot split one shared deployment
APIM subscription per consumer with token metricsPer consumer on shared deploymentsMost precise for shared model access
Custom span attributesPer feature, tenant or agentNeeds telemetry analysis

Budgets in Cost Management send alerts at thresholds of actual or forecast spend, and cost anomaly detection highlights sudden increases. In agent systems, a sudden increase is often a runaway loop or an attack, so cost alerts are connected to the same response process as reliability alerts.

Sort into groups

Can it split a shared deployment's cost?

Exam skills 3.3.4

Decide whether each attribution mechanism can split usage of one shared model deployment between teams.

Log in to try this activity Interactive activities are free with an account.

Unit economics

Total spend shows whether a budget is at risk, but it does not show whether the solution is efficient. Teams therefore track cost per unit of value, such as cost per completed workflow, per resolved support case or per processed document, calculated from token usage in traces and the prices of the deployments used.

Unit cost makes changes comparable. A new prompt that raises total spend because traffic grew is acceptable, while one that raises the cost per resolved case without improving quality is a regression. Breaking the unit cost down by agent and step shows where optimization pays off, for example a planner that uses a large model for every request, or a retrieval step that sends far more context than the answer needs.

Fill in the number

Cost per resolved case

Exam skills 3.3.4

Work out unit costs from monthly figures.

Log in to try this activity Interactive activities are free with an account.
Worked example

Shared model costs

Five departments share two model deployments through their own agents. Finance wants to charge each department for its token usage, and IT wants to stop any department from consuming more than 40% of capacity.

Route all agent traffic through the API Management AI gateway with one subscription per department; the token metric policy records usage per subscription for chargeback, and the token limit policy caps each subscription's TPM at 40% of capacity. Tags on the deployments cannot split shared usage, and separate deployments per department would fragment quota.

Check yourself

How is token usage enforced per consumer on a shared deployment?

Show answer

With the API Management token limit policy, applied to each consumer's subscription.

Exam Tips

Remember for the exam

  • Per-consumer usage on shared deployments: APIM subscriptions with token metrics.
  • Enforce allocations with the APIM token limit policy.
  • Budgets and anomaly alerts catch runaway loops; treat them like incidents.