Skip to content
This repository has been archived by the owner on Sep 19, 2024. It is now read-only.

jessie-codes/good-gelf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

89 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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\"]"}