A DynamoDB transport for winston.
var winston = require('winston');
require('winston-dynamodb').DynamoDB;
winston.add(winston.transports.DynamoDB, options);
accessKeyId : your AWS access key id
secretAccessKey : your AWS secret access key
region : the region where the domain is hosted
useEnvironment : use process.env values for AWS access, secret, & region
tableName : DynamoDB table name
dynamoDoc : if this is set to true, the *meta* parameter will be stored as a subobject using DynamoDB's DocumentClient rather than as a JSON string.
Make a table with tableName
The table schema depends on how you intend to use it.
The table should have
- hash key: (String) level
- range key: (String) timestamp
Note: Timestamp has a millisecond resolution. So whether this key setup will work depends on how many log messages you expect.
That is, the uniqueness of level + timestamp means max: 1 log message of a given level per millisecond.
It is nice to have it as a range key for queries.
To ensure you can log as many messages as you like, alternatively use:
- hash key: (String) id (Will be a uuid)
- range key: (String) timestamp
Using the id as hash ensures that all log items will have unique keys and be included.
Available Regions
- us-east-1
- us-west-1
- us-west-2
- eu-west-1
- ap-northeast-1
- ap-southeast-1
- ap-southeast-2
- sa-east-1
All of these options are values that you can find from your Amazon Web Services account: 'accessKeyId', 'secretAccessKey' and 'awsAccountId'.
Alternatively, pass in useEnvironment: true and the process.env values will be used.
(Functions in AWS Lambda environment and works with default AWS Credentials Global Configuration .config in other node environments.)
$ npm install winston
$ npm install winston-dynamodb