Skip to content

Commit 34b43aa

Browse files
authored
feat(bedrock-agentcore-alpha): add observability configuration for Runtime (#36689)
### Issue # (if applicable) Closes #36596 ### Reason for this change Add observability support (logging and tracing) for Amazon Bedrock AgentCore Runtime. This enables users to: - Send X-Ray traces for agent runtime invocations - Deliver application logs and usage logs to CloudWatch Logs, S3, or Kinesis Data Firehose This is essential for monitoring, debugging, and auditing AgentCore Runtime workloads in production environments. ### Description of changes Added observability configuration options to `Runtime` construct: **New Properties:** - `tracingEnabled`: Enable X-Ray tracing delivery for the runtime - `loggingConfigs`: Array of logging configurations specifying log type and destination **New Classes:** - `LoggingDestination`: Abstract class with factory methods for creating log destinations - `LoggingDestination.cloudWatchLogs(logGroup)` - Send logs to CloudWatch Logs - `LoggingDestination.s3(bucket)` - Send logs to S3 - `LoggingDestination.firehose(stream)` - Send logs to Kinesis Data Firehose **New Enums:** - `LogType`: `APPLICATION_LOGS` and `USAGE_LOGS` ### Describe any new or updated permissions being added The following IAM permissions are automatically configured: | Destination | Permissions | Principal | |-------------|-------------|-----------| | CloudWatch Logs | `logs:CreateLogStream`, `logs:PutLogEvents` | `delivery.logs.amazonaws.com` | | S3 | `s3:PutObject` | `delivery.logs.amazonaws.com` | | X-Ray | `xray:PutTraceSegments` | `delivery.logs.amazonaws.com` | | Firehose | Uses service-linked role via `LogDeliveryEnabled` tag | N/A | All policies include conditions restricting access by `aws:SourceAccount` and `aws:SourceArn`. ### Description of how you validated changes Add unit tests and integ tests. ### Checklist - [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 95696b4 commit 34b43aa

19 files changed

Lines changed: 3447 additions & 1 deletion

File tree

packages/@aws-cdk/aws-bedrock-agentcore-alpha/README.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -808,6 +808,52 @@ new agentcore.Runtime(this, 'test-runtime', {
808808
});
809809
```
810810

811+
#### Observability configuration
812+
813+
The Runtime construct supports observability features including X-Ray tracing and logging to CloudWatch Logs, S3, or Kinesis Data Firehose. This allows you to monitor and debug your agent runtime invocations.
814+
815+
You can configure:
816+
817+
- tracingEnabled: Enable X-Ray tracing for the runtime
818+
- loggingConfigs: Send APPLICATION_LOGS (agent runtime invocations) and USAGE_LOGS (session-level resource consumption) to CloudWatch Logs, S3, or Kinesis Data Firehose
819+
820+
For additional information, please refer to the [Set up logging and tracing for AgentCore](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/observability.html).
821+
822+
```typescript fixture=default
823+
const repository = new ecr.Repository(this, 'TestRepository', {
824+
repositoryName: 'test-agent-runtime',
825+
});
826+
827+
const agentRuntimeArtifact = agentcore.AgentRuntimeArtifact.fromEcrRepository(repository, 'v1.0.0');
828+
829+
// Create logging destinations
830+
const logGroup = new logs.LogGroup(this, 'RuntimeLogGroup');
831+
const logBucket = new s3.Bucket(this, 'RuntimeLogBucket');
832+
const firehoseStream = new firehose.DeliveryStream(this, 'RuntimeLogStream', {
833+
destination: new firehose.S3Bucket(logBucket),
834+
});
835+
836+
new agentcore.Runtime(this, 'test-runtime', {
837+
runtimeName: 'test_runtime',
838+
agentRuntimeArtifact: agentRuntimeArtifact,
839+
tracingEnabled: true,
840+
loggingConfigs: [
841+
{
842+
logType: agentcore.LogType.APPLICATION_LOGS,
843+
destination: agentcore.LoggingDestination.cloudWatchLogs(logGroup),
844+
},
845+
{
846+
logType: agentcore.LogType.APPLICATION_LOGS,
847+
destination: agentcore.LoggingDestination.s3(logBucket),
848+
},
849+
{
850+
logType: agentcore.LogType.APPLICATION_LOGS,
851+
destination: agentcore.LoggingDestination.firehose(firehoseStream),
852+
},
853+
],
854+
});
855+
```
856+
811857
## Browser
812858

813859
The Amazon Bedrock AgentCore Browser provides a secure, cloud-based browser that enables AI agents to interact with websites. It includes security features such as session isolation, built-in observability through live viewing, CloudTrail logging, and session replay capabilities.

packages/@aws-cdk/aws-bedrock-agentcore-alpha/lib/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export * from './runtime/inbound-auth/runtime-authorizer-configuration';
2424
export * from './runtime/runtime-endpoint-base';
2525
export * from './runtime/runtime-endpoint';
2626
export * from './runtime/runtime';
27+
export * from './runtime/observability';
2728
// Tools
2829
// ===================================
2930
export * from './tools/code-interpreter';

0 commit comments

Comments
 (0)