3.0.0 • Published 2 years ago
good-hapi-graylog2 v3.0.0
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
        adapter: '<protocol udp or tcp>' // optional, default udp
      }],
    }],
  },
};
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.