The New Relic Java agent reads its configuration from the newrelic.yml file. By default the agent looks for this file in the directory that contains newrelic.jar. You can override the config file's location by setting the newrelic.config.file system property to a fully qualified file name.
The newrelic.yml file has separate sections for different environments:
Test
Development
Staging
Production (default)
New Relic applies settings in the common section to each of these environments. You can select other environments as the default by setting the newrelic.environment system property to the environment name.
If you edit newrelic.yml, be careful to conform to the YAML format. Use a YAML validator to ensure the syntax is accurate before using the file with New Relic's Java agent, and follow these rules:
Java agent newrelic.yml
Requirements
Format
YML files are case sensitive.
Indentations
All indentations must be in increments of two characters. Other indentations will result in an Unable to parse configuration file error upon agent startup.
Use the same level of indentation for data in the same section of the file.
Indent any sub-sections by an additional two spaces.
Changes to file
You must restart your JVM host process for changes to take effect.
Exception: Property changes to log_level and audit_mode do not require a restart. Property changes under circuit breaker don't require a restart.
Configuration settings precedence
To override any setting in the config file, use a system property override. In certain environments, environment variables can also be used to override both the config file and the system properties. The environment variables primarily exist to support Heroku. When used, server-side configuration overrides all other configuration settings.
With the Java agent, server-side configuration overrides all other settings. Environment variables override Java system properties. Java properties override user configuration settings in your newrelic.yml file. User settings override the newrelic.yml default settings.
Configuring the Java extensions directory
The Java agent reads the configuration files on process startup. To identify the directory where the files are located, either create a new or specify an existing extensions directory:
To create the extensions directory:
Navigate to the directory where newrelic.jar and newrelic.yml are located. Create a directory named extensions.
In newrelic.yml, check that the property extensions.dir is not set.
To use an existing Java extensions directory:
In your newrelic.yml file, locate the common section.
Use the property extensions.dir to specify the location of the file.
General configuration settings
Set these options in the common section. To override any of these options, use a newrelic.config prefixed system property.
Typ
String
Default
(none)
This setting is required. You must specify the license key associated with your New Relic account. This key binds your agent's data to your account in the New Relic service.
Typ
String
Default
(none)
This setting is required. Defines the application name used to report data to New Relic.
If enable_auto_app_naming is false, the agent reports all data to this application. Otherwise, the agent reports only background tasks (transactions for non-web applications) to this application.
To report data to more than one application, separate the application names with a semicolon. For example, to report data to My Application and My Application 2 use this:
Flag to enable the agent. Use this setting to force the agent to run or not run.
Typ
Float
Default
1.0
The apdex_t threshold in seconds for the application's Apdex score. For Java agent versions 1.2.008 or higher, the apdex_t value is set in the UI and the value in newrelic.yml is ignored.
Typ
Integer
Default
(none)
Number to differentiate JVMs for the same app on the same machine. New Relic uses host/port for uniqueness, so you can distinguish the JVMs by putting a switch like this into the startup arguments for each JVM:
-Dnewrelic.config.appserver_port=8081
Once you have used appserver_port to name the JVMs and restart them, you should be able to see them individually in the dropdown and in the profiling interface.
Important
This is only a change for New Relic; it doesn't actually affect the port on which the host communicates in any way.
Typ
Boolean
Default
false
Enables plain text logging of all data sent to New Relic to the agent logfile. This setting is dynamic, so running agents will notice changes to newrelic.yml without a JVM restart.
Typ
String
Value Format
/path/to/ca/cert/bundle.pem
Specifies a path to a custom SSL certificate bundle that will be used by the agent to establish a secure connection to New Relic. If your custom SSL certificate bundle doesn't include certificates that are sufficient to connect to New Relic then you'll need to merge the required certs into your custom certificate bundle.
Important
Our implementation of the Java Flight Recorder that is currently bundled with the Java agent uses the Telemetry SDK. Specifying a ca_bundle_path will not update the certificate our JFR option uses to connect to New Relic. If you are using a custom truststore and would like to use the Java agent JFR implementation, then you'll need to add the required certs into your custom truststore.
Typ
Boolean
Default
false
Enables the reporting of data separately for each web app. Set to true to enable support for auto app naming. The name of each web app is detected automatically and the agent reports data separately for each one. This provides a finer-grained performance breakdown for web apps in New Relic.
Enables component-based transaction naming. Set to true to enable component-based transaction naming. Set to false to use the URI of a web request as the name of the transaction. For more information, see Naming web transactions.
Caution
Unless you implement API calls to name your transactions, disabling auto-transaction naming is very likely to cause Metric grouping issues.
Typ
Boolean
Default
true
Enables all instrumentation using an @Trace annotation. Disabling this causes @Trace annotations to be ignored.
Event ingest URI used by some agent features. Defaults to the US production ingest endpoint. Can be manually configured to send events to other ingest endpoints (for example, EU production: https://insights-collector.eu01.nr-data.net/v1/accounts/events).
FedRAMP compliant customers should use the FedRAMP compliant endpoint: https://gov-insights-collector.newrelic.com/v1/accounts/events
Typ
String
Default
(none)
Defines the location of the optional extensions directory. If this property is not set, the agent will look for a subdirectory named extensions in the same directory as newrelic.jar and newrelic.yml.
Typ
Boolean
Default
false
In order for high security to be enabled, this property must be set to true and the high security property in the New Relic user interface must be enabled. Enabling high security means SSL is turned on, request and message queue parameters are not collected, and queries cannot be sent to New Relic in their raw form.
Important
As of Java agent 3.48.0, SSL is enabled by default and the config option to disable it has been deprecated. As of Java agent 4.0.0, the ability to disable SSL has been removed.
Typ
String
Default
(none)
Provides the ability to configure a FedRAMP compliant endpoint for the agent to use, with the value gov-collector.newrelic.com.
Typ
String
Default
(none)
A valid Insert API Key for your account. This is not currently used by the agent.
Note that this option now enables tags, which replaced the label feature. You can still query your historical labels. Multiple tags can be attached by using a semicolon as a separator as follows:
In rare cases, a memory leak could occur with instrumentation that uses the legacy async API to track the lifecycle
of async servlets or Jetty Continuations. The memory leak would manifest as leaked transactions that were suspended
but never resumed. This configuration acts as a workaround to prevent such a scenario from occurring. It is
advised to only enable this workaround when encountering such a memory leak.
Typ
Integer
Default
30
Limits the number of lines the agent collects from each stack trace. Increasing this value may impact performance, because it increases the amount of memory the agent uses and the amount of data sent to New Relic.
Metric ingest URI used by some agent features. Defaults to the US production ingest endpoint. Can be manually configured to send metrics to other ingest endpoints (example EU production URI: https://metric-api.eu.newrelic.com/metric/v1).
FedRAMP compliant customers should use the FedRAMP compliant endpoint: https://gov-metric-api.newrelic.com/metric/v1
Typ
String
Default
(none)
The proxy host through which to connect to the New Relic collector. If a proxy is used, the host setting is required. Other proxy settings are optional.
Typ
String
Default
(none)
The password for proxy authentication. If a proxy is used, the host setting is required. Other proxy settings are optional. The username and password settings will be used to authenticate to Basic Auth challenges from a proxy server.
Important
The Java agent supports Basic (clear text) authentication.
Typ
String
Default
8080
The proxy host port number. If a proxy is used, the host setting is required. Other proxy settings are optional.
Typ
String
Default
(none)
The username for proxy authentication, such as Basic (clear text) authentication. If a proxy is used, the host setting is required. Other proxy settings are optional. The username and password settings will be used to authenticate to Basic Auth challenges from a proxy server.
Typ
String
Default
(none)
The proxy scheme used. Setting proxy_scheme: "https" will allow the agent to connect through proxies using the HTTPS scheme.
Typ
Boolean
Default
false
Whether errors are reported for Reactor Netty. Default is false. If set to true, Reactor Netty errors will be reported.
Notice, default was changed to false as of Java agent 6.5.0.
Typ
Boolean
Default
false
Enable delayed JVM shutdown to give the agent a chance to send latest metric data to New Relic before JVM shutdown.
Typ
Integer
Default
60
The number of seconds after which the agent will use the send_data_on_exit setting.
Typ
Boolean
Default
true
Enable reporting of JVM settings to New Relic.
Typ
Boolean
Default
true
When set to true, JVM properties will be sent to New Relic.
Typ
Boolean
Default
true
Requires connections to the New Relic collector to go over SSL.
The agent communicates with New Relic via HTTPS by default, and New Relic requires HTTPS for all traffic to and the New Relic REST API.
This work is done asynchronously to the threads that process your application code, so response times will not be directly affected by this change.
Important
As of Java agent 3.48.0, SSL is enabled by default and the config option to disable it has been deprecated. As of Java agent 4.0.0, the ability to disable SSL has been removed.
Typ
Boolean
Default
false
Enable the agent to connect the New Relic collector immediately upon app startup.
For more concise transaction trace details, the agent does not report Scala Futures as transaction segments, and those Futures do not contribute to the transaction’s total time.
Enabling scala_futures_as_segments increases your overhead. If you want Scala Futures to report as transaction segments so you can view them in a transaction trace, you can enable it:
scala_futures_as_segments:
enabled:true
Typ
Boolean
Default
true
When the exclusive time of a segment is less than 2% of the total transaction time, the metric for that method call will be aggregated under Java/other.
Setting trim_stats to false will disable this behavior, allowing metrics to be individually displayed.
trim_stats:false
Environment variables
Environment variables take the highest precedence and override the system properties and yml config settings.
To set environment variables, use the export VARNAME=value command.
To permanently set environment variables, add the export line to a file such as ~/.bashrc oder ~/.bash_profile.
You can override any setting from a system property or in the newrelic.yml by setting an environment variable. The environment variable corresponding to a given setting in the config file is the setting name prefixed by NEW_RELIC with all dots (.) and dashes (-) replaced by underscores (_). For example, the environment variable for the log_level setting is NEW_RELIC_LOG_LEVEL.
For settings nested in sections, prepend the section name to the setting name. For example:
The configuration above would convert to the following environment variable: NEW_RELIC_CLASS_TRANSFORMER_COM_NEWRELIC_INSTRUMENTATION_KAFKA_CLIENTS_SPANS_0_11_0_0_ENABLED
You can override any setting in the newrelic.yml file by setting a system property. The system property corresponding to a given setting in the config file is the setting name prefixed by newrelic.config. For example, the system property for the log_level setting is newrelic.config.log_level.
For settings nested in sections, prepend the section name to the setting name. For example, the system property for the enabled setting in the transaction_tracer section is newrelic.config.transaction_tracer.enabled.
In addition to overriding configuration settings, the agent recognizes these system properties:
Typ
Boolean
Default
(none)
Starting from agent version 8.7.0, if set to true and the Agent is running with JBoss EAP / Wildfly,
this will prevent the agent from requiring any class under the package javax.management to be loaded by the system classloader.
This is added to help fix application startup issues with JBoss Modules when the J2EE/Jakarta Management API is used.
More information is provided in the JBoss / Wildfly troubleshooting doc.
Typ
Boolean
Default
(none)
Expiramental flag that allows the agent to run with unsupported java versions.
Typ
String
Default
(none)
Set a display name to decorate the "host:port" label in the New Relic UI. Requires Java agent 3.17 or higher.
Typ
String
Default
(none)
String containing a fully qualified path to the newrelic configuration file. If empty, the agent assumes newrelic.yml is in the same directory as newrelic.jar.
Typ
Boolean
Default
(none)
Enable debug logging.
Typ
String
Default
(none)
String containing the environment configuration for the agent to use.
Typ
String
Default
(none)
String containing the home directory of agent. This defaults to the same directory as the agent jarfile.
Typ
String
Default
newrelic_agent.log
String containing the name of the agent log file.
AI monitoring
This section details the Java agent configuration options for AI monitoring. This feature can be configured in the ai_monitoring yaml config file stanza, with newrelic.config.ai_monitoring. prefixed system properties, or with NEW_RELIC_AI_MONITORING_ prefixed environment variables.
Important
If distributed tracing is disabled or high security mode is enabled, AI monitoring will not collect AI data.
Typ
Boolean
Default
false
When set to true, enables AI monitoring.
Typ
Boolean
Default
true
If set to false, agent will omit input and output content (like text strings from prompts and responses) captured in LLM events. This is an optional security setting if you don’t want to record sensitive data sent to and received from your LLMs.
Attributes
To set these options, use the attributes section. To override them, use a newrelic.config.attributes prefixed system property.
standard : Reporting will utilize standard (i.e. OTEL) Attributes. This configuration is encouraged. It will minimize impact to functionality and maintain the lowest level of ingest for attribute reporting.
legacy : Reporting will be done by the reintroduced HTTP Attributes, this configuration may impact current or future functionality.
both : This is the default configuration, reporting will be done by the reintroduced HTTP Attributes and the OTEL Attributes. This configuration will also increase your data ingest.
Important
Available since Java agent version 8.8.0. The default configuration, both, will increase data ingest. To avoid an increase in data ingest, you must override the default by setting http_attribute_mode to legacy oder standard.
Async instrumentation
These options are set directly in the common section and can be overridden by using a prefixed system property.
Typ
Integer
Default (seconds)
180
The number of seconds after which the agent will automatically expire an async token that has not been explicitly expired with token.expire(). For usage instructions, see Tokens: Connect async threads.
Important
Increasing this value may impact performance, because it increases the amount of memory the agent uses and prevents transactions from being reported due to unexpired tokens.
Typ
Integer
Default (seconds)
600
The number of seconds after which the agent will automatically end a segment that has not been explicitly ended with segment.end() oder segment.ignore(). For usage instructions, see Segments: Time arbitrary async activity.
Important
Increasing this value may impact performance, because it increases the amount of memory the agent uses and prevents transactions from being reported due to un-ended segments.
Browser monitoring
These options are set in the browser_monitoring section and can be overridden by using a newrelic.config.browser_monitoring prefixed system property.
Browser monitoring gives you insight into the performance real users are experiencing with your website. This is accomplished by measuring the time it takes for your users' browsers to download and render your web pages by injecting a small amount of JavaScript code into the header and footer of each page.
Typ
Boolean
Default
true
By default the agent automatically inserts API calls in compiled JSPs to inject the monitoring JavaScript into web pages. Set this attribute to false to turn off this behavior.
Typ
Comma-separated list of strings
Default
(none)
When auto_instrument is true, by default all pages are instrumented. List all pages that you want the auto instrumentation to skip here. You can still use manual instrumentation on these pages.
This setting can be used to turn on or off all attributes for browser monitoring. This is the data you can query. If attributes.enabled is false at the root level, no attributes will be sent up in browser monitoring regardless on how this property under browser_monitoring is set.
Typ
List of Strings
Default
(none)
If attributes are enabled for browser_monitoring, all attribute keys found in this list will be sent to New Relic in page views. For more information, see the agent attribute rules.
Typ
List of Strings
Default
(none)
All attribute keys found in this list will not be sent to New Relic in page views. For more information, see the agent attribute rules.
Circuit breaker
These settings customize the behavior of the Java circuit breaker. These settings are not included in newrelic.yml by default. You do not need to restart your JVM after changing them.
If you want to customize the circuit breaker, add it under the common section:
If your application is behaving as expected, you may want to disable the circuit breaker.
Typ
Integer (0 to 100)
Default
20
Customize the percentage of free heap memory below which the circuit breaker should trip. When the percentage of free heap memory is less than memory_threshold, and the CPU time spent doing garbage collection is greater than gc_cpu_threshold, the circuit breaker trips. In order to make the circuit breaker less likely to trip, decrease memory_threshold and/or increase gc_cpu_threshold. Adjust these values as needed, based on your application's operating performance and behavior.
Typ
Integer (0 to 100)
Default
10
Customize the precentage of garbage collection CPU time above which the circuit breaker should trip. When the percentage of free heap memory is less than memory_threshold, and the CPU time spent doing garbage collection is greater than gc_cpu_threshold, the circuit breaker trips. In order to make the circuit breaker less likely to trip, decrease memory_threshold and/or increase gc_cpu_threshold. Adjust these values as needed, based on your application's operating performance and behavior.
Cloud platform utilization
Set the cloud platform utilization settings in the utilization section and can be overridden with the newrelic.config.utilization prefixed system property.
The agent collects utilization information and sends it to the New Relic service. The agent can collect information from Amazon Web Services (AWS), Azure, Google Cloud Platform, and Pivotal Cloud Foundry instances. It will also collect information related to the Docker containers and Kubernetes services.
Typ
Boolean
Default
true
Determines whether the agent polls AWS metadata API.
Typ
Boolean
Default
true
Determines whether the agent polls Azure metadata API.
Typ
Boolean
Default
true
Determines whether the agent polls Google Cloud Platform metadata API.
Typ
Boolean
Default
true
Determines whether the agent reports the KUBERNETES_SERVICE_HOST environment variable.
Typ
Boolean
Default
true
Determines whether the agent reads Pivotal Cloud Foundry environment variables.
Typ
Boolean
Default
true
Determines whether the agent reads Docker information from the file system.
Code-level metrics
Code-level metrics give you detailed insight into how your code is performing at the method level. You'll see metrics for each method that's been automatically instrumented, or that's been instrumented by the @Trace annotation.
Set the code-level metrics options in the code_level_metrics section. They can be overridden with a newrelic.config.code_level_metrics prefixed system property.
Typ
Boolean
Default
true
Code-level metrics is disabled by default in agent version 7.10.0. Set this to true to turn it on. Beginning in agent version 7.11.0 the default is, as noted above, true.
Errors inbox configuration
Setting one of the following tags will help you identify which versions of your software are producing the errors.
NEW_RELIC_METADATA_SERVICE_VERSION will create tags.service.version on event data containing the version of your code that is deployed, in many cases a semantic version such as 1.2.3, but not always.
NEW_RELIC_METADATA_RELEASE_TAG will create tags.releaseTag on event data containing the release tag (such as v0.1.209 or release-209).
NEW_RELIC_METADATA_COMMIT will create tags.commit on event data containing the commit sha. You can use the entire sha or use just the first seven characters (e.g., 734713b).
An upcoming release of errors inbox will automatically track which versions of your software are producing errors. The version data will display in CodeStream.
Cross application tracer
Important
Cross application tracing has been deprecated as of agent version 7.4.0 and will be removed in a future agent version.
Instead of using cross application tracing, we recommend our distributed tracing features. Distributed tracing is an improvement on the cross application tracing feature and is recommended for large, distributed systems.
Set the cross application tracing options in the cross_application_tracer section. These settings can be overridden with a newrelic.config.cross_application_tracer prefixed system property.
Cross application tracing adds request and response headers to external calls using the Apache HttpClient libraries. This provides better performance data when calling applications monitored by other New Relic agents.
Set custom events settings in the custom_insights_events section. You can override these settings with a newrelic.config.custom_insights_events prefixed system property.
For Java agent versions prior to 4.1.0, the following YAML configuration is recognized:
custom_insights_events.enabled:true
custom_insights_events.max_samples_stored:5000
For agent versions 4.1.0 and above, the YAML configuration uses the nested section formatting:
custom_insights_events:
enabled:false
max_samples_stored:5000
Typ
Boolean
Default
true
This enables the custom event service.
Typ
Integer
Default
255
The maximum size of an attribute value, after which the value will be truncated. The default is 255 bytes (in UTF-8 charset encoding) and the max limit is 4095.
This config exists in Java agent version 8.9.0+.
Typ
Integer
Default
30000
The maximum number of sampled custom events reported every 60 seconds.
When configuring the agent for AI monitoring, set to max value 100000. Ensures that the maximum amount of LLM events are captured.
Class transformer
Set instrumentation related settings in the class_transformer section. You can override these settings with a newrelic.config.class_transformer prefixed system property or a NEW_RELIC_CLASS_TRANSFORMER_ prefixed environment variable.
Typ
Boolean
Default
False
When enabled, enhanced Spring transaction naming will name any transaction that originates from a Spring controller after the defined route and HTTP method. For example: /customer/v1/edit (POST). This includes controllers that implement or extend interfaces/classes with WebMVC related annotations (@RestController, @Controller, @RequestMapping, etc).
By default, this is configured to false, which will name transactions for those types of controllers based on the controller class name and method. For example; CustomerController/edit. This is the naming logic carried over from previous agent versions. "Standard" controllers, with all relevant annotations present on the actual class, will still get named based on route and HTTP method.
This config exists in Java agent version 8.9.0+.
Typ
String
Default
(none)
String containing the full class name of the annotation class the agent uses to determine which user-specified methods to instrument. For more information about custom annotations, see Java custom metric collection.
Distributed tracing lets you see the path that a request takes as it travels through a distributed system. It is on by default for Java agent version 7.4.0 or higher.
In the config file, you can override this manually in the distributed_tracing section. You can also override this using a prefixed system property (newrelic.config.distributed_tracing) or an environment variable (NEW_RELIC_DISTRIBUTED_TRACING_ENABLED). See the examples below.
By default, supported versions of the agent utilize both the newrelic header and W3C Trace Context headers for distributed tracing. The newrelic distributed tracing header allows interoperability with older agents that don't support W3C Trace Context headers. Agent versions that support W3C Trace Context headers will prioritize them over newrelic headers for distributed tracing.
If you do not want to utilize the newrelic header, setting this to true will result in the agent excluding the newrelic header and only using W3C Trace Context headers for distributed tracing.
For example, to exclude newrelic headers in the config file, you would use:
distributed_tracing:
exclude_newrelic_header:true
To exclude newrelic headers using a system property, you would use:
Set the error collector settings in the error_collector section. Unless otherwise noted, you can override these settings with a newrelic.config.error_collector prefixed system property. The error collector captures information about uncaught exceptions and sends them to New Relic for viewing.
Tip
For how to configure errors for the Java agent, including how to configure errors via the UI, see Java agent error configuration.
Typ
Boolean
Default
true
Enable error collection.
Typ
Section containing a list of fully qualified class_name strings
Default
(none)
Specified exception class names will be ignored and will not affect error rate or Apdex score, or be reported to APM. Cannot be specified by system property.
This setting is dynamic, so running agents will notice changes to newrelic.yml without a JVM restart.
For example:
error_collector:
ignore_classes:
-"com.example.MyException"
-"com.example.DifferentException"
An environment variable can be used to list exception class names you want to be ignored:
Section containing a fully qualified class_name and a list of messages per error class
Default
(none)
Specify exception class names the agent should ignore. Ignored messages will not affect error rate or Apdex score, or be reported to APM. Contains yaml pairs consisting of:
A fully qualified exception class name that should not be reported to APM
AND
A list of exception messages to match against (at least one is required)
If the exception class name matches an error but the message does not, then that error will not be ignored. Message strings use contains for matching. A message cannot be provided on its own and must always be paired with a fully qualified class name. Cannot be specified by system property.
This setting is dynamic, so running agents will notice changes to newrelic.yml without a JVM restart.
For example:
error_collector:
ignore_messages:
com.example.MyException:
-"Some error message to ignore"
-"Some other error message to ignore"
com.example.DifferentException:
-"Some different error message to ignore"
An environment variable can be used to list exception class names and messages you want to be ignored:
NEW_RELIC_ERROR_COLLECTOR_IGNORE_MESSAGES="{\"com.example.MyException\": [\"Some error message to ignore\", \"Some other error message to ignore\"], \"com.example.DifferentException\": [\"Some different error message to ignore\"]}"
Typ
Comma-separated list of strings and ranges
Default
404
A comma-separated list comprised of individual and dashed ranges of HTTP status codes that should not be treated as errors.
If this property is commented out in the newrelic.yml configuration file, then the 404 status code will automatically be ignored. When using server-side configuration, the status code 404 must be specified in order for it to be ignored.
This setting is dynamic, so running agents will notice changes to newrelic.yml without a JVM restart.
For example:
error_collector:
ignore_status_codes:404,507-511
Typ
Section containing a List of fully qualified class_name strings
Default
(none)
Prevents specified exception classes from affecting error rate or Apdex score while still reporting the errors to APM. Cannot be specified by system property.
This setting is dynamic, so running agents will notice changes to newrelic.yml without a JVM restart.
For example:
error_collector:
expected_classes:
-"com.example.MyException"
-"com.example.DifferentException"
An environment variable can be used to list expected exception class names:
Section containing a fully qualified class_name and a List of messages per error class
Default
(none)
Contains yaml pairs consisting of a fully qualified exception class name that should be marked as expected and thus prevented from affecting error rate or Apdex score and a List of exception messages to match against, the latter of which at least one is required. If the exception class name matches an error but the message does not, then that error will not be marked as expected and therefore will affect error rate and Apdex score.
Message strings use contains for matching. A message cannot be provided on its own and must always be paired with a fully qualified class name. Cannot be specified by system property.
This setting is dynamic, so running agents will notice changes to newrelic.yml without a JVM restart.
For example:
error_collector:
expected_messages:
com.example.MyException:
-"Some expected error message"
-"Some other expected error message"
com.example.DifferentException:
-"Some different expected error message"
An environment variable can be used to list expected exception class names and messages:
NEW_RELIC_ERROR_COLLECTOR_EXPECTED_MESSAGES="{\"com.example.MyException\": [\"Some error message to ignore\", \"Some other error message to ignore\"], \"com.example.DifferentException\": [\"Some different error message to ignore\"]}"
Typ
Comma-separated list of strings and ranges
Default
(none)
A comma-separated list comprised of individual and dashed ranges of HTTP status codes to be marked as expected and thus prevented from affecting error rate or Apdex score.
This setting is dynamic, so running agents will notice changes to newrelic.yml without a JVM restart.
For example:
error_collector:
expected_status_codes:415,500-506
Expected status codes can also be with the NEW_RELIC_ERROR_COLLECTOR_EXPECTED_STATUS_CODES environment variable.
Typ
Boolean
Default
true
This setting can be used to turn on or off all attributes for traced errors. If attributes.enabled is false at the root level, then no attributes will be sent to traced errors regardless of how this property is set under error_collector.
Typ
List of strings
Default
(none)
If attributes are enabled for traced errors, all attribute keys found in this list will be sent to New Relic in traced errors. For more information, see the agent attribute rules.
Typ
List of strings
Default
(none)
Attribute keys found in this list will not be sent to New Relic in traced errors. For more information, see the agent attribute rules.
Typ
Boolean
Default
true
When multiple errors are noticed in a transaction, only the last error will be reported by default. Setting this property to false will instead report only the first error that is noticed. For more information, see the noticeError API.
For example:
error_collector:
ignoreErrorPriority:false
Typ
Comma-separated list of Strings
Default
(none)
All specified exception class names specified will not be treated as errors. Deprecated as of Java agent 3.40.0 and replaced by ignore_classes.
For example:
error_collector:
ignore_errors: some.other.MyException
External tracer
Set the external tracing options in the external_tracer section. These options can be overridden with a newrelic.config.external_tracer prefixed system property.
Typ
Boolean
Default
false
This setting can be used to control the collection of outgoing request URIs for errors and transaction traces. Set this to true to disable collecting this information.
Hostname configuration
Set the hostname configuration options in the process_host section. These options can be overridden with a newrelic.config.process_host prefixed system property.
Use these properties to configure the hostname displayed in the UI:
Typ
String
Default
(none)
Set a display name to decorate the "host:port" label in the New Relic UI.
Typ
String
Default
4
If the hostname cannot be determined, then the IP address of the host will be used. This property determines whether the IPv4 or IPv6 address should be used. The default is IPv4.
You can also use the system property newrelic.config.infinite_tracing.trace_observer.host or the environment variable NEW_RELIC_INFINITE_TRACING_TRACE_OBSERVER_HOST.
Instrumentation
These options are set in the instrumentation stanza and can be overridden by using a newrelic.config.instrumentation prefixed system property.
Typ
Boolean
Default
false
By default, @TraceLambda annotations are disabled. To use the annotation functionality for tracing lambda methods you must explicitly enable the feature as follows:
You can configure this via YAML:
instrumentation:
trace_lambda:
enabled:true
You can also use the system property newrelic.config.instrumentation.trace_lambda.enabled=true or the environment variable NEW_RELIC_INSTRUMENTATION_TRACE_LAMBDA_ENABLED.
Jar collector
The Java agent collects information about jars and their versions on the application classpath.
Set the jar collection configuration in the jar_collector section. These configuration options can be overridden with a newrelic.config.jar_collector prefixed system property. Options include:
Typ
Boolean
Default
true
Used to enable/disable jar collection and reporting.
Typ
Boolean
Default
true
Used to enable/disable collection of temporary jars. Temporary jars are those residing in the directory specified by the system property java.io.tmpdir.
Typ
Integer
Default
10
The maximum number of jars to process per second. Must be positive.
JFR (Real-time profiling)
The Java agent uses Java Flight Recorder (JFR) to collect high fidelity JVM data for Real-time profiling.
Configure real-time profiling in the jfr section in the agent YAML with system properties prefixed by newrelic.config.jfr. or with environment variables prefixed with NEW_RELIC_JFR_.
Typ
Boolean
Default
false
Set to true to enable Real-time profiling with JFR. This setting will apply dynamically and does not require a JVM restart.
Important
Real-time profiling with JFR is on by default in Java agent version 7.1.0. If you are on any other agent version 7.0.0 or higher, you can turn on JFR by changing the value to true.
Typ
Boolean
Default
false
Set to true to enable audit logging which will display all JFR metrics and events in each harvest batch. Audit logging is extremely verbose and should only be used for troubleshooting purposes.
Starting with Java agent version 7.6.0, support for logs in context has been added to the agent, making it easy to use for supported logging frameworks. For tips on using the Java agent for logs in context, see Java logs in context.
Changing these settings in your local agent configuration file happens dynamically and doesn't require a restart of the agent for those changes to take effect. An example configuration:
application_logging:
enabled:true
forwarding:
enabled:true
max_samples_stored:10000
context_data:
enabled:false
include:
exclude:
metrics:
enabled:true
local_decorating:
enabled:false
Set the logs in context configuration in the application_logging section. This can be overridden with a newrelic.config.application_logging prefixed system property. The only option available is:
Typ
Boolean
Default
true
Set to true to enable the core logs in context feature. When enabled, additional logging framework instrumentation is enabled, whether or not logs are decorated or sent to New Relic.
Important
Agent releases 7.7.0 and higher has this feature enabled in the agent configuration file by default.
Set to false to completely disable this feature, including the collection of log metrics.
Log forwarding
If you're using a supported logging framework and want to use the agent to send your application logs to New Relic, you can control that through settings under the forwarding section. These settings can be overridden by the newrelic.config.application_logging.forwarding prefixed system property. Options available are:
Typ
Boolean
Default
true
Enables the sending of application logs to New Relic.
Important
Agent releases 7.7.0 and higher have this feature enabled in the agent configuration file by default.
Using the log forwarding feature will increase your data ingest, which may affect your billing. For more information, see our documentation about tracking your data ingest.
If you have an existing log forwarding solution and are updating your agent to use automatic logs in context, be sure to disable your old log forwarder. Otherwise, your app will be sending double log lines. Depending on your account, this could result in double billing. For more information, follow the procedures to disable your specific log forwarder.
Set this to true to have your decorated logs sent to New Relic.
Set this to false if you do not want your decorated logs sent to New Relic.
Typ
Integer
Default
10000
A positive integer specifying the maximum number of logs lines per minute to send.
Set this to 0 to effectively disable the sending of logs.
Important
This controls the number of logs sent per minute. Setting max_samples_stored to 0 - or any value less than 12 - does not disable the feature itself, though it does result in no log lines being sent to New Relic.
Set this to a lower value to reduce the amount of log lines sent (may cause log sampling). Set this to a higher value to send more log lines.
Each log receives the same priority as its associated transaction. Logs that occur outside of a transaction will receive a random priority. Some logs may not be included because they are limited by max_samples_stored. For example, if logging max_samples_stored is set to 10,000 and transaction 1 has 10,000 log entries, only log entries for transaction 1 will be recorded. If transaction 1 has less than 10,000 logs you receive all logs for transaction 1. If there is still space, you receive all the logs for transaction 2, and so on.
If after all the logs for sampled transactions are recorded, and they haven't reached the limit in max_samples_stored, then log messages for transactions that were not in our sampling are sent. If there are any left, log messages outside of transactions are recorded.
Log context data
The Java agent can capture context data (Mapped Diagnostic Context in logback/slf4j, ThreadContext in log4j2) and add its contents as attributes in the logs forwarded to New Relic. You can control that through settings in the context_data section, nested under the forwarding section. These settings can be overridden by the newrelic.config.application_logging.forwarding.context_data prefixed system property. Options available are:
Typ
Boolean
Default
false
Set this to true sending of context data as log attributes to New Relic.
Set this to false if you do not want context data in the logs sent to New Relic.
Typ
List of strings
Default
(none)
If context_data is enabled for log forwarding, all attribute keys found in this list will be sent to New Relic in log records. If this list is empty, then all attributes will be sent.
Typ
List of strings
Default
(none)
If context_data is enabled for log forwarding, all attribute keys found in this list will NOT be sent to New Relic in log records.
The include and exclude list follow the rules Exclude overrides include, More specific rules take priority, Keys are case-sensitive and Use an asterisk for wildcards defined in Attribute rules.
Log metrics
In addition to allowing you to decorate and send individual log lines, the Java agent can capture logging metric data. You can find this data in the logs chart in the New Relic UI. You can configure log metrics settings in the metrics section. You can override these settings with the newrelic.config.application_logging.metrics prefixed system property. The only available option is:
Typ
Boolean
Default
true
Enables the capture of metrics information about your logs and log levels, which is displayed in a chart on the APM Summary page.
Leave this set to true to allow the agent to capture metric information about your logs.
Set this to false to disable this feature.
Important
If you disable the collection of log metrics, the log chart on the summary page will appear blank.
Log decorating
You can configure the log decorating settings in the local_decorating section. You can use this to control how local log lines are decorated. You can override these settings with a newrelic.config.application_logging.local_decorating prefixed system property. The only option available is:
Typ
Boolean
Default
false
This controls whether locally stored log lines are decorated or not. This is independent of whether log forwarding is enabled or not and is used to support customers that want to use a separate log forwarding solution.
Set this to true to cause the agent to add logs in context linking metadata to log lines stored locally by supported frameworks.
Important
Enabling local log decorating will add linking metadata to your application log files, resulting in an increase in disk storage. Disable this feature if this is unacceptable.
It is not necessary to use local log decorating when log forwarding is enabled. Doing so will cause linking metadata to be added to your log messages unnecessarily, which may be visually distracting.
Set this to false to turn off the local decorating feature. This will not impact the decorating of log lines being sent to New Relic.
Logging configuration
These are part of the general configuration variables. They are broken out here because they are frequently tweaked for debugging.
Some of the logging configuration variables are dynamic and do not need a host restart for them to take effect. For instance, if log files are growing too quickly, log_level can be set to a less verbose setting to reduce the reporting rate.
Here is the order of precedence and explanation for configuration variables affecting log rotation.
If log_daily is true:
A log_limit_in_kbytes value greater than zero will result in a composite triggering policy, where logs will roll once per day or when the defined size is reached, retaining up to log_file_count files
A log_limit_in_kbytes value of zero will result in logs rolling once per day retaining up to log_file_count files
If log_daily is false and log_limit_in_kbytes > 0, a sized based policy will be configured, where logs will roll when the defined size is reached, retaining up to log_file_count files
If log_daily is false and log_limit_in_kbytes = 0, no log file rolling logic will be configured
Depending on the growth rate, it is possible for the log file size to exceed the configured value by a small amount.
Typ
Boolean
Default
false
Set to true to roll the logs daily.
Typ
Integer
Default
1
The maximum number of log files to keep when using log rotation.
Typ
String
Default
newrelic_agent.log
The unqualified log file name or the string STDOUT which will log to standard out.
Typ
String
Default
logs subdirectory where newrelic.jar is located
The log file path.
Tip
If log_file_path is specified, the directory must already exist. If the default value is used, the agent will attempt to create the directory.
Typ
String
Default
info
The log verbosity level. When you change this setting in the agent yaml config file, it will update dynamically. However, the environment variable and system property will not update dynamically.
The agent uses its own log file to keep its logging separate from that of your application. Valid options, in order of verboseness, are:
off
severe
warning
info
fine
finer
finest
Caution
Do not use debug oder trace logging unless New Relic Support asks you to use them. These levels of logging can generate excessive overhead. For most situations, use info.
This setting is dynamic, so running agents will notice changes to newrelic.yml without a JVM restart.
Typ
Integer
Default
0
The log file size in kilobytes at which log files are rotated. Set to 0 for no limit.
Message tracer
Set message tracer options in the message_tracer section. You can override these settings with a newrelic.config.message_tracer prefixed system property.
Typ
Boolean
Default
true
Adds message properties to tracer attributes. Set this to false to turn it off.
Open Telemetry SDK Auto-Configuration
Configuration for the open telemetry SDK autoconfigure instrumentation under the section:
opentelemetry:
sdk:
autoconfigure:
Typ
Boolean
Default
true
Allows the agent's Opentelemetry SDK autoconfiguration feature to be enabled. Can be set via the system property:
Run IAST with non-production deployments only to avoid exposing vulnerabilities on your production software.
You can set the New Relic Security agent configuration in the security section. These settings can be overridden with a newrelic.config.security prefixed system property. Options include:
Typ
Boolean
Default
false
To completely disable all security functionality, set this flag to false. This property is read only once at application start. Default is false.
Typ
Boolean
Default
false
Determines whether the security data is sent to New Relic or not. When this is disabled and agent.enabled is true, the security module will run but data will not be sent. Default is false.
Typ
String
Default
IAST
New Relic Security provide mode: IAST. Default is IAST. Due to the invasive nature of IAST scanning, DO NOT enable this mode in either a production environment or an environment where production data is processed.
Typ
String
Default
wss://csec.nr-data.net
New Relic Security’s SaaS connection URL. This is the endpoint that the security agent sends data to, it should match that environment that you have set for the APM Java agent.
US Production: wss://csec.nr-data.net
Typ
Boolean
Default
true
Enable RCI security event detection. Default is true.
Typ
Boolean
Default
true
Enable RXSS security event detection. Default is true.
Typ
Boolean
Default
true
Enable deserialization security event detection. Default is true.
The agent can now detect slow transactions via SlowTransaction events since Java Agent version 8.7.0.
These events are recorded when the transaction length exceed a certain threshold. By default the treshold is 600000 milliseconds (10 minutes).
Slow transaction detection is set in the slow_transactions and can be overridden by using a newrelic.config.slow_transactions prefixed system property. Options include:
Typ
Boolean
Default
true
Used to enable/disable slow transaction detection.
Typ
Integer
Default
600000
Determines how long a transaction has to take in milliseconds for a SlowTransaction event to be reported.
Typ
Boolean
Default
true
If this is set to true, every transaction will be checked for exceeding the defined threshold on
transaction completion. Note that if a large number of transactions exceed the threshold,
this can be computationally expensive since a stack trace is sent with every SlowTransaction event.
Set span events configuration in the span_events section. These settings can be overridden with a newrelic.config.span_events prefixed system property. Options include:
Typ
Boolean
Default
true
Used to enable/disable span event reporting.
Typ
Integer
Default
2000
Max
10000
Determines the number of span events that can be captured during an agent harvest cycle. Available in Java agent 7.4.0 and above.
When configuring the agent for AI monitoring, set to max value 10000. Ensures that the maximum amount of traces are captured.
Important
Increasing the number of span events can lead to additional agent overhead.
Typ
Boolean
Default
true
This setting can be used to turn on or off all attributes for span events. If attributes.enabled at the root level is false, no attributes will be sent to span events regardless on how this property (span_events.attributes.enabled) is set.
Typ
List of strings
Default
(none)
If attributes are enabled for span events, all attribute keys found in this list will be sent to New Relic in span_events. For more information, see the agent attribute rules.
Typ
List of strings
Default
(none)
All attribute keys found in this list will not be sent to New Relic in span events. For more information, see the agent attribute rules.
Set the strip exceptions options in the strip_exception_messages section. These options can be overridden with a newrelic.config.strip_exception_messages prefixed system property. Enable this setting to control whether Java exception messages are reported to New Relic.
Typ
Boolean
Default
false
By default, this is set to false, which means that the agent sends messages from all exceptions to the New Relic collector.
If you set this to true, the agent strips the messages from exceptions in order to prevent it from inadvertently capturing sensitive information.
If you set enabled to true but you want the agent to capture messages from specific exceptions, add the exceptions to your allow list.
Typ
String
Default
(none)
Important
This config has been deprecated as of agent version 5.10.0 and will be removed in a future agent version. Instead use allowed_classes.
If you set enabled to true but you want the agent to capture messages for specific exceptions, add each exception to the whitelist, separated by a comma.
Typ
String
Default
(none)
If you set enabled to true but you want the agent to capture messages for specific exceptions, add each exception to allowed_classes, separated by a comma.
Thread profiler
Set the thread profiler options in the thread_profiler section. These options can be overridden with a newrelic.config.thread_profiler prefixed system property.
Thread profiler measures wall clock time, CPU time, and method call counts in your application's threads as they run.
Typ
Boolean
Default
true
Enable the thread profiler.
Transaction events
Set the transaction events options in the transaction_events section. These options can be overridden with a newrelic.config.transaction_events prefixed system property.
Transaction events data is used to display histograms and percentiles in the UI.
Important
Previously, this section was called analytics_events. If your configuration file still uses analytics_events, update your agent to use transaction_events.
Typ
Boolean
Default
true
Enable the transaction events service.
Typ
Integer
Default
2000
Max
10000
The maximum number of sampled transaction events reported every 60 seconds.
Typ
List of maps
Default
(none)
Important
Unlike other settings, custom_request_headers have to be paired together and must be set in the newrelic.yml file. They can't be overwritten by Java virtual machine arguments (system property) or environment variables.
A list of maps with the paired keys header_name and the optional header_alias. Choose one or more custom HTTP request headers to add as transaction attributes.
You can list multiple header configurations:
transaction_events:
custom_request_headers:
-
header_name:"X-Custom-Header-1"
-
header_name:"X-Custom-Header-2"
header_alias:"CustomHeader2alias"
In the first map set, X-Custom-Header-1 is captured and reported by the agent as the header name for a corresponding value from the request object. The header_name will also be the name of the attribute sent to New Relic.
In the second map set, the request header is X-Custom-Header-2, but the CustomHeader2alias is the name sent to New Relic.
Typ
Boolean
Default
true
This setting can be used to turn on or off all attributes for transaction events. If attributes.enabled is false at the root level, then no attributes will be sent to transaction events regardless of how this property is set under transaction_events.
Typ
List of Strings
Default
(none)
If attributes are enabled for transaction events, all attribute keys found in this list will be sent to New Relic in transaction events. For more information, see the agent attribute rules.
Typ
List of Strings
Default
(none)
All attribute keys found in this list will not be sent to New Relic in transaction events. For more information, see the agent attribute rules.
Transaction segments
Set the transaction segments options in the transaction_segments section. These options can be overridden with a newrelic.config.transaction_segments prefixed system property.
Transaction segments represent discrete pieces of work (generally method calls) and are displayed within transaction traces.
This setting can be used to turn on or off all attributes for transaction segments. If attributes.enabled at the root level is false, no attributes will be sent to transaction segments regardless on how this property (transaction_segments.attributes.enabled) is set.
Typ
List of strings
Default
(none)
If attributes are enabled for transaction segments, all attribute keys found in this list will be sent to New Relic in transaction segments. For more information, see the agent attribute rules.
Typ
List of Strings
Default
(none)
All attribute keys found in this list will not be sent to New Relic in transaction segments. For more information, see the agent attribute rules.
Transaction tracer
Set the transaction tracer options in the transaction_tracer section. These options can be overridden with a newrelic.config.transaction_tracer prefixed system property.
Transaction tracing captures deep information about slow transactions and sends this to the New Relic service. The transaction includes the exact call sequence of the transactions, including any query statements issued.
Important
Do not use brackets [suffix] at the end of your transaction name. New Relic automatically strips brackets from the name. Instead, use parentheses (suffix) or other symbols if needed.
Typ
Boolean
Default
true
The transaction tracer is enabled by default. Set this to false to turn it off.
Threshold in seconds for query execution time below which the slow query and the EXPLAIN plan (if supported) will not be captured. Relevant to slow queries only when record_sql is set to raw oder obfuscated. Relevant to EXPLAIN plans only when explain_enabled is set to true.
Typ
Integer
Default
2000
The character limit for the SQL query string. If you have many slow SQL queries with large chunks of information, this could negatively affect performance or how quickly you see your data in New Relic. Increase the value gradually until you find the right balance of information and performance.
Typ
Boolean
Default
false
Set to true to enable logging of queries to the agent log file instead of uploading to New Relic. Queries are logged using the record_sql mode.
Typ
String
Default
obfuscated
When the transaction tracer is on, query statements can optionally be recorded. The recorder has three modes:
off: Send no queries.
raw: Send the query statement in its original form.
obfuscated: Strips out numeric and string literals.
Typ
Boolean
Default
false
Defaulted to true until Java agent version 3.12.1, when it was changed to false.
This option is for Play 2.x+ only. Play/Scala instrumentation can use Thread.getStackTrace() to improve tracer naming, but at the cost of increased overhead.
Typ
Integer
Default
0.5
Defines a threshold (in seconds) for collecting stack traces from an SQL call. When SQL statements exceed this threshold, the agent will capture the current stack trace. This is useful for pinpointing where long SQL calls originate from.
Typ
Integer
Default
20
Use this setting to control the variety of your transaction traces. top_n is an integer that represents the number of unique, slow transactions that traces will be created for.
If you want transaction traces to more accurately reflect the actual slowest transactions in your app, make this value lower.
If you want to sample a more diverse array of transactions, make the value higher.
A value of 0 would mean that only the slowest transaction is always traced. This is considered not to be optimal, though, because you may have one or two transactions that are always the slowest, and repeatedly seeing those same transaction traces will probably not give you much value.
If the same transaction is often the slowest, the top_n setting allows the Java agent (over time) to sample the slowest n transactions. This gives you greater variety and more insight into your application.
Typ
String (float)
Default
apdex_f
The time threshold used to determine when a transaction is eligible to be traced. When the transaction's response time exceeds this threshold, a transaction trace will be recorded and sent to New Relic.
The default is apdex_f (default), which sets the threshold to be the "Frustrated"Apdex level (four times the apdex_t value). You can also set a specific time threshold by entering a float value that represents a number of seconds.
Typ
String
Default
(none)
Important
This config has been deprecated as of agent version 5.10.0 and will be removed in a future agent version. Instead use collect_slow_queries_from.
By default, high-security mode does not allow the agent to collect slow queries. Enable this option to collect Cassandra queries from the DataStax driver, even with high security enabled. If you don't use high security, the agent collects slow queries automatically.
For DataStax driver 2.1.2, add this rule to your allow list:
By default, high-security mode does not allow the agent to collect slow queries. Enable this option to collect Cassandra queries from the DataStax driver, even with high security enabled. If you don't use high security, the agent collects slow queries automatically.
For DataStax driver 2.1.2, add this rule to your allow list:
This setting can be used to turn on or off all attributes for transaction traces. If attributes.enabled at the root level is false, no attributes will be sent to transaction traces regardless on how this property (transaction_tracer.attributes.enabled) is set.
Typ
List of strings
Default
(none)
If attributes are enabled for transaction traces, all attribute keys found in this list will be sent to New Relic in transaction traces. For more information, see the agent attribute rules.
Typ
List of Strings
Default
(none)
All attribute keys found in this list will not be sent to New Relic in transaction traces. For more information, see the agent attribute rules.
Typ
Integer
Default
3000
Limits the number of Tokens that can be created per Transaction. Increasing this value may impact performance, because it increases the amount of memory the agent uses and the amount of data sent to New Relic.
Typ
Integer
Default
3000
Limits the number of segments that can be created per transaction. Increasing this value may impact performance, because it increases the amount of memory the agent uses and the amount of data sent to New Relic.