Monitoring Amazon Personalize with Amazon CloudWatch
With Amazon CloudWatch, you can get metrics associated with Amazon Personalize.
You can set up alarms to notify you when one or more of these metrics fall outside a defined
threshold. To see metrics, you can use
Amazon CloudWatch
Topics
Using CloudWatch metrics for Amazon Personalize
To use metrics, you must specify the following information:
-
The metric name.
-
The metric dimension. A dimension is a name-value pair that helps you to uniquely identify a metric.
You can get monitoring data for Amazon Personalize using the AWS Management Console, the AWS CLI, or the CloudWatch API. You can also use the CloudWatch API through one of the AWS SDKs or the CloudWatch API tools. The console displays a series of graphs based on the raw data from the CloudWatch API. Depending on your needs, you might prefer to use either the graphs displayed in the console or retrieved from the API.
The following list shows some common uses for the metrics. These are suggestions to get you started, not a comprehensive list.
How do I? | Relevant metric |
---|---|
How do I track the number of events that have been recorded? |
Monitor the |
How can I monitor the DatasetImportJob errors? |
Use the |
How can I monitor the latency of |
Use the |
You must have the appropriate CloudWatch permissions to monitor Amazon Personalize with CloudWatch. For more information, see Authentication and access control for Amazon CloudWatch.
Accessing Amazon Personalize metrics
The following examples show how to access Amazon Personalize metrics using the CloudWatch console, the AWS CLI, and the CloudWatch API.
To view metrics (console)
-
Sign in to the AWS Management Console and open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/
. -
Choose Metrics, choose the All metrics tab, and then choose
AWS/Personalize
. -
Choose the metric dimension.
-
Choose the desired metric from the list, and choose a time period for the graph.
To view metrics for events received over a period of time (CLI)
-
Open the AWS CLI and enter the following command:
aws cloudwatch get-metric-statistics \ --metric-name PutEventsRequests \ --start-time 2019-03-15T00:00:20Z \ --period 3600 \ --end-time 2019-03-16T00:00:00Z \ --namespace AWS/Personalize \ --dimensions Name=EventTrackerArn,Value=
EventTrackerArn
\ --statistics SumThis example shows the events received for the given event tracker ARN over a period of time. For more information, see get-metric-statistics.
To access metrics (CloudWatch API)
-
Call
GetMetricStatistics
. For more information, see the Amazon CloudWatch API Reference.
Creating an alarm
You can create a CloudWatch alarm that sends an Amazon Simple Notification Service (Amazon SNS) message when the alarm changes state. An alarm watches a single metric over a time period you specify. The alarm performs one or more actions based on the value of the metric relative to a given threshold over a number of time periods. The action is a notification sent to an Amazon SNS topic or an AWS Auto Scaling policy.
Alarms invoke actions for sustained state changes only. CloudWatch alarms do not invoke actions simply because they are in a particular state. The state must have changed and been maintained for a specified number of time periods.
To set an alarm (console)
-
Sign in to the AWS Management Console and open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/
. In the navigation pane, Choose Alarms, and then choose Create alarm. This launches the Create Alarm Wizard.
Choose Select metric.
In the All metrics tab, choose
AWS/Personalize
.-
Choose EventTrackerArn, and then choose PutEventsRequests metrics.
Choose the Graphed metrics tab.
For Statistic choose Sum.
Choose Select metric.
-
Fill in the Name and Description. For Whenever, choose >, and then enter a maximum value of your choice.
-
If you want CloudWatch to send you email when the alarm state is reached, for Whenever this alarm:, choose State is ALARM. To send alarms to an existing Amazon SNS topic, for Send notification to:, choose an existing SNS topic. To set the name and email addresses for a new email subscription list, choose New list. CloudWatch saves the list and displays it in the field so you can use it to set future alarms.
Note
If you use New list to create a new Amazon SNS topic, the email addresses must be verified before the intended recipients receive notifications. Amazon SNS sends email only when the alarm enters an alarm state. If this alarm state change happens before the email addresses are verified, intended recipients do not receive a notification.
-
Choose Create alarm.
To set an alarm (AWS CLI)
-
Open the AWS CLI, and then enter the following command. Change the value of the
alarm-actions
parameter to reference an Amazon SNS topic that you previously created.aws cloudwatch put-metric-alarm \ --alarm-name PersonalizeCLI \ --alarm-description "Alarm when more than 10 events occur" \ --metric-name PutEventsRequests \ --namespace AWS/Personalize \ --statistic Sum \ --period 300 \ --threshold 10 \ --comparison-operator GreaterThanThreshold \ --evaluation-periods 1 \ --unit Count \ --dimensions Name=EventTrackerArn,Value=
EventTrackerArn
\ --alarm-actionsSNSTopicArn
This example shows how to create an alarm for when more than 10 events occur for the given event tracker ARN within 5 minutes. For more information, see put-metric-alarm.
To set an alarm (CloudWatch API)
-
Call
PutMetricAlarm
. For more information, see Amazon CloudWatch API Reference.
Amazon Personalize serverless monitoring app example
For an example app that adds monitoring, alerting, and optimization capabilities
for Amazon Personalize see Amazon Personalize monitor