npm.io
0.2.3 • Published 6 years ago

bunyan-aws

Licence
MIT
Version
0.2.3
Deps
1
Size
9 kB
Vulns
0
Weekly
0

bunyan-aws

Write buynan logs to Amazon Web Services CloudWatch.

Install

npm install bunyan-aws --save

Usage

var bunyan = require('bunyan');
var os = require('os');
var CloudWatchStream = require('bunyan-aws');
var myStream = new CloudWatchStream({
           logGroupName: 'MyApplicationLogs',
           logStreamName: 'MyStream-' + os.hostname(),
           cloudWatchOptions: {
               region: 'eu-central-1',
               sslEnabled: true
           }
       });
       
var log = bunyan.createLogger({
    name: 'logger',
    streams: [{
        stream: myStream,
        type: 'raw',
        level: 'info',
    }]
}; 
      
myStream.on('error', function (err) {
    console.error('Error in Cloud Watch stream', err);
});       

Configuration

AWS Credentials

This package uses the AWS SDK to write the logs to CloudWatch. You must set the AWS Credentials via one of the first three methods described here.

Log Group

The log group must exist in CloudWatch.

  1. Sign into the AWS console
  2. Click on CloudWatch found under Services > Management
  3. Click on Logs
  4. Select Actions > Create log group
Log Stream

You may use an existing log stream. However if the stream is not found, it will be created for you. The package assumes it is the only source writing to the stream. Errors will occur if other sources write to the same stream.

CloudWatch Options

These options are passed directly to the AWS SDK

Credits

This project was created by Aaron Schinkowitch (@schinkowitch), and is based on the work of Mirko Kiefer's bunyan-cloudwatch and Maurice Butler's bunyan-loggly. Hao Nguyen has made several fixes and improvements.

Keywords