---
title: Node.js agent other settings
source: https://docs.newrelic.com/docs/apm/agents/nodejs-agent/installation-configuration/nodejs-agent-configuration-other-settings
---

These settings cover additional Node.js agent configuration options including cloud provider variables, API configuration, event sampling, custom parameters, URL obfuscation, security, hosting services, and more.

> #### 💡 TIP
>
> Back to the full settings index: [Node.js agent configuration](https://docs.newrelic.com/docs/apm/agents/nodejs-agent/installation-configuration/nodejs-agent-configuration)

## Cloud variables [#cloud_config]

This section defines the Node.js agent variables to create a relationship between cloud providers and APM applications.

**cloud.aws.account_id**

| Type                             | Integer                          |
| -------------------------------- | -------------------------------- |
| Default                          | `null`                           |
| [Environ variable](#environment) | `NEW_RELIC_CLOUD_AWS_ACCOUNT_ID` |

The AWS account ID for the AWS account associated with this app.

## Audit logging [#audit_log]

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.

**enabled**

| Type                             | Boolean                       |
| -------------------------------- | ----------------------------- |
| Default                          | `false`                       |
| [Environ variable](#environment) | `NEW_RELIC_AUDIT_LOG_ENABLED` |

When enabled, the agent logs the payloads it sends to the collector. This data is included in the main log file even when logging level is set to the lowest level.

**endpoints**

| Type                             | Array                           |
| -------------------------------- | ------------------------------- |
| Default                          | `[]` (include all types)        |
| [Environ variable](#environment) | `NEW_RELIC_AUDIT_LOG_ENDPOINTS` |

The agent sends several different types of data to the collector in separate payloads. By default, all of them are included in the log file. This option makes it possible to limit logging only to specific types of data.

Valid values include:

-   `agent_settings`
-   `analytic_event_data`
-   `connect`
-   `custom_event_data`
-   `error_data`
-   `error_event_data`
-   `metric_data`
-   `preconnect`
-   `shutdown`
-   `span_event_data`
-   `sql_trace_data`
-   `transaction_sample_data`

## API configuration [#api_config]

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.

**custom_attributes_enabled**

| Type                             | Boolean                           |
| -------------------------------- | --------------------------------- |
| Default                          | `true`                            |
| [Environ variable](#environment) | `NEW_RELIC_API_CUSTOM_ATTRIBUTES` |

This option enables [`newrelic.addCustomAttribute`](https://docs.newrelic.com/docs/agents/nodejs-agent/supported-features/nodejs-agent-api#add-custom-param) and [`newrelic.addCustomAttributes`](https://docs.newrelic.com/docs/agents/nodejs-agent/supported-features/nodejs-agent-api#add-custom-params).

**custom_events_enabled**

| Type                             | Boolean                       |
| -------------------------------- | ----------------------------- |
| Default                          | `true`                        |
| [Environ variable](#environment) | `NEW_RELIC_API_CUSTOM_EVENTS` |

This option enables [`recordCustomEvent`](https://docs.newrelic.com/docs/agents/nodejs-agent/supported-features/nodejs-agent-api#record_custom_event).

**notice_error_enabled**

| Type                             | Boolean                      |
| -------------------------------- | ---------------------------- |
| Default                          | `true`                       |
| [Environ variable](#environment) | `NEW_RELIC_API_NOTICE_ERROR` |

This option enables [`newrelic.noticeError`](https://newrelic.github.io/node-newrelic/API.html#noticeError).

## Rules variables [#rules_config]

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.

**name**

| Type                             | Strings or regular expressions |
| -------------------------------- | ------------------------------ |
| Default                          | `[]`                           |
| [Environ variable](#environment) | `NEW_RELIC_NAMING_RULES`       |

A comma-delimited list of rules to match incoming request URLs and name the associated New Relic transaction. Uses the format:

````js
name: [
  { pattern: 'STRING_OR_REGEX', name: 'NAME' },
  { pattern: 'STRING_OR_REGEX', name: 'NAME' }
]
```

Both parameters are required. For strings, you must escape control characters. You do not need to escape control characters in regular expressions. Additional attributes are ignored.

Regular expressions support JavaScript-style capture groups, and names use `$1`-style replacement strings. Regular expressions only find the first matching result; subsequent matches are ignored. For more information, see [Node.js transaction naming API](/docs/agents/nodejs-agent/api-guides/nodejs-agent-api#ignoring).

For the `NEW_RELIC_NAMING_RULES` environment variable, pass the rules as comma-delimited JSON object literals:

```ini
NEW_RELIC_NAMING_RULES='{"pattern":"^t","name":"u"},{"pattern":"^u","name":"t"}'
```

````

**ignore**

| Type                             | Strings or regular expressions    |
| -------------------------------- | --------------------------------- |
| Default                          | `['^/socket.io/.*/xhr-polling/']` |
| [Environ variable](#environment) | `NEW_RELIC_IGNORING_RULES`        |

Define a list of request URLs you want the agent to ignore. Specify the list as patterns, which can be strings or regular expressions. The default value is a regular expression to match socket.io long-polling requests

**enforce_backstop**

| Type                             | Boolean                      |
| -------------------------------- | ---------------------------- |
| Default                          | `true`                       |
| [Environ variable](#environment) | `NEW_RELIC_ENFORCE_BACKSTOP` |

> #### ⚠️ CAUTION
>
> Do not change this setting unless you understand [metric grouping issues](https://docs.newrelic.com/docs/features/metric-grouping-issues).

When enabled, the agent renames transactions that are not affected by other naming logic (such as the API, rules, or metric normalization rules) to `NormalizedUri/*`. If you set this to `false`, the agent sets transaction names to `Uri/path/to/resource`.

## Transaction events variables [#tx_events]

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.

**enabled**

| Type                             | Boolean                                |
| -------------------------------- | -------------------------------------- |
| Default                          | `true`                                 |
| [Environ variable](#environment) | `NEW_RELIC_TRANSACTION_EVENTS_ENABLED` |

When enabled, the agent sends transaction events to New Relic. This event data includes transaction timing, transaction name, and any custom attributes. If this is disabled, the agent does not collect this data or send it to New Relic.

**max_samples_stored**

| Type                             | Integer                                           |
| -------------------------------- | ------------------------------------------------- |
| Default                          | `10000`                                           |
| [Environ variable](#environment) | `NEW_RELIC_TRANSACTION_EVENTS_MAX_SAMPLES_STORED` |

Defines the maximum number of events the agent collects per minute. If there are more than this number, the agent collects a statistical sampling.

We don't recommend configuring past 10,000. The server will cap data at 10,000 per-minute.

> #### ⚠️ IMPORTANT
>
> This configuration had different behavior in agent versions lower than 6.0.0. See [`max_samples_stored` (DEPRECATED)](#tx_events_max_samples_stored_legacy) for agent versions 5.x or lower.

**max_samples_stored (DEPRECATED)**

| Type    | Integer |
| ------- | ------- |
| Default | `20000` |

Defines the maximum number of events the agent stores if it is unable to communicate with the [New Relic collector](https://docs.newrelic.com/docs/accounts-partnerships/education/getting-started-new-relic/glossary#collector). The values from the previous [harvest cycle](https://docs.newrelic.com/docs/accounts-partnerships/education/getting-started-new-relic/glossary#harvest-cycle) will be merged into the next one, with this option limiting the maximum number. Make sure this number is greater than `max_samples_per_minute`; for example, set it to twice as much. Consider your memory overhead before increasing this value.

> #### ⚠️ CAUTION
>
> This configuration has different behavior starting with agent version 6.0.0 and a new recommended maximum. See [`max_samples_stored`](#tx_events_max_samples_stored) for agent versions 6.x or higher.

**max_samples_per_minute (DEPRECATED)**

| Type    | Integer |
| ------- | ------- |
| Default | `10000` |

Defines the maximum number of events the agent collects per minute. If there are more than this number, the agent collects a statistical sampling.

> #### ⚠️ CAUTION
>
> This configuration has been replaced with `max_samples_stored` starting with version 6.0.0 of the agent. See [`max_samples_stored`](#tx_events_max_samples_stored) for 6.x or later agents.

**attributes.enabled**

| Type                             | Boolean                                           |
| -------------------------------- | ------------------------------------------------- |
| Default                          | `true`                                            |
| [Environ variable](#environment) | `NEW_RELIC_TRANSACTION_EVENTS_ATTRIBUTES_ENABLED` |

If `true`, the agent captures attributes from transaction events.

> #### ⚠️ CAUTION
>
> Any header-related include/exclude rules must be in camelCase form to be filtered.

**attributes.exclude**

| Type                             | Array                                             |
| -------------------------------- | ------------------------------------------------- |
| Default                          | `[]`                                              |
| [Environ variable](#environment) | `NEW_RELIC_TRANSACTION_EVENTS_ATTRIBUTES_EXCLUDE` |

Prefix of attributes to exclude from transaction events. Allows `*` as wildcard at end.

**attributes.include**

| Type                             | Array                                             |
| -------------------------------- | ------------------------------------------------- |
| Default                          | `[]`                                              |
| [Environ variable](#environment) | `NEW_RELIC_TRANSACTION_EVENTS_ATTRIBUTES_INCLUDE` |

Prefix of attributes to include in transaction events. Allows `*` as wildcard at end.

## Custom events variables [#custom_events]

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.

**enabled**

| Type                             | Boolean                                    |
| -------------------------------- | ------------------------------------------ |
| Default                          | `true`                                     |
| [Environ variable](#environment) | `NEW_RELIC_CUSTOM_INSIGHTS_EVENTS_ENABLED` |

When enabled, the agent sends custom events recorded with [`recordCustomEvent()`](https://docs.newrelic.com/docs/agents/nodejs-agent/supported-features/nodejs-agent-api#custom-events-api) to [New Relic](https://docs.newrelic.com/docs/insights/new-relic-insights/adding-querying-data/inserting-custom-events-insights-api). If this is disabled, the agent does not collect this data or send it to New Relic.

**max_samples_stored**

| Type                             | Integer                                               |
| -------------------------------- | ----------------------------------------------------- |
| Default                          | `3000`                                                |
| [Environ variable](#environment) | `NEW_RELIC_CUSTOM_INSIGHTS_EVENTS_MAX_SAMPLES_STORED` |

-   Defines the maximum number of custom events the agent collects per minute. If the number of custom events exceeds this limit, the agent collects a statistical sampling.
-   When configuring the agent for [AI monitoring](https://docs.newrelic.com/docs/ai-monitoring/intro-to-ai-monitoring), set to max value `100000`. Ensures that the maximum amount of LLM events are captured.

    > #### ⚠️ IMPORTANT
    >
    > Increasing this limit may increase memory usage.

## Custom hostname variables [#custom-hostnames]

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.

**display_name**

| Type                             | String of 255 bytes or less           |
| -------------------------------- | ------------------------------------- |
| Default                          | (none)                                |
| [Environ variable](#environment) | `NEW_RELIC_PROCESS_HOST_DISPLAY_NAME` |

Specify a custom hostname for [display in New Relic](https://docs.newrelic.com/docs/apm/new-relic-apm/maintenance/add-rename-remove-hosts#display_name). If you do not set this field, New Relic will continue to use the default hostname found by calling `os.hostname()`.

-   If you use the default hostname settings, New Relic finds the hostname through `os.hostname()`.
-   If this call fails, New Relic uses the host's IP as the name.
-   If you set `ipv_preference: 4` or `ipv_preference: 6`, you can select the type of IP address (IPv4 or IPv6) that appears in the New Relic UI.

**ipv_preference**

| Type                             | Integer (`4` or `6`)       |
| -------------------------------- | -------------------------- |
| Default                          | `4`                        |
| [Environ variable](#environment) | `NEW_RELIC_IPV_PREFERENCE` |

## Error message redaction variables [#err-message-redact]

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

**enabled**

| Type                             | Boolean                                      |
| -------------------------------- | -------------------------------------------- |
| Default                          | `false`                                      |
| [Environ variable](#environment) | `NEW_RELIC_STRIP_EXCEPTION_MESSAGES_ENABLED` |

When `true`, the agent will redact the messages of captured errors.

## Code level metrics [#code-level-metrics]

The code-level metrics configuration settings require [Node.JS agent version 9.7.5 or higher](https://docs.newrelic.com/docs/apm/agents/nodejs-agent/installation-configuration/update-nodejs-agent/).

For more details, see [our code-level metrics docs](https://docs.newrelic.com/docs/apm/agents/nodejs-agent/installation-configuration/nodejs-code-level-metrics).

**code_level_metrics.enabled**

| Type                             | Boolean                                |
| -------------------------------- | -------------------------------------- |
| Default                          | `true`                                 |
| [Environ variable](#environment) | `NEW_RELIC_CODE_LEVEL_METRICS_ENABLED` |

Toggles whether to capture additional attributes on middleware spans for all Node.js web frameworks that help drive [Code level metrics](https://docs.newrelic.com/docs/apm/agents/nodejs-agent/installation-configuration/nodejs-code-level-metrics). The additional attributes are: `code.filepath`, `code.function`, `code.lineno`, and `code.column`.

## Errors inbox configuration [#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. The entire sha can be used or just the first seven characters (e.g., 734713b).

## Url obfuscation [#url-obfuscation]

The url obfuscation configuration settings require [Node.js agent version 9.9.0 or higher](https://docs.newrelic.com/docs/apm/agents/nodejs-agent/installation-configuration/update-nodejs-agent/).

For a configuration example, see our documentation for the [node agent url obfuscation](https://docs.newrelic.com/docs/url-obfuscation/configure-url-obfuscation-nodejs).

**url_obfuscation.enabled**

| Type                             | Boolean                             |
| -------------------------------- | ----------------------------------- |
| Default                          | `false`                             |
| [Environ variable](#environment) | `NEW_RELIC_URL_OBFUSCATION_ENABLED` |

Enables regex based [node agent url obfuscation](https://docs.newrelic.com/docs/url-obfuscation/configure-url-obfuscation-nodejs/).

**url_obfuscation.regex.pattern**

| Type                             | String or RegExp                          |
| -------------------------------- | ----------------------------------------- |
| Default                          | (none)                                    |
| [Environ variable](#environment) | `NEW_RELIC_URL_OBFUSCATION_REGEX_PATTERN` |

Specifies the regex pattern to use for url obfuscation. If this is not set, no url obfuscation will be performed.

**url_obfuscation.regex.flags**

| Type                             | String                                  |
| -------------------------------- | --------------------------------------- |
| Default                          | (none)                                  |
| [Environ variable](#environment) | `NEW_RELIC_URL_OBFUSCATION_REGEX_FLAGS` |

Specifies the regex flags to use for url obfuscation pattern matching e.g. `g` for global matching, `i` for case insensitive matching, etc. Multiple flags can be specified as a string e.g. `gi`. If this is not set, no flags will be used.

**url_obfuscation.regex.replacement**

| Type                             | String                                        |
| -------------------------------- | --------------------------------------------- |
| Default                          | (none)                                        |
| [Environ variable](#environment) | `NEW_RELIC_URL_OBFUSCATION_REGEX_REPLACEMENT` |

Specifies the replacement string to use for url obfuscation. Can contain refferences to capture groups in the pattern e.g. `$1`. If this is not set, everything will be replaced with a single empty string.

## Security Agent [#security-agent]

[New Relic Security agent interactive applications security testing](https://docs.newrelic.com/docs/iast/introduction/)(IAST) tests your applications for any exploitable vulnerability by replaying the generated HTTP request with vulnerable payloads.

> #### ⚠️ CAUTION
>
> Run IAST with non-production deployments only to avoid exposing vulnerabilities on your production software.

> #### ⚠️ IMPORTANT
>
> The security agent configuration settings require [Node.js agent version 10.3.0 or higher](https://docs.newrelic.com/docs/apm/agents/nodejs-agent/installation-configuration/update-nodejs-agent/).

**security.enabled**

| Type                             | Boolean                      |
| -------------------------------- | ---------------------------- |
| Default                          | `false`                      |
| [Environ variable](#environment) | `NEW_RELIC_SECURITY_ENABLED` |

Toggles whether the New Relic Security agent data is sent to New Relic or not. When this is disabled and security.agent.enabled is true, the security agent be registered but data will not be sent.

**security.agent.enabled**

| Type                             | Boolean                            |
| -------------------------------- | ---------------------------------- |
| Default                          | `false`                            |
| [Environ variable](#environment) | `NEW_RELIC_SECURITY_AGENT_ENABLED` |

Toggles whether the New Relic Security agent is loaded. This property is read only once at application start.

**security.mode**

| Type                             | String                    |
| -------------------------------- | ------------------------- |
| Default                          | `IAST`                    |
| [Environ variable](#environment) | `NEW_RELIC_SECURITY_MODE` |

New Relic Security provided 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.

**security.validator_service_url**

| Type                             | String                                     |
| -------------------------------- | ------------------------------------------ |
| Default                          | `wss://csec.nr-data.net`                   |
| [Environ variable](#environment) | `NEW_RELIC_SECURITY_VALIDATOR_SERVICE_URL` |

New Relic Security connection URL. This is the endpoint that the security agent sends data to, it should match that environment that you have set for the Node.js agent.

**security.detection.rci.enabled**

| Type                             | Boolean                                    |
| -------------------------------- | ------------------------------------------ |
| Default                          | `true`                                     |
| [Environ variable](#environment) | `NEW_RELIC_SECURITY_DETECTION_RCI_ENABLED` |

Enable RCI security event detection.

**security.detection.rxss.enabled**

| Type                             | Boolean                                     |
| -------------------------------- | ------------------------------------------- |
| Default                          | `true`                                      |
| [Environ variable](#environment) | `NEW_RELIC_SECURITY_DETECTION_RXSS_ENABLED` |

Enable RXSS security event detection.

**security.detection.deserialization.enabled**

| Type                             | Boolean                                                |
| -------------------------------- | ------------------------------------------------------ |
| Default                          | `true`                                                 |
| [Environ variable](#environment) | `NEW_RELIC_SECURITY_DETECTION_DESERIALIZATION_ENABLED` |

Enable deserialization security event detection.

## Heroku [#heroku]

**heroku.use_dyno_names**

| Type                             | Boolean                           |
| -------------------------------- | --------------------------------- |
| Default                          | `true`                            |
| [Environ variable](#environment) | `NEW_RELIC_HEROKU_USE_DYNO_NAMES` |

If true, the agent uses Heroku dyno names as the hostname.

## Worker Threads [#worker-threads]

In agent versions prior to 11.0.0, the agent ran in both main and worker threads.  In version 11.0.0 the agent stopped running in worker threads due to its incompatibility with our async context propagation. The ability to run in worker threads was restored in version 11.3.0 but you must set `worker_threads.enabled` to `true`.  The behavior of running in the worker threads varies and we do not officially support it. Some things like metrics generation, and self contained transaction traces may work but this is a use at your own risk capability.

**worker_threads.enabled**

| Type                             | Boolean                            |
| -------------------------------- | ---------------------------------- |
| Default                          | `false`                            |
| [Environ variable](#environment) | `NEW_RELIC_WORKER_THREADS_ENABLED` |

If true, the agent will load when in a worker thread if specified.

## Utilization [#utilization]

Configure how the agent detects host and cloud environment information to accurately calculate your utilization-based pricing. These settings appear in the `utilization` section of your app's `newrelic.js` configuration file.

**detect_aws**

| Type                             | Boolean                            |
| -------------------------------- | ---------------------------------- |
| Default                          | `true`                             |
| [Environ variable](#environment) | `NEW_RELIC_UTILIZATION_DETECT_AWS` |

Whether the agent attempts to reach out to AWS to get info about the VM the process is running on.

**detect_pcf**

| Type                             | Boolean                            |
| -------------------------------- | ---------------------------------- |
| Default                          | `true`                             |
| [Environ variable](#environment) | `NEW_RELIC_UTILIZATION_DETECT_PCF` |

Whether the agent attempts to detect if the process is running on Pivotal Cloud Foundry.

**detect_azure**

| Type                             | Boolean                              |
| -------------------------------- | ------------------------------------ |
| Default                          | `true`                               |
| [Environ variable](#environment) | `NEW_RELIC_UTILIZATION_DETECT_AZURE` |

Whether the agent attempts to reach out to Azure to get info about the VM the process is running on.

**detect_azurefunction**

| Type                             | Boolean                                      |
| -------------------------------- | -------------------------------------------- |
| Default                          | `true`                                       |
| [Environ variable](#environment) | `NEW_RELIC_UTILIZATION_DETECT_AZUREFUNCTION` |

Whether the agent attempts to read environment variables and invocation context to get info about the Azure Function it's running in.

**detect_docker**

| Type                             | Boolean                               |
| -------------------------------- | ------------------------------------- |
| Default                          | `true`                                |
| [Environ variable](#environment) | `NEW_RELIC_UTILIZATION_DETECT_DOCKER` |

Whether the agent attempts to read files to get info about the container the process is running in.

**detect_gcp**

| Type                             | Boolean                            |
| -------------------------------- | ---------------------------------- |
| Default                          | `true`                             |
| [Environ variable](#environment) | `NEW_RELIC_UTILIZATION_DETECT_GCP` |

Whether the agent attempts to reach out to GCP to get info about the VM the process is running on.

**detect_kubernetes**

| Type                             | Boolean                                   |
| -------------------------------- | ----------------------------------------- |
| Default                          | `true`                                    |
| [Environ variable](#environment) | `NEW_RELIC_UTILIZATION_DETECT_KUBERNETES` |

Whether the agent attempts to reach out to Kubernetes to get info about the container the process is running on.

**logical_processors**

| Type                             | Float                                      |
| -------------------------------- | ------------------------------------------ |
| Default                          | `null`                                     |
| [Environ variable](#environment) | `NEW_RELIC_UTILIZATION_LOGICAL_PROCESSORS` |

Overrides the number of logical processors the agent reports for the host.

**billing_hostname**

| Type                             | String                                   |
| -------------------------------- | ---------------------------------------- |
| Default                          | `null`                                   |
| [Environ variable](#environment) | `NEW_RELIC_UTILIZATION_BILLING_HOSTNAME` |

Overrides the hostname the agent reports for billing/utilization purposes.

**total_ram_mib**

| Type                             | Integer                               |
| -------------------------------- | ------------------------------------- |
| Default                          | `null`                                |
| [Environ variable](#environment) | `NEW_RELIC_UTILIZATION_TOTAL_RAM_MIB` |

Overrides the amount of total RAM (in MiB) the agent reports for the host.

**gcp_use_instance_as_host**

| Type                             | Boolean                                          |
| -------------------------------- | ------------------------------------------------ |
| Default                          | `true`                                           |
| [Environ variable](#environment) | `NEW_RELIC_UTILIZATION_GCP_USE_INSTANCE_AS_HOST` |

> #### ⚠️ IMPORTANT
>
> Deprecated and will be removed in version 15 of the agent. Please use `gcp_cloud_run.use_instance_as_host` instead.

When enabled, it will use the GCP metadata id to set the hostname of the running application (Services, Worker Pools, and Jobs).

**gcp_cloud_run.include_revision_in_host**

| Type                             | Boolean                                                        |
| -------------------------------- | -------------------------------------------------------------- |
| Default                          | `false`                                                        |
| [Environ variable](#environment) | `NEW_RELIC_UTILIZATION_GCP_CLOUD_RUN_INCLUDE_REVISION_IN_HOST` |

If `true`, the agent prepends the Cloud Run revision name to the GCP instance id to form the hostname (`{revision}-{instance id}`) on Google Cloud Run. The revision name comes from `K_REVISION` on a Cloud Run Service, `CLOUD_RUN_REVISION` on a Cloud Run Worker Pool, and `CLOUD_RUN_EXECUTION` on a Cloud Run Job. Has no effect unless `utilization.gcp_cloud_run.use_instance_as_host` is also `true`.

**gcp_cloud_run.use_instance_as_host**

| Type                             | Boolean                                                    |
| -------------------------------- | ---------------------------------------------------------- |
| Default                          | `true`                                                     |
| [Environ variable](#environment) | `NEW_RELIC_UTILIZATION_GCP_CLOUD_RUN_USE_INSTANCE_AS_HOST` |

When enabled, it will use the GCP metadata id to set the hostname of the running application (Services, Worker Pools, and Jobs).

## OpenTelemetry [#opentelemetry]

These settings govern the various OpenTelemetry-based features provided by the agent. They appear in the `opentelemetry` section of your app's `newrelic.js` configuration file.

> #### ⚠️ IMPORTANT
>
> This configuration is subject to change while the OpenTelemetry feature set is in development.

**opentelemetry.enabled**

| Type                             | Boolean                           |
| -------------------------------- | --------------------------------- |
| Default                          | `false`                           |
| [Environ variable](#environment) | `NEW_RELIC_OPENTELEMETRY_ENABLED` |

Global switch for the whole OpenTelemetry feature. If set to `false`, no other OpenTelemetry sub-feature (such as `traces`, `logs`, or `metrics`) will be enabled, regardless of that sub-feature's own setting.

**opentelemetry.traces.enabled**

| Type                             | Boolean                                  |
| -------------------------------- | ---------------------------------------- |
| Default                          | `true`                                   |
| [Environ variable](#environment) | `NEW_RELIC_OPENTELEMETRY_TRACES_ENABLED` |

Enables bridging OpenTelemetry instrumentations (for example, `@fastify/otel`) into the New Relic agent.

**opentelemetry.logs.enabled**

| Type                             | Boolean                                |
| -------------------------------- | -------------------------------------- |
| Default                          | `true`                                 |
| [Environ variable](#environment) | `NEW_RELIC_OPENTELEMETRY_LOGS_ENABLED` |

When `true`, the agent automatically configures the OpenTelemetry logs API to send logs emitted through the OTel-specific API to New Relic.

> #### ⚠️ IMPORTANT
>
> This feature depends on [application logs forwarding](#application-logging-forwarding-enabled) — `application_logging.forwarding.enabled` must also be `true`.

**opentelemetry.metrics.enabled**

| Type                             | Boolean                                   |
| -------------------------------- | ----------------------------------------- |
| Default                          | `true`                                    |
| [Environ variable](#environment) | `NEW_RELIC_OPENTELEMETRY_METRICS_ENABLED` |

When `true`, the agent automatically configures the OpenTelemetry metrics API to send metrics to New Relic, attached to the application entity instrumented by the agent.

**opentelemetry.metrics.export_interval**

| Type                             | Integer                                           |
| -------------------------------- | ------------------------------------------------- |
| Default                          | `60000`                                           |
| [Environ variable](#environment) | `NEW_RELIC_OPENTELEMETRY_METRICS_EXPORT_INTERVAL` |

The number of milliseconds between each attempt to ship OpenTelemetry metrics to New Relic. Must be greater than or equal to `opentelemetry.metrics.export_timeout`.

**opentelemetry.metrics.export_timeout**

| Type                             | Integer                                          |
| -------------------------------- | ------------------------------------------------ |
| Default                          | `10000`                                          |
| [Environ variable](#environment) | `NEW_RELIC_OPENTELEMETRY_METRICS_EXPORT_TIMEOUT` |

The number of milliseconds an OpenTelemetry metrics export operation is allowed before it must successfully complete. If the timeout is exceeded, it's reported via the OpenTelemetry diagnostics API.

## Apollo Server instrumentation [#apollo-server-instrumentation]

These settings customize the behavior of the agent's Apollo Server (GraphQL) instrumentation. They appear in the `apollo_server` section of your app's `newrelic.js` configuration file.

**apollo_server.scalars**

| Type                             | Boolean                           |
| -------------------------------- | --------------------------------- |
| Default                          | `false`                           |
| [Environ variable](#environment) | `NEW_RELIC_APOLLO_SERVER_SCALARS` |

Enables capture of timing for fields resolved with the `GraphQLScalarType` return type. This may be desired when performing time-intensive calculations to return a scalar value. Not recommended for queries that return a large number of pre-calculated scalar fields.

> #### 💡 TIP
>
> Query/mutation resolvers are always captured, even when they return a scalar type.

**apollo_server.introspection_queries**

| Type                             | Boolean                                         |
| -------------------------------- | ----------------------------------------------- |
| Default                          | `false`                                         |
| [Environ variable](#environment) | `NEW_RELIC_APOLLO_SERVER_INTROSPECTION_QUERIES` |

Enables capture of timings for an [IntrospectionQuery](https://www.graphql-js.org/api-v16/utilities/#introspectionquery).

**apollo_server.service_definition_queries**

| Type                             | Boolean                                              |
| -------------------------------- | ---------------------------------------------------- |
| Default                          | `false`                                              |
| [Environ variable](#environment) | `NEW_RELIC_APOLLO_SERVER_SERVICE_DEFINITION_QUERIES` |

Enables capture of timings for a [service definition query](https://www.apollographql.com/docs/federation/federation-spec/#fetch-service-capabilities) received from an Apollo Federated Gateway Server.

**apollo_server.health_check_queries**

| Type                             | Boolean                                        |
| -------------------------------- | ---------------------------------------------- |
| Default                          | `false`                                        |
| [Environ variable](#environment) | `NEW_RELIC_APOLLO_SERVER_HEALTH_CHECK_QUERIES` |

Enables capture of timings for a [health check query](https://www.apollographql.com/docs/federation/api/apollo-gateway/#servicehealthcheck) received from an Apollo Federated Gateway Server.

**apollo_server.field_metrics**

| Type                             | Boolean                                 |
| -------------------------------- | --------------------------------------- |
| Default                          | `false`                                 |
| [Environ variable](#environment) | `NEW_RELIC_APOLLO_SERVER_FIELD_METRICS` |

Enables capture of metrics for every field and resolver argument seen for an Apollo query. Intended for identifying unused fields in your GraphQL schema.

## Environment variable overrides

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

**NEW_RELIC_HOME**

Path to the directory containing `newrelic.js`. This is available only as an environment variable. You cannot set it in your config file.

| Type    | String |
| ------- | ------ |
| Default | (none) |

**NEW_RELIC_CONFIG_FILENAME**

Used to set a different config file name than the default `newrelic.js`. This is available only as an environment variable. You cannot set it in your config file.

| Type    | String |
| ------- | ------ |
| Default | (none) |

**NEW_RELIC_NO_CONFIG_FILE**

If used, this prevents the agent from reading configuration settings from `newrelic.js`. Default values and values from environment variables will still be set.

This is available only as an environment variable. You cannot set it in your config file.

| Type    | Boolean |
| ------- | ------- |
| Default | `false` |

## Environment variable type reference guide

This section describes how to properly format the complex data types.

**Array**

Array types are defined as comma-delimited strings.

````ini
NEW_RELIC_ERROR_COLLECTOR_IGNORE_ERROR_CODES=404,500,429
```

````

**Object**

Object types are defined as a json string.

````ini
NEW_RELIC_ERROR_COLLECTOR_EXPECTED_MESSAGES='{"Error":["Undefined", "No soup for you!"]}'
```

````
