Giter VIP home page Giter VIP logo

appmetrics-dash's Introduction

appmetrics-dash

Build Status codebeat badge codecov.io Apache 2 Homepage

appmetrics-dash provides a very easy to use, web based, dashboard to show the performance metrics of your running Node.js application.

The data available on the dashboard is as follows:

  • HTTP Incoming Requests
  • HTTP Throughput
  • Average Reponse Times (top 5)
  • CPU
  • Memory
  • Heap
  • Event loop Latency
  • Environment
  • Other Requests
  • HTTP Outbound Requests

As well as displaying data, it also provides the ability to generate both Node Report and Heap Snapshots directly from the dashboard. The Node Report will display in a new tab in the browser whilst the Heap Snapshot will be written to disk for loading into the Chrome DevTools for analysis.

The dashboard uses Node Application Metrics to monitor the application.

Installation

npm install appmetrics-dash

Performance overhead

Our testing has shown that the performance overhead in terms of processing is minimal, adding less than 0.5 % to the CPU usage of your application. The additional memory required is around 30 MB to gather information about your system and application which is then visualized in the dashboard.

We gathered this information by monitoring the sample application Acme Air. We used MongoDB as our datastore and used JMeter to drive load though the program. We have performed this testing with Node.js version 6.10.3

dash = require('appmetrics-dash').monitor()

This will launch the dashboard and start monitoring your application. When no options are specified, an http server will be created and listen on port 3001. The dashboard will be available at /appmetrics-dash

Simple example using the express framework

// This application uses express as its web server
// for more info, see: http://expressjs.com
var express = require('express');

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

// cfenv provides access to your Cloud Foundry environment
// for more info, see: https://www.npmjs.com/package/cfenv
var cfenv = require('cfenv');

// create a new express server
var app = express();

// serve the files out of ./public as our main files
app.use(express.static(__dirname + '/public'));

// get the app environment from Cloud Foundry
var appEnv = cfenv.getAppEnv();

// start server on the specified port and binding host
var server = app.listen(appEnv.port, '0.0.0.0', function() {
	// print a message when the server starts listening
  console.log("server starting on " + appEnv.url);
});

dash.monitor(options)

  • options.url {String} Path to serve dashboard from. Optional, defaults to '/appmetrics-dash'.
  • options.console {Object} Some messages are printed to the console using console.log() and console.error(). Optional, defaults to the global console object.
  • options.server {Object} An instance of a node http server to serve the dashboard from. Optional, default is to create a server (see port and host).
  • options.port {String|Number} Port to listen on if creating a server. Optional, unused if server option is used.
  • options.host {String} Host to listen on if creating a server. Optional, unused if server option is used.
  • options.appmetrics {Object} An instance of require('appmetrics') can be injected if the application wants to use appmetrics, since it is a singleton module and only one can be present in an application. Optional, defaults to the appmetrics dependency of this module.
  • options.node-report {Object} An instance of require('node-report') can be injected if the application wants to use node-report, since it is a singleton module and only one can be present in an application. Optional, defaults to the node-report dependency of this module.
  • options.title {String} Title for the dashboard.
  • options.docs {String} URL link to accompanying documentation.

dash.attach(options)

  • options {Object} Options are the same as for dash.monitor().

Auto-attach to all http servers created after this call, calling dash.monitor(options) for every server.

Simple example using attach

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

var http = require('http');

const port = 3000;

const requestHandler = (request, response) => {  
  response.end('Hello')
}

const server = http.createServer(requestHandler);

server.listen(port, (err) => {  
  if (err) {
    return console.log('An error occurred', err)
  }
  console.log(`Server is listening on ${port}`)
});

Contributing

We welcome contributions. Please see CONTRIBUTING.md for details about the contributor licence agreement and other information. If you want to do anything more involved than a bug fix or a minor enhancement then we would recommend discussing it in an issue first before doing the work to make sure that it's likely to be accepted. We're also keen to improve test coverage and may not accept new code unless there are accompanying tests.

License

The Node Application Metrics Dashboard is licensed using an Apache v2.0 License.

appmetrics-dash's People

Contributors

tobespc avatar sjanuary avatar sam-github avatar mattcolegate avatar stalleyj avatar hhellyer avatar julienarnold avatar rmg avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.