Open janvda opened 6 years ago
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.
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
+ appmetrics@4.0.0
added 48 packages in 202.314s
npm info ok
node-red@84ce20ee0b54:~$
we should also in
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.
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
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).
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 node-red-docker@1.0.0~start: node-red-docker@1.0.0
27.11.18 23:05:15 (+0100) node-red-test
27.11.18 23:05:15 (+0100) node-red-test > node-red-docker@1.0.0 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)
...
I also reported https://github.com/RuntimeTools/appmetrics-dash/issues/167
The goal of this feature request is to specifically monitor the node-red application running in the node-red containers using Telegraf and Grafana.