Archive for June, 2018

AWS Elastic Beanstalk remove health checks from Apache logs.

June 5, 2018

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