2

Trying to create an Amazon Cloudwatch alert to monitor an Elastic Beanstalk deployment of a public facing website. The alert options for Elastic Beanstalk don't seem to allow for monitoring specific instances that fail Beanstalk's health check URL query. I need to identify the specific unhealthy INSTANCE and terminate it. From there, my autoscaling policy will automatically replace the terminated instance.

Some background

Setup: Elastic Beanstalk deployment running LAMP for a public facing site.

Purpose: For additional failsafe security, I've added a daemon to monitor the state of the file system at /var/www. If the timestamp or size of the filesystem changes (i.e., unwanted file introduction or change), the monitor fires a script that deletes the php file located at elasticbeanstlak's health check URL (random url in the /var/www dir) and forces an "unhealthy" state at the ELB monitoring level.

All is working fine except I can't seem to find a way to get Amazon to identify the specific instance which has caused the health check to fail and let me terminate only that instance.

The AWS docs for creating alarms to handle this specific functionality and initiating instance termination is unclear. I've tried setting up health monitoring at the Beanstalk level, which works to identify an unhealthy state, but not the specific instance. Not new to AWS, but relatively new to Cloudwatch metrics.

Thanks for suggestions.

Adestin
  • 153
  • 3
  • 15

1 Answers1

1

So it looks like your base use case is this:

  1. Something is wrong in the /var/www dir and your script deleted the health check script.
  2. Instance fails the health check
  3. The instance gets terminated then replaced by Autoscaling

One option would be to use Elastic Beanstalk's Scaling Triggers setting to configure your Autoscaling Group to immediately replace hosts on the UnhealthyHostCount trigger measurement. If you are using the API you can set the triggers with these option settings.

nbalas
  • 1,243
  • 10
  • 16
  • An alternate solution is using the [DescribeInstanceHealth](http://docs.aws.amazon.com/elasticbeanstalk/latest/api/API_DescribeInstancesHealth.html) API to determine which specific instance is failing the health checks and handle it. – nbalas Feb 14 '16 at 00:13