Tag Archives: springboot app monitoring with newrelic

Web Solutions: How to enable newrelic monitoring in SpringBoot Application?

NewRelic is a very powerful tool to enable engineers, techops and devops to get insights about their application running in production. NewRelic can give you so many data points and you can resolve many modern enterprise problems. One of the need is to have enterprise application autoscale. And newrelic gives you many data points to automate server auto scaling.

How newrelic works?

Newrelic works with JavaAgent. With New Relic’s Java agent, you can track everything from performance issues to tiny errors within your code. New Relic’s Java agent monitors your Java app and provides visibility into the behavior of your JVM. After installing, you will be able to quickly monitor transactions, dive deep into errors, and more.

So let’s understand how to enable NEWRELIC in your spring boot application?

  • Download newrelic-java.zip using below commands. it does not require any authentication.
curl -O https://download.newrelic.com/newrelic/java-agent/newrelic-agent/current/newrelic-java.zip
  • Unzip “newrelic-java.zip” and goto newrelize-java folder.
  • Find newrelic.yml and open in editor.
  • Update license-key and app_name.
  • last step is to run application with javaagent newrelic.

If Springboot runs as a standalone jar file:

java -javaagent:/<Your Directory Path>/newrelic-java/newrelic.jar -jar SpringBootApp.jar

If Springboot is deployed in TOMCAT Container

First step is to deploy above newrelic-java.zip file in server where tomcat is running and make sure it is deployed outside of tomcat directory.

let's say.. tomcat is in /opt/tomcat and newrelic directory is /opt/newrelic-java/

To pass the -javaagent argument on Tomcat: You need to pass newrelic as javaagent into environment variables.

export JAVA_OPTS="$JAVA_OPTS -javaagent:/opt/newrelic-java/newrelic.jar"

After setting JAVA_OPTS as environment variables, Restart the tomcat server and start exploring websites. After a few mins you should be able to see metrics in newrelic console.