Answers: <p>Related StackOverflow question: <a href="https://stackoverflow.com/questions/43975456/how-to-implement-custom-health-checks-for-ec2-instances-without-using-an-elb">https://stackoverflow.com/questions/43975456/how-to-implement-custom-health-checks-for-ec2-instances-without-using-an-elb</a></p>
  <p>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.</p>
  
Answers: CC BY-SA 4.0
Answers: 2023-02-21T22:40:43.740Z
Answers: 2023-02-21T22:40:43.740Z
Answers: Logic32
Answers: <p>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:</p>
  <pre><code>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 &quot;Edit&quot; button, and then select the &quot;Health check type&quot; 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 &quot;Health check grace period&quot; 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 &quot;Save&quot; button to apply the health check settings to the Auto Scaling Group.
  </code></pre>
  <p>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.</p>
  
Answers: CC BY-SA 4.0
Answers: 2023-02-22T06:28:06.943Z
Answers: 2023-02-22T06:28:06.943Z
Answers: Issac
Body: <h1>Background</h1>
  <p>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.</p>
  <p>However, we also have other non-web instances in our Auto Scaling Groups (ASG) where this model doesn't apply:</p>
  <p><a href="https://i.sstatic.net/TxetI.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/TxetI.png" alt="enter image description here" /></a></p>
  <h1>Problem</h1>
  <p>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.</p>
  <h1>Question</h1>
  <p>How can we add a health check on a non-web instance (without actually turning it into one, ie by installing NGINX server etc)</p>
  
Comments: CC BY-SA 4.0
Comments: 2022-04-14T11:20:50.717Z
Comments: https://docs.aws.amazon.com/autoscaling/ec2/userguide/healthcheck.html#instance-health-status
Comments: Kyslik
Comments: CC BY-SA 4.0
Comments: 2022-04-14T13:06:29.907Z
Comments: I’m voting to close this question because it is already well-documented.
Comments: Bruce Becker
Tags: <amazon-web-services><autoscaling><healthcheck>
Title: How to add an AWS Auto Scaling Group health check on a non-web instance
UserDisplayName: abbood
ThreadText: # How to add an AWS Auto Scaling Group health check on a non-web instance
  
  (Asked by: username_0 on 2022-04-14)
  
  # 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](https://i.sstatic.net/TxetI.png)](https://i.sstatic.net/TxetI.png)
  
  # 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)
  
  **Tags:** amazon-web-services, autoscaling, healthcheck
  
  > **Comments:**
  > **username_1**: https://docs.aws.amazon.com/autoscaling/ec2/userguide/healthcheck.html#instance-health-status  
  > **username_2**: I’m voting to close this question because it is already well-documented.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_3 on 2023-02-21. Score: 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.
  
  
  ---
  
  ### Answer by username_4 on 2023-02-22. Score: 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.
  
  
  ---
  
  