Giter VIP home page Giter VIP logo

hapi-cloudwatch's Introduction

hapi-cloudwatch

A hapi plugin for sending request response time metrics to AWS CloudWatch.

Build Status Coverage Status npm version Dependencies Status DevDependencies Status Known Vulnerabilities

Installation

npm install hapi-cloudwatch

Usage

To install this plugin on your Hapi server, do something similar to this:

var Hapi = require('hapi');
var server = new Hapi.Server();

var options = {};

server.register({ register: require('hapi-cloudwatch'), options }, function(err) {
  if (err) {
    console.log('error', 'Failed loading plugin: hapi-cloudwatch');
  }
});

Plugin Options

region

AWS region to send the metrics to.

Defaults to eu-west-1

environment

The primary dimension added to the CloudWatch metric

Defaults to process.env.NODE_ENV

enabled

Turns on/off the sending of metrics to CloudWatch

Defaults to true

metricsSentCallback

A function to call when metrics have been sent to CloudWatch.

Defaults to no-op.

Example

A Hapi route configured like this:

server.route({
  method: 'GET',
  path: '/products/{id}',
  handler: function(request, reply) {
    reply('Success!');
  }
});

and run with NODE_ENV=production npm start will send a metric to AWS CloudWatch with the following dimensions:

  • metric name: responseTime
  • environment: production
  • method: GET
  • statusCode: 200
  • path: /products/{id}

Here's an example of what can be graphed in CloudWatch with this metric:

Example CloudWatch Graph

Version Compatibility

Currently in use by me with with: Hapi 16.1.0 (Node v6)

I'll add tests for other hapi and node versions shortly

hapi-cloudwatch's People

Contributors

clarkie avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 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.