New Relic attributes are key-value pairs containing information that determines the properties of an event or transaction. These key-value pairs can help you gain greater insight into your application and annotate the data when you query it. You can also automatically forward user information to New Relic.
Both default and custom attributes are visible in transaction traces, distributed traces, and error analytics; APM events and Browser events in dashboards. You can customize exactly which attributes will be sent to each of these destinations.
This document describes the Java agent attributes, details how to enable or disable attributes, and describes the rules the agent follows to determine which attributes to include or exclude for a destination.
Tip
These attribute settings apply to version 3.7.0 or higher of the Java agent. If you use an older version of the agent, see Update legacy attribute configuration.
Java-specific attributes
In addition to the default APM attributes, the Java agent collects attributes from these sources:
The response status code for a web request. The key for this attribute is http.statusCode. Note: Agent versions below 8.0.0 used the attribute httpResponseCode.
The default setting for each destination is:
Transaction traces: Enabled
Error analytics: Enabled
APM events: Enabled
Browser events: Disabled
The response status message if present for a web request. The key for this attribute is http.statusText. Note: Agent versions below 8.0.0 used the attribute httpResponseMessage.
The default setting for each destination is:
Transaction traces: Enabled
Error analytics: Enabled
APM events: Enabled
Browser events: Disabled
The name of the thread. The key for this attribute is jvm.thread_name.
The default setting for each destination is:
Transaction traces: Enabled
Error analytics: Enabled
APM events: Disabled
Browser events: Unavailable
The name of a locked thread. The key for this attribute is jvm.lock_thread_name.
The default setting for each destination is:
Transaction traces: Unavailable
Error analytics: Enabled
APM events: Unavailable
Browser events: Unavailable
Attributes added by a call to the NewRelic.addCustomParameter(...) Java agent API. The key name for this attribute depends on what you specify when you call the method.
The default setting for each destination is:
Transaction traces: Enabled
Error analytics: Enabled
APM events: Disabled
Browser events: Disabled
Important
Before creating custom attributes, review New Relic's list of reserved terms used by NRQL. Otherwise, you might get some unexpected results.
The attribute system does not apply to any header values other than the ones listed above. If you want to capture additional request headers not listed here, you must use the custom_request_headers config option to specify headers for the agent to capture. Alternatively, you can directly record the headers yourself using the addCustomParameter() method from the Java agent API.
The default setting for each destination is:
Transaction traces: Enabled
Error analytics: Enabled
APM events: Enabled
Browser events: Disabled
The Java agent captures request methods GET, POST and PUT by default as part of the request.method attribute.
Request parameters from the transaction are not captured by default. Use the addCustomParameter() Java agent API to capture request parameters.
The key for these attributes is request.parameters.*. If capturing sensitive information is a concern, you can use these options:
Avoid using wild cards in attributes.include. Instead, explicitly specify each field to capture.
If you want to use a wild card in attributes.include, explicitly exclude the sensitive fields using attributes.exclude.
Collect user attributes
With APM's Java agent, you can automatically collect user information in by editing your configuration file. You can then run NRQL queries against user information without needing to create custom attributes manually. This feature is available with New Relic's Java agent 3.10.0 or higher.
# This instrumentation reports the name of the user principal returned from
# HttpServletRequest.getUserPrincipal() when servlets and filters are invoked.
com.newrelic.instrumentation.servlet-user:
enabled:true
Restart your web server.
If you are using the 8.1.0 release of the Java agent, or higher, you can query the enduser.id attribute through either enabling com.newrelic.instrumentation.servlet-user or using the public API and waiting a few minutes. For example, you could use the following NRQL query to obtain a unique count of all users:
SELECT uniqueCount(enduser.id)FROMTransaction SINCE 1day ago
Configure attributes: Enable, include, and exclude
You can configure which types of attributes, or which specific attributes, the Java agent reports to New Relic. This is often done for security reasons, when there are certain sensitive attributes you don't want reported to New Relic. To learn what settings override other settings, see the attribute configuration rules.
The Java agent follows these rules when determining which attributes to include or exclude for a destination:
If you set the main attributes.enabled property to false, the agent does not report any attributes at all.
Agent configuration:
attributes.enabled: false
attributes.include: request.parameters.*
error_collector.attributes.enabled: true
Input keys:
foo
bar
request.parameters.foo
request.parameters.bar
Agent output:
Transaction traces: No attributes
Error analytics: No attributes
APM events: No attributes
Browser events: No attributes
When you set enabled to false for a destination, the agent ignores your include/exclude settings and doesn't report any attributes for that destination.
Agent configuration:
transaction_tracer.attributes.enabled: false
attributes.include: one, two*
transaction_tracer.attributes.include: three, four
Input keys:
one
two
three
four
Agent output:
Transaction traces: No attributes
Error analytics: one, two
APM events: one, two
Browser events: No attributes
The .exclude properties override the .include properties.
Agent configuration:
attributes.enabled: true
attributes.include: foo, myCustomAtt
attributes.exclude: password, myCustomAtt
Input keys:
foo
myCustomAtt
password
Agent output:
Transaction traces: foo
Error analytics: foo
APM events: foo
Browser events: foo
If multiple include or exclude attributes affect the same key, the most specific setting will have priority.