hapi-cloudwatch
A hapi plugin for sending request response time metrics to AWS CloudWatch.
Installation
npm install hapi-cloudwatch
Usage
To install this plugin on your Hapi server, do something similar to this:
var Hapi = ;var server = ; var options = {}; server;
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;
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:
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