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

rhq-metrics

v0.1.3

Published

Provides an interface to rhq-metrics REST API.

Downloads

15

Readme

node-rqh-metrics

Build Status

This is a Javascript API and NPM module package for the rhq-metrics server.

Usage

First you need to require the rhq-metrics module.

var RHQ = require('rhq-metrics');

The constructor function takes an options object where you can specify values for the RHQ server hostname, the port, and the URL path. The default URL for the server is http://localhost:8080/rhq-metrics/metrics.

var rhq = new RHQ({
  host: 'metricserver.com', // defaults to 'localhost'
  port: 4567, // defaults to 8080
  path: '/rhq-metrics/metrics' // defaults to '/rhq-metrics/metrics'
});

Timeseries data is posted as either a single JS object, or an array of objects. In either case, the three fields are required: id, value, and timestamp.

var data = [{id: 'server1', value: 44.1, timestamp: 1418672557728},
            {id: 'server1', value: 23.9, timestamp: 1418672557738},
            {id: 'server1', value: 34.7, timestamp: 1418672557748},
            {id: 'server1', value: 68.5, timestamp: 1418672557758}];

You can use a promises style API, or old school node-style callbacks. Here is a promises usage.

// all configuration parameters are optional
var options = {
  start: Date.now()-(4*60*60*1000), // defaults to 8 hours ago
  end: Date.now(), // defaults to now
  buckets: 20 // defaults to null - data is not bucketed
};

rhq.post(data)
  .then(function() {
    rhq.get('server1', options)
      .then(function(data) {
        // data is an array of timeseries objects for 'server1'
        // [{'timestamp': 1418672557728, 'value': 72.3}]
       });
  });

And here is the old school, node style.

rhq.post(data,
  function() {
    rhq.get('server1', options, function(er, result) {
        // result is an array of timeseries data
        // [{'timestamp': 1418672557728, 'value': 72.3}]
    });
  });

Development

First clone the project.

$ git clone https://github.com/lance/node-rhq-metrics.git

Then change into the project directory, install the dev dependencies, and build it.

$ cd node-rhq-metrics
$ npm install
$ grunt

This will run all tests and generate documentation.