This how-to marries Node-RED and Application Metrics for Node.js™ together in 3 easy steps so that you can monitor the performance characteristics of your Node-RED flows in real time.

Node-RED's browser-based flow editor showing an example flow
The Application Metrics for Node.js™ Dashboard, displaying graphs showing HTTP, CPU, Memory, Event Loop and Heap usage
Node-RED is a programming tool for wiring together hardware devices, APIs and online services in new and interesting ways. Built on Node.js™, it provides a browser-based editor that makes it easy to wire together flows using the wide range of nodes in the palette that can be deployed to its runtime in a single-click.
Application Metrics for Node.js™ provides instant and powerful insights into the live performance of your Node.js™ applications.

Step 1: First of all, install appmetrics-dash in the same way as you installed Node-RED.

  • If you installed Node-RED locally, navigate to your node_modules/node-red directory and install appmetrics-dash using npm.
    cd node_modules/node_red
    npm install appmetrics-dash
  • Otherwise, for a global installation of Node-RED, globally install appmetrics-dash using npm.
    npm install -g appmetrics-dash

Step 2: Next, add appmetrics-dash instantiation code into your red.js file

  • For a local Node-RED installation, the red.js file will be in the directory you’re currently in after step 1.
  • Else if you installed Node-RED globally, find the directory where your node-red command is (using the command where node-red or which node-red), navigate to that directory and it should be under node_modules/node-red.

Open the file in a text editor and paste the following at the top of the file, just before the http require:

var dash = require('appmetrics-dash');
dash.attach();

This instantiates appmetrics-dash and instructs it to attach itself to Node-RED’s web server instance.

Step 3: Finally, run node-red!

Start Node-RED in the normal way (typically running the node-red command). Appmetrics logging should now be present in the command output:

[07/26/17 15:49:44] com.ibm.diagnostics.healthcenter.loader INFO: Node Application Metrics 3.0.2.201706071954 (Agent Core 3.2.1)
[07/26/17 15:49:45] com.ibm.diagnostics.healthcenter.mqtt INFO: Connecting to broker localhost:1883
26 Jul 15:49:46 – [info]

Welcome to Node-RED
===================

26 Jul 15:49:46 – [info] Node-RED version: v0.17.5
26 Jul 15:49:46 – [info] Node.js version: v6.11.1
26 Jul 15:49:46 – [info] Windows_NT 6.1.7601 x64 LE
26 Jul 15:49:48 – [info] Loading palette nodes
26 Jul 15:49:50 – [warn] ——————————————————
26 Jul 15:49:50 – [warn] [rpi-gpio] Info : Ignoring Raspberry Pi specific node
26 Jul 15:49:50 – [warn] [tail] Not currently supported on Windows.
26 Jul 15:49:50 – [warn] ——————————————————
26 Jul 15:49:50 – [info] Settings file : C:\Users\IBM_ADMIN\Desktop\GitRepos\.node-red\settings.js
26 Jul 15:49:50 – [info] User directory : C:\Users\IBM_ADMIN\Desktop\GitRepos\.node-red
26 Jul 15:49:50 – [info] Flows file : C:\Users\IBM_ADMIN\Desktop\GitRepos\.node-red\flows_redacted.json
26 Jul 15:49:50 – [info] Starting flows
26 Jul 15:49:50 – [info] Started flows
26 Jul 15:49:50 – [info] Server now running at http://127.0.0.1:1880/

The Application Metrics for Node.js™ Dashboard will now be running on the Node-RED web server at /appmetrics-dash, so for the above example it will be on http://127.0.0.1:1880/appmetrics-dash.

Join The Discussion

Your email address will not be published. Required fields are marked *