richardzyx / good-hapi-graylog2

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

good-hapi-graylog2

Good Reporter For Graylog2

Hapi: http://hapijs.com/

Good: https://github.com/hapijs/good

Graylog2: https://www.graylog.org/

Usage:

npm install good-hapi-graylog2

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

const server = new Hapi.Server();
server.connection({ port: <your_port> });

const goodOptions = {
  includes: {
    request: ['headers'],
    response: ['payload'],
  },
  reporters: {
    logstash: [{
      module: 'good-squeeze',
      name: 'Squeeze',
      args: [{ response: '*', request: '*' }],
    }, {
      module: 'good-hapi-graylog2',
      args: [{
        host: '<graylog server ip>',
        port: '<graylog server port>',
        facility: '<your service name>',
        hostname: '<your host>',
        bufferSize: '<your buffer size>' // optional, default 1400
      }],
    }],
  },
};
try {
  server.register([{
      register: good,
      options: goodOptions,
    }], async () => {

    const start = await server.start();
    if (start instanceof Error) throw new Error('Ошибка запуска сервера');

    pino.info('Server running at:', server.info.uri);
  });
} catch((error) => {
  pino.error(error.message)
})

Graylog Setup:

This module requires a GELF_UDP input to be configured on your graylog server.

About

License:MIT License


Languages

Language:JavaScript 100.0%