Knowledge Base: The New Relic Java Agent and Security
Overview
The New Relic Java agent monitors web transactions, collecting information about them and communicating that information to the New Relic website. The agent is packaged as a JSR 163 compliant "javaagent" and is activated by the JVM via modifications to the JVM launch. Once activated, the agent inserts itself into the class loading stream and instruments "interesting" class methods using byte code instrumentation (bci). This technique allows the agent to insert software probes to measure the web application at key places. These places include request handlers like servlets, struts actions, and spring controllers, as well as remote system calls to databases and web services. The agent also polls data from the JVM and from JMX. Every minute the agent posts its data to the New Relic website where the owner of that data can login and use the data to see how their website is performing.
Environment
When the New Relic Java agent connects to the New Relic web service, it collects and sends information about your host environment. This information is primarily used by our support team. The agent collects:
- The OS type and version
- The version of Java
- All system properties
- The contents of the newrelic.yml file
Data Types
There are three types of data that the agent collects.
Aggregate Metrics
These are counters that track the number of times a method is called and it's average response time. For example, our software probe on a Spring controller might get called 1000 times a minute, in which case our aggregate metric would record 1000 as the call count and the sum of the response times for all 1000 calls. The amount of memory used for tracking an aggregate metric is fixed regardless of the number of calls. Aggregate metrics drive the time-series graphs on the New Relic website.
Among other things, we collect metrics for unique URIs and for access to database tables.
Transaction Trace
This is a complete snapshot of a single web request. They are collected only for slow requests. Only the slowest transaction trace per minute is sent to the New Relic website. Transaction traces include detailed information about the request, including (optionally) HTTP parameters and obfuscated SQL.
Error Snapshot
These record uncaught exceptions that the application is propagating back to the web browser. They contain the HTTP parameters of the request and also the exception that was unhandled. Part of the exception is a stack trace from the managed application.
Impact to your application
The agent was designed to minimally impact your web application. All of the classes are in the newrelic package namespace so as not to collide with your own classes. The agent uses the ASM bci engine to insert software probes - which we've measured to impact the start time of the application by less than 10%. Application response times should see less than a 5% slow down since our instrumentation is only at request handling and remote system call methods. Memory impact is also about 5%.
Security
Data is posted via https once a minute from the agent to the New Relic website. The message format is JSON. The website returns a JSON response to the agent letting it know if the data was correctly received or if there was an error. Data for accounts are isolated so that users can only see the data for accounts they own (or have been given permission to see). New Relic has certain rights regarding customer data - please see the Terms & Conditions on our website for more detailed information.