Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/segment-boneyard/metrics-express
Express server plugin for your business metrics
https://github.com/segment-boneyard/metrics-express
Last synced: about 5 hours ago
JSON representation
Express server plugin for your business metrics
- Host: GitHub
- URL: https://github.com/segment-boneyard/metrics-express
- Owner: segment-boneyard
- Created: 2014-05-25T07:22:57.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2015-07-12T00:12:11.000Z (over 9 years ago)
- Last Synced: 2024-11-12T14:46:39.842Z (3 days ago)
- Language: JavaScript
- Size: 198 KB
- Stars: 10
- Watchers: 38
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: Readme.md
- Changelog: History.md
Awesome Lists containing this project
README
# metrics-express
An [express](https://github.com/segmentio/aws-billing) app to serve your [segmentio/metrics](https://github.com/segmentio/metrics) as an internal API.
## Installation
$ npm install metrics-express
## Example
```js
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 /`
Fetch a list of all [Metric](https://github.com/segmentio/metrics#new-metric) keys.
![image](https://cloud.githubusercontent.com/assets/658544/3076432/04583784-e3dd-11e3-8c30-daa171f3a1da.png)
### `GET /:name`
Get a list of all valid [Metric](https://github.com/segmentio/metrics#new-metric) timestamps and values.
![image](https://cloud.githubusercontent.com/assets/658544/5654566/2eec19ee-9679-11e4-87cf-f0bf48c50874.png)
### `GET /:name/:timestamp`
Get a [Metric](https://github.com/segmentio/metrics#new-metric) value at a specific `timestamp`.
`timestamp` values could be specific timestamps, or human [date.js](https://github.com/MatthewMueller/date#examples) strings, like `today` or `2 weeks from wednesday`.
![image](https://cloud.githubusercontent.com/assets/658544/5654588/5561b804-9679-11e4-836f-b8797cb57a16.png)
## License
MIT