

# Monitoring the performance of Amazon Bedrock
<a name="monitoring"></a>

You can monitor all parts of your Amazon Bedrock application using Amazon CloudWatch, which collects raw data and processes it into readable, near real-time metrics. You can graph the metrics using the CloudWatch console. You can also set alarms that watch for certain thresholds, and send notifications or take actions when values exceed those thresholds.

For more information, see [What is Amazon CloudWatch](https://docs.aws.amazon.com/AmazonCloudWatch/latest/DeveloperGuide/WhatIsCloudWatch.html) in the *Amazon CloudWatch User Guide*.

Amazon Bedrock provides comprehensive monitoring capabilities across different components of your application:
+ [Monitor model invocation using CloudWatch Logs and Amazon S3](model-invocation-logging.md) - Track and analyze model invocations using CloudWatch Logs and Amazon S3.
+ [Monitor knowledge bases using CloudWatch Logs](knowledge-bases-logging.md) - Monitor knowledge base operations and performance.
+ [Monitor Amazon Bedrock Guardrails using CloudWatch metrics](monitoring-guardrails-cw-metrics.md) - Track guardrail evaluations and policy enforcement.
+ [Monitor Amazon Bedrock Agents using CloudWatch Metrics](monitoring-agents-cw-metrics.md) - Monitor agent invocations and performance metrics.
+ [Amazon Bedrock runtime metrics](#runtime-cloudwatch-metrics) - View key runtime metrics including invocations, latency, errors, and token counts.
+ [Monitor Amazon Bedrock job state changes using Amazon EventBridgeMonitor event changes](monitoring-eventbridge.md) - Track job state changes and automate responses to events.
+ [Monitor Amazon Bedrock API calls using CloudTrail](logging-using-cloudtrail.md) - Audit API calls and track user activity.

**Topics**
+ [Monitor model invocation using CloudWatch Logs and Amazon S3](model-invocation-logging.md)
+ [Monitor knowledge bases using CloudWatch Logs](knowledge-bases-logging.md)
+ [Monitor Amazon Bedrock Guardrails using CloudWatch metrics](monitoring-guardrails-cw-metrics.md)
+ [Monitor Amazon Bedrock Agents using CloudWatch Metrics](monitoring-agents-cw-metrics.md)
+ [Amazon Bedrock runtime metrics](#runtime-cloudwatch-metrics)
+ [Model invocation logging CloudWatch metrics](#br-cloudwatch-metrics)
+ [Monitor Amazon Bedrock job state changes using Amazon EventBridge](monitoring-eventbridge.md)
+ [Monitor Amazon Bedrock API calls using CloudTrail](logging-using-cloudtrail.md)

## Amazon Bedrock runtime metrics
<a name="runtime-cloudwatch-metrics"></a>

The following table describes runtime metrics provided by Amazon Bedrock.


| Metric name | Unit | Description | 
| --- | --- | --- | 
| Invocations | SampleCount | Number of successful requests to the [Converse](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_Converse.html), [ConverseStream](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_ConverseStream.html), [InvokeModel](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_InvokeModel.html), and [InvokeModelWithResponseStream](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_InvokeModelWithResponseStream.html) API operations. | 
| InvocationLatency | MilliSeconds | The time from when a request is sent to when the last token is received.<br />  | 
| InvocationClientErrors | SampleCount | Number of invocations that result in client-side errors. | 
| InvocationServerErrors | SampleCount | Number of invocations that result in AWS server-side errors. | 
| InvocationThrottles | SampleCount | Number of invocations that the system throttled. Throttled requests and other invocation errors don't count as either Invocations or Errors. The number of throttles you see will depend on your retry settings in the SDK. For more information, see [Retry behavior](https://docs.aws.amazon.com/sdkref/latest/guide/feature-retry-behavior.html) in the AWS SDKs and Tools Reference Guide.  | 
| InputTokenCount | SampleCount | Number of tokens in the input. | 
| LegacyModelInvocations | SampleCount | Number of invocations using [Legacy](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_FoundationModelLifecycle.html) models  | 
| OutputTokenCount | SampleCount | Number of tokens in the output. | 
| OutputImageCount | SampleCount | Number of images in the output (only applicable for image generation models). | 
| TimeToFirstToken | MilliSeconds | Time from when a request is sent to when the first token is received, for the [ConverseStream](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_ConverseStream.html) and [InvokeModelWithResponseStream](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_InvokeModelWithResponseStream.html) streaming API operations. | 
| EstimatedTPMQuotaUsage | SampleCount | Estimated Tokens Per Minute (TPM) quota consumption across the [Converse](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_Converse.html), [ConverseStream](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_ConverseStream.html), [InvokeModel](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_InvokeModel.html), and [InvokeModelWithResponseStream](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_InvokeModelWithResponseStream.html) API operations. This metric is an approximation and does not reflect the reservation-based token consumption that drives throttling decisions. Throttling is based on the upfront reservation of input tokens plus `max_tokens` (see [How tokens are counted in Amazon Bedrock](quotas-token-burndown.md)), which may differ from this estimate. Do not use this metric as the sole indicator for quota use or capacity planning. | 
| CacheReadInputTokens | SampleCount | Number of input tokens read from the [prompt cache](prompt-caching.md). These tokens are charged at a reduced rate and don't count toward your TPM quota. | 
| CacheWriteInputTokens | SampleCount | Number of input tokens written to the [prompt cache](prompt-caching.md). These tokens count toward your TPM quota. | 

There are also metrics for [Amazon Bedrock Guardrails](monitoring-guardrails-cw-metrics.md) and [Amazon Bedrock Agents](monitoring-agents-cw-metrics.md).

## Model invocation logging CloudWatch metrics
<a name="br-cloudwatch-metrics"></a>

For each delivery success or failure attempt, the following Amazon CloudWatch metrics are emitted under the namespace `AWS/Bedrock`, and `Across all model IDs` dimension:
+ `ModelInvocationLogsCloudWatchDeliverySuccess`
+ `ModelInvocationLogsCloudWatchDeliveryFailure`
+ `ModelInvocationLogsS3DeliverySuccess`
+ `ModelInvocationLogsS3DeliveryFailure`
+ `ModelInvocationLargeDataS3DeliverySuccess`
+ `ModelInvocationLargeDataS3DeliveryFailure`

To retrieve metrics for your Amazon Bedrock operations, you specify the following information:
+ The metric dimension. A *dimension* is a set of name-value pairs that you use to identify a metric. Amazon Bedrock supports the following dimensions:
  + `ModelId` – all metrics
  + `ModelId + ImageSize + BucketedStepSize` – OutputImageCount
+ The metric name, such as `InvocationClientErrors`. 

You can get metrics for Amazon Bedrock with the AWS Management Console, the AWS CLI, or the CloudWatch API. You can use the CloudWatch API through one of the AWS Software Development Kits (SDKs) or the CloudWatch API tools.

To view Amazon Bedrock metrics in the CloudWatch console, go to the metrics section in the navigation pane and select the all metrics option, then search for the model ID.

You must have the appropriate CloudWatch permissions to monitor Amazon Bedrock with CloudWatch For more information, see [ Authentication and Access Control for Amazon CloudWatch](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/auth-and-access-control-cw.html) in the *Amazon CloudWatch User Guide*.