-
Notifications
You must be signed in to change notification settings - Fork 2
/
fluentproxy.js
51 lines (43 loc) · 1.36 KB
/
fluentproxy.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//
// fluentproxy.js -- A Syslog-to-fluentd proxy.
// This implements a "push" model, rather than the existing "pull" model available with fluentd.
//
// John D. Allen
// A10 Networks
// jallen@a10networks.com
// July, 2020
//
// Copyright (C) 2020 by A10 Networks, All Rights Reserved
// Usage granted as provided in the MIT License.
//
// Uses:
// https://github.com/guithess/syslog-server
// https://www.npmjs.com/package/fluent-logger
//
var logger = require('fluent-logger');
var SyslogServer = require('syslog-server');
var server = new SyslogServer();
var config = require('./config.json');
var DEBUG = config.debug;
var fluentip = config.fluent_ip || '0.0.0.0';
var fluentport = config.fluent_port || 24224;
var fltimeout = config.timeout || 3.0;
var flreconnect = config.reconnect || 60000;
var port = config.port || 514;
var label = config.label || "a10";
if (DEBUG > 7) { console.log(">>>>" + fluentip); }
logger.configure('debug', {
host: fluentip,
port: fluentport,
timeout: fltimeout,
reconnectInterval: flreconnect
});
if (DEBUG > 3 || config.showstart) {
logger.emit(label, {message: "a10-fluent proxy started..."});
if (DEBUG > 7) { console.log("a10-fluent proxy starting..."); }
}
server.on("message", (msg) => {
if (DEBUG > 7) { console.log(">>" + JSON.stringify(msg)); }
logger.emit(label, msg);
});
server.start({port: port});