@flowio/metrics
TypeScript icon, indicating that this package has built-in type declarations

0.0.5 • Public • Published

@flowio/metrics

Module to send metrics to Hosted Graphite from Flow NodeJS applications. Built in support for automated metrics sent at a defined interval.

Usage

import FlowMetrics from '@flowio/metrics';

const flowMetrics = new FlowMetrics({
  serverHost: 'carbon.hostedgraphite.com',      // host of graphite server
  serverPort: 2003,                             // port of graphite server
  hgApiKey: 'super-secret-key',                 // hosted graphite api-key
  environment: 'production',                    // environment (production | development | test)
  appName: 'app-name',                          // application name
  disableAuto: true,                            // disable autmoatic system metrics (optional)
  collectionInterval: 10000,                    // interval for automatic metrics in ms (optional, default 10000)
});

If you do not pass disableAuto: true the module will automatically send metrics after a delay of collectionInterval milliseconds (default: 10000);

All metrics are expanded into the graphite standard of dot delimited metric names, including the Hosted Graphite API key, for example:

hg-api-key.environment.application-name.hostname.os.memory

default auto metrics are:

{
  os: {
    memory: {
      total: 12340000,
      free: 10240000
    },
    cpu: {
      cpu: 40;
      user: 20;
      nice: 0;
      sys: 20;
      idle: 60;
      irq: 0
    }
    disk: {
      available: 30000000;
      free: 25000000;
      total: 40000000;
    }
  }
}

Custom metrics can be sent using:

flowMetrics.sendMetrics({
  metrics: { ... },
  timestamp: Date.now(),    // optional
  callback: () => {}      // callback method
})

Dependents (0)

Package Sidebar

Install

npm i @flowio/metrics

Weekly Downloads

2

Version

0.0.5

License

UNLICENSED

Unpacked Size

18.4 kB

Total Files

6

Last publish

Collaborators

  • martapralat
  • sid.jain
  • gdxn96
  • flowtech
  • roryh
  • cbosatflow
  • garethgd