Docs » Instrument back-end applications to send spans to Splunk APM » Instrument Node.js applications for Splunk Observability Cloud » Troubleshoot Node.js instrumentation for Splunk Observability Cloud

Troubleshoot Node.js instrumentation for Splunk Observability Cloud ๐Ÿ”—

When you instrument a Node.js application using the Splunk Distribution of OpenTelemetry JS and you donโ€™t see your data in Observability Cloud, follow these troubleshooting steps.

Steps for troubleshooting Node.js OpenTelemetry issues ๐Ÿ”—

The following steps can help you troubleshoot Node.js instrumentation issues:

  1. Activate diagnostic logging

  2. Activate debug metrics

Activate diagnostic logging ๐Ÿ”—

Diagnostic logs can help you troubleshoot instrumentation issues.

To output instrumentation logs to the console, set the OTEL_LOG_LEVEL environment variable to debug.

You can also activate debug logging programmatically by setting the logLevel argument. For example:

   logLevel: 'debug',
   metrics: {
      // configuration passed to metrics signal
   profiling: {
      // configuration passed to profiling signal
   tracing: {
      // configuration passed to tracing signal

To deactivate debug logging in your code, call setLogger() as in the following example:

const { diag } = require('@opentelemetry/api');


Activate debug logging only when needed. Debug mode requires more resources.

Activate debug metrics ๐Ÿ”—

You can activate internal debug metrics by setting the SPLUNK_DEBUG_METRICS_ENABLED environment variable to true. For more information, see Debug metrics.

Trace exporter issues ๐Ÿ”—

By default, the Splunk Distribution of OpenTelemetry JS uses the OTLP exporter. Any issue affecting the export of traces produces an error in the debug logs.

OTLP canโ€™t export spans ๐Ÿ”—

The following error in the logs means that the instrumentation canโ€™t send trace data to the OpenTelemetry Collector:

@opentelemetry/instrumentation-http http.ClientRequest return request
{"stack":"Error: connect ECONNREFUSED\n    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1148:16)\n    at TCPConnectWrap.callbackTrampoline (internal/async_hooks.js:131:17)","message":"connect ECONNREFUSED","errno":"-111","code":"ECONNREFUSED","syscall":"connect","address":"","port":"55681","name":"Error"}

To troubleshoot the lack of connectivity between the OTLP exporter and the OTel Collector, make sure that the following is true:

  1. Make sure that OTEL_EXPORTER_OTLP_ENDPOINT points to the correct OpenTelemetry Collector instance host.

  2. Check that your collector instance is configured and running. See Troubleshoot the Splunk OpenTelemetry Collector.

  3. Check that the OTLP receiver is activated in the OTel Collector and plugged into the traces pipeline.

  4. Check that the OTel Collector points to the following address: http://<host>:4317. Verify that your URL is correct.

401 error when sending spans ๐Ÿ”—

If you send traces directly to Observability Cloud and receive a 401 error code, the authentication token specified in SPLUNK_ACCESS_TOKEN is invalid. The following are possible reasons:

  • The value is null.

  • The value is not a well-formed token.

  • The token is not an access token that has authScope set to ingest.

Make sure that youโ€™re using a valid Splunk access token when sending data directly to your Splunk platform instance. See Retrieve and manage user API access tokens using Splunk Observability Cloud.

Webpack compatibility issues ๐Ÿ”—

The Splunk Distribution of OpenTelemetry JS canโ€™t instrument modules bundled using Webpack, as OpenTelemetry can instrument libraries only by intercepting its require calls.

To instrument Node applications that use bundled modules, use the Webpack externals configuration option so that the require calls are visible to OpenTelemetry.

The following example shows how to edit the webpack.config.js file to instrument the express framework:

module.exports = {
   // ...
   externalsType: "node-commonjs",
   externals: [
   // See
   // for a list of supported instrumentations. Use the require name of the library or framework,
   // not the name of the instrumentation. For example, "tedious" instead of "instrumentation-tedious".

When added to externals, the express framework loads through the require method and OpenTelemetry can instrument it. Make sure that the package is in the node_modules folder so that the require method can find it:

# Install the library or framework and add it to node_modules
npm install express


You donโ€™t need to add Node.js core modules such as http, net, and dns to the externals list.

Troubleshoot AlwaysOn Profiling for Node.js ๐Ÿ”—

See the following common issues and fixes for AlwaysOn Profiling:

Check that AlwaysOn Profiling is activated ๐Ÿ”—

Make sure that youโ€™ve activated the profiler by setting the SPLUNK_PROFILER_ENABLED environment variable to true. See Node.js settings for AlwaysOn Profiling.

Unsupported Node version ๐Ÿ”—

To use AlwaysOn Profiling, upgrade to Node version 16 or higher.

AlwaysOn Profiling data and logs donโ€™t appear in Observability Cloud ๐Ÿ”—

Collector configuration issues might prevent AlwaysOn Profiling data and logs from appearing in Splunk Observability Cloud.

To solve this issue, do the following:

  1. Check the configuration of the Node agent, especially SPLUNK_PROFILER_LOGS_ENDPOINT.

  2. Verify that the Splunk Distribution of OpenTelemetry Collector is running at the expected endpoint and that the application host or container can resolve the host name and connect to the OTLP port.

  3. Make sure that youโ€™re running the Splunk Distribution of OpenTelemetry Collector and that the version is 0.34 or higher. Other collector distributions might not be able to route the log data that contains profiling data.

  4. A custom configuration might override settings that let the collector handle profiling data. Make sure to configure an otlp receiver and a splunk_hec exporter with correct token and endpoint fields. The profiling pipeline must use the OTLP receiver and Splunk HEC exporter youโ€™ve configured.

The following snippet contains a sample profiling pipeline:


     token: "${SFX_TOKEN}"
     endpoint: "https://ingest.${SFX_REALM}"
     loglevel: info


        receivers: [otlp]
        processors: [batch]
        exporters: [logging/info, splunk_hec]

Report an issue ๐Ÿ”—

Before you create an issue or open a support request, try gathering the following information:

  • What happened and the impact of the issue.

  • All the steps youโ€™ve followed until the issue appeared.

  • What was the expected outcome.

  • Your attempts to solve the issue, including workarounds.

  • The operating system, runtime or compiler version, libraries, frameworks, and application servers of your environment, including your instrumentation settings.

  • Debug logs and other logs that might help troubleshoot the issue.

To get help, see Splunk Observability Cloud support.