nogger-node-adapter
v0.5.3
Published
nogger - the node.js logger - node apdapter
Downloads
25
Maintainers
Readme
nogger - node.js logger and monitor
This is an adapter for node.js to use nogger. It allows to export logs and metrics about the server like cpu and memory consumption. More on nogger at the main repository: https://github.com/paul-em/nogger
Getting started
Install the module with: npm install nogger-node-adapter --save
In your project you simply include and initialize it by passing the config.
var nogger = require('nogger-node-adapter').init(config);
For the options in the config see the config part.
Custom Metrics
To use custom metrics you simply access objects from
var metrics = nogger.metrics;
Static
The static metrics allows you to log a text or numbers you don't want to visualize in any chart.
Here is an example:
var staticMetric = new nogger.metrics.Static(function(){
return {
"TestStatic" : "This is a text that will appear on the page"
}
});
This will look like this on the dashboard:
Arguments:
- val - the value to log. This can be a function that returns the value.
- interval - interval in ms how often the value should be updated
Options:
staticMetric.getData() // returns the Data
staticMetric.update() // triggers an update
Counter
Counter for incrementing and decrementing numbers and showing this in a graph.
Here is an example:
var counter = new nogger.metrics.Counter('TestCounter');
counter.inc();
counter.dec();
This will look like this on the dashboard:
Arguments:
- name - the name that should appear as headline
- interval - interval in ms how often the value should be updated in the database
Options:
counter.inc() // increments the value
counter.dec() // decrements the value
counter.getData() // returns the Data
counter.update() // triggers an update
Meter
Meter for only upwards counting objects and visualising this in a graph.
Here is an example:
var meter = new nogger.metrics.Meter('TestMeter');
meter.mark();
This will look like this on the dashboard:
Arguments:
- name - the name that should appear as headline
- interval - interval in ms how often the value should be updated in the database
Options:
meter.mark() // increments the value
meter.getData() // returns the Data
meter.update() // triggers an update
Histogram
Histogram allows to use different values each time. It is also allowed to combine different data model in one histogram.
Here is an example:
var histogram = new nogger.metrics.Histogram('TestHistogram2', ['alphaVal', 'betaVal'], function(){
return [
alphaVal,
betaVal
];
});
This will look like this on the dashboard:
Arguments:
- name - the name that should appear as headline
- labels - the label(s) of the value(s)
- val - can be a value or a function that returns one or multiple values in form of an array
- interval - interval in ms how often the value should be updated in the database
Options:
histogram.getData() // returns the Data
histogram.update() // triggers an update
Timer
This class allows you to measure time in nanoseconds. The mean, max and min value in interval is stored.
Here is an example:
var timer = new nogger.metrics.Timer('TestTimer');
timer.start();
timer.end();
This will look like this on the dashboard:
Arguments:
- name - the name that should appear as headline
- interval - interval in ms how often the value should be updated in the database
Options:
timer.start() // starts the timer
timer.end() // stops the timer
timer.getData() // returns the Data
timer.update() // triggers an update
timer.runnning // is true or false
Config
These are the default config options that can be overwritter
rotate: 'daily', // how often a new logFile should be generated
timezoneOffset: -60, // offset to your local timezone
maxLogLength: 250, // length of the string after it should be replaced with '...'
redisIP: '127.0.0.1', // ip of Redis database - preferably on your server
redisPort: 6379, // port of Redis database - 6379 is the default port for Redis
redisMetricsDb: 0, // Redis database where all metrics are saved
redisLogsDb: 1 // Redis database where all logs are saved
License
Copyright (c) 2014 Paul Em. Licensed under the MIT license.