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.):

.ebextensions/11_apache_dontlog.config

files:
“/etc/httpd/conf.d/dontlog.conf”:
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

commands:
“00”:
command: sed -i.bak ‘s+CustomLog “logs/access_log” combined.*+CustomLog “logs/access_log” combined env=!dontlog+’ /etc/httpd/conf/httpd.conf
“01”:
command: apachectl configtest
“02”:
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 story at Medium.com

JJ

Advertisements

Tags: , ,

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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