Live:CloudOps Webinars & Hands-on Workshops ·Register ↗
Skip to main content

Monitoring and Auditing AI Workloads on AWS

Introduction

Modern AI workloads on AWS generate telemetry across three independent pipelines — CloudTrail (who called what), Bedrock Model Invocation Logging (what the model said), and Agent Telemetry collected by the ADOT SDK (how the agent performed). Each pipeline is essential. CloudTrail by itself can tell you that an IAM role called InvokeModel, but not what that role asked the model or how the agent responded. Model Invocation Logging captures the content but not the agent orchestration. ADOT captures the orchestration but not inference parameters or IAM identity. Security and operational investigations almost always require correlating at least two.

This guide shows you how to build a complete monitoring and auditing story for AI workloads by:

  1. Enabling all three telemetry pipelines — with brief setup in this guide plus deep links to companion guides for details.
  2. Building detection rules on CloudTrail — metric filters, alarms, and Contributor Insights rules for the security and audit surface, covering both Bedrock and AgentCore data events.
  3. Running cross-pipeline correlation queries — joining CloudTrail with Bedrock Model Invocation Logging and ADOT spans to answer questions no single pipeline can answer on its own.

The Generative AI Security Scoping Matrix and the Agentic AI Security Scoping Matrix define the security dimensions organizations need to address when building AI applications, including audit and logging, identity context, agency perimeters, and data protection. This guide provides the concrete implementation for those dimensions using CloudTrail, CloudWatch, and cross-pipeline correlation. The tabs below map each matrix dimension to the guide sections that implement it.

DimensionGuide Sections
Identity — user, service, and agent identity managementAgentCore Identity & Credentials (Group 2), Query 4, Query 12, Query 14, Metric Filter 7, Metric Filter 18
Data — persistent memory and state securityAgentCore Memory & Evaluation (Group 4), Query 16, Metric Filter 19
Audit & Logging — action-level agent action trackingThree Telemetry Pipelines, Security Analytics, Cross-Pipeline Correlation, Metric Filters, Contributor Insights
Guardrails — behavioral monitoring, sandboxing, isolationAgentCore Built-in Tools (Group 1), Query 8, Query 21, Query 26, Query 27, Metric Filter 4, Metric Filter 17, Metric Filter 24, Metric Filter 25
Scope — operational boundaries and constraint evaluationNetwork Activity Events, Query 4, Query 9, Query 26, Metric Filter 9, Metric Filter 10, Metric Filter 24
Orchestration — agent-to-system interaction and flow controlAgentCore Runtime & Gateway (Group 3), Query 15, Query 17, Query 19, Query 23, Query 24, Metric Filter 21, Metric Filter 22
Shared Responsibility Model

AWS is responsible for the security of the cloud infrastructure running CloudTrail, CloudWatch, and Bedrock services. Customers are responsible for security in the cloud, including configuring event selectors, creating detection rules, setting alarm thresholds, and responding to security events. This guide focuses on customer configuration and monitoring responsibilities for AI workloads. For more information, see the AWS Shared Responsibility Model.

Three Compounding Challenges

Volume — AI model invocations can generate high event volumes. Without precise event selectors and aggregation, events of interest are difficult to isolate at high volume and the cost of capturing everything is prohibitive.

Speed — Agent-initiated activity sequences may involve multiple API calls, tool invocations, and model interactions within seconds. Near-real-time detection rules help surface operational anomalies closer to when they occur, supporting faster triage and shorter mean-time-to-investigate.

Complexity: - AI workload activity spans multiple AWS services. No single log source provides complete visibility. Correlation across pipelines is where investigations actually happen.

What This Guide Covers

  • The three telemetry pipelines and what each uniquely captures
  • Enablement for all three (CloudTrail in depth; the other two with brief steps + deep links)
  • CloudTrail-specific detection: metric filters, alarms, Contributor Insights for both Bedrock and AgentCore data events
  • AgentCore data events: gateway traffic, built-in tool usage, credential access, memory operations, and runtime activity
  • Cross-pipeline correlation queries for investigations
  • A unified dashboard combining all three data sources

The GenAI Telemetry Landscape: Three Complementary Pipelines

CloudTrail is one of three telemetry pipelines that together provide full observability for AI workloads on AWS. Each captures different data, serves different purposes, and is enabled differently. Security investigations almost always require correlating at least two.

Three GenAI Telemetry Pipelines

PipelineCapturesLog GroupPrimary Use
CloudTrailWho did what — every API call, caller ARN, source IP, error codes, access denials, control-plane changesYOUR_CLOUDTRAIL_LOG_GROUPSecurity audit, access investigation, configuration change tracking
Bedrock Model Invocation LoggingWhat the model said — full prompt, full response, inference parameters (temperature, max_tokens), caller IAM identity, token countsbedrock-model-invocation-loggingContent audit, compliance, prompt quality debugging, cost attribution
Agent Telemetry (collected by AWS Distro for OpenTelemetry — ADOT)How the agent performed — model call latency, tool execution, distributed trace correlation, session trackingaws/spans, /aws/bedrock-agentcore/runtimes/<agent>Operational monitoring, performance debugging, agent workflow observability

What Each Pipeline Answers on Its Own

CloudTrail alone tells you:

  • Which IAM identity called InvokeModel?
  • What was the source IP, user agent, and region?
  • Was the call denied (AccessDenied, UnauthorizedOperation)?
  • Did someone modify a guardrail, stop logging, or escalate IAM permissions?
  • Which VPC endpoint blocked the call?

Model Invocation Logging alone tells you:

  • What prompt was sent to the model?
  • What did the model return?
  • What temperature and max_tokens were used?
  • How many input and output tokens did the call consume?
  • Was the response truncated (stop_reason = max_tokens)?

Agent Telemetry (ADOT SDK) alone tells you:

  • How long did the model call take (client-side latency)?
  • Which tools did the agent call, in what order?
  • Did a tool fail, and which component caused the error?
  • How is the agent session chained across multiple model calls?

Where Correlation Unlocks Investigation

Questions only correlation can answer

Investigation QuestionPipelines to JoinJoin Key
Who asked the model this question, and what did it say?CloudTrail (caller) + Model Invocation Logging (prompt/response)requestId
Did the agent fail because of a model issue, a tool issue, or a permission issue?ADOT spans (component latency/errors) + CloudTrail (AccessDenied events)session + time
Was a guardrail weakened just before these unsafe model responses?CloudTrail (UpdateGuardrail events) + Model Invocation Logging (response content)timestamp
Is the agent role making Bedrock calls that violate least privilege?CloudTrail (cross-service AccessDenied from assumed role) + ADOT (agent session ID)session + time
Which external caller triggered this agent through the Gateway, and what credentials did the agent use?CloudTrail Gateway data events (JWT subject, source IP) + CloudTrail credential data events (TokenVault/OAuth2 access)time + agent runtime ARN
Is an agent executing code or browsing websites outside its intended scope?CloudTrail AgentCore tool data events (CodeInterpreter/Browser) + ADOT spans (agent session context)session + time

The Cross-Pipeline Correlation Queries section gives you the actual JOIN queries for these scenarios. :::

Implementation Overview

A phased rollout that enables all three pipelines, then layers detection and correlation on top.

Phase 1: Enable Observability Pipelines

Start with the two observability pipelines (Bedrock Model Invocation Logging and Agent Telemetry collected by the ADOT SDK). They're quick to enable and they're what makes the correlation queries possible. CloudTrail setup follows in Phase 2.

Pipeline A: Bedrock Model Invocation Logging

Captures full prompt, response, inference parameters, and caller IAM identity for every Bedrock model call. Manual opt-in only. (Implements the Generative AI Security Scoping Matrix Governance & Compliance dimension by capturing model interactions to support data sovereignty requirements and compliance audit workflows.)

  1. Open the Amazon Bedrock console
  2. Choose SettingsModel invocation logging
  3. Enable logging and choose CloudWatch Logs (and/or S3) as the destination
  4. Configure the log group name (default: bedrock-model-invocation-logging) and service role

For detailed configuration, PII masking, and dashboard setup, see GenAI Observability on AWS.

Pipeline B: Agent Telemetry (collected by ADOT SDK)

Captures agent orchestration, distributed traces, and tool execution.

  • AgentCore: No action required because the ADOT SDK is included in the runtime by default, and telemetry flows automatically to aws/spans and /aws/bedrock-agentcore/runtimes/<agent>
  • EKS/ECS/self-hosted: Attach the ADOT auto-instrumentation agent to your workload. No code changes needed

Enable CloudWatch Transaction Search to unlock the full Application Signals experience.

For detailed enablement steps, see GenAI Observability on AWS — Enabling Observability for Agentic Workloads and the AgentCore Observability Quickstart.

Phase 2: Enable CloudTrail — Start with Bedrock, Expand Coverage, Ingest to CloudWatch

Configure CloudTrail to capture the full AI workload audit surface, starting with the highest-value resource (Bedrock) and expanding outward. Deliver everything to CloudWatch Logs so it can be joined with Pipelines A and B.

Step 1: Bedrock and AgentCore data events and management events

Enable Bedrock Data Events on your trail using advanced event selectors. These operations are not logged by default. See Amazon Bedrock Data Events.

Bedrock resource types to enable
CategoryResource Types
Agent & OrchestrationAWS::Bedrock::AgentAlias, AWS::Bedrock::InlineAgent, AWS::Bedrock::FlowAlias, AWS::Bedrock::FlowExecution, AWS::Bedrock::Session
Model InvocationAWS::Bedrock::Model, AWS::Bedrock::AsyncInvoke, AWS::Bedrock::PromptVersion, AWS::Bedrock::AdvancedOptimizePromptJob
Safety & GuardrailsAWS::Bedrock::Guardrail, AWS::Bedrock::AutomatedReasoningPolicy, AWS::Bedrock::AutomatedReasoningPolicyVersion
Knowledge & RAGAWS::Bedrock::KnowledgeBase, AWS::Bedrock::Tool
Data AutomationAWS::Bedrock::DataAutomationProject, AWS::Bedrock::DataAutomationInvocation, AWS::Bedrock::DataAutomationProfile, AWS::Bedrock::Blueprint

Enable AgentCore Data Events using advanced event selectors. See Amazon Bedrock AgentCore Data Events.

AgentCore resource types to enable
CategoryResource Types
Runtime & GatewayAWS::BedrockAgentCore::Gateway, AWS::BedrockAgentCore::Runtime, AWS::BedrockAgentCore::RuntimeEndpoint
Built-in ToolsAWS::BedrockAgentCore::CodeInterpreter, AWS::BedrockAgentCore::Browser
Identity & CredentialsAWS::BedrockAgentCore::WorkloadIdentity, AWS::BedrockAgentCore::TokenVault, AWS::BedrockAgentCore::OAuth2CredentialProvider, AWS::BedrockAgentCore::APIKeyCredentialProvider
Memory & EvaluationAWS::BedrockAgentCore::Memory, AWS::BedrockAgentCore::Evaluator

Plus any remaining AgentCore resource types as they become available.

Verify Management Events (Read and Write) are enabled in all regions — this captures InvokeModel and Converse as management events automatically, and AgentCore management events like CreateGateway, CreateGatewayTarget, etc. See CloudTrail Management Events.

Enable CloudTrail Insights (ApiCallRateInsight and ApiErrorRateInsight) for anomaly detection. See CloudTrail Insights Events.

Step 2: Expand to S3, Lambda, and network activity

Step 3: Deliver to CloudWatch Logs

Phase 3: Build Detection Rules on CloudTrail

  • Create metric filters for CloudTrail events (unauthorized Bedrock access, guardrail changes, logging disruption). See Metric Filters.
  • Create CloudWatch Alarms on each metric filter with SNS notification targets. See CloudWatch Alarms.
  • Create Contributor Insights rules to identify top IAM identities and source IPs. See Contributor Insights Rules.

Phase 4: Build Cross-Pipeline Correlation Queries

  • Develop CloudWatch Logs Insights queries for standard CloudTrail detection. See Security Analytics.
  • Build cross-pipeline JOIN queries that combine CloudTrail with Bedrock Model Invocation Logging and ADOT spans. See Cross-Pipeline Correlation Queries.
  • Save validated queries for recurring use by security and operations analysts.

Phase 5: Optimize with Event Aggregation

  • Enable CloudTrail Event Aggregation (API_ACTIVITY, RESOURCE_ACCESS, USER_ACTIONS templates) for 5-minute summaries alongside raw data events. See CloudTrail Data Event Aggregation.
  • Use CloudWatch Subscription Filters to forward only management and aggregated events to downstream SIEM, reducing ingestion volume.

Phase 6: Assemble the Unified Dashboard

  • Build a CloudWatch Dashboard combining CloudTrail alarms, Contributor Insights widgets, Model Invocation Log cost widgets, ADOT performance widgets, and correlation query results into a single pane. See Unified Audit & Monitoring Dashboard.

Amazon Bedrock Data Events

By default, CloudTrail logs management events for your account, which already captures common Bedrock runtime calls like InvokeModel, Converse, and ConverseStream. Many key AI workload operations are logged as data events, including agent invocations, knowledge base retrievals, flow executions, guardrail applications, bidirectional streaming, async invocations, and prompt rendering. These operations require advanced event selectors on your trail. Data events provide your security team with visibility into model invocations. See Advanced Event Selectors for Bedrock below for the specific selectors to apply.

Key APIs to Monitor

The table below shows which Bedrock APIs are captured automatically and which require advanced event selector configuration on your trail.

APIEvent NameWhy It Matters
InvokeModelInvokeModelTracks which IAM identities are calling foundation models and when.
Streaming InvocationInvokeModelWithResponseStreamCaptures streaming model interactions for long-form generation tasks.
Conversational AIConverse / ConverseStreamRecords multi-turn conversational AI activity against foundation models.
Async Invocation ListingListAsyncInvokesMonitors listing of asynchronous invocation jobs.
Important

Because InvokeModel, Converse, and ConverseStream are logged as management events, they are captured by default on any trail with management event logging enabled. However, agent invocations, knowledge base retrievals, flow invocations, guardrail applications, prompt rendering, async invocations, bidirectional streaming, session activity, flow executions, automated reasoning, data automation, blueprint operations, advanced prompt optimization, and tool operations are only logged when you configure advanced event selectors for the corresponding Bedrock resource types on your trail. See Advanced Event Selectors for Bedrock for the configuration, and the Amazon Bedrock CloudTrail documentation for the full list of supported resource types.

Advanced Event Selectors for Bedrock

Use the following advanced event selectors to capture Bedrock data events on your CloudTrail trail. Each Bedrock resource type requires its own selector, and each selector should scope logging to your specific resources using resources.ARN prefixes. This configures eighteen separate selectors — one per resource type. Most filter on eventCategory = Data with a resources.ARN prefix scoped to your account. The Model and AsyncInvoke selectors use eventName filtering instead because foundation model ARNs are AWS-owned and don't contain your account ID.

warning

The selectors below are examples. Applying them without replacing placeholders will capture no events.

Bedrock placeholder reference
PlaceholderReplace WithWhere to Find
ACCOUNT_IDYour 12-digit AWS account IDAWS Console top-right menu
REGIONYour AWS region (e.g., us-east-1)Region selector in console
AGENT_ID / ALIAS_IDAgent and alias IDsBedrock console → Agents
KB_IDKnowledge Base IDBedrock console → Knowledge bases
FLOW_IDFlow IDBedrock console → Prompt flows
GUARDRAIL_IDGuardrail IDBedrock console → Guardrails
PROMPT_IDPrompt IDBedrock console → Prompt management
POLICY_IDAutomated Reasoning Policy IDBedrock console → Automated reasoning
PROJECT_IDData Automation Project IDBedrock console → Data automation
TOOL_IDBedrock Tool IDBedrock console → Tools
BEDROCK_EXECUTION_ROLE_NAMEIAM role name for Bedrock callsIAM console → Roles
YOUR_CLOUDTRAIL_LOG_GROUPCloudWatch Logs log group for your CloudTrail trailCloudTrail console → trail → CloudWatch Logs

To log all resources of a given type, remove the resource ID from the ARN prefix (e.g., agent-alias/AGENT_ID/ALIAS_IDagent-alias/) — this increases event volume and cost. If you use readOnly or eventName filters, verify they match the operations you need.

View all 18 Bedrock advanced event selectors (JSON)
bedrock-advanced-event-selectors.json
[
{
"Name": "Bedrock-AgentAlias-DataEvents",
"FieldSelectors": [
{
"Field": "eventCategory",
"Equals": ["Data"]
},
{
"Field": "resources.type",
"Equals": ["AWS::Bedrock::AgentAlias"]
},
{
"Field": "resources.ARN",
"StartsWith": [
"arn:aws:bedrock:REGION:ACCOUNT_ID:agent-alias/AGENT_ID/ALIAS_ID"
]
}
]
},
{
"Name": "Bedrock-InlineAgent-DataEvents",
"FieldSelectors": [
{
"Field": "eventCategory",
"Equals": ["Data"]
},
{
"Field": "resources.type",
"Equals": ["AWS::Bedrock::InlineAgent"]
},
{
"Field": "eventName",
"Equals": ["InvokeInlineAgent"]
},
{
"Field": "userIdentity.arn",
"StartsWith": [
"arn:aws:sts::ACCOUNT_ID:assumed-role/BEDROCK_EXECUTION_ROLE_NAME"
]
}
]
},
{
"Name": "Bedrock-KnowledgeBase-DataEvents",
"FieldSelectors": [
{
"Field": "eventCategory",
"Equals": ["Data"]
},
{
"Field": "resources.type",
"Equals": ["AWS::Bedrock::KnowledgeBase"]
},
{
"Field": "resources.ARN",
"StartsWith": [
"arn:aws:bedrock:REGION:ACCOUNT_ID:knowledge-base/KB_ID"
]
}
]
},
{
"Name": "Bedrock-FlowAlias-DataEvents",
"FieldSelectors": [
{
"Field": "eventCategory",
"Equals": ["Data"]
},
{
"Field": "resources.type",
"Equals": ["AWS::Bedrock::FlowAlias"]
},
{
"Field": "resources.ARN",
"StartsWith": [
"arn:aws:bedrock:REGION:ACCOUNT_ID:flow/FLOW_ID/alias/"
]
}
]
},
{
"Name": "Bedrock-Guardrail-DataEvents",
"FieldSelectors": [
{
"Field": "eventCategory",
"Equals": ["Data"]
},
{
"Field": "resources.type",
"Equals": ["AWS::Bedrock::Guardrail"]
},
{
"Field": "resources.ARN",
"StartsWith": [
"arn:aws:bedrock:REGION:ACCOUNT_ID:guardrail/GUARDRAIL_ID"
]
}
]
},
{
"Name": "Bedrock-Model-DataEvents",
"FieldSelectors": [
{
"Field": "eventCategory",
"Equals": ["Data"]
},
{
"Field": "resources.type",
"Equals": ["AWS::Bedrock::Model"]
},
{
"Field": "eventName",
"Equals": ["InvokeModelWithBidirectionalStream"]
}
]
},
{
"Name": "Bedrock-AsyncInvoke-DataEvents",
"FieldSelectors": [
{
"Field": "eventCategory",
"Equals": ["Data"]
},
{
"Field": "resources.type",
"Equals": ["AWS::Bedrock::AsyncInvoke"]
},
{
"Field": "eventName",
"Equals": ["GetAsyncInvoke", "StartAsyncInvoke"]
}
]
},
{
"Name": "Bedrock-Prompt-DataEvents",
"FieldSelectors": [
{
"Field": "eventCategory",
"Equals": ["Data"]
},
{
"Field": "resources.type",
"Equals": ["AWS::Bedrock::PromptVersion"]
},
{
"Field": "resources.ARN",
"StartsWith": [
"arn:aws:bedrock:REGION:ACCOUNT_ID:prompt/PROMPT_ID"
]
}
]
},
{
"Name": "Bedrock-Session-DataEvents",
"FieldSelectors": [
{
"Field": "eventCategory",
"Equals": ["Data"]
},
{
"Field": "resources.type",
"Equals": ["AWS::Bedrock::Session"]
},
{
"Field": "resources.ARN",
"StartsWith": [
"arn:aws:bedrock:REGION:ACCOUNT_ID:session/"
]
},
{
"Field": "readOnly",
"Equals": ["false"]
}
]
},
{
"Name": "Bedrock-FlowExecution-DataEvents",
"FieldSelectors": [
{
"Field": "eventCategory",
"Equals": ["Data"]
},
{
"Field": "resources.type",
"Equals": ["AWS::Bedrock::FlowExecution"]
},
{
"Field": "resources.ARN",
"StartsWith": [
"arn:aws:bedrock:REGION:ACCOUNT_ID:flow/FLOW_ID/alias/"
]
}
]
},
{
"Name": "Bedrock-AutomatedReasoningPolicy-DataEvents",
"FieldSelectors": [
{
"Field": "eventCategory",
"Equals": ["Data"]
},
{
"Field": "resources.type",
"Equals": ["AWS::Bedrock::AutomatedReasoningPolicy"]
},
{
"Field": "resources.ARN",
"StartsWith": [
"arn:aws:bedrock:REGION:ACCOUNT_ID:automated-reasoning-policy/POLICY_ID"
]
}
]
},
{
"Name": "Bedrock-AutomatedReasoningPolicyVersion-DataEvents",
"FieldSelectors": [
{
"Field": "eventCategory",
"Equals": ["Data"]
},
{
"Field": "resources.type",
"Equals": ["AWS::Bedrock::AutomatedReasoningPolicyVersion"]
},
{
"Field": "resources.ARN",
"StartsWith": [
"arn:aws:bedrock:REGION:ACCOUNT_ID:automated-reasoning-policy/POLICY_ID"
]
}
]
},
{
"Name": "Bedrock-DataAutomationProject-DataEvents",
"FieldSelectors": [
{
"Field": "eventCategory",
"Equals": ["Data"]
},
{
"Field": "resources.type",
"Equals": ["AWS::Bedrock::DataAutomationProject"]
},
{
"Field": "resources.ARN",
"StartsWith": [
"arn:aws:bedrock:REGION:ACCOUNT_ID:data-automation-project/PROJECT_ID"
]
}
]
},
{
"Name": "Bedrock-DataAutomationInvocation-DataEvents",
"FieldSelectors": [
{
"Field": "eventCategory",
"Equals": ["Data"]
},
{
"Field": "resources.type",
"Equals": ["AWS::Bedrock::DataAutomationInvocation"]
},
{
"Field": "resources.ARN",
"StartsWith": [
"arn:aws:bedrock:REGION:ACCOUNT_ID:data-automation-invocation/"
]
},
{
"Field": "readOnly",
"Equals": ["false"]
}
]
},
{
"Name": "Bedrock-DataAutomationProfile-DataEvents",
"FieldSelectors": [
{
"Field": "eventCategory",
"Equals": ["Data"]
},
{
"Field": "resources.type",
"Equals": ["AWS::Bedrock::DataAutomationProfile"]
},
{
"Field": "resources.ARN",
"StartsWith": [
"arn:aws:bedrock:REGION:ACCOUNT_ID:data-automation-profile/"
]
},
{
"Field": "readOnly",
"Equals": ["false"]
}
]
},
{
"Name": "Bedrock-Blueprint-DataEvents",
"FieldSelectors": [
{
"Field": "eventCategory",
"Equals": ["Data"]
},
{
"Field": "resources.type",
"Equals": ["AWS::Bedrock::Blueprint"]
},
{
"Field": "resources.ARN",
"StartsWith": [
"arn:aws:bedrock:REGION:ACCOUNT_ID:blueprint/"
]
},
{
"Field": "readOnly",
"Equals": ["false"]
}
]
},
{
"Name": "Bedrock-AdvancedOptimizePromptJob-DataEvents",
"FieldSelectors": [
{
"Field": "eventCategory",
"Equals": ["Data"]
},
{
"Field": "resources.type",
"Equals": ["AWS::Bedrock::AdvancedOptimizePromptJob"]
},
{
"Field": "resources.ARN",
"StartsWith": [
"arn:aws:bedrock:REGION:ACCOUNT_ID:advanced-optimize-prompt-job/"
]
},
{
"Field": "readOnly",
"Equals": ["false"]
}
]
},
{
"Name": "Bedrock-Tool-DataEvents",
"FieldSelectors": [
{
"Field": "eventCategory",
"Equals": ["Data"]
},
{
"Field": "resources.type",
"Equals": ["AWS::Bedrock::Tool"]
},
{
"Field": "resources.ARN",
"StartsWith": [
"arn:aws:bedrock:REGION:ACCOUNT_ID:tool/TOOL_ID"
]
}
]
}
]

Bedrock Data Event Resource Types

CloudTrail is designed to support data events for the following Bedrock resource types, providing full visibility into your AI pipeline:

Agent & Orchestration

Resource TypeKey APIsDescription
AWS::Bedrock::AgentAliasInvokeAgentTrack invocations of deployed Bedrock agent aliases
AWS::Bedrock::InlineAgentInvokeInlineAgentCapture inline agent invocations
AWS::Bedrock::FlowAliasInvokeFlowTrack Bedrock Prompt Flow invocations
AWS::Bedrock::FlowExecutionFlow execution APIsCapture flow execution activity for monitoring prompt flow runs
AWS::Bedrock::SessionSession APIsCapture session-level API activity for multi-turn conversations
Selector notes for Agent & Orchestration resources
  • FlowExecution — Narrow resources.ARN to a specific flow ID (e.g., flow/FLOW_ID/alias/) since flow execution ARNs share the flow/ prefix with flow aliases.
  • Session — Uses readOnly = false to focus on write operations (session creation and updates) and reduce volume from high-frequency read operations.

Model Invocation

Resource TypeKey APIsDescription
AWS::Bedrock::ModelInvokeModelWithBidirectionalStreamLog bidirectional streaming invocations
AWS::Bedrock::AsyncInvokeGetAsyncInvoke, StartAsyncInvokeLog asynchronous invocation operations
AWS::Bedrock::PromptVersionRenderPromptCapture prompt rendering operations
AWS::Bedrock::AdvancedOptimizePromptJobAdvanced optimize prompt APIsCapture advanced prompt optimization job activity
Selector notes for Model Invocation resources
  • Model — Foundation model ARNs are AWS-owned (e.g., arn:aws:bedrock:REGION::foundation-model/...) and do not contain your account ID, so this selector uses eventName filtering instead of resources.ARN.
  • AsyncInvoke — Uses eventName filtering to scope to specific async operations. Async invocations require selectors for both AWS::Bedrock::Model and AWS::Bedrock::AsyncInvoke.
  • AdvancedOptimizePromptJob — Uses readOnly = false to focus on write operations (job starts).

Safety & Guardrails

Resource TypeKey APIsDescription
AWS::Bedrock::GuardrailApplyGuardrailCapture apply-guardrail operations
AWS::Bedrock::AutomatedReasoningPolicyAutomated reasoning APIsCapture activity on automated reasoning policies for verifiable AI outputs
AWS::Bedrock::AutomatedReasoningPolicyVersionAutomated reasoning version APIsCapture activity on specific versions of automated reasoning policies
Selector notes for Safety & Guardrails resources
  • AutomatedReasoningPolicy — Narrow to a specific policy ID to avoid capturing all policies in the account.
  • AutomatedReasoningPolicyVersion — Uses the same policy ID prefix as the policy selector.

Knowledge & RAG

Resource TypeKey APIsDescription
AWS::Bedrock::KnowledgeBaseRetrieve, RetrieveAndGenerateMonitor data source retrieval and ingestion activity
AWS::Bedrock::ToolTool APIsCapture tool API activity for tool-use operations
Selector notes for Knowledge & RAG resources
  • Tool — Narrow to a specific tool ID to avoid capturing all tool activity in the account.

Data Automation

Resource TypeKey APIsDescription
AWS::Bedrock::DataAutomationProjectData automation project APIsCapture project activity for document and media processing
AWS::Bedrock::DataAutomationInvocationData automation invocation APIsCapture data automation invocation activity
AWS::Bedrock::DataAutomationProfileData automation profile APIsCapture data automation profile activity
AWS::Bedrock::BlueprintBlueprint APIsCapture blueprint activity for data automation configurations
Selector notes for Data Automation resources
  • DataAutomationProject — Narrow to a specific project ID.
  • DataAutomationInvocation, DataAutomationProfile, Blueprint — All use readOnly = false to focus on write operations.
Cost optimization for InlineAgent

The AWS::Bedrock::InlineAgent selector does not include a resources.ARN filter because inline agents don't have persistent resource ARNs. To reduce volume and cost, the selector uses an eventName filter (scoped to InvokeInlineAgent) and a userIdentity.arn filter to scope logging to specific IAM roles. Replace BEDROCK_EXECUTION_ROLE_NAME with your actual role name. If you don't use inline agents, remove this selector entirely. See Inline Agent: Filter by IAM Identity for the complete selector JSON.

warning

Configuring the advanced event selectors above across all relevant resource types is the critical first step for enabling AI workload visibility in this guide. Do not enable data events without specifying advanced event selectors — unfiltered data event logging can generate high volume and cost. For the latest supported resource types, see Amazon Bedrock data events in CloudTrail.

Amazon Bedrock AgentCore Data Events

Amazon Bedrock AgentCore provides managed infrastructure for running, securing, and connecting AI agents — including hosted runtimes, built-in tools (code interpreters, browsers), identity and credential management, API gateways, and persistent memory. Each of these components generates data-plane activity that CloudTrail can capture as data events, giving you visibility into how your agents execute code, browse the web, authenticate to third-party services, and interact with users through gateways.

AgentCore data events provide runtime visibility into agent behavior, including code runs, tool usage, memory operations — which tools they're invoking, which credentials they're fetching, which gateways are receiving traffic, or whether unrecognized callers are accessing your agent infrastructure.

Why AgentCore Data Events Matter for AI Security

AgentCore components represent the operational surface of your AI agents — the layer where agents take real-world actions. While Bedrock data events (covered above) capture what the agent is asked to do (invoke a model, retrieve from a knowledge base), AgentCore data events capture what the agent actually does. The Agentic AI Security Scoping Matrix defines six critical security dimensions for agentic systems — the bullets below map each AgentCore capability to the matrix dimension it addresses:

  • Code runs — Agents running user-provided code through CodeInterpreter can access files, make network calls, and produce side effects. Monitoring these invocations detects unintended code runs or agents operating outside their intended scope. (Agentic Matrix: Guardrails — sandboxing and isolation mechanisms)
  • Web browsing — Agents using the Browser tool navigate external websites, potentially accessing sensitive URLs or verify data transfer stays within intended boundaries. Logging browser activity provides an audit trail of every page an agent visits. (Agentic Matrix: Guardrails — behavioral monitoring)
  • Credential access — Agents authenticate to third-party APIs using OAuth2 tokens, API keys, and workload identity tokens stored in TokenVault. Unexpected credential access patterns may indicate anomalous agent activity or permission escalation. (Agentic Matrix: Identity — identity delegation and credential management)
  • Gateway traffic — AgentCore Gateways expose agents to external callers via MCP protocol with JWT-based authentication. Gateway data events capture every inbound request, including authentication failures — key for detecting unintended access attempts from outside your AWS environment. (Agentic Matrix: Scope — clear operational boundaries)
  • Agent runtime activity — Runtime and RuntimeEndpoint events track agent lifecycle operations, session management, and endpoint invocations. Anomalous patterns here indicate agents being started, stopped, or accessed outside normal operational windows. (Agentic Matrix: Orchestration — agent-to-system interaction management)
  • Memory operations — Agents with persistent memory store and retrieve conversation context across sessions. Unintended memory access may allow retrieval of conversation history or modification of agent context. Monitoring memory operations helps verify access stays within authorized scope. (Agentic Matrix: Data — persistent memory and state security)
  • Agent evaluation — Evaluator events track automated quality and safety assessments of agent outputs. Monitoring these helps verify your evaluation pipeline remains configured as intended. (Agentic Matrix: Audit & Logging — action-level agent action tracking)

AgentCore Data Event Resource Types

CloudTrail supports data events for the following AgentCore resource types:

Resource Typeresources.typeSecurity Relevance
Code InterpreterAWS::BedrockAgentCore::CodeInterpreterDetect unintended code runs, sandbox boundary issues
Code Interpreter (Custom)AWS::BedrockAgentCore::CodeInterpreterCustomDetect unauthorized custom code runs
BrowserAWS::BedrockAgentCore::BrowserAudit agent web navigation, detect unintended data transfer via URLs
Browser (Custom)AWS::BedrockAgentCore::BrowserCustomAudit custom browser tool usage

Advanced Event Selectors for AgentCore

Use the following advanced event selectors to capture AgentCore data events on your CloudTrail trail. These selectors are organized into four groups based on security function: built-in tools, identity and credentials, runtime and gateway, and memory and evaluation. Each selector scopes logging using resources.ARN prefixes. For AWS-managed built-in tools (CodeInterpreter and Browser), the resources.ARN filter is omitted because these use AWS-owned ARNs — the resources.type filter alone is sufficient.

warning

The selectors below are examples. Applying them without replacing placeholders will capture no events. Replace ACCOUNT_ID and REGION with your values (see the Bedrock placeholder table above). AgentCore-specific placeholders are listed below.

AgentCore placeholder reference
PlaceholderReplace WithWhere to Find
GATEWAY_IDAgentCore Gateway IDAgentCore console or ListGateways API
RUNTIME_IDAgentCore Runtime IDListRuntimes API
DIRECTORY_IDWorkload Identity Directory IDAgentCore console
PROVIDER_NAMEOAuth2 or APIKey credential provider nameAgentCore console
MEMORY_IDAgentCore Memory IDAgentCore console
EVALUATOR_IDAgentCore Evaluator IDAgentCore console
CUSTOM_TOOL_ID / CUSTOM_BROWSER_IDCustom tool or browser configuration IDsAgentCore console

To log all resources of a given type, remove the resource ID from the ARN prefix (e.g., gateway/GATEWAY_IDgateway/) — this increases event volume and cost.

These selectors capture agent tool usage — the actions agents take in the real world. Code interpreter events reveal what code agents execute; browser events reveal what websites agents visit. (Implements the Agentic AI Security Scoping Matrix Guardrails dimension — sandboxing, isolation mechanisms, and behavioral monitoring for agent actions.)

Important

AWS-managed built-in tools (CodeInterpreter and Browser) use AWS-owned resource ARNs with the account segment set to aws (e.g., arn:aws:bedrock-agentcore:REGION:aws:code-interpreter/), not your account ID. Custom tools (CodeInterpreterCustom and BrowserCustom) use your account ID. The selectors below reflect this distinction. If you only use the managed tools, you can omit the custom tool selectors.

AgentCore-BuiltInTools-DataEvents.json
[
{
"Name": "AgentCore-CodeInterpreter-DataEvents",
"FieldSelectors": [
{ "Field": "eventCategory", "Equals": ["Data"] },
{ "Field": "resources.type", "Equals": ["AWS::BedrockAgentCore::CodeInterpreter"] }
]
},
{
"Name": "AgentCore-CodeInterpreterCustom-DataEvents",
"FieldSelectors": [
{ "Field": "eventCategory", "Equals": ["Data"] },
{ "Field": "resources.type", "Equals": ["AWS::BedrockAgentCore::CodeInterpreterCustom"] },
{ "Field": "resources.ARN", "StartsWith": ["arn:aws:bedrock-agentcore:REGION:ACCOUNT_ID:code-interpreter-custom/CUSTOM_TOOL_ID"] }
]
},
{
"Name": "AgentCore-Browser-DataEvents",
"FieldSelectors": [
{ "Field": "eventCategory", "Equals": ["Data"] },
{ "Field": "resources.type", "Equals": ["AWS::BedrockAgentCore::Browser"] }
]
},
{
"Name": "AgentCore-BrowserCustom-DataEvents",
"FieldSelectors": [
{ "Field": "eventCategory", "Equals": ["Data"] },
{ "Field": "resources.type", "Equals": ["AWS::BedrockAgentCore::BrowserCustom"] },
{ "Field": "resources.ARN", "StartsWith": ["arn:aws:bedrock-agentcore:REGION:ACCOUNT_ID:browser-custom/CUSTOM_BROWSER_ID"] }
]
}
]
Cost optimization for AgentCore data events

AgentCore data events can generate significant volume, especially for Gateway (every inbound MCP request) and Runtime (every agent session operation).

Recommended rollout order:

  1. Start with Group 2 (credentials) and Group 3 (gateway) — these are typically the highest security priority.
  2. Expand to Groups 1 and 4 after establishing baseline volume and cost.

Narrowing selectors by resource ID: Use specific resources.ARN values to target individual resources — for example, arn:aws:bedrock-agentcore:REGION:ACCOUNT_ID:gateway/PROD_GATEWAY_ID for a single gateway. For managed built-in tools (CodeInterpreter and Browser), the resources.ARN filter is omitted because these use AWS-owned ARNs — the resources.type filter alone is sufficient.

CloudTrail Insights Events

CloudTrail Insights is designed to identify unusual API activity by continuously analyzing your account's operational baseline. For AI workloads, where legitimate usage can itself involve high call volumes, Insights provides a way to detect anomalous spikes that deviate from the established norm — even when the absolute call volume appears reasonable in isolation.

Insight Types

Insight TypeDetection Purpose
ApiCallRateInsightDetects spikes in API call volume that deviate from the baseline.
ApiErrorRateInsightDetects unusual error rate patterns. A sudden increase in AccessDenied or ThrottlingException errors can indicate repeated access attempts to credentials, repeated unintended access attempts, or an automated agent hitting rate limits.

Configuration Guidance

Enable Insights on your CloudTrail trail by navigating to the trail in the CloudTrail console, selecting Edit, and enabling both Insights event types under the Insights section.

For trails, you can enable Insights for both management events and data events. Select the event type (management events, data events, or both) and then choose the Insights types (API call rate, API error rate, or both). Your trail must be logging Write management or data events to enable API call rate Insights, and must be logging Read or Write management or data events to enable API error rate Insights.

CloudTrail Insights events are delivered to the same Amazon S3 bucket and CloudWatch Logs log group as your standard events, under an Insights prefix. You can create metric filters and alarms directly on Insights events to trigger automated responses when anomalous activity is detected. CloudTrail may take up to 36 hours to begin delivering Insights events after enablement, provided unusual activity is detected during that time.

CloudTrail Management Events

CloudTrail Management events are designed to record control-plane operations in your AWS environment: creating and deleting resources, modifying configurations, and changing permissions. For AI workload security, these events surface unexpected access patterns for review — disabling logging, redirecting audit trails, or weakening AI service guardrails.

Verify that both Read and Write management events are logged on all regions. The default CloudTrail trail provides one free copy of management events per region; additional copies incur charges. See CloudTrail pricing for details.

Key Management Events for AI Security

Event NameWhy It Matters
UpdateAccountSettingsDetects changes to account-level Bedrock configurations.
PutModelInvocationLoggingConfigurationDetects configuration changes with Bedrock invocation logging settings.
DeleteModelInvocationLoggingConfigurationDetects removal of Bedrock logging configuration entirely.
CreateGuardrail / UpdateGuardrail / DeleteGuardrailDetects changes to Bedrock content filtering and safety controls.
note

A common unintended access pattern involves changes to logging configurations, such as disabling trails or redirecting logs to an externally controlled bucket, before conducting further activity. Monitoring for StopLogging, DeleteTrail, and PutModelInvocationLoggingConfiguration is recommended to protect the integrity of your audit trail.

Amazon S3 and Lambda Data Events

AI workloads frequently interact with Amazon S3 buckets (for training data, model artifacts, and CI/CD pipeline assets) and Lambda functions (for AI inference, data preprocessing, and agent orchestration). Monitoring these resource types at the data event level gives you visibility into the object-level and function-invocation-level activity that management events do not capture.

Amazon S3 Target Buckets and Event Types

Enable Amazon S3 data events for buckets containing:

  • AI training datasets and fine-tuning data
  • Model artifacts and configuration files
  • CI/CD pipeline artifacts and code repositories

Key Amazon S3 operations to monitor:

  • PutObject — Detects unauthorized write access or data staging for unauthorized data access
  • GetObject — Detects bulk downloads of training data or model artifacts
  • DeleteObject — Detects data deletion or log modification activity
  • CopyObject — Detects unintended data movement across buckets

Amazon S3 Write-Only Selector

The following selector reduces Amazon S3 data event volume by logging only write operations on specifically named AI-related buckets:

Replace bucket name prefixes with your actual bucket names

The bucket name prefixes below (ai-training-data-, model-artifacts-, cicd-pipeline-) are examples. Replace them with the actual names or naming prefixes of your S3 buckets that contain AI training data, model artifacts, and pipeline assets. You can find your bucket names in the S3 console or by running aws s3 ls. If your buckets use a different naming convention, adjust the StartsWith values accordingly.

What this does

Filters Amazon S3 data events to capture only write operations (readOnly = false) on buckets whose names start with ai-training-data-, model-artifacts-, or cicd-pipeline-. This avoids logging high-volume read operations (like GetObject) while still detecting unauthorized writes, deletions, and data staging.

S3-AI-Sensitive-WriteOnly
[
{
"Name": "S3-AI-Sensitive-WriteOnly",
"FieldSelectors": [
{
"Field": "eventCategory",
"Equals": ["Data"]
},
{
"Field": "resources.type",
"Equals": ["AWS::S3::Object"]
},
{
"Field": "readOnly",
"Equals": ["false"]
},
{
"Field": "resources.ARN",
"StartsWith": [
"arn:aws:s3:::ai-training-data-",
"arn:aws:s3:::model-artifacts-",
"arn:aws:s3:::cicd-pipeline-"
]
}
]
}
]

Lambda AI Pipeline Functions

Enable Lambda data events to log InvokeFunction calls for:

  • AI inference pipeline functions
  • Data preprocessing and feature engineering workflows
  • Bedrock agent orchestration functions
note

An unexpected spike in Lambda invocations, especially from an unfamiliar IAM role, is an early indicator that an unintended access to your Lambda-based AI pipeline functions.

Lambda Production-Only Selector

This selector excludes development and test functions to focus logging on production AI workloads:

Replace function name prefixes with your actual naming convention

The function name prefixes below (prod-, ai-agent-) are examples. Replace them with the actual naming prefixes your organization uses for production AI Lambda functions. Also replace ACCOUNT_ID with your AWS account ID and REGION with your region. You can find your function names in the Lambda console or by running aws lambda list-functions.

What this does

Logs Lambda Invoke data events only for functions whose ARN starts with prod- or ai-agent-. Because StartsWith already scopes to these specific prefixes, development and test functions are excluded by definition — CloudTrail does not allow two field selectors on the same field (resources.ARN) within a single selector, even with different operators. Replace ACCOUNT_ID and region with your values.

Lambda-AI-Production-Invocations
[
{
"Name": "Lambda-AI-Production-Invocations",
"FieldSelectors": [
{
"Field": "eventCategory",
"Equals": ["Data"]
},
{
"Field": "resources.type",
"Equals": ["AWS::Lambda::Function"]
},
{
"Field": "resources.ARN",
"StartsWith": [
"arn:aws:lambda:REGION:ACCOUNT_ID:function:prod-",
"arn:aws:lambda:REGION:ACCOUNT_ID:function:ai-agent-"
]
}
]
}
]

CloudTrail Network Activity Events

CloudTrail Network Activity Events are designed to enable VPC endpoint owners to record AWS API calls made through VPC endpoints from a private VPC to AWS services. For AI workloads, this provides visibility into whether your Bedrock-integrated VPCs are making unexpected outbound calls or whether VPC endpoint access controls are being violated. (Implements the Agentic AI Security Scoping Matrix Scope dimension — enforcing clear operational boundaries and detecting agents operating outside their intended network perimeter.)

AI Workload VPC Endpoints

CloudTrail Network activity events support Amazon Bedrock (bedrock.amazonaws.com), Amazon S3 (s3.amazonaws.com), and AWS Lambda (lambda.amazonaws.com) as event sources. Enable these events on your VPC endpoints to capture API calls routed through each endpoint, including both permitted and denied access attempts. For AI workloads, this is particularly important because Bedrock agents operating within a VPC access downstream services — Amazon S3 for knowledge base data sources, Lambda for action group handlers — through VPC endpoints. Denied access at the VPC endpoint level indicates either a misconfigured endpoint policy or an unauthorized workload attempting to reach AI resources from within your private network.

Additional event sources to consider enabling:

Event SourceMonitoring Purpose
bedrock.amazonaws.comMonitor AI model access and detect unauthorized invocations through VPC endpoints.
s3.amazonaws.comDetect unauthorized Amazon S3 access to training data buckets through VPC endpoints.
kms.amazonaws.comMonitor encryption key access patterns for AI model encryption operations.
lambda.amazonaws.comTrack Lambda invocations through VPC endpoints from AI pipeline functions.
sagemaker.amazonaws.comTrack SageMaker endpoint activity in AI workload environments.

Advanced event selector fields for network activity events

For initial deployment, focus on capturing VpceAccessDenied errors across all AI-relevant VPC endpoints to detect violations of your VPC endpoint policies with minimal additional data volume. The selectors below cover Bedrock, Amazon S3, and Lambda — the three services most commonly accessed by AI agents through VPC endpoints.

What this does

Logs network activity events where Bedrock, Amazon S3, or Lambda returned a VpceAccessDenied error, indicating traffic from within your VPC was blocked by a VPC endpoint policy. This captures denied access across the full AI workload surface without the volume of logging all successful network activity. Amazon S3 denials detect agents blocked from reaching training data or model artifact buckets. Lambda denials detect agents blocked from invoking action group handlers or AI pipeline functions.

View Network Activity VpceAccessDenied selectors (JSON)
network-activity-vpce-access-denied.json
[
{
"Name": "Bedrock-NetworkActivity-VpceAccessDenied",
"FieldSelectors": [
{
"Field": "eventCategory",
"Equals": ["NetworkActivity"]
},
{
"Field": "eventSource",
"Equals": ["bedrock.amazonaws.com"]
},
{
"Field": "errorCode",
"Equals": ["VpceAccessDenied"]
}
]
},
{
"Name": "S3-NetworkActivity-VpceAccessDenied",
"FieldSelectors": [
{
"Field": "eventCategory",
"Equals": ["NetworkActivity"]
},
{
"Field": "eventSource",
"Equals": ["s3.amazonaws.com"]
},
{
"Field": "errorCode",
"Equals": ["VpceAccessDenied"]
}
]
},
{
"Name": "Lambda-NetworkActivity-VpceAccessDenied",
"FieldSelectors": [
{
"Field": "eventCategory",
"Equals": ["NetworkActivity"]
},
{
"Field": "eventSource",
"Equals": ["lambda.amazonaws.com"]
},
{
"Field": "errorCode",
"Equals": ["VpceAccessDenied"]
}
]
}
]

Implementation Priority Checklist

The following table presents the recommended implementation order for enabling CloudTrail event types in your AI workload environment. Each step builds on the previous, starting with the high-impact changes and progressing to more targeted monitoring configurations.

StepEvent TypeWhat to EnableDetails
1Management EventsAll services, all regions (Read + Write)Captures InvokeModel, Converse, ListAsyncInvokes, and AgentCore management events by default
2Data EventsAll 18 Bedrock resource typesAgent invocations, RAG, flows, guardrails, sessions, data automation, tools, and more. See Bedrock selectors
3Data EventsAll 14 AgentCore resource typesGateway traffic, runtime operations, built-in tools, credentials, memory, evaluation. See AgentCore selectors
4Insights EventsAccount-wideApiCallRateInsight and ApiErrorRateInsight for management and data events
5Data EventsAWS::S3::Object (AI buckets)Write-only on ai-training-data, model-artifacts, and cicd-pipeline prefixed buckets
6Data EventsAWS::Lambda::FunctionProduction AI functions only; exclude dev and test function name prefixes
7Network Activity EventsBedrock, S3, and Lambda VPC endpointsVpceAccessDenied on bedrock.amazonaws.com, s3.amazonaws.com, and lambda.amazonaws.com

Optimizing Data Event Collection

Advanced event selectors enable precise filtering to control both costs and log volume. The following strategies show how to narrow each major resource type to only the events of security interest.

Bedrock: Narrow to Production Resources

The advanced event selectors above already scope Bedrock data events to specific resources by ARN. To further reduce volume, narrow the ARN prefixes to only production agents and knowledge bases, excluding non-production or experimental resources:

Replace resource IDs with your actual production resource identifiers

The resource IDs below (PROD_AGENT_ID, PROD_KB_ID) are examples. Replace them with the actual agent and knowledge base IDs from your production environment. You can find these IDs in the Bedrock console under Agents and Knowledge bases, or by running aws bedrock list-agents and aws bedrock list-knowledge-bases.

What this does

Restricts Bedrock data event logging to only agent aliases and knowledge bases whose ARNs match specific resource ID prefixes. Use this when you have identified the exact agent and knowledge base IDs used in production and want to exclude all others. Replace ACCOUNT_ID and the resource IDs with your values.

Bedrock-Production-Agents-Only
[
{
"Name": "Bedrock-Production-Agents-Only",
"FieldSelectors": [
{
"Field": "eventCategory",
"Equals": ["Data"]
},
{
"Field": "resources.type",
"Equals": ["AWS::Bedrock::AgentAlias"]
},
{
"Field": "resources.ARN",
"StartsWith": [
"arn:aws:bedrock:REGION:ACCOUNT_ID:agent-alias/PROD_AGENT_ID"
]
}
]
},
{
"Name": "Bedrock-Production-KnowledgeBases-Only",
"FieldSelectors": [
{
"Field": "eventCategory",
"Equals": ["Data"]
},
{
"Field": "resources.type",
"Equals": ["AWS::Bedrock::KnowledgeBase"]
},
{
"Field": "resources.ARN",
"StartsWith": [
"arn:aws:bedrock:REGION:ACCOUNT_ID:knowledge-base/PROD_KB_ID"
]
}
]
}
]

Amazon S3: Write-Only on AI Buckets

Reduce Amazon S3 data event volume by logging only write operations on AI-specific buckets. Read operations can be added later for high-value buckets if unauthorized data transfer detection is prioritized.

Refer to Section 6.2 for the complete Amazon S3 write-only advanced event selector JSON.

Inline Agent: Filter by IAM Identity

The AWS::Bedrock::InlineAgent selector does not support resources.ARN filtering because inline agents do not have persistent resource ARNs. Without additional filtering, this selector captures all InvokeInlineAgent calls across the account, which can generate high data event volume and cost. Use the userIdentity.arn field to scope logging to specific IAM roles — for example, your production Bedrock execution roles — while excluding development or automated service roles that generate high-volume inline agent calls.

Replace role names with your actual IAM role names

The role names below (BEDROCK_EXECUTION_ROLE_NAME, dev-, test-) are examples. Replace ACCOUNT_ID with your AWS account ID and BEDROCK_EXECUTION_ROLE_NAME with the actual name of the IAM role your application uses to call InvokeInlineAgent. You can find your role names in the IAM console under Roles, or check the execution role configured on your Bedrock agents. In the "Exclude Dev Roles" tab, replace dev- and test- with the actual naming prefixes your organization uses for non-production roles.

What this does

Restricts InlineAgent data event logging to only invocations made by IAM roles matching a specific ARN prefix. The eventName filter restricts capture to only InvokeInlineAgent calls are captured, and the userIdentity.arn filter scopes to your production roles. Replace ACCOUNT_ID with your AWS account ID and BEDROCK_EXECUTION_ROLE_NAME with the actual name of the IAM role your application uses to call InvokeInlineAgent.

Bedrock-InlineAgent-ProductionRolesOnly
[
{
"Name": "Bedrock-InlineAgent-ProductionRolesOnly",
"FieldSelectors": [
{
"Field": "eventCategory",
"Equals": ["Data"]
},
{
"Field": "resources.type",
"Equals": ["AWS::Bedrock::InlineAgent"]
},
{
"Field": "eventName",
"Equals": ["InvokeInlineAgent"]
},
{
"Field": "userIdentity.arn",
"StartsWith": [
"arn:aws:sts::ACCOUNT_ID:assumed-role/BEDROCK_EXECUTION_ROLE_NAME"
]
}
]
}
]
tip

The userIdentity.arn field is supported on all advanced event selectors, not just InlineAgent. You can apply the same filtering technique to any high-volume data event selector where resources.ARN filtering is insufficient. For the full list of supported fields and operators, see Filtering data events by using advanced event selectors.

Lambda: Production Functions Only

Focus data event logging on production AI workloads by scoping the StartsWith operator to only production function prefixes (prod-, ai-agent-). Development and test functions are excluded by definition because their prefixes do not match.

Refer to Section 6.4 for the complete Lambda production-only advanced event selector JSON.

CloudTrail Network Activity Events: VpceAccessDenied Only

For network activity events, logging only denied access across Bedrock, Amazon S3, and Lambda VPC endpoints captures the key security events while reducing the volume compared to logging all network activity.

Refer to Advanced event selector fields for network activity events for the complete Bedrock, Amazon S3, and Lambda VpceAccessDenied network activity event selector JSON.

AgentCore: Phased Enablement by Security Priority

AgentCore data events span fourteen resource types. Enable them in phases based on security priority:

  1. Phase 1 (Highest priority): Gateway (AWS::BedrockAgentCore::Gateway) and credential access (TokenVault, OAuth2CredentialProvider, APIKeyCredentialProvider) — these capture external access and credential retrieval, the two most security-sensitive surfaces.
  2. Phase 2: Runtime and RuntimeEndpoint — captures agent lifecycle and session management.
  3. Phase 3: Built-in tools (CodeInterpreter, Browser and their Custom variants) — captures agent actions in the real world.
  4. Phase 4: Memory, WorkloadIdentity, WorkloadIdentityDirectory, and Evaluator — captures agent state and identity management.

To narrow Gateway data events to specific gateways, replace the broad gateway/ prefix with the specific gateway ID:

{
"Field": "resources.ARN",
"StartsWith": ["arn:aws:bedrock-agentcore:REGION:ACCOUNT_ID:gateway/PROD_GATEWAY_ID"]
}

Similarly, to narrow Runtime data events to a specific agent runtime:

{
"Field": "resources.ARN",
"StartsWith": ["arn:aws:bedrock-agentcore:REGION:ACCOUNT_ID:runtime/PROD_RUNTIME_ID"]
}

CloudTrail Advanced Event Selectors for Organization Level Trail

For an AWS Organizations trail covering multiple accounts, combine all AI workload selectors into a single trail configuration. This defines a complete set of advanced event selectors combining Bedrock data events, AgentCore data events, S3 write-only filtering, Lambda production function logging, and Bedrock network activity denied-access detection — all in one trail.

Replace all placeholder values before applying

The selectors below are examples that combine all service selectors into a single organization trail. Every placeholder must be replaced with your actual resource identifiers before applying.

See the Bedrock and AgentCore sections above for the full placeholder reference tables. For organization trails spanning multiple accounts, you may need to duplicate selectors with different ACCOUNT_ID values or use broader ARN prefixes scoped to each member account.

View complete Organization Trail selectors (34 selectors — JSON)
org-trail-all-ai-workload-selectors.json
[
{
"Name": "OrgTrail-Bedrock-AgentInvocations",
"FieldSelectors": [
{ "Field": "eventCategory", "Equals": ["Data"] },
{ "Field": "resources.type", "Equals": ["AWS::Bedrock::AgentAlias"] },
{ "Field": "resources.ARN", "StartsWith": ["arn:aws:bedrock:REGION:ACCOUNT_ID:agent-alias/AGENT_ID/"] }
]
},
{
"Name": "OrgTrail-Bedrock-InlineAgent",
"FieldSelectors": [
{ "Field": "eventCategory", "Equals": ["Data"] },
{ "Field": "resources.type", "Equals": ["AWS::Bedrock::InlineAgent"] },
{ "Field": "eventName", "Equals": ["InvokeInlineAgent"] },
{ "Field": "userIdentity.arn", "StartsWith": ["arn:aws:sts::ACCOUNT_ID:assumed-role/BEDROCK_EXECUTION_ROLE_NAME"] }
]
},
{
"Name": "OrgTrail-Bedrock-KnowledgeBase",
"FieldSelectors": [
{ "Field": "eventCategory", "Equals": ["Data"] },
{ "Field": "resources.type", "Equals": ["AWS::Bedrock::KnowledgeBase"] },
{ "Field": "resources.ARN", "StartsWith": ["arn:aws:bedrock:REGION:ACCOUNT_ID:knowledge-base/KB_ID"] }
]
},
{
"Name": "OrgTrail-Bedrock-FlowAlias",
"FieldSelectors": [
{ "Field": "eventCategory", "Equals": ["Data"] },
{ "Field": "resources.type", "Equals": ["AWS::Bedrock::FlowAlias"] },
{ "Field": "resources.ARN", "StartsWith": ["arn:aws:bedrock:REGION:ACCOUNT_ID:flow/FLOW_ID/alias/"] }
]
},
{
"Name": "OrgTrail-Bedrock-Guardrail",
"FieldSelectors": [
{ "Field": "eventCategory", "Equals": ["Data"] },
{ "Field": "resources.type", "Equals": ["AWS::Bedrock::Guardrail"] },
{ "Field": "resources.ARN", "StartsWith": ["arn:aws:bedrock:REGION:ACCOUNT_ID:guardrail/GUARDRAIL_ID"] }
]
},
{
"Name": "OrgTrail-Bedrock-Model",
"FieldSelectors": [
{ "Field": "eventCategory", "Equals": ["Data"] },
{ "Field": "resources.type", "Equals": ["AWS::Bedrock::Model"] },
{ "Field": "eventName", "Equals": ["InvokeModelWithBidirectionalStream"] }
]
},
{
"Name": "OrgTrail-Bedrock-AsyncInvoke",
"FieldSelectors": [
{ "Field": "eventCategory", "Equals": ["Data"] },
{ "Field": "resources.type", "Equals": ["AWS::Bedrock::AsyncInvoke"] },
{ "Field": "eventName", "Equals": ["GetAsyncInvoke", "StartAsyncInvoke"] }
]
},
{
"Name": "OrgTrail-Bedrock-Prompt",
"FieldSelectors": [
{ "Field": "eventCategory", "Equals": ["Data"] },
{ "Field": "resources.type", "Equals": ["AWS::Bedrock::PromptVersion"] },
{ "Field": "resources.ARN", "StartsWith": ["arn:aws:bedrock:REGION:ACCOUNT_ID:prompt/PROMPT_ID"] }
]
},
{
"Name": "OrgTrail-Bedrock-Session",
"FieldSelectors": [
{ "Field": "eventCategory", "Equals": ["Data"] },
{ "Field": "resources.type", "Equals": ["AWS::Bedrock::Session"] },
{ "Field": "resources.ARN", "StartsWith": ["arn:aws:bedrock:REGION:ACCOUNT_ID:session/"] },
{ "Field": "readOnly", "Equals": ["false"] }
]
},
{
"Name": "OrgTrail-Bedrock-FlowExecution",
"FieldSelectors": [
{ "Field": "eventCategory", "Equals": ["Data"] },
{ "Field": "resources.type", "Equals": ["AWS::Bedrock::FlowExecution"] },
{ "Field": "resources.ARN", "StartsWith": ["arn:aws:bedrock:REGION:ACCOUNT_ID:flow/FLOW_ID/alias/"] }
]
},
{
"Name": "OrgTrail-Bedrock-AutomatedReasoningPolicy",
"FieldSelectors": [
{ "Field": "eventCategory", "Equals": ["Data"] },
{ "Field": "resources.type", "Equals": ["AWS::Bedrock::AutomatedReasoningPolicy"] },
{ "Field": "resources.ARN", "StartsWith": ["arn:aws:bedrock:REGION:ACCOUNT_ID:automated-reasoning-policy/POLICY_ID"] }
]
},
{
"Name": "OrgTrail-Bedrock-AutomatedReasoningPolicyVersion",
"FieldSelectors": [
{ "Field": "eventCategory", "Equals": ["Data"] },
{ "Field": "resources.type", "Equals": ["AWS::Bedrock::AutomatedReasoningPolicyVersion"] },
{ "Field": "resources.ARN", "StartsWith": ["arn:aws:bedrock:REGION:ACCOUNT_ID:automated-reasoning-policy/POLICY_ID"] }
]
},
{
"Name": "OrgTrail-Bedrock-DataAutomationProject",
"FieldSelectors": [
{ "Field": "eventCategory", "Equals": ["Data"] },
{ "Field": "resources.type", "Equals": ["AWS::Bedrock::DataAutomationProject"] },
{ "Field": "resources.ARN", "StartsWith": ["arn:aws:bedrock:REGION:ACCOUNT_ID:data-automation-project/PROJECT_ID"] }
]
},
{
"Name": "OrgTrail-Bedrock-DataAutomationInvocation",
"FieldSelectors": [
{ "Field": "eventCategory", "Equals": ["Data"] },
{ "Field": "resources.type", "Equals": ["AWS::Bedrock::DataAutomationInvocation"] },
{ "Field": "resources.ARN", "StartsWith": ["arn:aws:bedrock:REGION:ACCOUNT_ID:data-automation-invocation/"] },
{ "Field": "readOnly", "Equals": ["false"] }
]
},
{
"Name": "OrgTrail-Bedrock-DataAutomationProfile",
"FieldSelectors": [
{ "Field": "eventCategory", "Equals": ["Data"] },
{ "Field": "resources.type", "Equals": ["AWS::Bedrock::DataAutomationProfile"] },
{ "Field": "resources.ARN", "StartsWith": ["arn:aws:bedrock:REGION:ACCOUNT_ID:data-automation-profile/"] },
{ "Field": "readOnly", "Equals": ["false"] }
]
},
{
"Name": "OrgTrail-Bedrock-Blueprint",
"FieldSelectors": [
{ "Field": "eventCategory", "Equals": ["Data"] },
{ "Field": "resources.type", "Equals": ["AWS::Bedrock::Blueprint"] },
{ "Field": "resources.ARN", "StartsWith": ["arn:aws:bedrock:REGION:ACCOUNT_ID:blueprint/"] },
{ "Field": "readOnly", "Equals": ["false"] }
]
},
{
"Name": "OrgTrail-Bedrock-AdvancedOptimizePromptJob",
"FieldSelectors": [
{ "Field": "eventCategory", "Equals": ["Data"] },
{ "Field": "resources.type", "Equals": ["AWS::Bedrock::AdvancedOptimizePromptJob"] },
{ "Field": "resources.ARN", "StartsWith": ["arn:aws:bedrock:REGION:ACCOUNT_ID:advanced-optimize-prompt-job/"] },
{ "Field": "readOnly", "Equals": ["false"] }
]
},
{
"Name": "OrgTrail-Bedrock-Tool",
"FieldSelectors": [
{ "Field": "eventCategory", "Equals": ["Data"] },
{ "Field": "resources.type", "Equals": ["AWS::Bedrock::Tool"] },
{ "Field": "resources.ARN", "StartsWith": ["arn:aws:bedrock:REGION:ACCOUNT_ID:tool/TOOL_ID"] }
]
},
{
"Name": "OrgTrail-AgentCore-Gateway",
"FieldSelectors": [
{ "Field": "eventCategory", "Equals": ["Data"] },
{ "Field": "resources.type", "Equals": ["AWS::BedrockAgentCore::Gateway"] },
{ "Field": "resources.ARN", "StartsWith": ["arn:aws:bedrock-agentcore:REGION:ACCOUNT_ID:gateway/GATEWAY_ID"] }
]
},
{
"Name": "OrgTrail-AgentCore-Runtime",
"FieldSelectors": [
{ "Field": "eventCategory", "Equals": ["Data"] },
{ "Field": "resources.type", "Equals": ["AWS::BedrockAgentCore::Runtime"] },
{ "Field": "resources.ARN", "StartsWith": ["arn:aws:bedrock-agentcore:REGION:ACCOUNT_ID:runtime/RUNTIME_ID"] }
]
},
{
"Name": "OrgTrail-AgentCore-RuntimeEndpoint",
"FieldSelectors": [
{ "Field": "eventCategory", "Equals": ["Data"] },
{ "Field": "resources.type", "Equals": ["AWS::BedrockAgentCore::RuntimeEndpoint"] },
{ "Field": "resources.ARN", "StartsWith": ["arn:aws:bedrock-agentcore:REGION:ACCOUNT_ID:runtime/RUNTIME_ID"] }
]
},
{
"Name": "OrgTrail-AgentCore-CodeInterpreter",
"FieldSelectors": [
{ "Field": "eventCategory", "Equals": ["Data"] },
{ "Field": "resources.type", "Equals": ["AWS::BedrockAgentCore::CodeInterpreter"] }
]
},
{
"Name": "OrgTrail-AgentCore-Browser",
"FieldSelectors": [
{ "Field": "eventCategory", "Equals": ["Data"] },
{ "Field": "resources.type", "Equals": ["AWS::BedrockAgentCore::Browser"] }
]
},
{
"Name": "OrgTrail-AgentCore-WorkloadIdentity",
"FieldSelectors": [
{ "Field": "eventCategory", "Equals": ["Data"] },
{ "Field": "resources.type", "Equals": ["AWS::BedrockAgentCore::WorkloadIdentity"] },
{ "Field": "resources.ARN", "StartsWith": ["arn:aws:bedrock-agentcore:REGION:ACCOUNT_ID:workload-identity-directory/DIRECTORY_ID"] }
]
},
{
"Name": "OrgTrail-AgentCore-TokenVault",
"FieldSelectors": [
{ "Field": "eventCategory", "Equals": ["Data"] },
{ "Field": "resources.type", "Equals": ["AWS::BedrockAgentCore::TokenVault"] },
{ "Field": "resources.ARN", "StartsWith": ["arn:aws:bedrock-agentcore:REGION:ACCOUNT_ID:token-vault/default"] }
]
},
{
"Name": "OrgTrail-AgentCore-OAuth2CredentialProvider",
"FieldSelectors": [
{ "Field": "eventCategory", "Equals": ["Data"] },
{ "Field": "resources.type", "Equals": ["AWS::BedrockAgentCore::OAuth2CredentialProvider"] },
{ "Field": "resources.ARN", "StartsWith": ["arn:aws:bedrock-agentcore:REGION:ACCOUNT_ID:token-vault/default/oauth2credentialprovider/PROVIDER_NAME"] }
]
},
{
"Name": "OrgTrail-AgentCore-APIKeyCredentialProvider",
"FieldSelectors": [
{ "Field": "eventCategory", "Equals": ["Data"] },
{ "Field": "resources.type", "Equals": ["AWS::BedrockAgentCore::APIKeyCredentialProvider"] },
{ "Field": "resources.ARN", "StartsWith": ["arn:aws:bedrock-agentcore:REGION:ACCOUNT_ID:token-vault/default/apikeycredentialprovider/PROVIDER_NAME"] }
]
},
{
"Name": "OrgTrail-AgentCore-Memory",
"FieldSelectors": [
{ "Field": "eventCategory", "Equals": ["Data"] },
{ "Field": "resources.type", "Equals": ["AWS::BedrockAgentCore::Memory"] },
{ "Field": "resources.ARN", "StartsWith": ["arn:aws:bedrock-agentcore:REGION:ACCOUNT_ID:memory/MEMORY_ID"] }
]
},
{
"Name": "OrgTrail-AgentCore-Evaluator",
"FieldSelectors": [
{ "Field": "eventCategory", "Equals": ["Data"] },
{ "Field": "resources.type", "Equals": ["AWS::BedrockAgentCore::Evaluator"] },
{ "Field": "resources.ARN", "StartsWith": ["arn:aws:bedrock-agentcore:REGION:ACCOUNT_ID:evaluator/EVALUATOR_ID"] }
]
},
{
"Name": "OrgTrail-S3-AI-WriteOnly",
"FieldSelectors": [
{ "Field": "eventCategory", "Equals": ["Data"] },
{ "Field": "resources.type", "Equals": ["AWS::S3::Object"] },
{ "Field": "readOnly", "Equals": ["false"] },
{
"Field": "resources.ARN",
"StartsWith": [
"arn:aws:s3:::ai-",
"arn:aws:s3:::model-",
"arn:aws:s3:::training-"
]
}
]
},
{
"Name": "OrgTrail-Lambda-ProdAI",
"FieldSelectors": [
{ "Field": "eventCategory", "Equals": ["Data"] },
{ "Field": "resources.type", "Equals": ["AWS::Lambda::Function"] },
{
"Field": "resources.ARN",
"StartsWith": ["arn:aws:lambda:REGION:ACCOUNT_ID:function:prod-"]
}
]
},
{
"Name": "OrgTrail-Network-BedrockDenied",
"FieldSelectors": [
{ "Field": "eventCategory", "Equals": ["NetworkActivity"] },
{ "Field": "eventSource", "Equals": ["bedrock.amazonaws.com"] },
{ "Field": "errorCode", "Equals": ["VpceAccessDenied"] }
]
},
{
"Name": "OrgTrail-Network-S3Denied",
"FieldSelectors": [
{ "Field": "eventCategory", "Equals": ["NetworkActivity"] },
{ "Field": "eventSource", "Equals": ["s3.amazonaws.com"] },
{ "Field": "errorCode", "Equals": ["VpceAccessDenied"] }
]
},
{
"Name": "OrgTrail-Network-LambdaDenied",
"FieldSelectors": [
{ "Field": "eventCategory", "Equals": ["NetworkActivity"] },
{ "Field": "eventSource", "Equals": ["lambda.amazonaws.com"] },
{ "Field": "errorCode", "Equals": ["VpceAccessDenied"] }
]
}
]

Security Analytics for Your AI Workloads

The previous sections configured what CloudTrail captures — event selectors, resource types, and delivery to CloudWatch Logs. This section shifts from enablement to detection: the queries below surface the security signals buried in those events, from unintended access attempts and guardrail modification to agent credential access and gateway authentication failures.

CloudWatch Logs Insights supports OpenSearch SQL syntax, enabling complex JOINs across log groups, sub-queries for cross-service correlation, and a rich set of SQL functions for time-based and aggregation analysis. All queries below are specifically scoped to the AI workload use case. The queries cover management events, data events (agent invocations, knowledge base retrievals, flow invocations, AgentCore gateway traffic, built-in tool usage, credential access, memory operations), network activity events (VPC endpoint denials), and cross-service correlation for agent-to-resource access patterns.

Replace log group names in all queries

All queries use YOUR_CLOUDTRAIL_LOG_GROUP as a placeholder. Replace it with the name of the CloudWatch Logs log group where your CloudTrail trail delivers events (e.g., aws-cloudtrail-logs/management-events). You can find this in the CloudTrail console under your trail's CloudWatch Logs configuration. Cross-pipeline queries also reference bedrock-model-invocation-logging and aws/spans — replace those if your log groups use different names.

Important

When using OpenSearch SQL syntax in CloudWatch Logs Insights, enclose fields with special characters in backticks. For example: `userIdentity.arn`, `responseElements.ConsoleLogin`. Set the query language to SQL when creating these query widgets in your dashboard.

Query 1: Detect Unauthorized Bedrock Access (Management and Data Events)

Surfaces all IAM identities receiving AccessDenied or UnauthorizedOperation errors against Bedrock APIs

Surfaces all IAM identities receiving AccessDenied or UnauthorizedOperation errors against Bedrock APIs across both management events (model invocations) and data events (agent, knowledge base, flow, guardrail operations), ranked by frequency. A high count from an unfamiliar identity is an indicator of unintended access attempts.

Query 1: Detect Unauthorized Bedrock Access
GROUP BY `userIdentity.arn`, eventName, errorCode, errorMessage, sourceIPAddress
ORDER BY attempt_count DESC

Query 2: Monitor Bedrock Agent Invocations by IAM Identity

Tracks which IAM identities are triggering Bedrock agent and inline agent invocations

Tracks which IAM identities are triggering Bedrock agent and inline agent invocations. Agents chain multiple downstream API calls per invocation — an unfamiliar identity or volume spike here has a high scope of access. This query targets data events captured by the AWS::Bedrock::AgentAlias and AWS::Bedrock::InlineAgent advanced event selectors.

Query 2: Bedrock Agent Invocations by IAM Identity
SELECT `userIdentity.arn` AS iam_identity,
eventName,
sourceIPAddress,
awsRegion,
COUNT(*) AS agent_invocation_count
FROM `YOUR_CLOUDTRAIL_LOG_GROUP`
WHERE eventSource = 'bedrock.amazonaws.com'
AND eventName IN ('InvokeAgent', 'InvokeInlineAgent')
GROUP BY `userIdentity.arn`, eventName, sourceIPAddress, awsRegion
ORDER BY agent_invocation_count DESC

Query 3: Monitor Knowledge Base Retrieval Activity by IAM Identity

Ranks which IAM identities are making Retrieve and RetrieveAndGenerate calls against Bedrock Knowledge Bases

Ranks which IAM identities are making Retrieve and RetrieveAndGenerate calls against Bedrock Knowledge Bases. Knowledge bases contain your organization's proprietary data — an unfamiliar identity or unexpected volume spike may indicate anomalous data access. This query targets data events captured by the AWS::Bedrock::KnowledgeBase advanced event selector.

Query 3: Knowledge Base Retrieval Activity
SELECT `userIdentity.arn` AS iam_identity,
eventName,
sourceIPAddress,
COUNT(*) AS retrieval_count
FROM `YOUR_CLOUDTRAIL_LOG_GROUP`
WHERE eventSource = 'bedrock.amazonaws.com'
AND eventName IN ('Retrieve', 'RetrieveAndGenerate')
GROUP BY `userIdentity.arn`, eventName, sourceIPAddress
ORDER BY retrieval_count DESC

Query 4: Detect Agent Cross-Service Access Denied

Surfaces assumed roles being denied access to downstream services like S3, Lambda, KMS, Secrets Manager, or SageMaker

Surfaces assumed roles — typically Bedrock agent execution roles — that are being denied access when attempting to reach Amazon S3, Lambda, KMS, Secrets Manager, or SageMaker. This is the key query for detecting agent-to-resource access control exceptions. A high count from a single role indicates either a misconfigured agent permission boundary or an agent accessing resources outside its intended scope. (Implements the Agentic AI Security Scoping Matrix Identity dimension — detecting the Confused Deputy Problem — and the Scope dimension — enforcing operational boundaries. Also implements the Generative AI Security Scoping Matrix Controls dimension — least privilege access enforcement.)

Query 4: Agent Cross-Service Access Denied
SELECT `userIdentity.arn` AS iam_identity,
eventSource,
eventName,
errorCode,
errorMessage,
sourceIPAddress,
COUNT(*) AS denied_count
FROM `YOUR_CLOUDTRAIL_LOG_GROUP`
WHERE errorCode IN ('AccessDenied', 'UnauthorizedOperation')
AND `userIdentity.type` = 'AssumedRole'
AND eventSource IN (
's3.amazonaws.com',
'lambda.amazonaws.com',
'kms.amazonaws.com',
'secretsmanager.amazonaws.com',
'sagemaker.amazonaws.com'
)
GROUP BY `userIdentity.arn`, eventSource, eventName, errorCode, errorMessage, sourceIPAddress
ORDER BY denied_count DESC

Query 6: Detect Bedrock Calls from Unexpected Source IPs

Lists all unique source IP addresses making Bedrock and AgentCore calls

Lists all unique source IP addresses making Bedrock and AgentCore calls — including model invocations, agent invocations, knowledge base retrievals, flow invocations, async invocations, guardrail applications, and AgentCore gateway invocations. If your AI workloads should only originate from specific CIDR ranges (VPC NAT gateway, corporate network), an unfamiliar IP address should be investigated to confirm it is authorized.

Query 6: Bedrock Calls from Unexpected Source IPs
SELECT sourceIPAddress,
`userIdentity.arn` AS iam_identity,
eventSource,
eventName,
COUNT(*) AS call_count
FROM `YOUR_CLOUDTRAIL_LOG_GROUP`
WHERE eventSource IN ('bedrock.amazonaws.com', 'bedrock-agentcore.amazonaws.com')
AND eventName IN ('InvokeModel', 'InvokeModelWithResponseStream',
'Converse', 'ConverseStream',
'InvokeAgent', 'InvokeInlineAgent',
'Retrieve', 'RetrieveAndGenerate',
'InvokeFlow', 'ApplyGuardrail',
'InvokeModelWithBidirectionalStream',
'GetAsyncInvoke', 'StartAsyncInvoke',
'RenderPrompt', 'InvokeGateway')
GROUP BY sourceIPAddress, `userIdentity.arn`, eventSource, eventName
ORDER BY call_count DESC

Query 10: Root Account Activity Detection

Returns all non-login events performed by the root account

Returns all non-login events performed by the root account. Root usage outside of emergency access scenarios is a key security event.

Query 10: Root Account Activity Detection
SELECT eventTime,
eventName,
eventSource,
sourceIPAddress,
awsRegion,
errorCode
FROM `YOUR_CLOUDTRAIL_LOG_GROUP`
WHERE `userIdentity.type` = 'Root'
AND eventName != 'ConsoleLogin'
ORDER BY eventTime DESC

Query 23: Monitor Bedrock Session Activity

Tracks session-level API activity for multi-turn Bedrock conversations

Surfaces all session operations across Bedrock, including session creation, updates, and retrievals. Sessions maintain state across multi-turn conversations — an unfamiliar identity creating or accessing sessions may indicate anomalous use of conversational AI resources. (Implements the Agentic AI Security Scoping Matrix Orchestration dimension — agent-to-system interaction management and session flow control.)

Query 23: Bedrock Session Activity
SELECT `userIdentity.arn` AS iam_identity,
eventName,
`resources.0.ARN` AS sessionArn,
sourceIPAddress,
awsRegion,
COUNT(*) AS session_operation_count
FROM `YOUR_CLOUDTRAIL_LOG_GROUP`
WHERE eventSource = 'bedrock.amazonaws.com'
AND `resources.0.type` = 'AWS::Bedrock::Session'
GROUP BY `userIdentity.arn`, eventName, `resources.0.ARN`, sourceIPAddress, awsRegion
ORDER BY session_operation_count DESC

Query 24: Monitor Bedrock Flow Execution Activity

Tracks flow execution operations for monitoring prompt flow runs

Flow executions represent active runs of Bedrock Prompt Flows — multi-step AI pipelines that chain model calls, data transformations, and conditional logic. An unexpected flow execution from an unfamiliar identity or a volume spike may indicate anomalous orchestration activity. (Implements the Agentic AI Security Scoping Matrix Orchestration dimension — execution flow control and agent-to-system interaction management.)

Query 24: Bedrock Flow Execution Activity
SELECT `userIdentity.arn` AS iam_identity,
eventName,
`resources.0.ARN` AS flowExecutionArn,
sourceIPAddress,
awsRegion,
errorCode,
COUNT(*) AS execution_count
FROM `YOUR_CLOUDTRAIL_LOG_GROUP`
WHERE eventSource = 'bedrock.amazonaws.com'
AND `resources.0.type` = 'AWS::Bedrock::FlowExecution'
GROUP BY `userIdentity.arn`, eventName, `resources.0.ARN`, sourceIPAddress, awsRegion, errorCode
ORDER BY execution_count DESC

Query 25: Monitor Bedrock Data Automation Activity

Tracks data automation project and invocation activity for document and media processing

Bedrock Data Automation processes documents, images, and media through AI pipelines. Unintended invocations may process documents or move data outside intended boundaries through automation workflows. This query surfaces all data automation activity across projects and invocations. (Implements the Generative AI Security Scoping Matrix Governance & Compliance dimension — audit trail for data processing operations and data sovereignty.)

Query 25: Bedrock Data Automation Activity
SELECT `userIdentity.arn` AS iam_identity,
eventName,
`resources.0.type` AS resourceType,
`resources.0.ARN` AS resourceArn,
sourceIPAddress,
errorCode,
COUNT(*) AS automation_count
FROM `YOUR_CLOUDTRAIL_LOG_GROUP`
WHERE eventSource = 'bedrock.amazonaws.com'
AND `resources.0.type` IN (
'AWS::Bedrock::DataAutomationProject',
'AWS::Bedrock::DataAutomationInvocation',
'AWS::Bedrock::DataAutomationProfile'
)
GROUP BY `userIdentity.arn`, eventName, `resources.0.type`, `resources.0.ARN`, sourceIPAddress, errorCode
ORDER BY automation_count DESC

Query 26: Monitor Bedrock Tool Invocations

Tracks Bedrock tool API activity for tool-use operations

Bedrock Tool events capture when models invoke tools during conversations — these are the actions models take in the real world through tool-use. An unexpected tool invocation pattern or unfamiliar caller indicates a model operating outside its intended scope. (Implements the Agentic AI Security Scoping Matrix Guardrails dimension — behavioral monitoring for tool-use actions — and the Scope dimension — enforcing operational boundaries on what tools models can invoke.)

Query 26: Bedrock Tool Invocations
SELECT `userIdentity.arn` AS iam_identity,
eventName,
`resources.0.ARN` AS toolArn,
sourceIPAddress,
COUNT(*) AS tool_invocation_count
FROM `YOUR_CLOUDTRAIL_LOG_GROUP`
WHERE eventSource = 'bedrock.amazonaws.com'
AND `resources.0.type` = 'AWS::Bedrock::Tool'
GROUP BY `userIdentity.arn`, eventName, `resources.0.ARN`, sourceIPAddress
ORDER BY tool_invocation_count DESC

Cross-Pipeline Correlation Queries

The queries above operate on CloudTrail alone. The queries below join CloudTrail with Bedrock Model Invocation Logging and ADOT spans to answer questions that no single pipeline can answer on its own.

Prerequisites

These queries require all three pipelines enabled:

  • CloudTrail delivering to YOUR_CLOUDTRAIL_LOG_GROUP with Bedrock and AgentCore management and data events
  • Bedrock Model Invocation Logging enabled, delivering to bedrock-model-invocation-logging
  • Agent Telemetry (ADOT SDK) flowing to aws/spans
  • Query language set to SQL when creating these widgets (all correlation queries use OpenSearch SQL)

Correlation Keys

JoinKey FieldNotes
CloudTrail ↔ Model Invocation LoggingrequestID (CT) = requestId (Invocation Log)Same Bedrock API call, different views
CloudTrail ↔ ADOT spansrequestID (CT) = attributes.aws.request_id (span)Both reference the same Bedrock request
ADOT spans ↔ Model Invocation Loggingattributes.aws.request_id (span) = requestId (Invocation Log)Same model call, spans include latency, MIL includes content
Across agent sessionsattributes.session.id (spans)Agent framework sets session; not in CloudTrail or MIL
Expand each query

Click on any query title below to expand it and view the full description, metadata, and SQL statement.

Query 18: Who Asked What, and What Did the Model Say?

Joins CloudTrail caller identity with Bedrock Model Invocation Logging prompt and response content
  • Purpose: Joins CloudTrail (caller identity, source IP) with Bedrock Model Invocation Logging (prompt and response content) on requestId. This is a frequently used query for answering "who asked the model what, and what did it say?" — the foundation for security audit, compliance reviews, and hallucination investigations. Example: a customer reports an offensive model response; this query gives you the caller's IAM role, source IP, the exact prompt sent, the inference parameters used, and the response in one row. (Implements the Generative AI Security Scoping Matrix Governance & Compliance dimension — audit trail to support your data sovereignty and compliance review processes — and the Agentic AI Security Scoping Matrix Audit & Logging dimension — action-level action tracking with identity context.)
  • Source: YOUR_CLOUDTRAIL_LOG_GROUP + bedrock-model-invocation-logging
  • View: Table
  • Query Language: OpenSearch SQL
Query 18: Who Asked What, and What Did the Model Say?
SELECT
ct.eventTime AS timestamp,
ct.`userIdentity.arn` AS caller,
ct.sourceIPAddress AS sourceIP,
ct.eventName AS api,
ct.`userIdentity.inScopeOf.credentialsIssuedTo` AS lambdaFunction,
ct.requestID AS requestId,
ct.`additionalEventData.inputTokens` AS inputTokens,
ct.`additionalEventData.outputTokens` AS outputTokens,
inv.`input.inputBodyJson.messages.0.content.0.text` AS prompt,
inv.`input.inputBodyJson.inferenceConfig.temperature` AS temperature,
inv.`input.inputBodyJson.inferenceConfig.maxTokens` AS maxTokens,
inv.`output.outputBodyJson.stopReason` AS stopReason,
inv.`output.outputBodyJson.output.message.content.0.text` AS response,
inv.`output.outputBodyJson.usage.cacheReadInputTokens` AS cacheReadTokens,
inv.`output.outputBodyJson.usage.cacheCreationInputTokens` AS cacheWriteTokens,
inv.inferenceRegion
FROM `YOUR_CLOUDTRAIL_LOG_GROUP` AS ct
LEFT OUTER JOIN `bedrock-model-invocation-logging` AS inv
ON ct.requestID = inv.requestId
WHERE ct.eventSource = 'bedrock.amazonaws.com'
AND ct.eventName IN ('InvokeModel', 'InvokeModelWithResponseStream',
'Converse', 'ConverseStream')
ORDER BY ct.eventTime DESC
LIMIT 20

Query 19: Agent Session Performance with Caller Identity

Joins ADOT spans with CloudTrail to link agent session performance to caller identity
  • Purpose: Joins ADOT spans (session.id, latency, token counts) with CloudTrail (caller IAM role, source IP) by requestId. Answers "which IAM identity is behind this agent session, and how is it performing?" Example: the ADOT dashboard shows a slow agent session with p95 latency of 12s; this query reveals it's being triggered by a specific Lambda function or AgentCore runtime calling an expensive model — now you can tune the caller's model selection.
  • Source: aws/spans + YOUR_CLOUDTRAIL_LOG_GROUP
  • View: Table
  • Query Language: OpenSearch SQL
Query 19: Agent Session Performance with Caller Identity
SELECT
spans.`attributes.session.id` AS sessionId,
spans.traceId,
spans.`attributes.gen_ai.request.model` AS model,
spans.durationNano / 1000000 AS latencyMs,
spans.`attributes.gen_ai.usage.input_tokens` AS inputTokens,
spans.`attributes.gen_ai.usage.output_tokens` AS outputTokens,
ct.`userIdentity.arn` AS caller,
ct.sourceIPAddress AS sourceIP,
ct.`userIdentity.inScopeOf.issuerType` AS callerType,
ct.`userIdentity.inScopeOf.credentialsIssuedTo` AS callerResource
FROM `aws/spans` AS spans
LEFT OUTER JOIN `YOUR_CLOUDTRAIL_LOG_GROUP` AS ct
ON spans.`attributes.aws.request_id` = ct.requestID
WHERE spans.`resource.attributes.aws.service.type` = 'gen_ai_agent'
AND spans.`attributes.gen_ai.system` = 'aws.bedrock'
ORDER BY spans.`attributes.session.id`, spans.startTimeUnixNano DESC
LIMIT 50

Query 20: Full Three-Pipeline Join — Session, Content, and Performance

Joins all three log groups on requestId for a unified view of a single model invocation
  • Purpose: Joins all three log groups on requestId to give a single row containing agent session (ADOT), model call content (Model Invocation Logging), and caller identity (CloudTrail). This is a unified view of a single model invocation across the entire telemetry stack. Use for deep event investigations where you need everything — who called, what they asked, what the model said, how long it took, and which agent session it belonged to.
  • Source: YOUR_CLOUDTRAIL_LOG_GROUP + bedrock-model-invocation-logging + aws/spans
  • View: Table
  • Query Language: OpenSearch SQL
Query 20: Full Three-Pipeline Join
SELECT
ct.eventTime AS timestamp,
ct.`userIdentity.arn` AS caller,
ct.sourceIPAddress AS sourceIP,
spans.`attributes.session.id` AS sessionId,
spans.traceId,
spans.durationNano / 1000000 AS latencyMs,
inv.modelId,
inv.`input.inputBodyJson.inferenceConfig.temperature` AS temperature,
inv.`input.inputBodyJson.messages.0.content.0.text` AS prompt,
inv.`output.outputBodyJson.output.message.content.0.text` AS response,
inv.`output.outputBodyJson.stopReason` AS stopReason,
inv.`input.inputTokenCount` AS inputTokens,
inv.`output.outputTokenCount` AS outputTokens
FROM `YOUR_CLOUDTRAIL_LOG_GROUP` AS ct
LEFT OUTER JOIN `bedrock-model-invocation-logging` AS inv
ON ct.requestID = inv.requestId
LEFT OUTER JOIN `aws/spans` AS spans
ON ct.requestID = spans.`attributes.aws.request_id`
WHERE ct.eventSource = 'bedrock.amazonaws.com'
AND ct.eventName IN ('InvokeModel', 'Converse', 'ConverseStream')
ORDER BY ct.eventTime DESC
LIMIT 20

Query 21: Guardrail Modification Correlated with Downstream Model Content

Finds guardrail changes in CloudTrail and correlates them with model responses after the change
  • Purpose: Finds UpdateGuardrail or DeleteGuardrail events in CloudTrail and correlates them with model responses in the window after the change. Detects whether a guardrail modification preceded unvalidated or off-policy model output. Example: a security alert triggers on UpdateGuardrail; this query immediately shows the model responses produced under the weakened guardrail for review. (Implements the Agentic AI Security Scoping Matrix Guardrails dimension — dynamic behavioral monitoring — and the Generative AI Security Scoping Matrix Risk Management dimension — detecting guardrail modification and its downstream impact.)
  • Source: YOUR_CLOUDTRAIL_LOG_GROUP + bedrock-model-invocation-logging
  • View: Table
  • Query Language: OpenSearch SQL
Query 21: Guardrail Modification Correlated with Model Content
SELECT
ct.eventTime AS guardrailChangeTime,
ct.`userIdentity.arn` AS whoChangedGuardrail,
ct.eventName AS changeType,
inv.timestamp AS modelCallTime,
inv.`identity.arn` AS modelCaller,
inv.modelId,
inv.`output.outputBodyJson.stopReason` AS stopReason,
inv.`output.outputBodyJson.output.message.content.0.text` AS response
FROM `YOUR_CLOUDTRAIL_LOG_GROUP` AS ct
LEFT OUTER JOIN `bedrock-model-invocation-logging` AS inv
ON inv.timestamp >= ct.eventTime
WHERE ct.eventSource = 'bedrock.amazonaws.com'
AND ct.eventName IN ('UpdateGuardrail', 'DeleteGuardrail', 'DeleteGuardrailVersion')
ORDER BY ct.eventTime DESC
LIMIT 50

Query 22: Agent Session with Cross-Service Access Denied

Correlates ADOT agent sessions with CloudTrail AccessDenied events from the same assumed role
  • Purpose: Correlates ADOT agent sessions with CloudTrail AccessDenied events from the same assumed role. Answers "which agent sessions triggered a permission error on a downstream service?" Example: your agent returns 5xx responses from a tool; this query shows whether the root cause is IAM denial at the downstream service rather than the tool itself — often a misconfigured agent permission boundary.
  • Source: aws/spans + YOUR_CLOUDTRAIL_LOG_GROUP
  • View: Table
  • Query Language: OpenSearch SQL
Query 22: Agent Session with Cross-Service Access Denied
SELECT
spans.`attributes.session.id` AS sessionId,
spans.`resource.attributes.service.name` AS agentService,
ct.eventTime AS denialTime,
ct.`userIdentity.arn` AS agentRole,
ct.eventSource AS blockedService,
ct.eventName AS blockedAction,
ct.errorCode,
ct.errorMessage
FROM `aws/spans` AS spans
LEFT OUTER JOIN `YOUR_CLOUDTRAIL_LOG_GROUP` AS ct
ON ct.`userIdentity.arn` = spans.`attributes.aws.local.service`
WHERE spans.`resource.attributes.aws.service.type` = 'gen_ai_agent'
AND ct.errorCode IN ('AccessDenied', 'UnauthorizedOperation')
AND ct.`userIdentity.type` = 'AssumedRole'
AND ct.eventSource IN (
's3.amazonaws.com', 'lambda.amazonaws.com',
'kms.amazonaws.com', 'secretsmanager.amazonaws.com',
'sagemaker.amazonaws.com'
)
ORDER BY ct.eventTime DESC
LIMIT 50
Performance Note

Cross-log-group JOINs in CloudWatch Logs Insights SQL may be slow on large datasets. Test with narrow time windows (last 15 minutes, last hour) before scheduling these as dashboard widgets with long time ranges. For continuous correlation, consider exporting all three log groups to a single destination (S3, OpenSearch) and running the joins there.

Metric Filters

Metric filters are designed to extract values from CloudTrail log events and create custom CloudWatch metrics, enabling near real-time alerting without continuous querying. The filter pattern syntax uses JSON property selectors to match specific fields in CloudTrail event records. The filters below are scoped specifically to AI workload security events — detecting unauthorized access to Bedrock resources, agent activity anomalies, guardrail modification, and AI infrastructure configuration changes.

Metric Filter 1: Unauthorized Access to Bedrock Services

Captures AccessDenied and UnauthorizedOperation errors against Bedrock APIs

A sudden increase in denied Bedrock calls from a single identity often indicates repeated unintended access attempts or an agent attempting to access models or knowledge bases outside its authorized scope.

Filter Pattern:

{ ($.eventSource = "bedrock.amazonaws.com") && (($.errorCode = "AccessDenied") || ($.errorCode = "UnauthorizedOperation")) }
  • Metric Namespace: AIWorkloadMetrics
  • Metric Name: BedrockUnauthorizedAccess

Metric Filter 2: Bedrock Agent Invocations

Counts invocations of Bedrock agents and inline agents

Agents can chain multiple API calls across services within a single invocation, making them a high-impact surface. Track this metric to detect unexpected agent activity or volume spikes that may indicate an agent is being triggered by an unrecognized caller.

Filter Pattern:

{ ($.eventSource = "bedrock.amazonaws.com") && ($.eventName = "InvokeAgent" || $.eventName = "InvokeInlineAgent") }
  • Metric Namespace: AIWorkloadMetrics
  • Metric Name: BedrockAgentInvocations

Metric Filter 3: Bedrock Knowledge Base Retrieval Activity

Tracks Retrieve and RetrieveAndGenerate calls against Knowledge Bases

Knowledge bases contain your organization's proprietary data — anomalous retrieval activity may indicate unauthorized data access. Monitor for unexpected identities or volume spikes.

Filter Pattern:

{ ($.eventSource = "bedrock.amazonaws.com") && ($.eventName = "Retrieve" || $.eventName = "RetrieveAndGenerate") }
  • Metric Namespace: AIWorkloadMetrics
  • Metric Name: BedrockKnowledgeBaseRetrievals

Metric Filter 6: Bedrock Model Invocation Volume

Counts all Bedrock model invocation calls for baseline and spike detection

Use this metric to establish a baseline of normal AI model usage and detect volume spikes that may indicate unintended automated activity, unintended credential use, or an agent in an unintended recursive cycle.

Filter Pattern:

{ ($.eventSource = "bedrock.amazonaws.com") && ($.eventName = "InvokeModel" || $.eventName = "InvokeModelWithResponseStream" || $.eventName = "Converse" || $.eventName = "ConverseStream" || $.eventName = "InvokeModelWithBidirectionalStream" || $.eventName = "GetAsyncInvoke" || $.eventName = "StartAsyncInvoke") }
  • Metric Namespace: AIWorkloadMetrics
  • Metric Name: BedrockModelInvocations

Metric Filter 8: Bedrock Flow Invocations

Tracks InvokeFlow calls against Bedrock Prompt Flow aliases

Flows orchestrate multi-step AI pipelines — an unexpected flow invocation from an unfamiliar identity or a unexpected volume change may indicate that an unrecognized identity is triggering your orchestration logic. This is a data event captured by the AWS::Bedrock::FlowAlias advanced event selector.

Filter Pattern:

{ ($.eventSource = "bedrock.amazonaws.com") && ($.eventName = "InvokeFlow") }
  • Metric Namespace: AIWorkloadMetrics
  • Metric Name: BedrockFlowInvocations

Metric Filter 21: Bedrock Session Activity

Counts session-level API operations for multi-turn Bedrock conversations

Sessions maintain state across multi-turn conversations. Track this metric to detect unexpected session creation or access patterns that may indicate unintended use of conversational AI resources. (Implements the Agentic AI Security Scoping Matrix Orchestration dimension — agent-to-system interaction management and session flow control.)

Filter Pattern:

{ ($.eventSource = "bedrock.amazonaws.com") && ($.resources[0].type = "AWS::Bedrock::Session") }
  • Metric Namespace: AIWorkloadMetrics
  • Metric Name: BedrockSessionOperations

Metric Filter 22: Bedrock Flow Execution Activity

Counts flow execution operations for monitoring prompt flow runs

Flow executions represent active runs of multi-step AI pipelines. An unexpected volume change indicates unintended orchestration of your AI pipeline or a flow stuck in a retry loop. (Implements the Agentic AI Security Scoping Matrix Orchestration dimension — execution flow control and agent-to-system interaction management.)

Filter Pattern:

{ ($.eventSource = "bedrock.amazonaws.com") && ($.resources[0].type = "AWS::Bedrock::FlowExecution") }
  • Metric Namespace: AIWorkloadMetrics
  • Metric Name: BedrockFlowExecutions

Metric Filter 23: Bedrock Data Automation Invocations

Counts data automation invocations for document and media processing

Data automation processes documents, images, and media through AI pipelines. Unintended invocations may process documents or move data outside intended boundaries through automation workflows. (Implements the Generative AI Security Scoping Matrix Governance & Compliance dimension — audit trail for data processing operations.)

Filter Pattern:

{ ($.eventSource = "bedrock.amazonaws.com") && ($.resources[0].type = "AWS::Bedrock::DataAutomationInvocation" || $.resources[0].type = "AWS::Bedrock::DataAutomationProject") }
  • Metric Namespace: AIWorkloadMetrics
  • Metric Name: BedrockDataAutomationInvocations

Metric Filter 24: Bedrock Tool Invocations

Counts Bedrock tool API activity for tool-use operations

Tool events capture when models invoke tools during conversations — these are the actions models take in the real world. An unexpected spike indicates a model operating outside its intended scope or an unrecognized caller triggering tool-use. (Implements the Agentic AI Security Scoping Matrix Guardrails dimension — behavioral monitoring for tool-use actions.)

Filter Pattern:

{ ($.eventSource = "bedrock.amazonaws.com") && ($.resources[0].type = "AWS::Bedrock::Tool") }
  • Metric Namespace: AIWorkloadMetrics
  • Metric Name: BedrockToolInvocations

CloudWatch Alarms

Create CloudWatch Alarms on each of the metric filters defined in Section 11. Route alarm notifications through Amazon SNS to your security operations team with appropriate severity tiers. The table below provides recommended thresholds and evaluation periods for each alarm.

These alarms trigger on configuration changes, unauthorized access, and authentication failures — route to your security team via SNS.

Alarm NameMetricThresholdPeriod
Bedrock Unauthorized AccessBedrockUnauthorizedAccess> 55 min
Bedrock Guardrail ModificationBedrockGuardrailChanges> 01 min
Bedrock Logging Config ChangeBedrockLoggingConfigChanges> 01 min
AI Role Permission EscalationAIRolePermissionChanges> 01 min
AI Services VPC Endpoint Access DeniedAIServicesVpceAccessDenied> 05 min
Agent Cross-Service Access DeniedAgentCrossServiceAccessDenied> 105 min
CloudTrail Insights AnomalyCloudTrailInsightsAnomalies> 05 min
CloudTrail Logging DisruptionCloudTrailLoggingDisruption> 01 min
AgentCore Gateway Auth FailuresAgentCoreGatewayAuthFailures> 55 min
AgentCore Credential Access AnomalyAgentCoreCredentialAccess> 505 min
AgentCore Gateway Config ChangeAgentCoreGatewayConfigChanges> 01 min
Automated Reasoning Policy ChangeBedrockAutomatedReasoningChanges> 01 min

Contributor Insights Rules

CloudWatch Contributor Insights is designed to analyze time-series data in near real time to surface the top contributors influencing activity patterns in your CloudWatch Logs log groups. Applied to your CloudTrail log group, Contributor Insights rules continuously identify the top IAM identities, resources, and source IPs driving activity across your AI workload — without requiring manual query execution. The rules below cover every event category the guide captures: management events, data events, network activity events, and security configuration changes.

Important

Contributor Insights rules can only be applied to CloudWatch Logs Standard log class log groups. Verify your CloudTrail delivery log group is set to the Standard class.

Rule 1: Top IAM Identities Invoking Bedrock Models

Ranks which IAM principals are making the most Bedrock model invocation calls

A sudden new identity appearing as a top contributor, or an existing identity with a significant increase, warrants prioritized response.

Rule Name: AI-TopBedrockModelCallers

{
"Schema": { "Name": "CloudWatchLogRule", "Version": 1 },
"AggregateOn": "Count",
"Contribution": {
"Filters": [
{ "Match": "$.eventSource", "In": ["bedrock.amazonaws.com"] },
{
"Match": "$.eventName",
"In": ["InvokeModel", "InvokeModelWithResponseStream",
"Converse", "ConverseStream",
"InvokeModelWithBidirectionalStream",
"GetAsyncInvoke", "StartAsyncInvoke",
"ListAsyncInvokes"]
}
],
"Keys": ["$.userIdentity.arn", "$.eventName"]
},
"LogFormat": "JSON",
"LogGroupNames": ["YOUR_CLOUDTRAIL_LOG_GROUP"]
}

Rule 2: Top IAM Identities Invoking Bedrock Agents

Surfaces which IAM principals are triggering Bedrock agent invocations

Rule Name: AI-TopBedrockAgentCallers

{
"Schema": { "Name": "CloudWatchLogRule", "Version": 1 },
"AggregateOn": "Count",
"Contribution": {
"Filters": [
{ "Match": "$.eventSource", "In": ["bedrock.amazonaws.com"] },
{
"Match": "$.eventName",
"In": ["InvokeAgent", "InvokeInlineAgent"]
}
],
"Keys": ["$.userIdentity.arn", "$.eventName", "$.sourceIPAddress"]
},
"LogFormat": "JSON",
"LogGroupNames": ["YOUR_CLOUDTRAIL_LOG_GROUP"]
}

Rule 3: Top IAM Identities Retrieving from Knowledge Bases

Ranks which IAM principals are retrieving from Bedrock Knowledge Bases

Rule Name: AI-TopKnowledgeBaseCallers

{
"Schema": { "Name": "CloudWatchLogRule", "Version": 1 },
"AggregateOn": "Count",
"Contribution": {
"Filters": [
{ "Match": "$.eventSource", "In": ["bedrock.amazonaws.com"] },
{
"Match": "$.eventName",
"In": ["Retrieve", "RetrieveAndGenerate"]
}
],
"Keys": ["$.userIdentity.arn", "$.eventName", "$.sourceIPAddress"]
},
"LogFormat": "JSON",
"LogGroupNames": ["YOUR_CLOUDTRAIL_LOG_GROUP"]
}

Rule 4: Top IAM Identities Invoking Bedrock Flows

Tracks which IAM principals are triggering Bedrock Prompt Flow invocations

Rule Name: AI-TopBedrockFlowCallers

{
"Schema": { "Name": "CloudWatchLogRule", "Version": 1 },
"AggregateOn": "Count",
"Contribution": {
"Filters": [
{ "Match": "$.eventSource", "In": ["bedrock.amazonaws.com"] },
{ "Match": "$.eventName", "In": ["InvokeFlow"] }
],
"Keys": ["$.userIdentity.arn", "$.sourceIPAddress"]
},
"LogFormat": "JSON",
"LogGroupNames": ["YOUR_CLOUDTRAIL_LOG_GROUP"]
}

Rule 19: Top IAM Identities by Bedrock Session Activity

Surfaces which IAM principals are creating and accessing Bedrock sessions

Rule Name: AI-TopBedrockSessionCallers

{
"Schema": { "Name": "CloudWatchLogRule", "Version": 1 },
"AggregateOn": "Count",
"Contribution": {
"Filters": [
{ "Match": "$.eventSource", "In": ["bedrock.amazonaws.com"] },
{ "Match": "$.resources[0].type", "In": ["AWS::Bedrock::Session"] }
],
"Keys": ["$.userIdentity.arn", "$.eventName", "$.sourceIPAddress"]
},
"LogFormat": "JSON",
"LogGroupNames": ["YOUR_CLOUDTRAIL_LOG_GROUP"]
}

Rule 20: Top IAM Identities by Bedrock Flow Execution Activity

Surfaces which IAM principals are running Bedrock flow executions

Rule Name: AI-TopBedrockFlowExecutionCallers

{
"Schema": { "Name": "CloudWatchLogRule", "Version": 1 },
"AggregateOn": "Count",
"Contribution": {
"Filters": [
{ "Match": "$.eventSource", "In": ["bedrock.amazonaws.com"] },
{ "Match": "$.resources[0].type", "In": ["AWS::Bedrock::FlowExecution"] }
],
"Keys": ["$.userIdentity.arn", "$.eventName", "$.sourceIPAddress"]
},
"LogFormat": "JSON",
"LogGroupNames": ["YOUR_CLOUDTRAIL_LOG_GROUP"]
}

Rule 21: Top IAM Identities by Bedrock Data Automation Activity

Surfaces which IAM principals are invoking Bedrock data automation for document and media processing

Rule Name: AI-TopBedrockDataAutomationCallers

{
"Schema": { "Name": "CloudWatchLogRule", "Version": 1 },
"AggregateOn": "Count",
"Contribution": {
"Filters": [
{ "Match": "$.eventSource", "In": ["bedrock.amazonaws.com"] },
{
"Match": "$.resources[0].type",
"In": [
"AWS::Bedrock::DataAutomationProject",
"AWS::Bedrock::DataAutomationInvocation",
"AWS::Bedrock::DataAutomationProfile"
]
}
],
"Keys": ["$.userIdentity.arn", "$.resources[0].type", "$.eventName"]
},
"LogFormat": "JSON",
"LogGroupNames": ["YOUR_CLOUDTRAIL_LOG_GROUP"]
}

Rule 22: Top IAM Identities by Bedrock Tool Invocations

Surfaces which IAM principals are triggering Bedrock tool-use operations

Rule Name: AI-TopBedrockToolCallers

{
"Schema": { "Name": "CloudWatchLogRule", "Version": 1 },
"AggregateOn": "Count",
"Contribution": {
"Filters": [
{ "Match": "$.eventSource", "In": ["bedrock.amazonaws.com"] },
{ "Match": "$.resources[0].type", "In": ["AWS::Bedrock::Tool"] }
],
"Keys": ["$.userIdentity.arn", "$.eventName", "$.sourceIPAddress"]
},
"LogFormat": "JSON",
"LogGroupNames": ["YOUR_CLOUDTRAIL_LOG_GROUP"]
}

CloudTrail Data Event Aggregation

Event Aggregation is designed to consolidate data events into 5-minute summaries, providing visibility into key trends such as access frequency, error rates, and most frequently used API actions. This significantly reduces the volume of data transmitted to downstream analysis systems while preserving the recommended insights needed for security monitoring and trend analysis. Aggregated events use the eventCategory = Aggregated and eventType = AwsAggregatedEvent fields in the aggregated event record.

Enabling Aggregation

Navigate to the CloudTrail console and select your trail. Under the Aggregated Events section, choose Edit and enable the following aggregation templates:

  • API Activity — 5-minute summary of data events based on API calls made, including frequency, top callers, and source IP distribution
  • Resource Access — Activity patterns on your AWS resources showing who is accessing which resources and how many times
  • User Actions — Activity patterns based on IAM principals making API calls, useful for identifying behavioral anomalies

Querying CloudTrail Aggregated Events

Aggregated events are delivered alongside standard events in your CloudWatch Logs log group with eventCategory = 'Aggregated'. Use the following OpenSearch SQL query to surface aggregated Bedrock API activity summaries:

Query: Aggregated Bedrock API Activity
SELECT eventTime,
eventSource,
`summary.primaryDimension.dimension` AS primary_dimension,
`timeWindow.windowStart` AS window_start,
`timeWindow.windowEnd` AS window_end
FROM `YOUR_CLOUDTRAIL_LOG_GROUP`
WHERE eventCategory = 'Aggregated'
AND eventSource = 'bedrock.amazonaws.com'
ORDER BY eventTime DESC

Subscription Filter for Downstream Efficiency

To reduce the volume sent to downstream systems such as a SIEM or Kinesis Data Firehose, create a CloudWatch Logs Subscription Filter that forwards only management events and aggregated summaries instead of raw data events. This reduces downstream ingestion volume while maintaining recommended security insights from the 5-minute aggregated summaries.

Subscription Filter Pattern (management + aggregated events only):

{ ($.eventCategory = "Management") || ($.eventCategory = "Aggregated") }

Unified Audit & Monitoring Dashboard

Build a unified CloudWatch dashboard that combines the security/audit surface (CloudTrail) with operational monitoring (Bedrock Model Invocation Logging and Agent Telemetry (ADOT SDK)) into a centralized view. The layout below organizes widgets by audience — security/audit on the left, operational monitoring in the middle, cost/FinOps on the right — and tiers them from high-level status indicators to detailed investigation queries.

Dashboard Name

Create the dashboard with the name AI-Workload-Security-Dashboard in your primary monitoring region.

AI-Workload-Security-Dashboard

Pro Tip

For Logs Insights widgets, select SQL or CWLI as the query language depending on the query source. Cross-log-group JOIN queries (from Cross-Pipeline Correlation Queries) must use SQL. Single-log-group queries can use either.

Row 1 — High-level health and key counters.

WidgetWidget TypeData Source
Alarm Status GridAlarm StatusAll metric filter alarms from CloudWatch Alarms
Bedrock Model Invocations CountNumber (Metric)AIWorkloadMetrics/BedrockModelInvocations
Total Bedrock SpendSingle value (Logs)Model Invocation Log — total cost query (FinOps dashboard)
Agent Cross-Service Denied CountNumber (Metric)AIWorkloadMetrics/AgentCrossServiceAccessDenied
note

Rows 5-7 use queries from the companion Custom Dashboards for GenAI Telemetry guide. Use those queries directly rather than duplicating them here.

Conclusion and Next Steps

This guide covered the end-to-end monitoring and auditing architecture for AI workloads on AWS — the three telemetry pipelines, enablement for each, CloudTrail-specific detection (metric filters, alarms, Contributor Insights) for both Bedrock and AgentCore data events, cross-pipeline correlation queries that join CloudTrail with Bedrock Model Invocation Logging and ADOT spans, and a unified CloudWatch dashboard. Each section is designed to be implemented incrementally following the phased roadmap in the Implementation Overview.

The core idea: CloudTrail alone shows who did what, Model Invocation Logging shows what the model said, and ADOT shows how the agent performed. With AgentCore data events, CloudTrail now also shows what the agent actually did — which tools it invoked, which credentials it accessed, which gateways received traffic, and what it stored in memory. The value comes from joining these signals during investigations — no single pipeline answers every question.

Together, these capabilities provide concrete implementation for the security dimensions defined in the Generative AI Security Scoping Matrix and the Agentic AI Security Scoping Matrix.

Next Steps

  1. Start with Phase 1. Enable all three telemetry pipelines. The other two (Model Invocation Logging, ADOT) which makes the correlation queries possible.
  2. Enable CloudTrail Bedrock data events. A critical step for auditing AI workloads.
  3. Enable CloudTrail AgentCore data events. Start with Gateway and credential access (Groups 2 and 3), then expand to built-in tools and memory (Groups 1 and 4) after establishing baseline volume.
  4. Validate your baseline. Run Queries 2 and 4 from Security Analytics and Queries 12-14 from the AgentCore tab in Security Analytics to establish normal usage before setting alarm thresholds.
  5. Automate response. Connect your CloudWatch Alarms to Amazon SNS topics, AWS Lambda functions, or Systems Manager runbooks to close the gap between detection and remediation.
  6. Integrate with GuardDuty. Amazon GuardDuty provides managed threat detection that complements the custom monitoring here. GuardDuty analyzes CloudTrail events for known threat patterns without requiring you to maintain detection rules.
  7. Review costs. Data events, Insights analysis, and network activity events all incur charges. Use the CloudTrail pricing page and the volume reduction strategies in Optimizing Data Event Collection.

Companion Guides