Comments (17)
Hi @neilyoung,
appmetrics is designed to run alongside a Node.js application to provide monitoring information for that application. It doesn't matter to appmetrics if your application outputs to console, HTTP or HTTPS, it will run alongside just the same.
Information from appmetrics can be output by your application by utilising the monitoring.on
function to obtain the monitoring data as an object (see https://github.com/RuntimeTools/appmetrics#modifying-your-application-to-use-appmetrics). Your application is then free to output that data in whatever form you wish.
If you are looking for something more visual in output, might I suggest https://github.com/runtimetools/appmetrics-dash ? It uses either your or it's own HTTP server to visually display data from appmetrics on a web dashboard.
from appmetrics.
If you are looking for something more visual in output, might I suggest https://github.com/runtimetools/appmetrics-dash ? It uses either your or it's own HTTP server to visually display data from appmetrics on a web dashboard.
This is what I'm using. And it just displays a screen full of empty field:
Setup like so:
(package.json):
"appmetrics-dash": "^5.3.0",
Then first line of my server code:
// Before all other 'require' statements
require('appmetrics-dash').attach()
As far as I know that was it.
My server is started like so:
var server = url.protocol === 'http:' ? http.createServer(app).listen(port, () => {
logger.info('non-Secure server started at %s', args.srv_url)
}) :
https.createServer(options, app).listen(port, () => {
logger.info('secure server started at %s', args.srv_url)
http.createServer((req, res) => {
res.writeHead(302, { 'location': 'https://' + req.headers.host + req.url })
res.end()
}).listen(80)
})
A call to the dashboard route brings the above screen.
from appmetrics.
That's interesting - there's code in appmetrics-dash
to support both https and http servers - I wonder if it's being thrown off by your http redirect server? Does it work if you create a http server rather than a https server?
from appmetrics.
Will check later and let you know
from appmetrics.
I threw together a quick sample HTTPS server and can confirm that appmetrics-dash appeared on https://localhost:3000/appmetrics-dash with meaningful data
from appmetrics.
I've now recreated your issue using your code snippet above - it looks like although the dashboard is available in both places data is only being sent to one of them. Your secure site's appmetrics-dash is empty, but your http redirect's one (on http://<host>:80/appmetrics-dash
) is populated with data.
To get your data going back where it should, you'll need to use the appmetrics-dash.monitor()
method to just target your secure server - have a look at the following example to see what to do:
from appmetrics.
Cool. Thanks. As you said, it works via HTTPS, if I omit HTTP. Will try your latest suggestion now.
Having another problem on the same machine with another node server running at 8443, secure.
Same setup: First line the require statement. No HTTP server only HTTPS.
The first attempt to get the dashboard crashes the node server:
[Thu May 14 14:01:01 2020] com.ibm.diagnostics.healthcenter.loader INFO: Node Application Metrics 5.1.1.202005141355 (Agent Core 4.0.5)
[Thu May 14 14:01:02 2020] com.ibm.diagnostics.healthcenter.mqtt INFO: Connecting to broker localhost:1883
events.js:292
throw er; // Unhandled 'error' event
^
Error [ERR_STREAM_WRITE_AFTER_END]: write after end
at write_ (_http_outgoing.js:646:17)
at ServerResponse.write (_http_outgoing.js:638:15)
at ReadStream.ondata (_stream_readable.js:708:22)
at ReadStream.emit (events.js:315:20)
at ReadStream.EventEmitter.emit (domain.js:485:12)
at addChunk (_stream_readable.js:297:12)
at readableAddChunk (_stream_readable.js:273:9)
at ReadStream.Readable.push (_stream_readable.js:214:10)
at internal/fs/streams.js:242:14
at /home/decades/awss-server/node_modules/async-listener/glue.js:188:31
Emitted 'error' event on ServerResponse instance at:
at errorOrDestroy (internal/streams/destroy.js:128:12)
at ServerResponse.onerror (_stream_readable.js:745:9)
at ServerResponse.emit (events.js:327:22)
at ServerResponse.EventEmitter.emit (domain.js:485:12)
at writeAfterEndNT (_http_outgoing.js:701:7)
at /home/decades/awss-server/node_modules/async-listener/glue.js:188:31
at processTicksAndRejections (internal/process/task_queues.js:85:21) {
code: 'ERR_STREAM_WRITE_AFTER_END'
}
Reproducible. With each attempt to access something.
from appmetrics.
OK, found it. I had to place the call to
dash.monitor({ server: server }) // Does not work yet
after all
app.thisandthat setups
from appmetrics.
Just one thing: There is a file resourceRegistry.log
written by your plugin. Can this be omitted?
from appmetrics.
Unfortunately at the moment it can't - it's generated automatically by one of our dependencies' dependencies. There is an open issue for it at IBM/node-ibmapm-restclient#5
from appmetrics.
Ok. Understand. What about authentication? Haven't found yet.
from appmetrics.
Currently appmetrics-dash
doesn't have built-in security such as authentication-based access. We do support the passing through of code to run when the endpoint is hit via <appmetrics-dash>.attach(options.middleware)
or <application-dash>.monitor(options.middleware)
so it should be possible to put a third-party security solution in place.
from appmetrics.
@mattcolegate May I ask you, what the mqtt
broker thing does? Is it required to monitor the things, via the appmetrics-dash
route?
Then: Is there a way to add own probes, like counters etc?
from appmetrics.
MQTT http://mqtt.org/ is a transport mechanism that can be used by appmetrics to communicate with an MQTT broker, such as https://mosquitto.org/. It is not required to monitor things via the appmetrics-dash route.
You can certainly add your own probes - there is no official guide, but there are some pull requests that you can look at to get an idea of what to do.
from appmetrics.
OK, thanks. I don't need that. Can MQTT be disabled at all?
from appmetrics.
Change com.ibm.diagnostics.healthcenter.mqtt=on
to off
in .../node_modules/appmetrics/appmetrics.properties
from appmetrics.
Cool. Thanks.
from appmetrics.
Related Issues (20)
- Man-in-the-Middle vulnerability in dependency https-proxy-agent HOT 2
- Including appmetrics breaks promisified setTimeout HOT 1
- Windows automated tests broken on all node versions except 10
- Unable to install appmetrics HOT 15
- Build fails with GCC version 10.1.0 HOT 4
- Outdated node-gyp dependency throws error upon npm i HOT 1
- monitor HTTP HOT 2
- install appmetrics failed with node 14 HOT 5
- 5.1.1 segfaults node HOT 2
- Warnings emitted on Node 14 HOT 7
- SHA-1 Weak Authentication Algorithm vulnerability in dependency "request" HOT 6
- Error with node:14-alpine3.13 image HOT 3
- incompatible with socket.io@3 and @4 - Exception thrown "TypeError: Cannot read property 'on' of undefined" HOT 5
- unable to install on Fedora 34 HOT 5
- Unable to install library from npm HOT 5
- Error with node:14.17.6-alpine3.14 image HOT 1
- Prototype pollution vulnerability in `[email protected]`
- Can't compile HOT 2
- is this being maintained? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from appmetrics.