Create a target tracking policy using high-resolution metrics for faster response
Target tracking supports high-resolution CloudWatch metrics with seconds-level data points that are published at lower intervals than one minute. Configure target tracking policies to monitor utilization through high-resolution CloudWatch metrics for applications that have volatile demand patterns, such as client-serving APIs, live streaming services, ecommerce websites, and on-demand data processing. To achieve higher precision in matching capacity with demand, target tracking uses this fine-grained monitoring to detect and respond to changing demand and utilization of your EC2 instances more quickly.
For more information about how to publish your metrics at high resolution, see Publish custom metrics in the Amazon CloudWatch User Guide. To access and publish EC2 metrics, such as CPU utilization at high resolution, you might want to use CloudWatch agent.
AWS Regions
Target tracking using high-resolution metrics is available in all AWS Regions except the AWS GovCloud (US) Regions.
How target tracking policy with high-resolution metrics works
You create target tracking policies by defining the metric that you want to track and the target value that you want to maintain for the metric. To scale on a high-resolution metric, specify the name of the metric and set the metric period at which the target tracking observes this metric to a value lower than 60 seconds. Currently the lowest supported interval is 10 seconds. You can publish your metric at lower intervals than this.
Note
A metric period greater than 60 isn't supported.
You can configure target tracking on a single CloudWatch metric or query multiple CloudWatch metrics and use math expressions to create new single time series based on these metrics. Both options allow you to define the metric period.
Examples
Example 1
The following example creates a target tracking policy based on a high-resolution CloudWatch metric. The metric is published at 10 seconds resolution. By defining the period, you can enable target tracking to monitor this metric at 10-second granularity.
Replace each user input placeholder
with your own information.
$ cat ~/config.json { "TargetValue":
100.0
, "CustomizedMetricSpecification": { "MetricName": "MyHighResolutionMetric
", "Namespace": "MyNamespace
", "Dimensions": [ { "Name": "MyOptionalDimensionName
", "Value": "MyOptionalMetricDimensionValue
" } ], "Statistic": "Average
", "Unit": "None
" "Period": "10
} }
Example 2
You can use metric math expressions to combine multiple metrics into a single time series for scaling. Metric math is particularly useful to convert existing metrics into average per-instance. Converting metrics is essential because target tracking assumes that the metric is inversely proportional to the capacity of the Auto Scaling group. So when capacity increases, the metric should decrease by nearly the same proportion.
For example, suppose you have a metric that represents the pending jobs to be processed by your application. You can use metric math to divide the pending jobs by the running capacity of your Auto Scaling group. Auto Scaling publishes the capacity metric at 1-minute granularity, so there won't be any value for this metric for sub-minute intervals. If you want to use higher resolution for scaling, this can lead to a period mismatch between capacity and pending job metric. To avoid this mismatch, we recommend that you use the FILL expression to fill the missing values with the capacity number recorded in the previous minute timestamp.
The following example uses metric math to divide the pending jobs metric by the capacity. For period, we are setting both metrics at 10 seconds. Because the metric is published at 1-minute intervals, we are using the FILL operation on the capacity metric.
To use metric math to modify multiple metrics
{ "CustomizedMetricSpecification": { "Metrics": [ { "Label": "Pending jobs to be processed", "Id": "m1", "MetricStat": { "Metric": { "MetricName": "MyPendingJobsMetric", "Namespace": "Custom", }, "Stat": "Sum" "Period": 10 }, "ReturnData": false }, { "Label": "Get the running instance capacity (matching the period to that of the m1)", "Id": "m2", "MetricStat": { "Metric": { "MetricName": "GroupInService", "Namespace": "AWS/AutoScaling", "Dimensions": [ { "Name": "AutoScalingGroupName", "Value": "
my-asg
" } ] }, "Stat": "Average" "Period": 10 }, "ReturnData": false }, { "Label": "Calculate the pending job per capacity (note the use of the FILL expression)", "Id": "e1", "Expression": "m1 / FILL(m2,REPEAT)", "ReturnData": true } ] }, "TargetValue":100
}
Considerations
Consider the following when using target tracking and high-resolution metrics.
-
To make sure that you don’t have missing data points that could lead to undesired automatic scaling results, your CloudWatch metric must be published at the same or higher resolution than the period that you specify.
-
Define the target value as the per-instance-per-minute metric value that you want to maintain for your Auto Scaling group. Setting an appropriate target value is crucial if you use a metric whose value can multiply based on the period of the metric. For example, any count-based metrics such as request counts or pending jobs that use the SUM statistic will have a different metric value depending on the chosen period. You should still assume that you are setting a target against the per-minute average.
-
Although there are no additional fees for using Amazon EC2 Auto Scaling, you must pay for the resources such as Amazon EC2 instances, CloudWatch metrics, and CloudWatch alarms. The high-resolution alarms created in preceding example are priced differently than standard CloudWatch alarms. For more information about CloudWatch pricing, see Amazon CloudWatch Pricing
. -
Target tracking requires that metrics represent the average per-instance utilization of your EC2 instances. To achieve this, you can use metric math operations as part of your target tracking policy configuration. Divide your metric by the running capacity of your Auto Scaling group. Make sure that the same metric period is defined for each of the metrics that you use to create a single time series. If these metrics publish at different intervals, use the FILL operation on the metric with the higher interval to fill in the missing data points.