Question

How to use pm2 monitoring on node app in new DO Apps ?

Posted September 23, 2020 1.9k views
Node.jsDigitalOceanMonitoringDeploymentDigitalOcean App Platform

With the new Digital Ocean app launch system, I’m having a hard time figuring out how I can use pm2 monitor to effectively monitor the health, traffic and over all status on my API. My current setup is running it on a droplet but I have had issues with security on it, so I would like to move my node app to DO Apps to remove the whole security concern of the droplet. My main issue is getting logged into pm2 monitor once the build process is complete.

edited by AHA

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
Submit an Answer
1 answer

Hi WeaponizedLogo,

Make sure your start command uses pm2-runtime instead of pm2. Also, add your Environment Variables to the app component PM2PUBLICKEY and PM2SECRETKEY.

Best,
Moises

  • Hello Moises. I thought I had this working, as the services was succesfully being added to pm2.io. However it seems that fails to properly log any activity besides restarts or latency. CPU, RAM, Heap size and so remains on either 0 or inactive. Even though I put some stress on the server, and see that it is live and working when I poke the endpoints. Do you have an idea what this could be?

  • Is it necessary to install pm2 in the Component? pm2 doesn’t seem to be installed yet and I’m unsure what the best way to run it is?

    • Yes, I found it best to install it as a global package in the build process. But I still have issues with it not reading CPU and ram usage properly. I’ve also had contact with support, but they also couldn’t figure out why the new APPS web services don’t allow pm2 to read those stats.

      • Dumb question probably but how did you install it as a global package?

        • In the component settings of you APP if it is a web service will have a “Build Command” and a “Run Command”

          In the build command you can type:

          npm install pm2 -g
          

          And it will make pm2 globally available in your app container. Which I found game the best results when trying to use the pm2 runtime.

    • I’m having the same issue regardless of how it is set up, locally or globally.

      If you’re looking at PM2’s logs, you will see that every 500ms, it triggers:

      PM2 error: Error caught while calling pidusage

      After looking what “pidusage” is on NPM, it becomes clear why CPU or RAM is not shown at all. You can see it does exactly that, checks for CPU and RAM usage, as well as being one of the 30 dependencies of PM2 on NPM.

      I will raise a ticket to DO, maybe there is something we could do about it.