

# How the cost views are calculated

This topic describes the span attributes that the **Observability** tab reads, how it charges cost to agents, how it queries the data, and what it costs to use.

## Span attributes that the tab reads
<a name="registry-cost-observability-how-it-works-attributes"></a>

The following table lists the span fields behind the cost views. These are fields of the spans that the centralization rule copies into the registry’s account. Amazon Bedrock AgentCore, your agents' OpenTelemetry instrumentation, and CloudWatch Logs centralization set these fields.


| Field | How the tab uses it | 
| --- | --- | 
|  `attributes.aws.cost.total`  | The span’s estimated cost, which AgentCore adds when it records the span. The tab adds these values up. A span that AgentCore couldn’t price has the value `unavailable`. The tab counts such spans and warns that totals might be low. | 
|  `attributes.aws.cost.currency`  | The currency of `aws.cost.total`. The tab adds up only the costs in the currency of the registry’s AWS Region. | 
|  `attributes.aws.resource.type`  | The AgentCore resource type that the cost is for, such as `AWS::BedrockAgentCore::Runtime`, `AWS::BedrockAgentCore::Memory`, or `AWS::BedrockAgentCore::Gateway`. The tab uses it to group cost **By resource type**. | 
|  `attributes.gen_ai.request.model`  | The model of a model call. The tab groups the **Inference** cost by model. | 
|  `attributes.gen_ai.usage.input_tokens`, `attributes.gen_ai.usage.output_tokens`  | The tokens of a model call. The tab adds them up for the token figures. | 
|  `attributes.aws.evaluation.target.cloud.resource_id`  | On an evaluation result, the endpoint Amazon Resource Name (ARN) of the agent that it evaluated. The tab charges the result’s cost to that agent. | 
|  `resource.attributes.cloud.resource_id`  | The ARN of the AgentCore Runtime agent (runtime endpoint) that recorded the span. The tab uses it to charge the agent’s own model calls and runtime compute to the agent, and to find the account where the cost was spent. | 
|  `attributes.aws.client.cloud.resource_id`  | On spans that AgentCore Gateway, Memory, and the built-in tools record, the ARN of the AgentCore Runtime agent that made the call. The tab uses it to charge these calls to the calling agent. | 
|  `attributes.session.id`  | The session that the span belongs to. | 
|  `traceId`, `spanId`, `parentSpanId`  | The span’s trace and its parent span. The tab counts traces and builds the **Agent calls** tree from them. | 
|  `@aws.account`, `@aws.region`  | The source account and Region of a copied event, added by CloudWatch Logs centralization. The tab reads only spans from the registry’s Region. | 

## How cost is attributed to agents
<a name="registry-cost-observability-how-it-works-attribution"></a>

Each priced span belongs to one agent, its **owner**. The tab identifies the owner by the agent’s runtime ARN without its endpoint, as follows:

1. If the span was recorded by an agent on AgentCore Runtime (`resource.attributes.cloud.resource_id` is a runtime endpoint ARN), the owner is that agent. This covers the agent’s model calls and its runtime compute.

1. Otherwise, if the span records a call made by an agent on AgentCore Runtime (`aws.client.cloud.resource_id` is a runtime ARN), the owner is the calling agent. This covers the agent’s calls to AgentCore Gateway, Memory, and the Browser and Code Interpreter tools.

1. Otherwise, the span is **Not attributed to an agent**.

An agent’s **direct cost** is the cost of the spans that it owns. Because each span has one owner, agents' direct costs add up to the attributed total without counting a span twice. A called agent owns its own spans. Its cost isn’t added to its caller’s.

To match an agent to its registry record, the tab compares the runtime ARN with the ARNs of the registry’s auto-detected records.

## How the tab loads its data
<a name="registry-cost-observability-how-it-works-queries"></a>

The tab queries CloudWatch Logs Insights from your browser. It calls the CloudWatch Logs `StartQuery`, `GetQueryResults`, and `StopQuery` actions with the credentials of your console session.
+  **What it reads** – Each query reads the Standard-class log groups in the registry’s account and narrows them to span events with the `@data_format` field index, so the tab finds the copied spans wherever your rule put them. If the registry’s account is also a CloudWatch cross-account observability monitoring account, the queries skip the log groups of the linked source accounts, so that no span is counted twice.
+  **Evaluation results** – An AgentCore Evaluations result is a log event, not a span, so beside each span query the tab runs a second query for the priced evaluation results. It reads the log groups that CloudWatch Logs files under the AgentCore Evaluations data sources (`amazon_bedrock_agentcore`, with the types `online_evaluation_config` and `batch_evaluation`), so it finds the copied results wherever your rule put them, including the results that an online evaluation configuration writes to an agent’s own log group. It adds the results' cost to the same figures, and charges an evaluation’s cost to the agent that it evaluated.
+  **How it queries** – Each panel runs its own query. The **Sessions** list and a session’s details run when you open them. A session’s details match the session ID with the `attributes.session.id` field index when every span log group has it, which reads much less data.
+  **When it queries** – Queries run when you open the tab, change the date range or filters, open the **Sessions** view or a session, choose **Refresh cost data**, or choose **Retry**. When you change your choice before a query finishes, the tab stops the query.
+  **Where results go** – Results stay in your browser’s memory. The tab doesn’t write span data anywhere.

The queries count toward your account’s CloudWatch Logs Insights quotas, such as the number of concurrent queries. For more information, see [CloudWatch Logs quotas](https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/cloudwatch_limits_cwl.html) in the *Amazon CloudWatch Logs User Guide*.

## What it costs to use the Observability tab
<a name="registry-cost-observability-how-it-works-costs"></a>

The **Observability** tab has no charge of its own. You pay standard CloudWatch prices for the data that it relies on and for the queries that it runs.

**Important**  
Opening the **Observability** tab, changing the date range or filters, choosing **Refresh cost data** or **Retry**, and opening sessions run CloudWatch Logs Insights queries. These queries are billed to the registry’s account for the data that they scan.


| What you pay for | Where | When | 
| --- | --- | --- | 
| Span ingestion | Each member account | AgentCore records spans when CloudWatch Transaction Search and tracing are turned on. You pay this whether or not you use the **Observability** tab. | 
| Copying the spans | Registry’s account | When the centralization rule copies spans into the registry’s account. For how CloudWatch charges for centralized copies, see the CloudWatch pricing page. | 
| Storing the copies | Registry’s account | For as long as the destination log groups keep the copied spans. Set a retention period on those log groups. | 
| Logs Insights queries | Registry’s account | Each time the tab runs a query, for the data that the query scans. | 

For current prices, see [Amazon CloudWatch pricing](https://aws.amazon.com/cloudwatch/pricing/).

To keep query costs down:
+ Choose the shortest date range that you need. The data that a query scans grows with the date range and with the number of spans in it.
+ An **Account** or **Agent** filter doesn’t reduce the data that a query scans. Only a shorter date range does.
+ Avoid refreshing more often than you need. While the tab is open, it reuses the results of a date range that it already read, until you choose **Refresh cost data**.

To keep storage costs down, set a retention period on the log groups that hold the copied spans. The tab reads at most 7 days at a time, plus the previous period of the same length for comparisons.