AWS Elastic Beanstalk remove health checks from Apache logs.

We running a PHP web application using AWS Elastic Beanstalk. Been looking at improving our monitoring using CloudWatch logs. Unfortunately the logs are polluted by our health checks originating from our ELB.

Here’s a quick guide on how to stop this.

Using the .ebextensions add the following file into your project (If you haven’t heard about EB extensions, read here.):


mode: “000644”
owner: root
group: root
content: |
SetEnvIf Request_URI “^/elb-health-check\.php$” dontlog
SetEnvIf Remote_Addr “127\.0\.0\.1” dontlog
SetEnvIf Remote_Addr “::1” dontlog

command: sed -i.bak ‘s+CustomLog “logs/access_log” combined.*+CustomLog “logs/access_log” combined env=!dontlog+’ /etc/httpd/conf/httpd.conf
command: apachectl configtest
command: service httpd restart

Change the health check URL in the Request_URI, my health check is at /elb-health-check.php. Then simply eb deploy and you should have a clearer view of your logs. 😀

Articles that helped:

AWS ELB in Apache logs

Apache Logs in AWS

View at


Tags: , ,

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.