How to troubleshoot an Elastic Load Balancer (Application) — AWS
Troubleshooting strategies
- Access Logs
- Inspecting the code in the cloudformation script (Only if cloudformation was used)
- Use CloudTrail logs
- Use AWS ELB troubleshooting guide
Access Logs
Try this approach
In this experimentation we are going to start from zero. If you already have a load balancer that is configured you can ignore the steps where I create the load balancer and the EC2 instance.
- Create an EC2 instance
Follow the instructions in here https://docs.aws.amazon.com/efs/latest/ug/gs-step-one-create-ec2-resources.html
2. Add a security group to the EC2 instance
The security group for this instance needs the following rules:
3. Add a load Balancer and connect it to the EC2 instance
NOTE: It is very IMPORTANT that you set the EC2 instance previously created as the target
Follow the instructions in here https://docs.aws.amazon.com/elasticloadbalancing/latest/application/create-application-load-balancer.html
4. Creating the S3 bucket to store the access logs
Follow the instructions in here https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-access-logs.html#access-logging-bucket-permissions
5. Enable logging access in the load balancer
Follow the instructions in here https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-access-logs.html#enable-access-logging
6. Process the information
6.1 Download the access log file from S3
6.2 Create an spreadsheet in excel or in Google Sheets like this one:
You can use this example: https://docs.google.com/spreadsheets/d/1Y6QsV1r_sEYTEpyqkBHMQqFyKMGpYQY2cwevaq6UKV0/edit?usp=sharing
6.3 Copy the info in the log file and paste it in the spreadsheet.
6.4 Divide the info in each row into columns, dividing its content by whitespace
7. Analyze the processed information
- Verify that the client port and target port are correct
- If request_processing_time == -1, then the load balancer can’t dispatch the request to a target.
- Find the elb_status_code and look in here the meaning of the code https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-troubleshooting.html#load-balancer-http-error-codes
- Find the target_status_code. It is the status code of the response from the target. This value is recorded only if a connection was established to the target and the target sent a response. Otherwise, it is set to -.