Skip to content

jessie-codes/good-gelf

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
lib
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

good-gelf

NPM

Known Vulnerabilities JavaScript Style Guide Build Status Coverage Status

Good Reporter for Graylog.

This module is for transforming good logs into gelf format for Graylog. This module is intended to be used with other good modules, such as good-file for saving the output for scenarios in which UDP will not work.

If you're looking for a UDP version, try good-graylog2.

Options

  • format String : The format the timestamp should be saved with. If not passed, it will default to POSIX time.
  • info Object : An object containing parameters that should be added to each log entry.

Usage

'use strict';

const Hapi = require('hapi');
const good = require('good');

const server = new Hapi.Server();
server.connection();

const options = {
    reporters: {
        gelf: [{
            module: 'good-squeeze',
            name: 'Squeeze',
            args: [{ log: '*', response: '*' }]
        }, {
            module: 'good-gelf',
			args: ['YYYY-MM-DD', {app: 'Dashboard'}]
        }, {
            module: 'good-file',
            args: ['./server.log']
        }]
    }
};

server.register({
    register: good,
    options
}, err => {
    if (err) return console.error(err);

    server.start(() => {
        console.info(`Server started at ${ server.info.uri }`);
    });
});

Output

{"_event":"request","timestamp":"2017-08-10 16:42:24.957","_tags_0":"user","_tags_1":"info","_data":"you made a default log","_pid":64291,"version":"1.1","host":"hostname","message":"Log event for tags: [\"user\",\"info\"]","short_message":"Log event for tags: [\"user\",\"info\"]"}