项目作者: jessie-codes

项目描述 :
Gelf transformation for good logs.
高级语言: JavaScript
项目地址: git://github.com/jessie-codes/good-gelf.git
创建时间: 2017-06-13T16:06:25Z
项目社区:https://github.com/jessie-codes/good-gelf

开源协议:MIT License

下载


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

  1. 'use strict';
  2. const Hapi = require('hapi');
  3. const good = require('good');
  4. const server = new Hapi.Server();
  5. server.connection();
  6. const options = {
  7. reporters: {
  8. gelf: [{
  9. module: 'good-squeeze',
  10. name: 'Squeeze',
  11. args: [{ log: '*', response: '*' }]
  12. }, {
  13. module: 'good-gelf',
  14. args: ['YYYY-MM-DD', {app: 'Dashboard'}]
  15. }, {
  16. module: 'good-file',
  17. args: ['./server.log']
  18. }]
  19. }
  20. };
  21. server.register({
  22. register: good,
  23. options
  24. }, err => {
  25. if (err) return console.error(err);
  26. server.start(() => {
  27. console.info(`Server started at ${ server.info.uri }`);
  28. });
  29. });

Output

  1. {"_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\"]"}