@flowio/metrics
v0.0.5
Published
Flow Library for sending app metrics to Hosted Graphite
Downloads
2
Readme
@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
})