Before the latest customizing and configuration improvement in AWS Beanstalk, one had to create a custom AMI if you want to use the server and application monitoring of NewRelic with Java.
It took a bit of experimenting to work also for updates, but here are the steps:
- In your webapp directory create a .ebextensions folder
- copy the newrelic.jar and newrelic.yml files and create a file ending with .config - e,g, server-update.config:
# 2.9.0 Production/Test
commands:
do_update_yum:
command: yum -y update
newrelic1:
command: rpm -U --nosignature --replacepkgs http://download.newrelic.com/pub/newrelic/el5/i386/newrelic-repo-5-3.noarch.rpm
newrelic2:
command: yum -y install newrelic-sysmond
newrelic3:
command: nrsysmond-config --set license_key=XXX
newrelic4:
command: /etc/init.d/newrelic-sysmond start
container_commands:
apache_mods:
command: cp .ebextensions/bf_mod_*.conf /etc/httpd/conf.d
newrelic_copy:
command: cp .ebextensions/newrelic.* /etc/tomcat7
option_settings:
- namespace: aws:elasticbeanstalk:container:tomcat:jvmoptions
option_name: JVM Options
value: -javaagent:/etc/tomcat7/newrelic.jar -Dnewrelic.environment=test
- namespace: aws:elasticbeanstalk:application:environment
option_name: PARAM1
value: whatever
Be careful to use only spaces (no tabs). I added also the Apache configurations for cache control (expires) and gzip (deflate).
Here the link to the AWS Documentation.
When trying to debug errors the AWS Event details are not too helpful. Log into the running EC2 instance - in /var/log you find the two main log files: eb-tools.log and cfn-init.log with a bit more details and at least the step the deployment failed.