Bootstrap FreeKB - Amazon Web Services (AWS) - Resolve "Health checks failed"
Amazon Web Services (AWS) - Resolve "Health checks failed"


Let's say you have EC2 instances registered in your Load Balancer Target Group and their health check status is "Health checks failed" which can be checked by Listing Target Group Health Status using the AWS CLI.

~]$ aws elbv2 describe-target-health --target-group-arn arn:aws:elasticloadbalancing:us-east-1:123456789012:targetgroup/my-target-group/d2aeec2157e4a95d
{
    "TargetHealthDescriptions": [
        {
            "Target": {
                "Id": "i-0d2401ecf9665ec4e",
                "Port": 80
            },
            "HealthCheckPort": "80",
            "TargetHealth": {
                "State": "unhealthy",
                "Reason": "Target.FailedHealthChecks",
                "Description": "Health checks failed"
            }
        }
}

 

I would definitely recommend that you create a Cloudwatch Alarm so that you get alerted when there are one or more unhealthy EC2 instances in your Target Group.

aws cloudwatch put-metric-alarm \
--alarm-name load-balancer-target-group-unhealthy-target \
--alarm-description "One or more EC2 instances in my-target-group is unhealthy" \
--namespace AWS/ApplicationELB \
--metric-name UnHealthyHostCount \
--comparison-operator GreaterThanThreshold \
--threshold 1.0 \
--statistic Sum \
--period 300 \
--evaluation-periods 1 \
--treat-missing-data missing \
--datapoints-to-alarm 1 \
--dimensions "Name=TargetGroup,Value=targetgroup/<the name of your target group>/<the ID of your target group>" \
--alarm-actions arn:aws:sns:<region goes here, e.g. us-east-1>:<your AWS account ID goes here>:<the name of your topic>

 

First and foremost, you'll want to see if the EC2 instances are running, which can be checked using the aws ec2 describe-instances command.

~]$ aws ec2 describe-instances --filters "Name=tag:Name,Values=my-instance"
{
    "Reservations": [
        {
            "Groups": [],
            "Instances": [
                {
                    "State": {
                        "Code": 16,
                        "Name": "running"

 

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter cc5809 in the box below so that we can be sure you are a human.