windowsamazon-ec2amazon-cloudwatchaws-auto-scalingcloudwatch-alarms

Can we create individual cloudwatch alarms for each instance in an Autoscaling group


So we have a task to create alarms for disk storage for Windows instances. We created alarms but its giving average of all instances in an autoscaling group. Is it possible to create metrics and alarms for each instances and when the ASG scales in, it deletes those alarms.

Im not sure that if it is even feasible to do so !


Solution

  • Yes, it's possible to create alarms for each indivisual instances. You need to make use of a lambda or simply a script which is run via User data in your ASG Launch template. This guide can help you create alarms when ASG scaleout and a new node is created. Be sure your source image has the proper tools installed to create the alarms.On scalein, you need to run another script which can delete the alarms for you. Check this for reference. You also need to check lifecycle hooks for this to work.
    Another method is to make use of "cloudwatch rules -> event pattern -> autoscaling*" which can send you all the reqired data about the node through an sns (or directly to a lmbda) and you can trigger a lambda and do whatever you like.