bunyan-dynamodb

A DynamoDB Stream for Bunyan

Usage no npm install needed!

<script type="module">
  import bunyanDynamodb from 'https://cdn.skypack.dev/bunyan-dynamodb';
</script>

README

Bunyan DynamoDB Build Status

A Bunyan Stream for logging to a DynamoDB table.

Installation

npm install --save bunyan-dynamodb

Usage

var BunyanDynamoDb = require('bunyan-dynamodb');

var dynamoStream = new BunyanDynamoDb({
  accessKeyId: 'AWS_ACCESS_KEY_ID',          // required
  secretAccessKey: 'AWS_SECRET_ACCESS_KEY',  // required
  region: 'us-east-1',                       // required
  tableName: 'event_log',                    // name of table. defaults to event_log
  
  batchSize: 25                              // number of records to queue up before 
                                             //  sending. defaults to maximum, 25.

  hashKeyField: 'hostname'  // the property from the Bunyan log event to use as the 
                            // table's hash key. any top-level attribute may be 
                            // used. defaults to 'hostname'.  the value of 
                            // the hashkey field is always converted to a string.

  readCapacityUnits: 1,     // required: read and write capacity to provision table   
  writeCapacityUnits: 2,    // with. if table already exists will have no effect.
}); 


var logger = new bunyan.createLogger({ 
  name: 'app',
  streams: [{
    level: 'trace',
    type: 'raw',
    stream: dynamoStream,
  }],
});

Table Schema

The logger will create a DynamoDB table with the following fields:

Name Type Description
hostname String The default hash key field. Value of the event's hostname field.
timestamp Numeric The table's range key. A number based on the time field of the log event with a number and hostname appended to ensure uniqueness. ex: 20150714151724593.44001647.localhost
level Numeric Value of the event's level field.
message String Value of the msg field.
event String JSON stringified representation of the entire log event.