Enable metrics collction for an auto scaling group

You created an auto scaling group through the management console. The issue is "group metrics collection is not enabled for the following auto scaling groups" and; you would simply like to know how to enable metric collection using the AWS CLI. Here you will a bash function aws-cli wrapper to help automate enabling metrics collection for autoscaling groups in AWS.


Today in AWS, enabling metrics collection for an auto scaling group was on my to-do list. (28 Jul 2017)

This page dedicated to the task of enabling auto scaling metrics collection.

Introduction

As you may know by know, group metrics collection in AWS is not enabled by default for auto scaling groups. Why?

  1. Metrics collection is not free;
  2. In most cases, autoscaling metrics collection is not need. However, if you would like to track your autoscaling capacity over time, you need to enable auto scaling metrics collection, which can be done using the aws-cli. At the time of creating this document, there was no place to click in the management console, leaving the aws-cli the only way to enable metrics collection for an auto scaling group.

Enable auto scaling metrics collection shortcut

If you are really in a hurry to enable auto scaling metrics collection in AWS that you are currently working on, here is the aws-cli shortcut you need.

Enable auto scaling metrics collection guide

If you've ever picked up where you left off, in the middle of a test, or are in your free tier period, you will find out or be reminded that metrics collection is not enabled by default. So, what do you do?

Why enable auto scaling metrics collection?

Metrics collection is used by scaling policies to achieve autoscaling.

Auto scaling groups are created without enabled metrics by default. Auto scaling group metrics collection may be enabled manually via command line through the aws-cli.

AWS CLI

aws autoscaling enable-metrics-collection

required options

The following options are required by the 'enable-metrics-collection' command of the 'aws autoscaling' command namespace.

--auto-scaling-group-name

The name or ARN of the auto scaling group is required.

--granularity

Despite the only valid value being "1Minute", granularity is required.

example

bash function
aws-cli wrapper

enable-metrics-collection() { { local auto_scaling_group_name ; auto_scaling_group_name="${1}" ; }
local granularity
granularity="1Minute"
aws 
autoscaling
enable-metrics-collection
--auto-scaling-group-name "${auto_scaling_group_name}"
--granularity "${granularity}" }

Changelog

(3 Feb 2019) Minor revision

(12 Jan 2018) Update example converting original bash example code into a aws-cli wrapper bash function

( 7 Aug 2017) Add introduction

(28 Jul 2017) Create document


© Nicholas Shellabarger