Logstash stream via AMQP for the Bunyan logger
An AMQP logger for Logstash
$ npm install bunyan-logstash-amqp
"use strict";
var bunyan = require('bunyan');
var amqp_stream = require('bunyan-logstash-amqp').createStream({
vhost: "logging",
exchange: {
routingKey: 'logs'
}})
.on('connect', function() { console.log("Connected to amqp"); })
.on('close', function() { console.log("Closed connection to amqp"); })
.on('error', console.log );
var log = bunyan.createLogger({
name: 'example',
streams: [{
level: 'debug',
stream: process.stdout
},{
level: 'debug',
type: "raw",
stream: amqp_stream
}],
level: 'debug'
});
A raw bunyan stream can be created using the module createStream(options)
method.
The options
object accepts the following fields:
Parameter | Type | Default | Description |
---|---|---|---|
host | string | localhost |
AMQP host |
port | number | 5672 |
AMQP port |
vhost | string | / |
AMQP virtual host |
login | string | guest |
AMQP username |
password | string | guest |
AMQP password |
sslEnable | boolean | false |
Enable AMQP SSL |
sslKey | string | '' |
AMQP SSL private key file path |
sslCert | string | '' |
AMQP SSL certificate file path |
sslCA | string | '' |
AMQP SSL CA file path |
sslRejectUnauthorized | boolean | true |
Verify AMQP SSL certificate against CA |
exchange | object | undefined |
AMQP exchange options |
level | string | info |
Logstash message level |
server | string | os.hostname() |
Logstash message source server |
application | string | process.title |
Logstash message source application |
pid | string | process.pid |
Logstash message pid |
tags | string array | ["bunyan"] |
Logstash message tags |
type | string | undefined |
Logstash message type |
bufferSize | number | 100 |
Outstanding message buffer size |
messageFormatter | function | undefined |
Optional message formatting function |
The exchange object accepts the following fields:
Parameter | Type | Default | Description |
---|---|---|---|
name | string | undefined |
AMQP exchange name |
routingKey | string | message.level |
AMQP message routing key |
properties | object | {} |
AMQP exchange options |
The stream will emit open
, close
and error
events from the underlying AMQP connection.
This module is heavily based on bunyan-logstash-tcp.
The MIT License (MIT)
Copyright (c) 2015 Brandon Hamilton
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.