appmetrics-dash provides a dashboard to visualize the performance of your Node.js application. The dashboard uses Node Application Metrics to monitor the application displaying the results in a web based front end.

To add monitoring capabailities to your existing Express applications is very easy. The appmetrics-dash constructor allows you to pass in a number of configuration options (see https://github.com/RuntimeTools/appmetrics-dash for full list).  One of these options is an existing server to use rather than have appmetrics-dash start an additional server.

If we take the simple “Hello World” express application


var express = require('express')
var app = express()
app.get('/', function (req, res) {
    res.send('Hello World!')
})
app.listen(3000, function () {
    console.log('Example app listening on port 3000!')
})

First step is to install appmetrics-dash from npmjs.org:

npm install appmetrics-dash

To add appmetrics-dash you just need to add one line of code:

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

This will make appmetrics-dash use the server already being created and add an appmetrics-dash endpoint.
The full code now looks like this

var express = require('express')
var app = express()
var dash = require('appmetrics-dash').attach()
app.get('/', function (req, res) {
    res.send('Hello World!')
})
app.listen(3000, function () {
    console.log('Example app listening on port 3000!')
})

Pointing your browser at <hostname>:<port>/appmetrics-dash will now display the dashboard monitoring your application

1 comment on"Monitoring Express Node.js applications with appmetrics-dash"

Join The Discussion

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