With New Relic's Java agent, you can track everything from performance issues to tiny errors within your code. Every minute the agent posts metric timeslice and event data to the New Relic user interface, where the owner of that data can sign in and use the data to see how their website is performing.
To use the Java agent:
- Make sure your system meets the Java agent's compatibility and requirements.
- Sign up for a New Relic account.
- Install the Java agent using our launcher, or by following the standard installation procedures. Depending on your tools and frameworks, refer to additional installation procedures to install or configure the Java agent.
To view your app's performance in the New Relic UI, go to one.newrelic.com > APM > (select an app) > Summary. The APM user interface includes a dedicated JVM metrics page, transaction and error details, a thread profiler tool to sample Java threads and report stack traces, and more.
The Java agent reads the startup configuration from the
newrelic.yml file, which must be in the same directory as
newrelic.jar. You can also override settings using Java system properties.
The agent needs the
app_name settings at startup (bootstrap). You can customize the location of the log file and other settings in your
newrelic.yml file. In addition, you can adjust the naming configuration if your app server runs multiple applications in the same JVM.
You can configure application reporting from the New Relic web interface using server-side configuration. Changes will be applied to all agents reporting for your application when the JVM restarts. However, if you use server-side configuration, you must still maintain required settings (
app_name) in the local config file.
Both transaction traces and error snapshots can optionally record HTTP parameters. Sometimes HTTP parameters contain sensitive information, such as a credit card number. The agent has several configuration options to ensure data security, such as collecting HTTP parameters but excluding certain named parameters.
After installing the Java agent, use any of these methods to extend your instrumentation:
- Custom instrumentation: Implement Java custom instrumentation via annotation or XML.
- Enable distributed tracing: See the paths of your requests as they spread across a distributed, multiple-services architecture.
- Collect custom attributes: Collect custom attributes via API or XML file.
- Java agent API: Use the API to control, customize, or extend the functionality of the Java agent.
- Browser instrumentation: Integrate the Java agent with browser monitoring to gain visibility into end-user activity.
- Circuit breaker for Java custom instrumentation: Use a circuit breaker to protect applications from over-instrumentation.
- Custom JMX instrumentation by YAML: View custom JMX metrics with a YAML custom instrumentation file.
- JVM metrics page: Collect metrics from the most common application servers through JMX.
- Open source telemetry: We offer a variety of tools, such as Kamon Reporter, OpenTelemetry exporter, Micrometer metrics registry, and Java Telemetry SDK.
When you make a change to your configuration or to your custom XML, in almost all cases you must restart your JVM. There are only four situations where a restart is not necessary:
JVM restart is not required for...
Log level or audit mode changes
If you are simply changing the
Custom instrumentation XML file
JVM restart depends on your Java agent version:
Circuit breaker changes
If you are changing the circuit breaker for Java custom instrumentation, a JVM restart is not required.
Ignored or expected errors
If you are ignoring or expecting errors by configuring the
All other changes require an agent restart, which means restarting the JVM.
The New Relic Java agent monitors web transactions, receiving information about them and communicating that information to the New Relic user interface with strong data security measures in place. The agent is packaged as a JSR 163 compliant
javaagent that is activated by the JVM through modifications to the JVM launch. Once activated, the agent inserts itself into the class loading stream and instruments class methods using byte code instrumentation (bci).
Designed to have minimal impact on your web application, all of the classes are in the
newrelic package namespace so they do not collide with your own classes. The agent uses the ASM bci engine to insert software probes.
The agent receives basic information about your host environment, such as operating system, Java version, system properties, and your New Relic configuration file. The agent also polls data from the JVM and from JMX.
If you encounter problems with the Java agent, see the troubleshooting documentation.
If you need more help, check out these support and learning resources:
- Browse the Explorers Hub to get help from the community and join in discussions.
- Find answers on our sites and learn how to use our support portal.
- Run New Relic Diagnostics, our troubleshooting tool for Linux, Windows, and macOS.
- Review New Relic's data security and licenses documentation.