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

cloud-functions-metrics-service

v0.2.0

Published

Node.js library to save serverless metrics from openwhisk to IBM Cloud Monitoring Service

Downloads

4

Readme

cloud-functions-metrics-service

This project uses IBM Cloud Monitoring to save metrics from IBM Cloud Functions.

Metrics collected by the openwhisk-metrics library are forwarded into the external monitoring service.

usage

Metrics can be forwarded into IBM Cloud Monitoring in real-time or sent in batches using a background process.

  • Real-time ingestion ensures metrics appear immediately in the monitoring service. Metrics forwarded using the batch ingestion won't be available until the next background task execution.
  • Batch ingestion does not add any delay to action invocations. Real-time ingestion saves invocation metrics each time the action handler is called. This adds a (small) delay to each invocation, where the library calls the external metrics service.

real-time ingestion

  • Install OpenWhisk metrics and IBM Cloud Monitoring service libraries

    $ npm install openwhisk-metrics cloud-functions-metrics-service
  • Wrap action handlers using external libraries

    const metrics = require('openwhisk-metrics')
    const service = require('cloud-functions-metrics-service')
    
    metrics.service = service.client({  
      host: 'metrics.ng.bluemix.net',
      scope: '...',
      api_key: '...'
    })
    
    const main = params => {
      return { message: "Hello World" }
    }
    
    exports.main = metrics(main)

Configuration options for the openwhisk-metrics library are available in the project repository.

Configuration options for the IBM Cloud Monitoring service are available in the project repository.

Metrics forwarded using external real-time ingestion will not be logged to the console. If you want to enable this for debugging or testing, use this code snippet.

const client = service.client({  
  host: 'metrics.ng.bluemix.net',
  scope: '...',
  api_key: '...'
})

const log = metrics.service

metrics.service = values => {
  log.save(values)
  return client.save(values)
}

batch ingestion

set up metric collectors

  • Set up action handlers with openwhisk-metrics

    const metrics = require('openwhisk-metrics')
    
    const main = params => {
      return { message: "Hello World" }
    }
    
    module.exports.main = metrics(main) 

All actions you want to collect metrics for should use the library as above. Use the action names in the configuration below for the background task.

create metric forwarder action

  • Download project repository

    $ git clone https://github.com/jthomas/cloud-functions-metrics-service
    $ cd cloud-functions-metrics-service
  • Create action deployment package.

    $ npm install
    $ zip -r action.zip index.js package.json lib node_modules
  • Fill in authentication parameters in action configuration file (config.json).

    {
      "actions": ["action_names_to_monitor"],
      "service": {
        "host": "metrics.ng.bluemix.net",
        "scope": "...",
        "api_key": "..."          
      }
    }

    Configuration options for the IBM Cloud Monitoring service are available in the project repository.

  • Create new OpenWhisk action from deployment package and configuration file.

    $ wsk action create metric-forwarder --kind nodejs:8 action.zip --param-file config.json
  • Create trigger feed for alarm package to run metric-forwarder on periodic schedule.

    $ wsk trigger create interval \
      --feed /whisk.system/alarms/interval \
      --param minutes 10 \
  • Bind trigger to action using rule.

    $ wsk rule create forward-metrics-on-interval interval metric-forwarder