Monitor predictive scaling metrics with CloudWatch
Depending on your needs, you might prefer to access monitoring data for predictive scaling from Amazon CloudWatch instead of the Amazon EC2 Auto Scaling console. After you create a predictive scaling policy, the policy collects data that is used to forecast your future load and capacity. After this data is collected, it is automatically stored in CloudWatch at regular intervals. Then, you can use CloudWatch to visualize how well the policy performs over time. You can also create CloudWatch alarms to notify you when performance indicators change beyond the limits that you define in CloudWatch.
Visualize historical forecast data
You can view the load and capacity forecast data for a predictive scaling policy in CloudWatch. This can be useful when visualizing forecasts against other CloudWatch metrics in a single graph. It can also help when viewing a broader time range so that you can see trends over time. You can access up to 15 months of historical metrics to get a better perspective on how your policy is performing.
For more information, see Predictive scaling metrics and dimensions.
To view historical forecast data using the CloudWatch console
Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/
. -
In the navigation pane, choose Metrics and then All metrics.
-
Choose the Auto Scaling metric namespace.
-
Choose one of the following options to view either the load forecast or capacity forecast metrics:
-
Predictive Scaling Load Forecasts
-
Predictive Scaling Capacity Forecasts
-
-
In the search field, enter the name of the predictive scaling policy or the name of the Auto Scaling group, and then press Enter to filter the results.
-
To graph a metric, select the check box next to the metric. To change the name of the graph, choose the pencil icon. To change the time range, select one of the predefined values or choose custom. For more information, see Graphing a metric in the Amazon CloudWatch User Guide.
-
To change the statistic, choose the Graphed metrics tab. Choose the column heading or an individual value, and then choose a different statistic. Although you can choose any statistic for each metric, not all statistics are useful for PredictiveScalingLoadForecast and PredictiveScalingCapacityForecast metrics. For example, the Average, Minimum, and Maximum statistics are useful, but the Sum statistic is not.
-
To add another metric to the graph, under Browse, choose All, find the specific metric, and then select the check box next to it. You can add up to 10 metrics.
For example, to add the actual values for CPU utilization to the graph, choose the EC2 namespace and then choose By Auto Scaling Group. Then, select the check box for the CPUUtilization metric and the specific Auto Scaling group.
-
(Optional) To add the graph to a CloudWatch dashboard, choose Actions, Add to dashboard.
Create accuracy metrics using metric math
With metric math, you can query multiple CloudWatch metrics and use math expressions to create new time series based on these metrics. You can visualize the resulting time series on the CloudWatch console and add them to dashboards. For more information about metric math, see Using metric math in the Amazon CloudWatch User Guide.
Using metric math, you can graph the data that Amazon EC2 Auto Scaling generates for predictive scaling in different ways. This helps you monitor policy performance over time, and helps you understand whether your combination of metrics can be improved.
For example, you can use a metric math expression to monitor the mean
absolute percentage error
Example: Metric math expression
To get started with this type of graph, you can create a metric math expression like the one shown in the following example.
{ "MetricDataQueries": [ { "Expression": "TIME_SERIES(AVG(ABS(m1-m2)/m1))", "Id": "e1", "Period": 3600, "Label": "
MeanAbsolutePercentageError
", "ReturnData": true }, { "Id": "m1", "Label": "ActualLoadValues
", "MetricStat": { "Metric": { "Namespace": "AWS/EC2", "MetricName": "CPUUtilization
", "Dimensions": [ { "Name": "AutoScalingGroupName", "Value": "my-asg
" } ] }, "Period": 3600, "Stat": "Sum" }, "ReturnData": false }, { "Id": "m2", "Label": "ForecastedLoadValues
", "MetricStat": { "Metric": { "Namespace": "AWS/AutoScaling", "MetricName": "PredictiveScalingLoadForecast", "Dimensions": [ { "Name": "AutoScalingGroupName", "Value": "my-asg
" }, { "Name": "PolicyName", "Value": "my-predictive-scaling-policy
" }, { "Name": "PairIndex", "Value": "0" } ] }, "Period": 3600, "Stat": "Average" }, "ReturnData": false } ] }
Instead of a single metric, there is an array of metric data query structures
for MetricDataQueries
. Each item in MetricDataQueries
gets a metric or performs a math expression. The first item, e1
, is
the math expression. The designated expression sets the ReturnData
parameter to true
, which ultimately produces a single time series.
For all other metrics, the ReturnData
value is false
.
In the example, the designated expression uses the actual and forecasted
values as input and returns the new metric (MAPE). m1
is the CloudWatch
metric that contains the actual load values (assuming CPU utilization is the
load metric that was originally specified for the policy named
my-predictive-scaling-policy
). m2
is the CloudWatch
metric that contains the forecasted load values. The math syntax for the MAPE
metric is as follows:
Average of (abs ((Actual - Forecast)/(Actual)))
Visualize your accuracy metrics and set alarms
To visualize the accuracy metric data, select the Metrics tab in the CloudWatch console. You can graph the data from there. For more information, see Adding a math expression to a CloudWatch graph in the Amazon CloudWatch User Guide.
You can also set an alarm on a metric that you're monitoring from the Metrics section. While on the Graphed metrics tab, select the Create alarm icon under the Actions column. The Create alarm icon is represented as a small bell. For more information and notification options, see Creating a CloudWatch alarm based on a metric math expression and Notifying users on alarm changes in the Amazon CloudWatch User Guide.
Alternatively, you can use GetMetricData and PutMetricAlarm to perform calculations using metric math and create alarms based on the output.