AWS Amplify is integrated with Amazon CloudWatch, enabling you to monitor metrics for your Amplify applications in near real-time. You can create alarms that send notifications when a metric exceeds a threshold you set. For more information about how the CloudWatch service works, see the Amazon CloudWatch User Guide.
Supported CloudWatch metrics
Amplify supports six CloudWatch metrics in the AWS/AmplifyHosting
namespace for monitoring traffic, errors, data transfer, and latency for your apps.
These metrics are aggregated at one minute intervals. CloudWatch monitoring metrics are free
of charge and don't count against the CloudWatch service
quotas.
Not all available statistics are applicable for every metric. The following table lists the most relevant statistics with a description for each supported metric.
Metrics | Description |
---|---|
Requests |
The total number of viewer requests received by your app. The most relevant statistic is |
BytesDownloaded |
The total amount of data transferred out of your app (downloaded) in
bytes by viewers for The most relevant statistic is |
BytesUploaded |
The total amount of data transferred into your app (uploaded) in bytes for any request, including headers. Amplify doesn't charge you for data uploaded in your applications. The most relevant statistic is |
4xxErrors |
The number of requests that returned an error in the HTTP status code 400-499 range. The most relevant statistic is |
5xxErrors |
The number of requests that returned an error in the HTTP status code 500-599 range. The most relevant statistic is |
Latency |
The time to first byte in seconds. This is the total time between when Amplify Hosting receives a request and when it returns a response to the network. This doesn't include the network latency encountered for a response to reach the viewer's device. The most relevant statistics are Use the |
Amplify provides the following CloudWatch metric dimensions.
Dimension | Description |
---|---|
App |
Metric data is provided by app. |
AWS account |
Metric data is provided across all apps in the AWS account. |
Accessing CloudWatch metrics
You can access CloudWatch metrics directly from the Amplify console using the following procedure.
Note
You can also access CloudWatch metrics in the AWS Management Console at https://console.aws.amazon.com/cloudwatch/
To access metrics in the Amplify console
-
Sign in to the AWS Management Console and open the Amplify console
. -
Choose the app that you want to view metrics for.
-
In the navigation pane, choose App Settings, Monitoring.
-
On the Monitoring page, choose Metrics.
Creating CloudWatch alarms
You can create CloudWatch alarms in the Amplify console that send notifications when specific criteria are met. An alarm watches a single CloudWatch metric and sends an Amazon Simple Notification Service notification when the metric breaches the threshold for a specified number of evaluation periods.
You can create more advanced alarms that use metric math expressions in the CloudWatch console or using the CloudWatch APIs. For example, you can create an alarm that notifies you when the percentage of 4xxErrors exceeds 15% for three consecutive periods. For more information, see Creating a CloudWatch Alarm Based on a Metric Math Expression in the Amazon CloudWatch User Guide.
Standard CloudWatch pricing applies to alarms. For more information, see Amazon CloudWatch
pricing
Use the following procedure to create an alarm in the Amplify console.
To create a CloudWatch alarm for an Amplify metric
-
Sign in to the AWS Management Console and open the Amplify console
. -
Choose the app that you want to set an alarm on.
-
In the navigation pane, choose App Settings, Monitoring.
-
On the Monitoring page, choose Alarms.
-
Choose Create alarm.
-
In the Create alarm window, configure your alarm as follows:
-
For Metric, choose the name of the metric to monitor from the list.
-
For Name of alarm, enter a meaningful name for the alarm. For example, if you are monitoring Requests, you could name the alarm
HighTraffic
. The name must contain only ASCII characters. -
For Set up notifications, do one of the following:
-
-
Choose New to set up a new Amazon SNS topic.
-
For Email address, enter the email address for the recipient of the notifications.
-
Choose Add new email address to add additional recipients.
-
-
-
Choose Existing to reuse an Amazon SNS topic.
-
For SNS topic, select the name of an existing Amazon SNS topic from the list.
-
-
-
For Whenever the Statistic of Metric, set the conditions for your alarm as follows:
-
Specify whether the metric must be greater than, less than, or equal to the threshold value.
-
Specify the threshold value.
-
Specify the number of consecutive evaluation periods that must be in the alarm state to invoke the alarm.
-
Specify the length of time of the evaluation period.
-
-
Choose Create alarm.
-
Note
Each Amazon SNS recipient that you specify receives a confirmation email from AWS Notifications. The email contains a link that the recipient must follow to confirm their subscription and receive notifications.
Accessing CloudWatch Logs for SSR apps
Amplify sends information about your Next.js runtime to Amazon CloudWatch Logs in your AWS account. When you deploy an SSR app, the app requires an IAM service role that Amplify assumes when calling other services on your behalf. You can either allow Amplify Hosting compute to automatically create a service role for you or you can specify a role that you have created.
If you choose to allow Amplify to create an IAM role for you, the role will already have the permissions to create CloudWatch Logs. If you create your own IAM role, you will need to add the following permissions to your policy to allow Amplify to access Amazon CloudWatch Logs.
logs:CreateLogStream logs:CreateLogGroup logs:DescribeLogGroups logs:PutLogEvents
For more information about service roles, see Adding a service role to an Amplify app. For more information about deploying server-side rendered apps, see Deploying server-side rendered applications with Amplify Hosting.