npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

metrano

v0.1.2

Published

Real-time metrics datastore & server

Downloads

8

Readme

Metrano is an PostgreSQL backed HTTP server for time series aggregation.

This package provide both the server an a node.js library which exposes the server's functionality.

It is designed to scale to billions (untested) of records per server. If you need more capacity, you can either shard your data and run more DB instances or you can look into Hadoop.

Install

npm install metrano --save

Server

start with node metrano.js

options:

  • --cleanup to reset the config table

APIs

fetch data

GET /feeds/<feedName>/<deviceId>/<aggrFunction>/<fromTimestamp>/<toTimestamp>

Where:

  • feedName is the name of the feed to retrieve data from
  • deviceId is the unique id of the data of the feed
  • aggrFunction is the calculation function to apply to feed values when they need to be aggregated. Can be one of:
    • sum
      • avg
      • count
      • max
      • min
      • stddev_pop population standard deviation of the input values
      • stddev_samp sample standard deviation of the input values
      • var_pop population variance of the input values (square of the population standard deviation)
      • var_samp sample variance of the input values (square of the sample standard deviation)
  • fromTimestamp the time in milliseconds since UTC Epoch from which data should be retrieved
  • toTimestamp the time in milliseconds since UTC Epoch until which the data should be retrieved

The data is automatically aggregated based on the feed configuration and the requested time interval.

push values

a single data point:

POST /api/feeds/<feedName>/<deviceId>
{
	value: 123,
	timestamp: 1414943636741
}

The timestamp (in milliseconds) timezone is interpreted as UTC.

define a new metric

POST /api/feeds
{
	name: 'temperature',
	aggregateThresholds: {
		minute: 0,
		hour: (2 * 60 * 60 * 1000),
		day: (2 * 24 * 60 * 60 * 1000),
		month: (24 * 30 * 24 * 60 * 60 * 1000)
	}
}

The aggregateThresholds attribute contains the timestamps for which an aggregate should kick off. Depending on the amount of data you want to retrieve, Metrano will reduce it based on the values in the configuration.

Available aggregates references are:

  • microseconds
  • milliseconds
  • second
  • minute
  • hour
  • day
  • week
  • month
  • quarter
  • year
  • decade
  • century
  • millennium

Client

var Metrano = require('metrano')

var metrano = new Metrano('http://localhost:3000/')

metrano.define({ name: 'temperature', aggregateThresholds: { minute: 0, hour: (2 * 60 * 60 * 1000), day: (2 * 24 * 60 * 60 * 1000), month: (24 * 30 * 24 * 60 * 60 * 1000) } }, function(err) { // metric ready })

metrano.remove(feed, function(err) { // feed removed })

metrano.save(, <device_id>, , <UTC_timestamp>, function(err) { // metric saved })