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

rts

v0.5.0

Published

Redis storage for timeseries data.

Downloads

50

Readme

rts

Build Status

Use redis as time series data store.

  • Data for the line chart of a period time, can be use to stat sum/avg/max/min/count of a behavior.

e.g. Every 5 minutes, sum of user click of the website.

e.g. Every Day, average consume money of the website.

  • Aggregate data of DayOfWeek or HoursOfDay, to analytisic behavior.

e.g. The sum of click from Monday to SunDay.

Init

var rts = require('rts')(options);

var rts = require('rts')({
        redis: redis,
        gran: '5m, 1h, 1d, 1w',
        points: 500,
        prefix: ''
});

Options:

  • redis the redis client
  • gran granularity of recored time. Format is '{number}{unit}, {number}{unit}...'. The unit can be s second, m minute, h hour, d day, w week, M month, y year. e.g. 5m, 1h, store data for 5 mintues and 1 hour.
  • points how many data will be keep. We care about recently n points of data for each granularity. Think about 1s data, if store 1 day data, it is 86400 rows data, we should reduce it to 5m data, it is only 288 rows. We just care small granularity data for recently, for the history, we just care large granualrity, like revenue of 2010-11, not revenue of 2010-11-05 12 o'clock.
  • prefix the redis key prefix.

Record

record(behavior, [behaviorValue], [statistics], [aggregations])

  • behavior
  • behaviorValue
  • statistics: Array of statistic type, avariable member of sum, count, avg, max, min. default [sum].
  • aggragations
    • hm hour of day, splite data every month
    • hq hour of day, splite data every season
    • hy hour of day, splite data every year
    • dm day of week, splite data every month.
    • dq day of week, splite data every season
    • dy day of week, splite data every year
ts.record('click') // recore a click
ts.record('consume', 5, null, ['hm', 'dq']) // recored behavior with value, and aggragation. 
ts.record('delay', 100, ['avg','max','min'])

Query

ts.getStat(statistic, behavior, granularity, fromDate, toDate, callback)

ts[statistic](behavior, granularity, fromDate, toDate, callback)

ts.aggr{statistic}(behavior, aggragation, date, callback)

  • statistic sum, avg, count, max, min. Must be a member when statistics when record!
  • behavior
  • granularity The time unit, see Options, Must be a part of options.gran
  • fromDate
  • toDate
ts.sum('click', '5m', fromDate, \[toDate\], callback)
ts.count('delay', '5m', fromDate, \[toDate\], callback)
ts.avg('delay', '5m', fromDate, \[toDate\], callback)
ts.max('delay', '5m', fromDate, \[toDate\], callback)
ts.min('delay', '5m', fromDate, \[toDate\], callback)

ts.aggravg('click', 'hm', date, callback)

Others

ts.setValue(name, stat, value, gran, timestamp, callback)

ts.getTimePeriord(gran, points)