

# Publish cost as CloudWatch metrics

When you want to alarm on cost, you first publish cost as metrics, so the figures are available to Amazon CloudWatch.

## Why cost metrics are off by default
<a name="_why_cost_metrics_are_off_by_default"></a>

Publishing metrics has its own CloudWatch charges, so cost metrics are off until you turn them on. You can read cost in the Observability console without turning metrics on; you only need metrics to alarm on cost or to use anomaly detection.

## Turn on cost metrics
<a name="_turn_on_cost_metrics"></a>

The cost-metrics setting is per agent and per Region. Turning it on for an agent creates that agent’s cost metric filters on the span log groups in the account and Region; turning it off deletes them, which stops that agent’s metric and its charge.

The setting lives in the AgentCore Observability console. In the **Trends and distribution** section of the **Overview** view, choose **Manage** to open the **Manage agents in observability** panel. Its **Agent metrics** section is where you enable cost metrics per agent.

 **To turn on cost metrics for an agent (console)** 

1. Open the [AgentCore](https://console.aws.amazon.com/bedrock-agentcore) console and choose **Observability** in the left navigation.

1. In the **Trends and distribution** section, choose **Manage** to open the **Manage agents in observability** panel.

1. In the **Agent metrics** section, select the agents, then choose **Enable**.

## What becomes available
<a name="_what_becomes_available"></a>

After cost metrics publish, you can:
+ Create CloudWatch alarms on estimated cost in the Amazon CloudWatch console.
+ Use CloudWatch anomaly detection to catch unusual spend without setting a fixed threshold.

The metrics let you watch recurring things: an agent, a model, or a cost component.

## When the metrics appear
<a name="_when_the_metrics_appear"></a>

The cost metrics come from CloudWatch Logs metric filters on the span log groups, published at 1-minute granularity as the priced spans are ingested; there is no separate publishing schedule. A metric lags its spans by the ingestion delay: model and per-call costs arrive within minutes, and running-time costs (Runtime, Code Interpreter, and Browser) 15 to 35 minutes after the session ends. Only spans ingested after you turn the toggle on are counted; there is no backfill for earlier work.

## Metrics that get published
<a name="_metrics_that_get_published"></a>

When cost metrics are on, AgentCore publishes cost to the `AgentCore/CostGovernance` namespace:


| Metric | Dimensions | What it measures | 
| --- | --- | --- | 
|  `EstimatedCostByAgent`  |  `AgentId`, `Currency`  | The agent’s own spans (its model calls and Runtime compute), the Gateway, Memory, and tool calls it made, and the evaluations that targeted it. `AgentId` is the agent’s runtime endpoint ARN, for example `arn:aws:bedrock-agentcore:us-west-2:111122223333:runtime/my_agent-AbCdEf1234/runtime-endpoint/DEFAULT:DEFAULT`. For a self-hosted agent that is not on AgentCore Runtime, `AgentId` is the agent’s `cloud.resource_id`, and the Gateway, Memory, and tool calls it makes land in the same series. | 
|  `EstimatedCostTotal`  |  `Currency`  | Every priced span and evaluation result in the account and Region. | 

Alarm on `EstimatedCostByAgent` to watch one agent’s estimated cost, or on `EstimatedCostTotal` to watch the whole account and Region in one alarm. A model call appears in both: in `EstimatedCostByAgent` under the calling agent’s `AgentId`, and in `EstimatedCostTotal`.

## What metrics do and do not cover
<a name="_what_metrics_do_and_do_not_cover"></a>

You cannot alarm on the cost of a single session. A session happens once and does not recur, so a per-session threshold has nothing to keep watching. Finding one expensive session is an investigation task, not an alarm; use the drill-down views instead. See [Investigate an agent session’s cost](acv-see-what-one-session-cost.md). For what is in and out of scope, see [Cost estimate coverage and limits](acv-cost-coverage-by-primitive.md).

## Create alarms in CloudWatch
<a name="_create_alarms_in_cloudwatch"></a>

The Amazon Bedrock AgentCore console does not create alarms. After cost metrics publish, create alarms on them in the Amazon CloudWatch console. See [Using Amazon CloudWatch alarms](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Alarms.html).