AWS ELB – How to Get Detailed Logs of Non-Application 500 Errors

amazon-elbamazon-web-services

I have an auto-scaling group of EC2 instances running a WordPress site behind an elastic load balancer. I can see that there are periodic 500 errors being reported by the elastic beanstalk app in Cloudwatch, but they're not coming from the application servers. I can see ELB logs in S3, but they're very laborious to use. Is there any way to log only 5xx errors with information like time, request, exact error code, etc, using Cloudwatch or something similar?

Best Answer

Use AWS Athena to analyse the ALB logs. There is a worked example here: https://docs.aws.amazon.com/athena/latest/ug/application-load-balancer-logs.html

You want to look for entries where elb_status_code LIKE '50%'