My current set up has AWS Couldwatch alarm triggering the sending of an email notification when, eg. CPU usage is below x% for n minutes. This is easy enough to set up through the AWS Management Console. However, under this arrangement, I then need to remote login into the instance and restart my failed application manually. I'd like to automate this with the same Cloudwatch alarm event, instead triggering the running of a script (on the same EC2 instance as my application) which would then restart my application. How to do this?
If there is a way to catch the Cloudwatch alarm event from within the instance running the application, then this might be an easy way to proceed, but I can't find out how to do that.
There is a similar question posted here (How to restart EC2 instance from CloudWatch alarm). In my case however, I don't think that Auto Scaling is a viable option; because of licensing restrictions on some other software running on the instance.
I'm running a windows based EC2 instance.
Thanks, Yug
An AWS CloudWatch alarm can be used to trigger:
SNS can then send the notification to subscribers in various formats:
Based on your scenario, the HTTP or SQS notifications could be used, but you would have to write a program to respond to the notifications. However, you would only be using a proxy for your app's health (eg CPU Utilization) rather than actually monitoring the health of your app.
You can send a Custom Metric from an application to CloudWatch and then configure an alarm to trigger based on this Custom Metric. But, if you're going to all that trouble, then the code that detects the problem should probably fix it directly, rather than going via CloudWatch.