0

Background

Adding health checks to our web ec2 instances on AWS is easy, we simply have to create an endpoint that always returns a 200 http response when it's healthy.

However, we also have other non-web instances in our Auto Scaling Groups (ASG) where this model doesn't apply:

enter image description here

Problem

The problem we have is that our non-web instances are failing due to various reasons (ie disk running out of space, sometimes the instances are not reachable via ssh even for us to investigate what went wrong). When this happens, the ASG is unaware of that and so doesn't automatically attempt to recycle the instance.

Question

How can we add a health check on a non-web instance (without actually turning it into one, ie by installing NGINX server etc)

2

2 Answers 2

0

Related StackOverflow question: https://stackoverflow.com/questions/43975456/how-to-implement-custom-health-checks-for-ec2-instances-without-using-an-elb

Basic suggestion: use a cron job to push health info to AWS using the CLI. I've not encountered a better solution in recent/limited research unfortunately.

0

An Amazon Web Services (AWS) Auto Scaling Group is a service that automatically adjusts the number of instances in a group based on user-defined policies. To add a health check on a non-web instance in an Auto Scaling Group, you can follow these steps:

Determine the type of health check to use: There are two types of health checks you can use with an Auto Scaling Group: EC2 and ELB. The EC2 health check checks the health of each instance in the group by running a script or command on the instance. The ELB health check checks the health of each instance behind an Elastic Load Balancer (ELB) by sending HTTP or HTTPS requests to the instance.

Create a health check script or command: If you choose to use the EC2 health check, you will need to create a script or command that returns a response of 0 if the instance is healthy, and a response of 1 if the instance is not healthy. The script or command can be anything that checks the health of your application or service running on the instance.

Configure the Auto Scaling Group: In the AWS Management Console, navigate to the Auto Scaling Groups page and select the group you want to add the health check to. Click the "Edit" button, and then select the "Health check type" option. Choose either EC2 or ELB depending on the type of health check you want to use.

Configure the health check settings: If you choose to use the EC2 health check, enter the script or command you created in step 2 into the "Health check grace period" field. If you choose to use the ELB health check, select the ELB from the dropdown list and configure the health check settings for the ELB.

Save the changes: Click the "Save" button to apply the health check settings to the Auto Scaling Group.

By following these steps, you can add a health check to a non-web instance in an AWS Auto Scaling Group. This will help ensure that the instance is always running and healthy, and will trigger the Auto Scaling Group to replace any unhealthy instances as needed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.