Skip to main content
Version: 6.x (latest)

Configuration

This page explains how to configure the N|Solid Runtime to send data to N|Solid SaaS, a self-hosted N|Solid Console, OpenTelemetry (OTLP) endpoints, and StatsD. It ends with a complete configuration reference.

Configuration methods​

You can configure the N|Solid Runtime in three ways:

  • Environment variables, for example NSOLID_GRPC=localhost:50051.
  • The nsolid section of your package.json file. The runtime reads the nearest package.json above your main script, or the file named in NSOLID_PACKAGE_JSON.
  • The JavaScript API, by calling nsolid.start() from your application.

The three methods accept the same settings, except a few that are environment-only (marked env only in the configuration reference). When a setting is defined in more than one place, the runtime uses this order of precedence:

  1. The object passed to nsolid.start()
  2. Environment variables
  3. The nsolid section of package.json
  4. The built-in default

Boolean environment variables are off when unset or set to 0 or false. Any other value turns them on.

By default, the N|Solid Agent thread starts, but it doesn't perform automated checks or send observability data anywhere until you configure an endpoint.

To connect to an N|Solid Console, the minimum configuration is one of NSOLID_SAAS, NSOLID_GRPC, or NSOLID_COMMAND, pointing at your N|Solid SaaS instance or your self-hosted N|Solid Console. The runtime completes the handshake and the Console supplies the rest of the connection settings.

NSOLID_GRPC connects over the gRPC protocol. It's available in N|Solid Runtime 5.4.0 and later and requires N|Solid Console 6.1.0 or later. NSOLID_COMMAND connects over the legacy ZeroMQ protocol.

Running with the agent disabled​

If none of NSOLID_SAAS, NSOLID_GRPC, NSOLID_COMMAND, NSOLID_STATSD, or NSOLID_OTLP is set, the agent is created but most functionality is disabled, and the runtime behaves like unmodified Node.js.

In this mode the N|Solid JavaScript API is still active, including nsolid.start(), which you can use to configure and start the N|Solid Agent's connections at any time.

Connect to N|Solid SaaS​

N|Solid SaaS is the quickest way to start working with observability data for your application. NodeSource runs a dedicated N|Solid Console for your organization and gives you a connection token that the runtime uses to connect and authenticate.

To find your NSOLID_SAAS token, log in to NodeSource Accounts and copy the connection string. To open your N|Solid Console, click Visit Now.

NodeSource Accounts page showing the NSOLID_SAAS connection string

Set the NSOLID_SAAS token as an environment variable:

NSOLID_SAAS='<your-saas-token>' nsolid index.js

After you apply any of these methods, your process connects and appears in the N|Solid Console.

NSOLID_SAAS connects over gRPC with TLS to your N|Solid SaaS Console's gRPC endpoint on port 443.

note

If both NSOLID_SAAS and NSOLID_COMMAND are set, NSOLID_COMMAND takes precedence and the SaaS token is ignored.

Connect to a self-hosted N|Solid Console​

To connect to a self-hosted N|Solid Console, specify the address where it listens for agent connections. You can use the gRPC protocol (NSOLID_GRPC, N|Solid Console 6.1.0 and later) or the ZeroMQ protocol (NSOLID_COMMAND).

  • NSOLID_GRPC: the address of the Console's gRPC endpoint. gRPC uses a single connection. Default Console port: 50051.
  • NSOLID_COMMAND: the address of the ZeroMQ "command" channel, used for bidirectional communication between the agent and the Console. Default port: 9001.
  • NSOLID_DATA: the ZeroMQ channel for one-shot replies with small payloads. Default port: 9002.
  • NSOLID_BULK: the ZeroMQ channel for large, multi-chunk content such as heap snapshots and CPU profiles. Default port: 9003.

With ZeroMQ, the runtime connects to the Console on three ports so that commands and data are prioritized over bulk asset transfers. You only need to set NSOLID_COMMAND: the Console provides the data and bulk addresses during the handshake.

warning

The agent uses TLS for gRPC connections by default. A self-hosted N|Solid Console serves gRPC without TLS unless you put a TLS endpoint in front of it. If your Console's gRPC endpoint isn't behind TLS, set NSOLID_GRPC_INSECURE=1. To trust a private certificate authority instead, set NSOLID_GRPC_CERTS to the path of a PEM file with your CA certificates. Both are environment variables only.

gRPC, to a Console without TLS:

NSOLID_GRPC='localhost:50051' NSOLID_GRPC_INSECURE=1 nsolid index.js

gRPC, to a Console behind TLS with a private CA:

NSOLID_GRPC='console.example.com:50051' NSOLID_GRPC_CERTS=/path/to/ca.pem nsolid index.js

ZeroMQ:

NSOLID_COMMAND='localhost:9001' nsolid index.js
note

Custom commands are only delivered over the ZeroMQ (NSOLID_COMMAND) connection. They aren't available when you connect with NSOLID_GRPC or NSOLID_SAAS.

Connect to an OpenTelemetry endpoint​

Three settings control OpenTelemetry export: NSOLID_TRACING_ENABLED, NSOLID_OTLP, and NSOLID_OTLP_CONFIG.

NSOLID_TRACING_ENABLED​

Tracing is off by default. To enable it at startup, set this flag to a true value. You can also turn tracing on and off while the process runs from the N|Solid Console.

NSOLID_TRACING_ENABLED=1 nsolid index.js

With tracing enabled, the N|Solid Agent sends trace data to the N|Solid Console automatically if it's connected to one.

info

You must enable tracing to send traces to OTLP endpoints, even if you aren't connected to an N|Solid Console. Metrics are exported to a configured OTLP endpoint on every metrics interval, whether or not tracing is enabled.

NSOLID_OTLP and NSOLID_OTLP_CONFIG​

Use NSOLID_OTLP and NSOLID_OTLP_CONFIG to export traces and metrics to additional endpoints.

NSOLID_OTLP sets the type of endpoint. The options are:

  • datadog
  • dynatrace
  • newrelic
  • otlp

NSOLID_OTLP_CONFIG is a JSON object with the configuration for the selected type:

Endpoint typeKeysExampleBehavior
datadogzone, key, url (all required){"zone": "us", "key": "<your-datadog-api-key>", "url": "http://localhost:4318"}zone is us or eu. url is the base URL of your Datadog Agent's OTLP HTTP receiver; the runtime appends /v1/traces. Metrics go to the Datadog API for the selected zone.
dynatracesite, token (both required){"site": "<your-dynatrace-environment-id>", "token": "<your-dynatrace-api-token>"}Traces go to https://<site>.live.dynatrace.com/api/v2/otlp/v1/traces, authenticated with Api-Token <token>.
newreliczone, key (both required){"zone": "us", "key": "<your-newrelic-license-key>"}zone is us or eu. Traces go to New Relic's OTLP endpoint for the zone; metrics go to the New Relic Metric API.
otlpurl (required), protocol (optional){"url": "http://localhost:4318", "protocol": "http"}url is the base URL of the collector, with scheme and port; the runtime appends /v1/traces and /v1/metrics. protocol is http (default) or grpc (typically port 4317).
warning

If NSOLID_OTLP_CONFIG is missing a required key or isn't valid JSON, OTLP export is disabled. The only exception is NSOLID_OTLP=otlp, which works without NSOLID_OTLP_CONFIG (see below).

NSOLID_TRACING_ENABLED=1 NSOLID_OTLP=dynatrace NSOLID_OTLP_CONFIG='{"site":"<your-dynatrace-environment-id>","token":"<your-dynatrace-api-token>"}' nsolid index.js

Standard OpenTelemetry exporter variables​

With NSOLID_OTLP=otlp, you can omit NSOLID_OTLP_CONFIG and configure the exporter with the standard OpenTelemetry environment variables instead:

  • OTEL_EXPORTER_OTLP_ENDPOINT, OTEL_EXPORTER_OTLP_TRACES_ENDPOINT, OTEL_EXPORTER_OTLP_METRICS_ENDPOINT
  • OTEL_EXPORTER_OTLP_PROTOCOL (and the _TRACES_ / _METRICS_ variants): grpc or http/protobuf (default). http/json applies to metrics only; traces are always sent as protobuf over HTTP.
  • OTEL_EXPORTER_OTLP_HEADERS, OTEL_EXPORTER_OTLP_CERTIFICATE, OTEL_EXPORTER_OTLP_CLIENT_KEY, OTEL_EXPORTER_OTLP_CLIENT_CERTIFICATE, OTEL_EXPORTER_OTLP_COMPRESSION, OTEL_EXPORTER_OTLP_TIMEOUT, OTEL_EXPORTER_OTLP_INSECURE (and their _TRACES_ / _METRICS_ variants)
NSOLID_TRACING_ENABLED=1 NSOLID_OTLP=otlp OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318 nsolid index.js

Run nsolid --help to see the full list of variables supported by your runtime version.

Connect to a StatsD endpoint​

NSOLID_STATSD​

To send N|Solid metrics to a StatsD daemon, set NSOLID_STATSD to its address. The format is [udp://|tcp://]host[:port]. The protocol defaults to UDP and the port to 8125. A bare number is treated as a port on localhost. Only UDP and TCP are supported.

NSOLID_STATSD=localhost:8125 nsolid index.js

Use TCP instead of UDP:

NSOLID_STATSD=tcp://statsd.example.com:8125 nsolid index.js

StatsD bucket names​

StatsD metrics are reported using "buckets". The right format depends on your reporting frontend and may take some experimentation.

By default, N|Solid prefixes bucket names with nsolid.${env}.${app}.${hostname}.${shortId}., followed by the name of the metric. In this string:

  • env is the value of the NODE_ENV environment variable if set, otherwise the env property of the nsolid section in package.json. Defaults to prod.
  • app is the value of the NSOLID_APP environment variable (NSOLID_APPNAME is accepted as an alias and takes precedence), otherwise the app property of the nsolid section in package.json, otherwise the name property in package.json, otherwise process.title if your application changed it. Defaults to untitled application.
  • hostname is the value of the NSOLID_HOSTNAME environment variable if set, otherwise the hostname property of the nsolid section in package.json. Otherwise, the value of os.hostname() is used.
  • shortId is the first 7 characters of the random alphanumeric ID the N|Solid Agent creates at startup. Use it to identify individual processes. The full 40-character ID is available as id.

By default, your StatsD data is sent to the collector in this format:

nsolid.prod.myapp.nodehost.803bbd5.uptime:314.4|g
nsolid.prod.myapp.nodehost.803bbd5.rss:28401664|g
nsolid.prod.myapp.nodehost.803bbd5.heapTotal:8425472|g
nsolid.prod.myapp.nodehost.803bbd5.heapUsed:5342488|g
...

All metrics are sent as gauges (|g). The string metrics user and title aren't sent.

StatsD tags​

Some backends, such as Datadog, support tags for metrics.

By default, N|Solid adds no tags to process-level metrics. Per-thread metrics always carry threadId:<id> (and threadName:<name> if the thread is named) as DogStatsD-style tags.

NSOLID_STATSD_BUCKET and NSOLID_STATSD_TAGS​

To change the bucket prefix or add tags to your StatsD data, use NSOLID_STATSD_BUCKET and NSOLID_STATSD_TAGS (or the statsdBucket and statsdTags properties of the nsolid section in package.json).

Both settings support substitution of the variables listed above: env, app, hostname, shortId, and id. Write them in template-literal style, for example ${app}. The default bucket prefix is written as nsolid.${env}.${app}.${hostname}.${shortId}.

NSOLID_STATSD_TAGS also supports ${tags}, which inserts the N|Solid tags configured for the process.

StatsD tags are a comma-separated string that your backend can decode. Check your StatsD provider's documentation to find out whether it supports tags and what format it expects.

Substitution follows these rules:

  • Variable names are case-insensitive (${shortId} and ${shortid} are equivalent).
  • Periods (.) in substituted values are replaced with hyphens (-), so a hostname like web.example.com becomes web-example-com. In tags, every period in the resulting string is replaced.
NSOLID_STATSD=localhost:8125 NSOLID_STATSD_BUCKET='COOLCORP.${env}.${app}.${hostname}.${shortId}' NSOLID_STATSD_TAGS='env:${env},${tags}' nsolid index.js

Configuration reference​

Each table lists the environment variable, the equivalent key for the nsolid section of package.json and for nsolid.start(), the default, and a description. Settings marked "env only" have no package.json or JavaScript equivalent.

Connection​

Environment variableKeyDefaultDescription
NSOLID_SAASsaasnoneN|Solid SaaS token. Connects over gRPC with TLS on port 443. Ignored if NSOLID_COMMAND is set.
NSOLID_GRPCgrpcnonehost:port of a self-hosted N|Solid Console's gRPC endpoint (Console default port 50051). A bare number means localhost:<port>. N|Solid Runtime 5.4.0 and later; requires N|Solid Console 6.1.0 or later.
NSOLID_GRPC_INSECUREenv only0 (TLS on)Set to 1 to connect to a gRPC endpoint without TLS. Must be an integer. Ignored for N|Solid SaaS.
NSOLID_GRPC_CERTSenv onlybundled root CAsPath to a PEM file with the CA certificates to trust for gRPC TLS.
NSOLID_COMMAND (legacy alias NSOLID_COMMAND_REMOTE, which takes precedence)commandnoneAddress of the Console's ZeroMQ command channel (default port 9001). A bare number means localhost:<port>.
NSOLID_DATA (legacy alias NSOLID_DATA_REMOTE, which takes precedence)datasupplied by the ConsoleZeroMQ data channel (default port 9002). Normally provided during the handshake.
NSOLID_BULK (legacy alias NSOLID_BULK_REMOTE, which takes precedence)bulksupplied by the ConsoleZeroMQ bulk channel (default port 9003). Normally provided during the handshake.
NSOLID_PUBKEY (legacy alias NSOLID_STORAGE_PUBKEY, which takes precedence)pubkeybuilt-in default keyThe Console's 40-character CurveZMQ public key. Set this if you generated new keys for your Console (see nsolid-cli generate-keypair).
NSOLID_DISABLE_IPV6disableIpv6falseDisable IPv6 for ZeroMQ connections, for hosts that don't support it.

Identity​

Environment variableKeyDefaultDescription
NSOLID_APP (alias NSOLID_APPNAME, which takes precedence)apppackage.json name, then process.title if changed, then untitled applicationApplication name shown in the Console.
(none)appVersion in nsolid.start()package.json versionApplication version.
NSOLID_TAGStags (comma-separated string or array)noneTags used to filter processes in the Console. Up to 20 tags, each 2 to 140 bytes.
NSOLID_HOSTNAMEhostnameos.hostname()Overrides the reported hostname.
NODE_ENVenvprodEnvironment name. Reported as nodeEnv and available as ${env} in StatsD templates.
NSOLID_PACKAGE_JSONenv onlynearest package.json above the main scriptPath of the package.json to read N|Solid configuration from. An empty string disables package.json lookup.

Tracing​

Environment variableKeyDefaultDescription
NSOLID_TRACING_ENABLEDtracingEnabledfalseGenerate spans for HTTP client and server requests, DNS lookups, and custom OpenTelemetry spans. Can be changed from the Console.
NSOLID_TRACE_SAMPLE_RATEtraceSampleRate1.0Fraction of traces to sample, from 0.0 to 1.0. Invalid values are ignored. N|Solid 6.3.0 and later.
NSOLID_TRACING_MODULES_BLACKLISTtracingModulesBlacklist (string or array)noneComma-separated core modules to exclude from automatic instrumentation: dns, http (covers HTTP client and server).

Assets and profiling​

Environment variableKeyDefaultDescription
NSOLID_ASSETS_ENABLEDassetsEnabledtrueSet to 0 or false to block CPU profiles, heap profiles, heap samples, and heap snapshots, including continuous profiling. Can be changed from the Console or with nsolid.enableAssets() and nsolid.disableAssets(). N|Solid 6.1.0 and later.
NSOLID_DISABLE_SNAPSHOTSdisableSnapshotsfalseDisable heap snapshots for the process. Once on, it can't be turned off.
NSOLID_REDACT_SNAPSHOTSredactSnapshotsfalseRedact all string values from heap snapshots.
NSOLID_CONT_CPU_PROFILEcontCpuProfilefalseContinuous CPU profiling. Profiles are delivered only over gRPC (NSOLID_GRPC or NSOLID_SAAS) connections. While continuous profiling is on, the runtime rejects on-demand CPU profiles over gRPC, whether they come from the Console, nsolid-cli profile, or nsolid.profile().
NSOLID_CONT_CPU_PROFILE_INTERVALcontCpuProfileInterval30000Length of each continuous-profile window, in milliseconds.

Metrics​

Environment variableKeyDefaultDescription
NSOLID_INTERVALinterval5000Metrics collection and reporting interval, in milliseconds. (The default changed from 3000 to 5000 in N|Solid 6.2.0.)
NSOLID_BLOCKED_LOOP_THRESHOLDblockedLoopThreshold200Time, in milliseconds, a single event loop iteration can run before the process is reported as blocked.
NSOLID_PROMISE_TRACKINGpromiseTrackingfalseTrack promises, which enables the promiseCreatedCount and promiseResolvedCount metrics. Can be changed from the Console.
NSOLID_DISABLE_PACKAGE_SCANdisablePackageScanfalseDon't scan node_modules directories at startup. Only packages the application actually loads are reported.
NSOLID_TRACK_GLOBAL_PACKAGEStrackGlobalPackagesfalseAlso scan the global module paths (require('module').globalPaths).

StatsD​

Environment variableKeyDefaultDescription
NSOLID_STATSDstatsdnoneStatsD address, [udp://|tcp://]host[:port]. UDP and port 8125 by default.
NSOLID_STATSD_BUCKETstatsdBucketnsolid.${env}.${app}.${hostname}.${shortId}Bucket prefix template.
NSOLID_STATSD_TAGSstatsdTagsnoneTag template string (DogStatsD format).

OTLP​

Environment variableKeyDefaultDescription
NSOLID_OTLPotlpnoneEndpoint type: otlp, datadog, dynatrace, or newrelic.
NSOLID_OTLP_CONFIGotlpConfignoneJSON configuration for the selected type. See NSOLID_OTLP and NSOLID_OTLP_CONFIG.
OTEL_EXPORTER_OTLP_*env onlyOpenTelemetry defaultsStandard OpenTelemetry exporter settings, used when NSOLID_OTLP=otlp and NSOLID_OTLP_CONFIG is not set.

Advanced​

Environment variableKeyDefaultDescription
NSOLID_DELAY_INITenv only0Delay, in milliseconds, before the agent starts after the process starts.
NSOLID_IISNODEiisNodefalseSet when running under iisnode, so the runtime reports the real main script.
NSOLID_GRPC_KEYLOGenv onlyoffFor debugging only: writes TLS session keys to ./nsolid-tls-keylog-<pid>.log. N|Solid 6.2.0 and later.
NodeSource Support