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

@jambonz/time-series

v0.2.11

Published

write and query data to time series daetabase

Downloads

944

Readme

time-series

Read and write call detail records and alerts to an influxdb database.

Usage

Import a function and invoke it with the ip address of the influxdb database and a pino logger.

const {
  writeCdrs,
  queryCdrs,
  writeAlerts,
  queryAlerts,
  AlertType
} = require('@jambonz/time-series')(pinoLogger, '172.32.10.44');

CDRs

writing

await writeCdrs([{
    from: 'me',
    to: 'you',
    sip_callid: '[email protected]',
    answered: true,
    duration: 22,
    attempted_at: new Date(Date.now() - (3600 * 1000)),
    answered_at: Date.now() - (3590 * 1000),
    terminated_at: Date.now(),
    termination_reason: 'caller hungup',
    direction: 'inbound',
    host: '10.10.100.1',
    remote_host: '10.10.100.8',
    trunk: 'device',
    account_sid: 'xxxx',
    call_sid: 'foo'
  }]);

reading

Reading is pagination-based: request a page of data, providing the page number and count of records (i.e page size).

Begin by querying page 1 and a count of records >= 25 and <= 500. The response will include a "total" property indicating the total number of records meeting the supplied criteria; based on this you can calculate the total number of page and then provide pagination.

result = await queryCdrs({account_sid: 'yyyy', page: 1, page_size:50});

{
	"total": 1,
	"page_size": 50,
	"page": 1,
	"data": [{cdr 1}, {cdr 2}, .. {cdr 50}]
}
filtering data

CDR data has these tags, of which you must provide at least account_sid in your query, and you may optionally filter the data further by providing any of the other tags and associated values to filter on:

  • account_sid
  • host (IP address of SBC that generated the CDR)
  • trunk (carrier name)
  • direction (inbound or outbound)
  • answered (true or false)
result = await queryCdrs({account_sid: 'yyyy', direction: 'inbound', page: 1, page_size:50});

Alerts

writing

await writeAlerts([{
      alert_type: AlertType.WEBHOOK_STATUS_FAILURE,
      account_sid: 'yyyy',
      url: 'http://foo.bar',
      status: 404
    },
    {
      alert_type: AlertType.TTS_NOT_PROVISIONED,
      account_sid: 'yyyy',
      vendor: 'google'
    },
    {
      alert_type: AlertType.CARRIER_NOT_PROVISIONED,
      account_sid: 'yyyy',
    },
    {
      alert_type: AlertType.CALL_LIMIT,
      account_sid: 'yyyy',
      count: 50,
    }
]);

reading

result = await queryAlerts({account_sid: 'yyyy', page: 1, page_size:50});

{
	"total": 1,
	"page_size": 50,
	"page": 1,
	"data": [{alert 1}, {alert 2}, .. {alert 50}]
}
filtering data

Alert data has these tags, of which you must provide at least account_sid in your query, and you may optionally filter the data further by providing any of the other tags and associated values to filter on:

  • account_sid
  • alert_type
result = await queryAlerts({account_sid: 'yyyy', alert_type: AlertType.CARRIER_NOT_PROVISIONED, page: 1, page_size:50});