Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Monitoring the Node-RED application using "appmetrics" #8

Open
janvda opened this issue Nov 23, 2018 · 7 comments
Open

Monitoring the Node-RED application using "appmetrics" #8

janvda opened this issue Nov 23, 2018 · 7 comments
Labels
enhancement New feature or request

Comments

@janvda
Copy link
Owner

janvda commented Nov 23, 2018

The goal of this feature request is to specifically monitor the node-red application running in the node-red containers using Telegraf and Grafana.

@janvda janvda added the enhancement New feature or request label Nov 23, 2018
@janvda janvda changed the title Monitoring the Node-RED application using Telegram and Grafana. Monitoring the Node-RED application using Telegraf and Grafana. Nov 23, 2018
@janvda
Copy link
Owner Author

janvda commented Nov 23, 2018

Check if the following can be used for this.
https://www.influxdata.com/blog/instrumenting-your-node-express-application/
which is based on https://github.com/RuntimeTools/appmetrics

The configuration of some of the appmetrics.properties is defined here: https://www.ibm.com/support/knowledgecenter/SS3KLZ/com.ibm.java.diagnostics.healthcenter.doc/topics/configproperties.html

To check first: if appmetrics is supported for arm architecture.

@janvda
Copy link
Owner Author

janvda commented Nov 23, 2018

It is possible to install appmetrics on arm device (raspberry) by issuing the following command in one of the node-red containers:
npm install appmetrics
it takes some time as it has to compile several source files ... in the end you should get something like:

...
npm info lifecycle undefined~preshrinkwrap: undefined
npm info lifecycle undefined~shrinkwrap: undefined
npm info lifecycle undefined~postshrinkwrap: undefined
+ [email protected]
added 48 packages in 202.314s
npm info ok
node-red@84ce20ee0b54:~$

we should also in

  1. node_modules/appmetrics/appmetrics.properties properly set the mqtt host.
  2. node_modules/node-red/red.js add the require and monitor instruction.

@janvda
Copy link
Owner Author

janvda commented Nov 24, 2018

As next step I would in node-red flow listen to topic # (is all messages) to check if it really sends an mqtt and what the topic is.

Update: I have tested it and it effectively showed many mqtt messages.

@janvda
Copy link
Owner Author

janvda commented Nov 26, 2018

The following instruction can be executed in the node-red-test shell to activitate instrumentation:

sed -i 's?var fs = require("fs-extra");?var fs = require("fs-extra");\n\n/* JVA: adding appmetrics instructions*/\nvar appmetrics = require("appmetrics");\nvar monitoring = appmetrics.monitor();\n?' /usr/src/node-red/node_modules/node-red/red.js

@janvda
Copy link
Owner Author

janvda commented Nov 26, 2018

Following github defines a dashboard https://github.com/RuntimeTools/appmetrics-dash
or a better link:
https://developer.ibm.com/node/2017/07/26/visualize-node-red-flow-performance-using-node-application-metrics/

It is currently not working but it might conflict with the other appmetrics module that is installed (maybe best to remove it).

@janvda janvda changed the title Monitoring the Node-RED application using Telegraf and Grafana. Monitoring the Node-RED application using "appmetrics" Nov 26, 2018
@janvda
Copy link
Owner Author

janvda commented Nov 27, 2018

I have posted below comment on site: https://developer.ibm.com/node/2017/07/26/visualize-node-red-flow-performance-using-node-application-metrics/

Hi Matthew,

This is a very interesting tutorial.
I have tried to reproduce this without much success.
So I am just wondering if this tutorial can still be used on a linux device(raspberry pi) with node.js version 8.1.3 and latest version of Node Application Metrics =4.0.1.201811271705 (Agent Core 3.2.9)

When I added the 2 following instructions after the first line in my red.js
=====================================================================
var dash = require('appmetrics-dash');
dash.attach();
===================================================================

I got the following log file 
======================================================================
npm info lifecycle [email protected]~start: [email protected]
27.11.18 23:05:15 (+0100)  node-red-test
27.11.18 23:05:15 (+0100)  node-red-test  > [email protected] start /usr/src/node-red
27.11.18 23:05:15 (+0100)  node-red-test  > node $NODE_OPTIONS node_modules/node-red/red.js -v $FLOWS "--userDir" "/data"
27.11.18 23:05:15 (+0100)  node-red-test
27.11.18 23:05:15 (+0100)  node-red-test  [Tue Nov 27 22:05:15 2018] com.ibm.diagnostics.healthcenter.loader INFO: Node Application Metrics 4.0.1.201811271705 (Agent Core 3.2.9)
27.11.18 23:05:20 (+0100)  node-red-test  [Tue Nov 27 22:05:20 2018] com.ibm.diagnostics.healthcenter.mqtt INFO: Connecting to broker localhost:1883
27.11.18 23:05:22 (+0100)  node-red-test  27 Nov 22:05:22 - [info]
27.11.18 23:05:22 (+0100)  node-red-test
27.11.18 23:05:22 (+0100)  node-red-test  Welcome to Node-RED
27.11.18 23:05:22 (+0100)  node-red-test  ===================
27.11.18 23:05:22 (+0100)  node-red-test
27.11.18 23:05:22 (+0100)  node-red-test  27 Nov 22:05:22 - [info] Node-RED version: v0.19.5
27.11.18 23:05:22 (+0100)  node-red-test  27 Nov 22:05:22 - [info] Node.js  version: v8.1.3
27.11.18 23:05:22 (+0100)  node-red-test  27 Nov 22:05:22 - [info] Linux 4.14.39 arm LE
27.11.18 23:05:23 (+0100)  node-red-test  27 Nov 22:05:23 - [info] Loading palette nodes
27.11.18 23:05:28 (+0100)  node-red-test  27 Nov 22:05:28 - [info] Dashboard version 2.11.0 started at /node-red-test/ui
27.11.18 23:05:29 (+0100)  node-red-test  27 Nov 22:05:29 - [info] Settings file  : /data/settings.js
27.11.18 23:05:29 (+0100)  node-red-test  27 Nov 22:05:29 - [info] Context store  : 'default' [module=memory]
27.11.18 23:05:29 (+0100)  node-red-test  27 Nov 22:05:29 - [info] User directory : /data
27.11.18 23:05:29 (+0100)  node-red-test  27 Nov 22:05:29 - [warn] No active project : using default flows file
27.11.18 23:05:29 (+0100)  node-red-test  27 Nov 22:05:29 - [info] Flows file     : /data/flows.json
27.11.18 23:05:29 (+0100)  node-red-test  27 Nov 22:05:29 - [info] Server now running at http://127.0.0.1:1880/node-red-test/
27.11.18 23:05:29 (+0100)  node-red-test  27 Nov 22:05:29 - [warn]
27.11.18 23:05:29 (+0100)  node-red-test
27.11.18 23:05:29 (+0100)  node-red-test  ---------------------------------------------------------------------
27.11.18 23:05:29 (+0100)  node-red-test  Your flow credentials file is encrypted using a system-generated key.
27.11.18 23:05:29 (+0100)  node-red-test
27.11.18 23:05:29 (+0100)  node-red-test  If the system-generated key is lost for any reason, your credentials
27.11.18 23:05:29 (+0100)  node-red-test  file will not be recoverable, you will have to delete it and re-enter
27.11.18 23:05:29 (+0100)  node-red-test  your credentials.
27.11.18 23:05:29 (+0100)  node-red-test
27.11.18 23:05:29 (+0100)  node-red-test  You should set your own key using the 'credentialSecret' option in
27.11.18 23:05:29 (+0100)  node-red-test  your settings file. Node-RED will then re-encrypt your credentials
27.11.18 23:05:29 (+0100)  node-red-test  file using your chosen key the next time you deploy a change.
27.11.18 23:05:29 (+0100)  node-red-test  ---------------------------------------------------------------------
27.11.18 23:05:29 (+0100)  node-red-test
27.11.18 23:05:29 (+0100)  node-red-test  27 Nov 22:05:29 - [info] Starting flows
27.11.18 23:05:29 (+0100)  node-red-test  27 Nov 22:05:29 - [info] Started flows
27.11.18 23:05:29 (+0100)  node-red-test  27 Nov 22:05:29 - [info] [mqtt-broker:mqtt broker] Connected to broker: mqtt://mqtt:1883
27.11.18 23:05:35 (+0100)  node-red-test  Error: Can't set headers after they are sent.
27.11.18 23:05:35 (+0100)  node-red-test      at validateHeader (_http_outgoing.js:504:11)
27.11.18 23:05:35 (+0100)  node-red-test      at ServerResponse.setHeader (_http_outgoing.js:511:3)
27.11.18 23:05:35 (+0100)  node-red-test      at expressInit (/usr/src/node-red/node_modules/express/lib/middleware/init.js:30:42)
27.11.18 23:05:35 (+0100)  node-red-test      at Layer.handle [as handle_request] (/usr/src/node-red/node_modules/express/lib/router/layer.js:95:5)
27.11.18 23:05:35 (+0100)  node-red-test      at trim_prefix (/usr/src/node-red/node_modules/express/lib/router/index.js:317:13)
27.11.18 23:05:35 (+0100)  node-red-test      at /usr/src/node-red/node_modules/express/lib/router/index.js:284:7
27.11.18 23:05:35 (+0100)  node-red-test      at Function.process_params (/usr/src/node-red/node_modules/express/lib/router/index.js:335:12)
27.11.18 23:05:35 (+0100)  node-red-test      at next (/usr/src/node-red/node_modules/express/lib/router/index.js:275:10)
27.11.18 23:05:35 (+0100)  node-red-test      at query (/usr/src/node-red/node_modules/express/lib/middleware/query.js:45:5)
27.11.18 23:05:35 (+0100)  node-red-test      at Layer.handle [as handle_request] (/usr/src/node-red/node_modules/express/lib/router/layer.js:95:5)
...

@janvda
Copy link
Owner Author

janvda commented Nov 27, 2018

I also reported RuntimeTools/appmetrics-dash#167

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant