Jump to content

Newrelic APM- Install and Configure using Tomcat & Java Agent Tutorials


Recommended Posts

Step 1 – Install JDK

Step 2 – Install & Start Tomcat

Step 3 – Install your apps

Lets use Tomcat’s default example app only. You may have permission issues for accessing http://18.210.16.76:8080/examples/ which can be fixed by following commands below

$ cd /opt/apache-tomcat-9.0.82/webapps/examples
$ find . -name context.xml
$ vi ./META-INF/context.xml
image-1024x468.png

Step 4 – Install NewRelic Infra Agent & APM Agent

NewRelic Infra Agent would detect the Tomcat and Java automatically and try to configure APM Java Agent as per the image as below;


image-1-1024x546.png
image-2-1024x376.png
image-3-1024x445.png
root@ip-172-31-58-86:/etc/newrelic-infra/integrations.d# ls
docker-config.yml  java-dynamic-attach.yml

root@ip-172-31-58-86:/etc/newrelic-infra/integrations.d# more java-dynamic-attach.yml
integrations:
  - name: java-dynamic-attach
    exec: ./dynamic-attach.sh
    working_dir: /etc/newrelic-java
    interval: 60s
    timeout: 1200s
    integration_user: root

root@ip-172-31-58-86:/etc/newrelic-infra/integrations.d#

Step 5 -(Manual) Install NewRelic APM Java Agent


image-5-1024x675.png image-6-1024x605.png image-7-1024x616.png image-8-1024x407.png image-9-1024x450.png

Alternative

curl -Ls https://download.newrelic.com/install/newrelic-cli/scripts/install.sh | bash && sudo NEW_RELIC_API_KEY=NRAK-32EHABRB7444 NEW_RELIC_ACCOUNT_ID=3404444 /usr/local/bin/newrelic install -n java-agent-installer


Manual way to set Newrelic APM Agent in Tomcat


$ cd /opt
$ curl -O https://download.newrelic.com/newrelic/java-agent/newrelic-agent/current/newrelic-java.zip
$ unzip newrelic-java.zip
$ cd newrelic
$ mv newrelic.yml newrelic.yml-bkp
$ vi newrelic.yml # COPY PASTE from Download newrelic.yml
$ chmod -R 755 .
$ cd /opt/
$ cd apache-tomcat-9.0.73
$ cd bin
$ vi catalina.sh

export CATALINA_OPTS="$CATALINA_OPTS -javaagent:/opt/newrelic/newrelic/newrelic.jar \
-Dnewrelic.config.file=/path/to/newrelic.yml \
-Dnewrelic.environment=production \
-Dnewrelic.appname=MyApp \
-Dnewrelic.verbose=true \
-Dnewrelic.config.log_file_path=/path/to/newrelic.log"

$ ./shutdown.sh
$ ./startup.sh
$ ps -eaf | grep newrelic.jar

The CATALINA_OPTS environment variable is used to set Java options for the Tomcat server. The option -javaagent:/opt/newrelic/newrelic/newrelic.jar is used to load the New Relic Java agent, which enables monitoring of your Tomcat application using New Relic APM.

If you are looking for other options to set in CATALINA_OPTS to configure the New Relic Java agent, some common options include:

  • -Dnewrelic.config.file=<path to newrelic.yml>: This option can be used to specify the path to the New Relic configuration file, which contains settings such as application name, license key, and logging configuration.
  • -Dnewrelic.environment=<environment name>: This option can be used to specify the name of the environment in which your application is running, such as “production” or “staging”.
  • -Dnewrelic.appname=<application name>: This option can be used to specify the name of your application as it will appear in the New Relic APM dashboard.
  • -Dnewrelic.verbose=true: This option can be used to enable verbose logging for the New Relic Java agent.
  • -Dnewrelic.config.log_file_path=<path to log file>: This option can be used to specify the path to the New Relic log file.

Step 6 – Access the apps

You may create a Traffic on App using Jmeter as below;

image-11-1024x403.png

Step 7 – Verify a APM apps on NewRelic Dashboard

image-10-1024x330.png

The post Newrelic APM- Install and Configure using Tomcat & Java Agent Tutorials appeared first on DevOpsSchool.com.

View the full article

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...