Monday, October 28, 2013

New Relic Integration

New Relic Integration
With Java Application deployed on heroku

Step 1: Add new relic add-on to your application

add new relic from addons
From UI: Login > Add-ons > Analytics - new relic > select <YOUR_APP> and Add
From Commandline:  $ heroku addons:add newrelic --app <YOUR_APP>

Step 2: Add dependency

add this following code to pom.xml dependencies
with current latest version in version portion**


Step 3: Add plugin

add this following code to pom.xml to add this plugin
with current latest version in version portion**


Step 4: Download new relic agent

From UI Go to apps > select your app > go to new relic addon > click on Get start > select language JAVA
at there you can find ‘Download new relic agent’ at there (just download it)

Step 5: Add newrelic.yml to project

form that “” you can find newrelic.yml copy it and paste it at the root level of the project

Step 6: Replace App name

replace the value of ‘app_name’ in newrelic.yml with actual name of your application

Step 7: commit & push

now just commit those changes and push to the heroku application.

Step 8: Enable Java Agent

you need to add java_opts to enable java agent
for heroku you need to follow these commands

Add the following flag to your JAVA_OPTS config var on Heroku:


You can get the current value of your config var with:

$ heroku config --app <YOUR_APP>
JAVA_OPTS         => -Xmx384m -Xss512k -XX:+UseCompressedOops

Copy the value, add the Java agent flag and app name :
*Make sure to enter your own app name in this example.

$ heroku config:set JAVA_OPTS='-Xmx384m -Xss512k -XX:+UseCompressedOops -javaagent:target/dependency/newrelic-agent.jar' NEW_RELIC_APP_NAME="YOUR APP NAME" --app <YOUR_APP>
Adding config vars:
   JAVA_OPTS => -Xmx384m -Xss512.../newrelic-agent.jar

Step 9: Restart application and see your application analytics

now just restart your application using following command and then you can see analytics on ui

$ heroku restart --app <YOUR_APP>

Now Go to apps > select your app > go to new relic (from addons)
and you can see the analytics of your application

**You can check current latest version of maven repository by this link

No comments:

Post a Comment