enableMetricsCollection method
Enables group metrics collection for the specified Auto Scaling group.
You can use these metrics to track changes in an Auto Scaling group and to set alarms on threshold values. You can view group metrics using the Amazon EC2 Auto Scaling console or the CloudWatch console. For more information, see Monitor CloudWatch metrics for your Auto Scaling groups and instances in the Amazon EC2 Auto Scaling User Guide.
May throw ResourceContentionFault.
Parameter autoScalingGroupName :
The name of the Auto Scaling group.
Parameter granularity :
The frequency at which Amazon EC2 Auto Scaling sends aggregated data to
CloudWatch. The only valid value is 1Minute.
Parameter metrics :
Identifies the metrics to enable.
You can specify one or more of the following metrics:
-
GroupMinSize -
GroupMaxSize -
GroupDesiredCapacity -
GroupInServiceInstances -
GroupPendingInstances -
GroupStandbyInstances -
GroupTerminatingInstances -
GroupTotalInstances -
GroupInServiceCapacity -
GroupPendingCapacity -
GroupStandbyCapacity -
GroupTerminatingCapacity -
GroupTotalCapacity -
WarmPoolDesiredCapacity -
WarmPoolWarmedCapacity -
WarmPoolPendingCapacity -
WarmPoolTerminatingCapacity -
WarmPoolTotalCapacity -
GroupAndWarmPoolDesiredCapacity -
GroupAndWarmPoolTotalCapacity
Granularity and don't specify any metrics, all
metrics are enabled.
For more information, see Amazon CloudWatch metrics for Amazon EC2 Auto Scaling in the Amazon EC2 Auto Scaling User Guide.
Implementation
Future<void> enableMetricsCollection({
required String autoScalingGroupName,
required String granularity,
List<String>? metrics,
}) async {
final $request = <String, String>{
'AutoScalingGroupName': autoScalingGroupName,
'Granularity': granularity,
if (metrics != null)
if (metrics.isEmpty)
'Metrics': ''
else
for (var i1 = 0; i1 < metrics.length; i1++)
'Metrics.member.${i1 + 1}': metrics[i1],
};
await _protocol.send(
$request,
action: 'EnableMetricsCollection',
version: '2011-01-01',
method: 'POST',
requestUri: '/',
exceptionFnMap: _exceptionFns,
);
}