• /
  • Log in

Node.js agent configuration

You can tailor the Node.js agent to your app's requirements by editing your newrelic.js config file or by setting an environment variable. The config file resides in the root directory of your app. You can also configure a few options from New Relic, or use the Node.js agent API.

Important

The license_key setting is required. We highly recommend setting the app_name so that your app has a meaningful name instead of the default My Application.

Configuration methods and precedence

The primary method to configure the Node.js agent is the agent configuration file (newrelic.js). You can also configure most settings with environment variables. You can also adjust some settings with server-side configuration.

The Node.js agent uses this order of precedence for configuration methods:

Node.js agent configuration precedence

Node.js configuration hierarchy: Server-side configuration settings override environment variables. Environment variables override the agent config file. The config file overrides the agent defaults.

Here are detailed descriptions of each configuration method:

Exports variables

This section defines the Node.js agent variables in the order they typically appear in the exports.config = { section of your app's newrelic.js configuration file.

Logging variables

This section defines the Node.js agent variables in the order they typically appear in the logging: { section of your app's newrelic.js configuration file.

Audit logging

This section defines the Node.js agent variables in the order they typically appear in the audit_log: { section of your app's newrelic.js configuration file.

API configuration

This section allows you to choose which API methods are enabled. Each configuration option allows you to modularly enable API methods that are responsible for sending custom information to New Relic.

Important

All of these are set to false when the agent is in high security mode.

Attributes

This section defines the variables for Node.js agent attributes in the order they typically appear in the attributes: { section of your app's newrelic.js configuration file.

Caution

Any header-related include/exclude rules must be in camelCase form to be filtered.

Error collector variables

You can manage how error are handled in New Relic. This section defines the Node.js agent variables in the order they typically appear in the error_collector: { section of your app's newrelic.js configuration file.

Transaction tracer variables

The agent groups your requests into transactions, which are used to:

  • Visualize where your app spends its time (in transaction breakdowns).
  • Identify slow requests.
  • Group metrics.
  • Isolate other issues, such as slow database performance.

This section defines the Node.js agent variables in the order they typically appear in the transaction_tracer: { section of your app's newrelic.js configuration file.

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.

Rules variables

This section defines the Node.js agent variables in the order they typically appear in the rules: { section of your app's newrelic.js configuration file.

Transaction events variables

This section defines the Node.js agent variables in the order they typically appear in the transaction_events: { section of your app's newrelic.js configuration file.

Browser monitoring variables

This section defines the Node.js agent variables in the order they typically appear in the browser_monitoring: { section of your app's newrelic.js configuration file.

Custom events variables

This section defines the Node.js agent variables in the order they typically appear in the custom_insights_events: { section of your app's newrelic.js configuration file. Currently there are no environment variables for custom events.

Slow queries variables

This section defines the Node.js agent variables in the order they typically appear in the slow_sql: { section of your app's newrelic.js configuration file. These options control behavior for slow queries, but do not affect SQL nodes in transaction traces.

Custom hostname variables

This section defines the Node.js agent variables in the order they typically appear in the process_host: { section of your app's newrelic.js configuration file. These options control behavior regarding the host display name in the APM UI.

Environment variable overrides

This section defines two configuration options only available with environment variables. These overrides are not used in most configurations.

Datastore tracer variables

This section defines the Node.js agent variables in the order they typically appear in the datastore_tracer section of your app's newrelic.js configuration file. These options control behavior for collecting datastore instance metrics.

Cross application tracing (DEPRECATED)

The Node.js agent variables that control cross application tracing typically appear in the cross_application_tracer section of your app's newrelic.js configuration file:

Important

Cross application tracing (CAT) has been deprecated and will be removed in a future major release. For cross-service visibility, we recommend using distributed tracing, which is enabled by default as of agent version 8.3.0. Before enabling, read the transition guide.

Error message redaction variables

The Node.js agent variables that control error message redaction appear in the allow_raw_exception_messages section of your app's newrelic.js configuration file:

Distributed tracing

Important

Enabling distributed tracing disables cross application tracing, and has effects on other APM features. Before enabling, read the transition guide. Requires Node.js agent version 4.7.0 or higher.

Distributed tracing lets you see the path that a request takes as it travels through a distributed system. When configuring via the config file, place the following option in the distributed_tracing section.

Span events

Span data is reported for distributed tracing. Distributed tracing must be enabled to report spans. Span configuration is set in the span_events stanza. Options include:

Infinite Tracing

To turn on Infinite Tracing, enable distributed tracing (set distributed_tracing to enabled: true) and add the additional settings below. For an example, see Language agents: configure distributed tracing.

For more help

If you need more help, check out these support and learning resources:

Create issueEdit page
Copyright © 2021 New Relic Inc.