Setting up CloudWatch metrics and alarms - Amazon Bedrock AgentCore

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

Setting up CloudWatch metrics and alarms

Gateway publishes the following metrics to CloudWatch:

Invocation metrics

These metrics provide information about API invocations, performance, and errors.

For these metrics, the following dimensions are used:

  • Operation: Represents the MCP operation being invoked (e.g., tools/list, tools/call)

  • Resource: Represents the identifier of the resource (ARN)

  • Name: Represents the version of the resource

Invocation metrics
Metric Description Statistics Units
Invocations The total number of requests made to each Data Plane API. Each API call counts as one invocation regardless of the response status. Sum Count
Throttles The number of requests throttled (status code 429) by the service. Sum Count
SystemErrors The number of requests which failed with 5xx status code. Sum Count
UserErrors The number of requests which failed with 4xx status code except 429. Sum Count
Latency The time elapsed between when the service receives the request and when it begins sending the first response token. In other words, initial response time. Average, Minimum, Maximum, p50, p90, p99 Milliseconds
Duration The total time elapsed between receiving the request and sending the final response token. Represents complete end-to-end processing time of the request. Average, Minimum, Maximum, p50, p90, p99 Milliseconds
TargetExecutionTime The total time taken to execute the target over Lambda / OpenAPI / etc. This helps determine the contribution of the target to the total Latency. Average, Minimum, Maximum, p50, p90, p99 Milliseconds

Usage metrics

These metrics provide information about how your gateway is being used.

Usage metrics
Metric Description Statistics Units
TargetType The total number of requests served by each type of target (MCP, Lambda, OpenAPI). Sum Count

To view these metrics in the CloudWatch console:

  1. Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/.

  2. In the navigation pane, choose Metrics.

  3. Choose the BedrockAgentCore namespace.

  4. Choose a dimension to view the metrics (e.g., By Endpoint).

  5. Select the metrics you want to view and choose Add to graph.

Setting up CloudWatch alarms

You can set up CloudWatch alarms to alert you when certain metrics exceed thresholds. For example, you might want to be notified when the error rate exceeds 5% or when the latency exceeds 1 second.

Here's an example of how to create an alarm for high error rates using the AWS CLI:

aws cloudwatch put-metric-alarm \ --alarm-name "HighErrorRate" \ --alarm-description "Alarm when error rate exceeds 5%" \ --metric-name "SystemErrors" \ --namespace "BedrockAgentCore" \ --statistic "Sum" \ --dimensions "Name=Resource,Value=my-gateway-arn" \ --period 300 \ --evaluation-periods 1 \ --threshold 5 \ --comparison-operator "GreaterThanThreshold" \ --alarm-actions "arn:aws:sns:us-west-2:123456789012:my-topic"

This alarm will trigger when the number of system errors exceeds 5 in a 5-minute period. When the alarm triggers, it will send a notification to the specified SNS topic.