1.0.0 • Published 5 years ago

monitoringserver v1.0.0

Weekly downloads
1
License
ISC
Repository
github
Last release
5 years ago

Description

This modules aggregates time series metrics and logs for monitoring purpose.

Metrics

Useful to store number of online users / cron execution time / number of executions of a script / uptime / https grade / postfix queue size / etc

Granularity

Metrics data are organized in different granularity :

  • all : every inserted point (maximum granularity)
  • minute : aggregated (aligned) at 1 point per minute
  • hour : 1 per hour
  • day : 1 per day

You will have for each granularity an array of dates and for each date, a statistical summary (nb min max avg)

Inserting data

Just do an http post request on /metric endpoint exemple :

curl -X POST http://localhost:3000/metric/test

will save a new metric called "test" with value "123" at current timestamp

Reading data

do a http get request on /metric

It will return an array describing the test metric previously inserted.

Parameters:

  • granularity (required) : default all
  • before : get points before this date
  • after : get points after this date
  • nb : downsamples data using lttb algorythm

Exemple

$> curl http://localhost:3000/metric/test?granularity=minute&after=2019-01-01 21:21:00
[
	{date: '2019-01-01 21:21:00', avg: 123, nb: 1, min: 123, max: 123},
	...
]

Streaming data

With socket io you can subscribe to a metric. Therefore each time something is inserted your callback will be called. Useful for live plotting :

Socket.emit('subscribe')
Socket.on('data', function(data){})

Benchmark

My tests reports ~100000 inserts / s

node benchmark.js
1.0.0

5 years ago