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
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
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)
-
Open the AgentCore
console and choose Observability in the left navigation. -
In the Trends and distribution section, choose Manage to open the Manage agents in observability panel.
-
In the Agent metrics section, select the agents, then choose Enable.
What becomes available
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
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
When cost metrics are on, AgentCore publishes cost to the AgentCore/CostGovernance namespace:
| Metric | Dimensions | What it measures |
|---|---|---|
|
|
|
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. |
|
|
|
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
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. For what is in and out of scope, see Cost estimate coverage and limits.
Create alarms in CloudWatch
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.