SkillSprout
Chapter 8 · Lesson 3
Intermediate
6 min read

Monitoring Amazon Bedrock and AI Workloads

Overview

Generative AI workloads are now ordinary production workloads: an application calls a foundation model through Amazon Bedrock, and operations must keep it available, fast, safe and affordable. The SOA-C03 guide explicitly lists monitoring and logging for AI workloads and includes Bedrock among in-scope services, so you should know the basic operational signals even though model building is out of scope.

The analogy is a call centre that outsources difficult questions to an expert consultant. You track how many calls are made, how long each takes, how many are refused because the consultant is busy, what each call costs, and whether anything confidential was said. Bedrock's metrics, invocation logs, CloudTrail events and guardrails answer those questions.

You are not asked to tune models. You are asked to make AI workloads observable and controlled with the same CloudWatch, CloudTrail, IAM and budgets tooling you already know.

Key Concepts

  • CloudWatch namespace AWS/Bedrock publishes Invocations, InvocationLatency, InvocationClientErrors, InvocationServerErrors, InvocationThrottles, InputTokenCount and OutputTokenCount, dimensioned by ModelId.
  • Model invocation logging (off by default) delivers request and response details to CloudWatch Logs and/or S3; encrypt the destination and restrict access because prompts may contain sensitive data.
  • CloudTrail records Bedrock control-plane and data-plane API calls (who invoked which model) for audit.
  • Throttling (ThrottlingException, InvocationThrottles) occurs when on-demand quotas are exceeded; remedies: retries with exponential backoff, cross-Region inference profiles, quota increases, or Provisioned Throughput.
  • Guardrails for Amazon Bedrock filter harmful content, deny topics, redact PII and check grounding; their intervention counts are monitored.
  • Cost scales with tokens; use application inference profiles with tags for cost allocation, AWS Budgets and alarms on token metrics.
  • IAM: restrict bedrock:InvokeModel to approved model ARNs; model access is enabled per account and Region; use VPC interface endpoints (PrivateLink) to keep traffic private.
  • Agents, knowledge bases and Lambda tools add more components; trace them with X-Ray / OpenTelemetry and monitor the vector store and ingestion jobs.

Detailed Notes

What to monitor

SignalWhereWhy it matters
Request volumeInvocationsCapacity planning, anomaly detection
LatencyInvocationLatency (p90/p99)User experience; time to first token for streaming
ErrorsInvocationClientErrors, InvocationServerErrorsBad prompts, permissions, service issues
ThrottlesInvocationThrottlesQuota exhausted; need backoff or more capacity
TokensInputTokenCount, OutputTokenCountDirect driver of cost
Content safetyGuardrail intervention metrics and logsPolicy enforcement
AuditCloudTrail events (InvokeModel, Converse)Who used which model

Enabling logging

bash
aws bedrock put-model-invocation-logging-configuration --logging-config '{
  "cloudWatchConfig": {"logGroupName": "/bedrock/invocations", "roleArn": "arn:aws:iam::111122223333:role/BedrockLogRole",
                       "largeDataDeliveryS3Config": {"bucketName": "ai-logs-bucket", "keyPrefix": "large"}},
  "s3Config": {"bucketName": "ai-logs-bucket", "keyPrefix": "invocations"},
  "textDataDeliveryEnabled": true, "imageDataDeliveryEnabled": false, "embeddingDataDeliveryEnabled": false }'
aws bedrock get-model-invocation-logging-configuration

Treat these logs as sensitive: encrypt the S3 bucket and log group with KMS, limit access with IAM, set retention, and consider redaction because prompts and completions are stored verbatim when text delivery is enabled.

Alarms and dashboards

bash
aws cloudwatch put-metric-alarm --alarm-name bedrock-throttles \
  --namespace AWS/Bedrock --metric-name InvocationThrottles --dimensions Name=ModelId,Value=anthropic.claude-3-haiku-20240307-v1:0 \
  --statistic Sum --period 60 --evaluation-periods 3 --threshold 5 --comparison-operator GreaterThanThreshold \
  --alarm-actions arn:aws:sns:us-east-1:111122223333:ops-alerts

Create alarms for throttles and server errors, a latency percentile alarm, and an anomaly detection alarm on OutputTokenCount to catch runaway loops that would inflate cost.

Handling throttling and capacity

OptionWhen to use
Retries with exponential backoff and jitter (SDK adaptive mode)First line of defence
Cross-Region inference profilesSpread demand across Regions for higher throughput
Quota increase (Service Quotas)Sustained legitimate growth
Provisioned ThroughputGuaranteed capacity and custom models; priced per model unit hour
Batch inferenceOffline jobs at lower cost
Caching/prompt caching, smaller modelsReduce tokens and latency

Security and governance

json
{ "Effect": "Allow", "Action": ["bedrock:InvokeModel", "bedrock:InvokeModelWithResponseStream"],
  "Resource": "arn:aws:bedrock:us-east-1::foundation-model/anthropic.claude-3-haiku-20240307-v1:0" }
  • Use SCPs or IAM conditions to limit which models and Regions teams may use.
  • Interface VPC endpoints (com.amazonaws.<region>.bedrock-runtime) keep inference traffic off the public internet.
  • Guardrails (content filters, denied topics, word filters, sensitive-information filters, contextual grounding) are applied via a guardrail ID in the request.
  • Tag application inference profiles so Cost Explorer can split spend by team or product.

Operational runbook items

  1. Dashboard: invocations, p99 latency, throttles, tokens per minute, estimated cost.
  2. Alarms: throttles, 5xx, token anomaly, budget threshold.
  3. Logs: invocation logging on in non-sensitive environments, or with redaction and strict access in sensitive ones.
  4. Resilience: fallback model, timeouts, circuit breaker, retry budget.
  5. Audit: CloudTrail data events and periodic IAM Access Analyzer review.

Real World Example

Scenario – chatbot costs spike. A support chatbot built on Bedrock normally uses 40 million tokens a day. One afternoon OutputTokenCount triples and users report slow answers.

An anomaly detection alarm on token metrics notifies the team. Dashboards show InvocationThrottles rising on one model and the invocation logs reveal a retry loop in a new release that re-sent long prompts. They fix the loop, add exponential backoff, switch to a cross-Region inference profile for headroom and set an AWS Budgets alert on the tagged inference profile. Guardrail metrics confirm no policy violations occurred.

Architecture Diagram

Observing a Bedrock-backed application
Architecture
AWS account
App / agentInvokeModel
Amazon Bedrockguardrails
CloudWatchAWS/Bedrock
CloudTrail
Budgets
  1. 1The application calls Bedrock through a VPC endpoint with a least-privilege role.
  2. 2Guardrails filter prompts and responses.
  3. 3Bedrock publishes invocation, latency, throttle and token metrics to CloudWatch.
  4. 4Invocation logs go to encrypted CloudWatch Logs or S3; CloudTrail records API calls.
  5. 5Alarms and Budgets notify operators about throttling, anomalies and cost.

Best Practices

  • ✓Alarm on throttles, server errors, p99 latency and token anomalies per model.
  • ✓Enable model invocation logging only with encryption, access control and retention in place.
  • ✓Implement retries with exponential backoff and jitter, and consider cross-Region inference profiles for capacity.
  • ✓Restrict models and Regions with IAM and SCPs; use VPC endpoints.
  • ✓Tag inference profiles and set Budgets to attribute and cap AI spend.

Common Interview Questions

Exam Tips

SOA-C03 focus

  • Bedrock metrics live in CloudWatch AWS/Bedrock; prompts/responses need model invocation logging (disabled by default).
  • Auditing who called a model -> CloudTrail.
  • Throttling fix -> backoff, cross-Region inference, quota increase, Provisioned Throughput.
  • Private inference traffic -> interface VPC endpoint (PrivateLink); content safety -> Guardrails.

Finished this lesson?

0 of 46 lessons done · 0% of the course