Splunk AppDynamics

Monitoring Nodejs with pm2

CommunityUser
Splunk Employee
Splunk Employee

Hi, good morning.

I'm testing Appdinamyc nodejs monitor.
I have verified that it works perfectly.
But I have problems when I use the application manager nodejs "pm2" to start them with "n instances".
How can I configure Appdynamics with pm2 nodejs?

Labels (1)
0 Karma

CommunityUser
Splunk Employee
Splunk Employee

sorry for delay. .

I`ll summarize the actions

I first  started correctly started manualy proxy

second started pm2 -i 2 start server.js

but no monitoring .

Also be where to put  these options

  • Configure each agent for manual launch of the proxy. In the AppDynamics require.profile() block of each Node.js process, set proxyAutolaunchDisabled to true and set the proxyCtrlDir to the directory that you created. For example:

    ...
    proxyAutolaunchDisabled: true,
    proxyCtrlDir: '/tmp/appd/proxy_ctrl_dir',
    ...

very best regards

0 Karma

Ayush_Ghosh
Path Finder

Hi,

In your node application you initiate the appdynamics profiler like

require("appdynamics").profile({
  controllerHostName: '<controller host name>',
  controllerPort: <controller port number>, 
  controllerSslEnabled: false,  // Set to true if controllerPort is SSL
  accountName: '<AppDynamics_account_name>',
  accountAccessKey: '<AppDynamics_account_key>', //required
  applicationName: 'your_app_name',
  tierName: 'choose_a_tier_name', 
  nodeName: 'choose_a_node_name', 
 });

You need to add the 

proxyAutolaunchDisabled: true,
proxyCtrlDir: '/tmp/appd/proxy_ctrl_dir',

to the same block.

Please remember to start proxy first, and use the same file location for control and logs directory.

Thanks

Ayush

0 Karma

CommunityUser
Splunk Employee
Splunk Employee

PM2 gained the most popularity and is now considered an enterprise standard. One of the most important thing is that It’s in active development, has a stable API and is constantly assailed by more than 1000 tests. If you are interested in monitoring & scaling Node.js apps you should read this article https://www.netguru.co/codestories/monitoring-vertically-scaling-nodejs-applications. It's definitely worth it. 🙂

0 Karma

Ayush_Ghosh
Path Finder

Explaining a bit further.

If the process manager spins up only 1 instance, it will work perfectly. As its same as just running application with node app.js.

But if you use of PM2 is to run multiple processes/instances, in which case there may be an issue. As with each instance a new proxy could be spinned.

Thus we suggest starting the proxy manually, and the steps are as follows

Create two directories /tmp/appd/proxy_ctrl_dir/tmp/appd/logs

In Appdynamics config for NodeJS

Set proxyCtrlDir as /tmp/appd/proxy_ctrl_dir

Set proxyAutolaunchDisabled as true

Then start the proxy manually as described in the documentation 

nohup /<application_root_dir>/node_modules/appdynamics-proxy/proxy/runProxy -j /<application_root_dir>/node_modules/appdynamics-jre/jre – /tmp/appd/proxy_ctrl_dir /tmp/appd/logs & 

https://docs.appdynamics.com/display/PRO42/Run+the+Proxy+Daemon+Manually+for+Node.js+Agents

Then start the NodeJs application so that with any number of instance, there is only one proxy.

0 Karma

Ayush_Ghosh
Path Finder

Hi,

If you want to use a process manager like PM2, you need to start the proxy manually. 

AppDynamics NodeJs agent talk to the controller via a proxy, there should be only one instance of proxy running. When you use a process manager like PM2. It may start multiple proxy which creates issue.

Here is the documentation to start the proxy manually. 

https://docs.appdynamics.com/display/PRO42/Run+the+Proxy+Daemon+Manually+for+Node.js+Agents

0 Karma

CommunityUser
Splunk Employee
Splunk Employee

Hi, thaks.

I followed your instructions but I always fail because I can not find the directory.
I have tried to create the directories tmp / appd / tmp / appd / logs and / tmp / appd / proxy_ctrl_dir

I have execute:

[nodejs@svtarqfrt1re proxy]$ ./runProxy -j /appsrv/LIBERBANK.PROYECTO/LBK_ARQ_SPA_SERVER/node_modules/appdynamics/node_modules/appdynamics-jre/jre - /tmp/appd/proxy_ctrl_dir /tmp/appd/logs/
Proxy communication directory, "-", does not exist or is not a directory.
Usage: runProxy options -- proxyCommunicationDir logDirectory [jvmOption [ jvmOption [...] ]
Options:
  -r <dir>, --proxy-runtime-dir=<dir>   Specifies proxy runtime directory
  -d <dir>, --proxy-dir=<dir>           Specifies root proxy directory
  -j <dir>, --jre-dir=<dir>             Specifies root JRE directory
  -v, --verbose                         Enable verbose output
  -h,--help                   Show this message

Example: ./runProxy -d ./proxy -r /tmp/appd/app1/tier1/node1 /tmp/proxy.communication /tmp/agentLogs
Note: Please use quotes for the entries wherever applicable.


But always getting the following error


"Proxy communication directory," - ", does not exist or is not a directory."
Would be kind enough to show me some example.
Many thank

0 Karma
Get Updates on the Splunk Community!

New This Month - Splunk Observability updates and improvements for faster ...

What’s New? This month, we’re delivering several enhancements across Splunk Observability Cloud for faster and ...

What's New in Splunk Cloud Platform 9.3.2411?

Hey Splunky People! We are excited to share the latest updates in Splunk Cloud Platform 9.3.2411. This release ...

Buttercup Games: Further Dashboarding Techniques (Part 6)

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