A node.js bindings for Librato metrics that provides advanced statistics which allow you to reduce your reporting frequency and ultimately lower your montly Librato bill.
It was originally created for http://showgoers.tv but I forked it out of that codebase to open it up for community use and contributions.
let metricDefinitions = {
'errors': {
libratoAggFunction: 'sum',
periodMs: 10000 //perhaps we want errors reported at a higher resolution than other metrics
},
'star_rating': {
libratoAggFunction: 'average',
},
'web_requests': {
clientAggFunction: 'sum',
libratoAggFunction: 'average',
libratoMetricProperties: {
display_name: 'Site Requests',
description: 'The number of requests made to the web server',
attributes: {
color: '#ff0000'
}
},
},
'response_time_ms': {
clientAggFunction: 'quantiles',
libratoAggFunction: 'min',
quantiles: [0, .1, .90, 1], //when submitted to librato, will actually create 4 separate metrics (ie. response_time_ms.q0, response_time_ms.q10, response_time_ms.q90, response_time_ms.q100)
periodMs: 30 * 60 * 1000 //because we're intelligently aggregating, we only need to report every thirty minutes
}
}
let librato = new Librato({
source: 'my_default_source',
definitions: metricDefinitions,
logging: true, //turn on debug output to console
periodMs: 10000
})
librato.start()
librato.increment('requests', 10)
librato.measure('response_time_ms', 1)
librato.measure('star_rating', 5)
librato.measure('star_rating', 4, 'another_source')
librato.measure('not_defined_metric', 1) //when using the measure method will default to "mean" as an aggregation function
librato.increment('not_defined_count', 1) //when using the increment method will default to "sum" as an aggregation function