Here is what I want to do. --> Deploy a play framework (2.2.1) Java web application on Heroku and use newrelic as an add on.
**Issue /problem:**
These are the steps i did so far.
1) I am able to add addon using the heroku command of addon "heroku addons:add newrelic:stark" I see the add on in the heroku resources.
2) Adding the newrelic.yml file. added the newrelic.yml file as attached and saved in the conf folder of the play framework (were the application.conf file is present). The file I picked up is from https://gist.github.com/anfuerer/6169040 (just updated licence and app info)
3) As its play 2.2.1, changed the built.sbt file to add dependencies.
"com.newrelic.agent.java" % "newrelic-agent" % "3.4.0",
"com.newrelic.agent.java" % "newrelic-api" % "3.4.0"
4) My Procfile which is required for heroku has the JAVA_OPTS specified and the JAVA_OPTS is set by using the command
heroku config:set JAVA_OPTS=”-Xmx384m -Xss512k -XX:+UseCompressedOops -Dfile.encoding=UTF-8 -javaagent:target/staged/newrelic-agent-3.4.0.jar -Dnewrelic.bootstrap_classpath=true -Dnewrelic.config.file=./conf/newrelic.yml newrelic.config.log_level=finer newrelic.debug=true”
5) obviously all the changes are added to git and committed before pushing to heroku by command "git heroku push master".
6) some basic sanity test.. I see my config after heroku config command as -
JAVA_OPTS: -Xmx384m -Xss512k -XX:+UseCompressedOops -Dfile.encoding=UTF-8 -javaagent:target/staged/newrelic-agent-3.4.0.jar -Dnewrelic.bootstrap_classpath=true -Dnewrelic.config.file=./conf/newrelic.yml newrelic.config.log_level=finer newrelic.debug=true
NEW_RELIC_APP_NAME: test_application
NEW_RELIC_LICENSE_KEY: 000000000000000000000000000000000 (changed offcourse)
NEW_RELIC_LOG: stdout
PATH: .jdk/bin:.sbt_home/bin:/usr/local/bin:/usr/bin:/bin
REPO: /app/.sbt_home/.ivy2/cache
SBT_OPTS: -Xmx384m -Xss512k -XX:+UseCompressedOops
Also tried to check by "heroku run env | grep NEW_RELIC" which gives me output -
NEW_RELIC_LOG=stdout
NEW_RELIC_LICENSE_KEY=00000000000000000000000000000
NEW_RELIC_APP_NAME=test_application
Now I go to my Heroku app dashboard, click on my app to see the add ons and click on new relic and i come to a screen which asks me to setup my app-
I click on setup, but which takes me to download the Java agent and it want me to install the java agent on to the webserver.
#################EDITTrying to install java newrelic on Play app framework as per @Jeanie's comment
1) download the new relic java agent in downloads folder.
2) unzip to the play framework app folder(project folder) (does this need to be the play framework folder where play build files are??) using
unzip newrelic_agent3.4.0.zip -d /path/to/appserver/
3) change directory to /appfolder/newrelic/
4) install the jars using
java -jar newrelic.jar install
5) This is the message I am getting.
Jan 20, 2014 12:48:39 -0700 [6935 1] com.newrelic INFO: Agent is using Logback
***** ( ( o)) New Relic Java Agent Installer
***** Installing version 3.4.0 ...
Could not edit start script because:
.:. Could not locate a Tomcat, Jetty, JBoss, JBoss7 or Glassfish instance in /home/amit/Applications/play-2.2.1/appfolder/
Try re-running the install command with the -s <AppServerRootDirectory> option or from <AppServerRootDirectory>/newrelic.
If that doesn't work, locate and edit the start script manually.
No need to create New Relic configuration file because:
.:. A config file already exists: /home/amit/Applications/play-2.2.1/appfolder/newrelic/newrelic.yml
***** Install incomplete
***** Next steps:
For help completing the install, see https://newrelic.com/docs/java/new-relic-for-java
Am I missing something here? Please note this is a Play framework app and I want newrelic addon to work on heroku and not locally on my machine.
#Questions:
1) How do I install the java agent on heroku?? Do I need to in the first place?
2) Shouldn't heroku and new relic add on pick up my app as I have already added the api and java agent as a add on as step 3 ??
Any help or direction appreciated.
Issue resolved. Here are the steps.
1) Get the add on on Heroku by
$ heroku addons:add newrelic:stark
2) Go to your app dashboard and click on resources. Then click on the new relic addon. This will take you to a page where it will ask you to do a set up.
3) Click on set up, select Java, click to see your licence number and download the jar files.
4) As mentioned on the set up page unzip the jars files to the root of your project. Don't run the installer as you need the new relic working on Heroku.
5) Edit the Heroku Procfile as below:
web: target/universal/stage/bin/myapp -Dhttp.port=${PORT} ${java_opts} -DapplyEvolutions.default=true -Ddb.default.driver=com.mysql.jdbc.Driver -Ddb.default.url=${CLEARDB_DATABASE_URL} -J-javaagent:newrelic/newrelic.jar -J-Dnewrelic.config.file=newrelic/newrelic.yml
(change the other settings as per your need, keep the new relic settings unchanged, dont forget to put your app name in place of myapp in "target/universal/stage/bin/myapp")
6) Add dependency to either build.sbt or Build.scala
"com.newrelic.agent.java" % "newrelic-agent" % "3.7.0"
7) Deploy the app to heroku using git push heroku master
8) New relic will be automatically detected and the setup page will show the relevant metrics.
If anyone face any issues, let me know.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With