View a markdown version of this page

Monitor agents with Amazon CloudWatch and AWS CloudTrail - Amazon Bedrock

Monitor agents with Amazon CloudWatch and AWS CloudTrail

Claude Managed Agents for Amazon Bedrock can send a trace of every session in a project to Amazon CloudWatch. A trace is a step-by-step record of a session: each turn, model request, and tool call, with how long it took and whether it failed. Use traces to see what your agents did, where they slowed down, and where they failed.

You turn on traces for each Amazon Bedrock project. The traces of every session in the project then go to AWS X-Ray in your account, and you view them in CloudWatch.

What

Where you see it

What you set up

Traces and spans of each session

CloudWatch GenAI Observability and CloudWatch Transaction Search

CloudWatch Transaction Search, once per account and Region, and a trace delivery for each project

API calls to Claude Managed Agents

AWS CloudTrail

Nothing. Management events are recorded by default.

Model usage

Amazon Bedrock model invocation metrics, and your bill

Nothing

Sessions also report each model request's token usage in their events. See span.model_request_end in Reference.

Prerequisites

  • CloudWatch Transaction Search, once per account and Region. Traces need Transaction Search turned on in the Region where your sessions run. To turn it on, see Transaction Search in the Amazon CloudWatch User Guide.

  • Permission to set up the delivery. The principal that turns on traces needs permission to create a CloudWatch Logs delivery source on the project, a delivery destination, and a delivery. For the permissions, see Enable logging from AWS services in the Amazon CloudWatch Logs User Guide.

  • An active project. You can't turn on traces for an archived project.

Turn on traces in the console

To turn on traces for a project

  1. Open the Amazon Bedrock console, and choose the Region where your sessions run.

  2. In the left navigation pane, choose Projects.

  3. Select one project, and then choose Actions, Configure traces. The Traces panel opens.

  4. If Transaction Search isn't on in this Region yet, choose Transaction Search settings. The CloudWatch console opens in a new tab. Turn on Transaction Search there, and then return to the Traces panel.

  5. Under Tracing, choose Edit.

  6. In the Tracing dialog box, under Enable tracing, turn on Enable, and then choose Save.

Tracing shows Enabled. Sessions that run in the project from then on send their traces to CloudWatch.

You can also start from a session. After you create a session in the console, the success message says Next, turn on traces for this project to see its sessions' traces in Amazon CloudWatch. Choose turn on traces, and then Enable traces to open the Traces panel for the session's project.

To turn traces off, open the project's Traces panel, choose Edit, turn off Enable, and choose Save.

Turn on traces with the AWS CLI

Traces are a CloudWatch Logs delivery. The source is the project, with the log type BedrockProjectTraces, and the destination is AWS X-Ray.

  1. Create the delivery source on the project:

    aws logs put-delivery-source --region us-west-2 \ --name cma-traces-default \ --resource-arn arn:aws:bedrock:us-west-2:111122223333:project/default \ --log-type BedrockProjectTraces
  2. Create an X-Ray delivery destination:

    aws logs put-delivery-destination --region us-west-2 \ --name cma-traces-xray \ --delivery-destination-type XRAY
  3. Connect them. Use the destination's ARN from the previous command's output:

    aws logs create-delivery --region us-west-2 \ --delivery-source-name cma-traces-default \ --delivery-destination-arn arn:aws:logs:us-west-2:111122223333:delivery-destination:cma-traces-xray

Repeat the first and third steps for each project. To turn traces off, delete the delivery with aws logs delete-delivery.

View traces in CloudWatch

  1. Open the CloudWatch console, in the Region where your sessions run.

  2. In the left navigation pane, choose GenAI Observability, and then choose Claude Managed Agents.

  3. Choose an agent to see its sessions, and choose a session to see its traces. Each trace shows the session's turns, model requests, and tool calls as spans.

To search spans across all your agents, use CloudWatch Transaction Search.

In the Amazon Bedrock console, the agent and session pages have View metrics in CloudWatch, which opens CloudWatch's agent observability view.

Traces reach CloudWatch a few minutes after the work they record. A session that ran before you turned on traces has no traces.

Log API calls with AWS CloudTrail

AWS CloudTrail records calls to the Claude Managed Agents API as Amazon Bedrock events, with the IAM action as the event name, such as CreateAnthropicSession. CloudTrail also records the calls that the service makes in your account with your roles: model calls as the session role, AgentCore Runtime calls to start and stop each session's container, and AWS KMS calls with a customer managed key (see Encryption at rest).

Most calls are management events, which every trail and Event history record. Calls that read or write a session's events and threads, or a memory store's memories and memory versions, are data events. CloudTrail data events for these calls aren't available yet. To see what happened in a session, list or stream its events, or turn on traces (see View traces in CloudWatch). Redacting a memory version is a management event.

The tool runner's connection to a session is recorded as the management event CreateAnthropicSessionConnection.

Charges

Traces are charged at CloudWatch pricing for the spans that Transaction Search ingests and stores. For details, see Amazon CloudWatch pricing.