Installing New Relic (APM) on Java Spring Boot
This article was translated from the original Korean post with AI assistance. Read the original Korean post →

Goal
Install New Relic on a Java Spring Boot server to monitor transactions and errors through APM.
Deployment Environment
Assuming you have multiple repositories and use a mix of the following two deployment methods:
- Docker on EC2
- ECS & Code Deploy
Installation
After signing up, follow the guide provided by New Relic in order.
- Select APM, then select Java
- Click the Begin installation button
- Click Other Java installation options in the bottom right

- 1. Enter the app name.
- 2. Click the Download button to download the newrelic.yml file.

- 3. Click Copy to clipboard to copy the curl command, and paste it into your shell to download newrelic-java.zip.
- 4. Select Spring Boot.
- You can ignore the subsequent steps. For step 6, if you want to check Docker conditions, you can access the AWS console and enter the commands. However, since New Relic charges $0.25 per 1GB once you exceed the free 100GB per month, I recommend checking this with other monitoring tools.
- Unzip the downloaded newrelic-java.zip and place it right under your Spring project root. At this time, rename the folder if necessary so that the jars are located under the newrelic folder.
- git push to reflect this in your repository. Since most developers have jar files in their gitignore, you'll need to force add it.
git add <blar>.jar -f
- Proceed with deployment once so the New Relic files are uploaded to the server.
For Docker on EC2
- Open the docker-compose.yml on your system and modify it as follows:
- Added -javaagent:/newrelic/newrelic.jar to the entrypoint. The -javaagent flag must come before -jar.
- Added ./newrelic:/newrelic/ to volumes. If you use -javaagent:/app/newrelic/newrelic.jar in the entrypoint where the javaagent runs, you don't need to mount it.
maven:
build:
context: ./
dockerfile: Dockerfile
args:
PROCESS: test
environment:
- PROCESS=test
container_name: maven
expose: [ 8080 ]
ports:
- 8080:8080
entrypoint: java -javaagent:/newrelic/newrelic.jar -Dnewrelic.environment=test -jar -DSpring.profiles.active=test /app/target/test-0.0.1-SNAPSHOT.jar
depends_on:
volumes:
- ./:/app
- ./newrelic:/newrelic/
- git push and deploy.
For ECS & Code Deploy
- Go to AWS ECS and click Task Definitions.
- Select the server where you want to apply New Relic and click Create new revision.
- On the Create new revision page, scroll to the very bottom and click the "Configure via JSON" button in the volumes section.
- Change the command part in the JSON as shown below. This is identical to what we wrote in the entrypoint when using EC2. Click the Save button after changing it.
- I tried mounting it, but it didn't work as intended, so I gave up.
"command": [
"java",
"-javaagent:/app/newrelic/newrelic.jar",
"-jar",
"-DSpring.profiles.active=release",
"/app/target/test-0.0.1-SNAPSHOT.jar"
],
- Click the Create button to make a new revision.
- Deploy.