n2parko / metrics-express

Express server plugin for your business metrics

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

metrics-express

An express app to serve your segmentio/metrics as an internal API.

Installation

$ npm install metrics-express

Example

var Metrics = require('metrics');
var serve = require('metrics-express');

var metrics = Metrics()
  .every('10m', charges('stripe-key')
  .every('10m', subscriptions('stripe-key')
  .every('1d', awsBilling(accountId, key, secret, bucket, region))
  .every('10m', helpscout('helpscout-key', ['mailbox']));

express()
  .use('/', serve(metrics))
  .listen(7002);

After your server starts, you'll be able to access a list of your metrics at:

GET /

image

And get the detailed metric value at this route:

GET /:name

image

POST /:name/:newVal

Posts values to the server. For example, let's say your current Monthly Recurring Revenue is $5000.

When you make a sale, you can add to your current MRR from the terminal using:

curl -X POST https://localhost:7002/MRR/10000

This will bring your total MRR to $15000

License

MIT

About

Express server plugin for your business metrics


Languages

Language:JavaScript 100.0%