Observability and session replay - Amazon Bedrock AgentCore

Amazon Bedrock AgentCore is in preview release and is subject to change.

Observability and session replay

The AgentCore Browser provides the following observability features:

Session replay

You can replay browser sessions using the Amazon Bedrock AgentCore SDK to view session recordings stored in Amazon S3. This feature enables you to review past browser interactions for debugging, auditing, or training purposes. The recordings in S3 include DOM change events, browser network activity, and console logs for comprehensive session analysis.

Metrics

You can view browser session metrics in Amazon CloudWatch, including session counts, durations, and error rates to monitor usage and performance.

Session replay

For session replay to work, you'll first need to create a Browser with recording enabled and provide the S3 bucket and prefix where you want the recording to be stored. Note that session replay is not available in the AWS managed Browser (aws.browser.v1).

Note

Session replay in Amazon Bedrock AgentCore captures DOM mutations within your browser session and replays those changes by reconstructing the DOM. During replay, the browser may make cross-origin HTTP requests to fetch external assets such as JavaScript files, CSS stylesheets, images, and other resources required to render the page accurately.

Boto3
## Request response = cp_client.create_browser( name="my_custom_browser", description="Test browser for development", networkConfiguration={ "networkMode": "PUBLIC" }, executionRoleArn="arn:aws:iam::123456789012:role/Sessionreplay", clientToken=str(uuid.uuid4()), recording={ "enabled": True, "s3Location": { "bucket": "session-record-123456789012", "prefix": "replay-data" } } )
API
awscurl \ --region <Region> \ --service bedrock-agentcore \ --request PUT \ --header "Content-Type: application/json" \ --data '{ "name": "dsi_browser_2", "description": "Test sandbox for development", "networkConfiguration": { "networkMode": "PUBLIC" }, "clientToken": "a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0u1v2w3x4y5z" }' \ https://bedrock-agentcore.<Region>.amazonaws.com/browsers )

Permissions

The executionRoleArn will be used to write the recording data to your given s3 bucket. The IAM role should have the below permissions:

{ "Sid": "BedrockAgentCoreBuiltInToolsS3Policy", "Effect": "Allow", "Action": [ "s3:PutObject", "s3:ListMultipartUploadParts", "s3:AbortMultipartUpload" ], "Resource": "arn:aws:s3:::example-s3-bucket/example-prefix/*", "Condition": { "StringEquals": { "aws:ResourceAccount": "{{accountId}}" } } }

Following is the trust policy for the role ARN.

JSON
{ "Version": "2012-10-17", "Statement": [{ "Sid": "BedrockAgentCoreBuiltInTools", "Effect": "Allow", "Principal": { "Service": "bedrock-agentcore.amazonaws.com" }, "Action": "sts:AssumeRole", "Condition": { "StringEquals": { "aws:SourceAccount": "111122223333" }, "ArnLike": { "aws:SourceArn": "arn:aws:bedrock-agentcore:us-east-1:111122223333:*" } } }] }

Once you starts a browser session and interact with the browser either via automation end point or via live view, the session recording will start getting generated and pushed to your provided s3 in chunks.

Standalone Session Replay Viewer

A separate tool for viewing recorded browser sessions directly from S3 without creating a new browser.

  • Connect directly to S3 to view recordings

  • View any past recording by specifying its session ID

  • Automatically finds the latest recording if no session ID is provided

# View the latest recording in a bucket python view_recordings.py --bucket session-record-test-123456789012 --prefix replay-data # View a specific recording python view_recordings.py --bucket session-record-test-123456789012 --prefix replay-data --session 01JZVDG02M8MXZY2N7P3PKDQ74 # Use a specific AWS profile python view_recordings.py --bucket session-record-test-123456789012 --prefix replay-data --profile my-profile

For reference, see Standalone session replay viewer on GitHub.

Complete Browser Experience with Recording and Replay

A separate tool for viewing recorded browser sessions directly from S3 without creating a new browser.

  • Create browser sessions with automatic recording to S3

  • Live view with interactive control (take/release)

  • Adjust display resolution on the fly

  • Automatic session recording to S3

  • Integrated session replay viewer for watching recordings

# View the latest recording in a bucket python -m live_view_sessionreplay.browser_interactive_session

For reference, see Interactive browser session on GitHub.

CloudWatch Metrics

You can view the following metrics in Amazon CloudWatch:

  • Session counts: The number of browser sessions that have been requested

  • Session duration: The length of time browser sessions are active

  • Error rates: The frequency of errors encountered during browser sessions

  • Resource utilization: CPU, memory, and network usage by browser sessions

These metrics can be used to monitor the usage and performance of your browser sessions, set up alarms for abnormal behavior, and optimize your resource allocation.