Splunk AppDynamics

Unable to bundle Node.js with Appdynamics using Webpack (broken dependencies?)

CommunityUser
Splunk Employee
Splunk Employee

When trying to install the AppDynamics package for monitoring a Node.js application, our Webpack build process is not able to import a handful of dependencies. Specifically, the errors output are:

WARNING in ./node_modules/appdynamics/lib/core/agent.js 445:8-28
require.main.require is not supported by webpack.
@ ./node_modules/appdynamics/index.js 1:17-44
@ ./server.ts

ERROR in ./node_modules/appdynamics-zmq/lib/index.js
Module not found: Error: Can't resolve '../zmq' in '.../my-app/node_modules/appdynamics-zmq/lib'
@ ./node_modules/appdynamics-zmq/lib/index.js 24:10-27
@ ./node_modules/appdynamics-zmq/index.js
@ ./node_modules/appdynamics/lib/libproxy/proxy-transport.js
@ ./node_modules/appdynamics/lib/libproxy/libproxy.js
@ ./node_modules/appdynamics/lib/core/agent.js
@ ./node_modules/appdynamics/index.js
@ ./server.ts

ERROR in ./node_modules/appdynamics-libagent/index.js
Module not found: Error: Can't resolve './appd_libagent' in '.../my-app/node_modules/appdynamics-libagent'
@ ./node_modules/appdynamics-libagent/index.js 36:9-35
@ ./node_modules/appdynamics/lib/libagent/libagent-connector.js
@ ./node_modules/appdynamics/lib/core/agent.js
@ ./node_modules/appdynamics/index.js
@ ./server.ts

ERROR in ./node_modules/appdynamics-native/index.js
Module not found: Error: Can't resolve './appdynamics' in '.../my-app/node_modules/appdynamics-native'
@ ./node_modules/appdynamics-native/index.js 29:10-34
@ ./node_modules/appdynamics/lib/core/agent.js
@ ./node_modules/appdynamics/index.js
@ ./server.ts

ERROR in ./node_modules/appdynamics-protobuf/index.js
Module not found: Error: Can't resolve './protobuf_for_node' in '.../my-app/node_modules/appdynamics-protobuf'
@ ./node_modules/appdynamics-protobuf/index.js 29:10-40
@ ./node_modules/appdynamics/lib/libproxy/proxy-transport.js
@ ./node_modules/appdynamics/lib/libproxy/libproxy.js
@ ./node_modules/appdynamics/lib/core/agent.js
@ ./node_modules/appdynamics/index.js
@ ./server.ts

ERROR in ./node_modules/log4js/lib/appenders/hipchat.js
Module not found: Error: Can't resolve 'hipchat-notifier' in '.../my-app/node_modules/log4js/lib/appenders'
@ ./node_modules/log4js/lib/appenders/hipchat.js 3:14-41
@ ./node_modules/log4js/lib/appenders sync ^\.\/.*$
@ ./node_modules/log4js/lib/log4js.js
@ ./node_modules/appdynamics/lib/core/logger.js
@ ./node_modules/appdynamics/lib/core/agent.js
@ ./node_modules/appdynamics/index.js
@ ./server.ts

ERROR in ./node_modules/log4js/lib/appenders/loggly.js
Module not found: Error: Can't resolve 'loggly' in '.../node_modules/log4js/lib/appenders'
@ ./node_modules/log4js/lib/appenders/loggly.js 3:11-28
@ ./node_modules/log4js/lib/appenders sync ^\.\/.*$
@ ./node_modules/log4js/lib/log4js.js
@ ./node_modules/appdynamics/lib/core/logger.js
@ ./node_modules/appdynamics/lib/core/agent.js
@ ./node_modules/appdynamics/index.js
@ ./server.ts

ERROR in ./node_modules/log4js/lib/appenders/mailgun.js
Module not found: Error: Can't resolve 'mailgun-js' in '.../my-app/node_modules/log4js/lib/appenders'
@ ./node_modules/log4js/lib/appenders/mailgun.js 34:14-35
@ ./node_modules/log4js/lib/appenders sync ^\.\/.*$
@ ./node_modules/log4js/lib/log4js.js
@ ./node_modules/appdynamics/lib/core/logger.js
@ ./node_modules/appdynamics/lib/core/agent.js
@ ./node_modules/appdynamics/index.js
@ ./server.ts

ERROR in ./node_modules/log4js/lib/appenders/smtp.js
Module not found: Error: Can't resolve 'nodemailer' in '.../my-app/node_modules/log4js/lib/appenders'
@ ./node_modules/log4js/lib/appenders/smtp.js 4:13-34
@ ./node_modules/log4js/lib/appenders sync ^\.\/.*$
@ ./node_modules/log4js/lib/log4js.js
@ ./node_modules/appdynamics/lib/core/logger.js
@ ./node_modules/appdynamics/lib/core/agent.js
@ ./node_modules/appdynamics/index.js
@ ./server.ts

ERROR in ./node_modules/log4js/lib/appenders/slack.js
Module not found: Error: Can't resolve 'slack-node' in '.../node_modules/log4js/lib/appenders'
@ ./node_modules/log4js/lib/appenders/slack.js 2:12-33
@ ./node_modules/log4js/lib/appenders sync ^\.\/.*$
@ ./node_modules/log4js/lib/log4js.js
@ ./node_modules/appdynamics/lib/core/logger.js
@ ./node_modules/appdynamics/lib/core/agent.js
@ ./node_modules/appdynamics/index.js
@ ./server.ts

Our project is set up with:
- Webpack v4.29.0
- Node.js v11.0.0
- Appdynamics v4.5

The Appdynamics usage is at the top of our server file as:

// AppDynamics monitoring
require("appdynamics").profile({
controllerHostName: ***
controllerPort: 443,
controllerSslEnabled: true,
accountName: ****
accountAccessKey: ***
applicationName: ***
tierName: ***
nodeName: '01'
});

And our Webpack configuration is:

const path = require('path');
const webpack = require('webpack');

module.exports = {
entry: { server: './server.ts' },
resolve: { extensions: ['.js', '.ts'] },
target: 'node',
mode: 'development',
// this makes sure we include node_modules and other 3rd party libraries
externals: [/node_modules/],
output: {
path: path.join(__dirname, 'dist'),
filename: '[name].js'
},
module: {
rules: [{ test: /\.ts$/, loader: 'ts-loader' }]
},
plugins: [
]
};

So far we have tried downgrading the Webpack version, downgrading the Node environment to 10.15, and using other import methods for the AppDynamics package, but this seems like an issue internal to the Appdynamics library?

Has anyone experienced anything similar? Or had success using the Appdynamics node package with Webpack?

Labels (1)
Tags (2)
0 Karma
1 Solution

Kyle_Furlong
Contributor

Hi Cody,

Could you try adding "appdynamics" to the externals array? Let me know if that helps.

View solution in original post

0 Karma

Sahil_Gupta2
Explorer

I attempted to use the AppD NodeJS agent to monitor a single-page application (SPA) built on NodeJS using React - webpack . However, since these SPAs only use NodeJS as a building block and the communication between the frontend and backend is direct (not via the frontend server), the AppD BRUM monitoring is more suitable than the NodeJS agent for monitoring the necessary metrics.

Kyle_Furlong
Contributor

Hi Cody,

Could you try adding "appdynamics" to the externals array? Let me know if that helps.

0 Karma

CommunityUser
Splunk Employee
Splunk Employee

Thank you Kyle, that did the trick!

CommunityUser
Splunk Employee
Splunk Employee

can you tell m e external arrays means  plz ?


@Anonymous wrote:

Thank you Kyle, that did the trick!


0 Karma

Umervali_Niyama
Path Finder

4.5.16 agent has the fix for this . Tested

J_R__Willett
New Member

I updated my externals array in webpack.base.babel.js as shown:

image.png

That made webpack happy, but when I try to run the app it crashes and I see this in my console:

image.png

I'm trying to evaluate AppDynamics, but I can't even install it properly. Please tell me what to do to fix this!

Thanks!

0 Karma

Kyle_Furlong
Contributor

Hi J.R.,

I believe externals is an array of module names, but more importantly you can skip it altogether with the following: https://stackoverflow.com/a/41063795

Let us know if that helps!

0 Karma

Umervali_Niyama
Path Finder

The other fix I see is as below:

ensure you're installing the 4.5.11 or higher version of the agent (@latest will work)

  1. install with npm install
  2. edit the package-lock.json file to remove the lines and sections that show jre / proxy
  3. "appdynamics-jre": "https://packages.appdynamics.com/nodejs/4.5.11.0/appdynamics-jre.tgz",
  4. "appdynamics-proxy": "https://packages.appdynamics.com/nodejs/4.5.11.0/appdynamics-proxy.tgz",
  5. "appdynamics-jre": { "version": "https://packages.appdynamics.com/nodejs/4.5.11.0/appdynamics-jre.tgz", "integrity": "sha512-hmnixIubwz8TBxQMe1/5QYwxmrCsnimYrZvNbvWZHOx2XifRnenzaPHw3avFCTvXgkTWt5lsY3UBIqlDYxTg3Q==" },
  6. "appdynamics-proxy": { "version": "https://packages.appdynamics.com/nodejs/4.5.11.0/appdynamics-proxy.tgz", "integrity": "sha512-1E+UxBrR4Vo0FAG0z+66RYx3dGZfb55W+6G/lTnDxt3U0TZUzA/rKo9PaQNDLKwogcgkraZYgBFYlVsvtvQy4w==" },
0 Karma

CommunityUser
Splunk Employee
Splunk Employee
I’ve also had to do similar within our yarn.lock file, specifically when encountering:
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
error https://packages.appdynamics.com/nodejs/4.5.11.0/appdynamics-proxy.tgz: Integrity check failed for "appdynamics-proxy" (computed integrity doesn't match our records, got "sha1-wcdDKNB8QnI4D/YdYd+hAc6Ywy4=")

It seems like there is something about the node.js AppDynamics library which, at minimum, isn’t configured in a typical way. Maybe it’s just related to how they host their own children dependencies?
0 Karma

CommunityUser
Splunk Employee
Splunk Employee

Hi All,

I am also facing a similar problem, all i am doing is adding the dependency as below in my package.json and it fails with the error shown below.

"axios": "^0.18.0",
"appdynamics": "^4.3.7",
"d3-axis": "^1.0.12",
"d3-geo": "^1.11.3",

Error:

./node_modules/appdynamics-zmq/lib/index.js
Module not found: Can't resolve '../zmq' in 'Drive:\myapp\mymodule\node_modules\appdynamics-zmq\lib'

Thank you!

0 Karma
Get Updates on the Splunk Community!

Splunk AI Assistant for SPL | Key Use Cases to Unlock the Power of SPL

Splunk AI Assistant for SPL | Key Use Cases to Unlock the Power of SPL  The Splunk AI Assistant for SPL ...

Buttercup Games: Further Dashboarding Techniques (Part 5)

This series of blogs assumes you have already completed the Splunk Enterprise Search Tutorial as it uses the ...

Customers Increasingly Choose Splunk for Observability

For the second year in a row, Splunk was recognized as a Leader in the 2024 Gartner® Magic Quadrant™ for ...