elk-kinesis-logger
v0.1.0
Published
Logging to a Kinesis stream for consumption into an ELK cluster
Downloads
3
Readme
ELK Kinesis Logger
Send logs to an ELK stack via an AWS Kinesis stream.
The ELK stack should be using the Kinesis Input Plugin.
Uses STSAssumeRole
to authenticate to Kinesis.
Why
The main use case is for AWS Lambdas. When you console.log
within a Lambda, they go into CloudWatch Logs.
Whilst CloudWatch Logs is good, an ELK stack is better!
Using this module, we can easily get logs into an ELK stack.
Installation
npm install elk-kinesis-logger
Usage
Import the module:
const ELKKinesisLogger = require('elk-kinesis-logger');
Create a new logger:
const logger = new ELKKinesisLogger({
stage: 'PROD',
stack: 'my-stack',
app: 'my-app',
roleArn: 'arn:aws:iam::000000000000:role/my-role',
streamName: 'my-stream'
});
Open the logger:
logger.open().then(() => {
});
Write a log message:
logger.log('something happened');
Ensure all logs have written by closing the logger:
logger.close().then(() => {
});
Complete example
const ELKKinesisLogger = require('elk-kinesis-logger');
const logger = new ELKKinesisLogger({
stage: 'PROD',
stack: 'my-stack',
app: 'my-app',
roleArn: 'arn:aws:iam::000000000000:role/my-role',
streamName: 'my-stream'
});
logger.open().then(() => {
const value = 5 * 5;
logger.log(`the value is ${value}`);
return logger.close();
}).then((writtenLogs) => {
// other work
});
Further examples
See the examples.
Contributing
- clone the repo
- update the code
- write a test
npm test
- commit
Publishing
npm publish