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

ibm-cloud-monitoring

v0.1.0

Published

IBM Cloud Monitoring JavaScript Client Library

Downloads

2

Readme

IBM Cloud Monitoring JavaScript SDK

JavaScript library for the IBM Cloud Monitoring service.

Use the IBM® Cloud Monitoring service to expand your collection and retention capabilities when working with metrics, and to be able to define rules and alerts that notify you of conditions that require attention.

Provides a wrapper around the HTTP APIs for interacting with the service.

Supports listing, retrieving and savings metrics from the IBM Cloud Monitoring service.

usage

const Monitoring = require('ibm-cloud-monitoring')
const client = new Monitoring({ scope: 's-XXX', api_key: 'API_KEY' })

// retrieve Node.js memory usage stats => { rss, heapTotal, heapUsed, external }                               
const memUsage = process.memoryUsage()

// metrics should use label name
const metricName = metric => `app.metric.${metric}`

// convert to memory usage stats to {key: '...', value: '...'}
const metrics = Object.entries(memUsage).map(
  entry => ({key: metricName(entry[0]), value: entry[1]})
)

await client.save(metrics)

This example saves the current memory usage statistics for a Node.js application to the IBM Cloud Monitoring Service.

installation

npm install ibm-cloud-monitoring

configuration

host

The following regional endpoints are available for the metrics service.

| Region | Hostname | | -------- | -------------------------- | | US-South | metrics.ng.bluemix.net | | UK | metrics.eu-gb.bluemix.net | | Germany | metrics.eu-de.bluemix.net | | Sydney | metrics.au-syd.bluemix.net |

scope

scope must be the GUID for the space being monitored.

Using the Bluemix CLI, the GUID for a space can be retrieved.

$ bx iam space SpaceName --guid
667fadfc-jhtg-1234-9f0e-cf4123451095

Space GUIDs must be prefixed with s- to identify a space in the scope parameter.

Passing this GUID as the scope parameter would therefore use the following value.

s-667fadfc-jhtg-1234-9f0e-cf4123451095

authentication

The monitoring service supports using one of the following authentication tokens.

api

constructor

const Monitoring = require('ibm-cloud-monitoring')

const client = new Monitoring({
  host: 'metrics.ng.bluemix.net'
  scope: 's-<SPACE_GUID>',
  // plus one of the following auth parameters...
  api_key: 'API_KEY' // OR...
  iam_token: 'IAM_TOKEN' // OR...
  uaa_token: 'UAA_TOKEN'
})

The following constructor parameters are supported.

  • host - Host name for the IBM Cloud Monitoring service.
  • scope - Scope identifier must be set to space GUID for monitoring instance.
  • api_key - IBM Cloud API Key
  • iam_token - IBM Cloud IAM token
  • uaa_token - IBM Cloud UAA token

methods

list metrics

client.list()
client.list('metric.name.*')

parameters

The method takes a single string parameter for the metric query path to search. This value defaults to '*'.

returns

Promise with Array of metric labels from JSON response.

retrieve metrics

client.retrieve({
  target: 'metric.name.*'
})

parameters

The method takes a single object parameter with values for the retrieval operation.

This parameter must have a target property, containing metric labels to retrieve. It also supports the from and until properties to select the search time.

returns

Promise with Array of metrics and data points from JSON response.

save metrics

// save single metric value
client.save({ name: 'metric.name.label', value: 0.05 })

// save multiple metric values
client.save([
  { name: 'metric.name.label', value: 0.05 },
  { name: 'metric.name.foo', value: 0.15 },
  { name: 'metric.name.bar', value: 0.25 }
])

parameters

This method takes a single parameter with metric values to save. Metric values must be an object with the name and value properties. An optional timestamp property is also supported on metric values.

Multiple metric values can be saved by passing in an array of metric values.

returns

Promise with no content to indicate when save operation has finished.

bugs / feedback / issues?

Please open issues in the open-source repository on Github if you have problems.