Skip to content

ApplicationInsights:Invalid JSON config file when using APPLICATIONINSIGHTS_CONNECTION_STRING #1226

Closed

Description

Environment:
OS: NixOS 23.05 (Linux)
Node: 18.17.1
applicationinsights version: 2.9.0

After upgrading the applicationinsights package in my project from 2.7.3 to 2.8.0 and then to 2.9.0 when running my NodeJS application using the APPLICATIONINSIGHTS_CONNECTION_STRING variable as done prior to 2.8.0 I get the warning:

[1] ApplicationInsights:Invalid JSON config file:  [
[1]   SyntaxError: Unexpected end of JSON input
[1]       at JSON.parse (<anonymous>)
[1]       at r._loadJsonFile (/home/keanu/Documents/Development/redacted/dist/redacted.js:2:5417)
[1]       at new r (/home/keanu/Documents/Development/redacted/dist/redacted.js:2:4957)
[1]       at r.getInstance (/home/keanu/Documents/Development/redacted/dist/redacted.js:2:5038)
[1]       at /home/keanu/Documents/Development/redacted/dist/redacted.js:7:72232
[1]       at /home/keanu/Documents/Development/redacted/dist/redacted.js:1:263
[1]       at /home/keanu/Documents/Development/redacted/dist/redacted.js:12:32841
[1]       at /home/keanu/Documents/Development/redacted/dist/redacted.js:1:263
[1]       at /home/keanu/Documents/Development/redacted/dist/redacted.js:43:26129
[1]       at /home/keanu/Documents/Development/redacted/dist/redacted.js:1:263
[1] ]

the warning is not present during build and goes away if i provide the applicationinsights.json however this functionality looks to be opt-in via the APPLICATIONINSIGHTS_CONFIGURATION_FILE variable which I've not set.

When the application is running after the warning, the live metrics page doesnt load and reports no telemetry is being received, this works again as expected when downgrading to 2.7.3.

My application insights initialisation looks like the following:

applicationInsights.setup()
  .setSendLiveMetrics(true)
  .setAutoCollectConsole(true, true)
  .setAutoCollectDependencies(true)
  .setAutoCollectExceptions(true)
  .setAutoCollectHeartbeat(true)
  .setAutoCollectPerformance(true)
  .setAutoCollectPreAggregatedMetrics(true)
  .setAutoDependencyCorrelation(true)
  .start();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions