Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@guardian/elk-kinesis-logger

Package Overview
Dependencies
Maintainers
16
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@guardian/elk-kinesis-logger

Logging to a Kinesis stream for consumption into an ELK cluster

  • 0.2.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
16
Created
Source

CircleCI NPM

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 @guardian/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',
  streamName: 'my-stream'
});

If the stream's access is restricted, you can specify a role arn to assume:

const logger = new ELKKinesisLogger({
  stage: 'PROD',
  stack: 'my-stack',
  app: 'my-app',
  streamName: 'my-stream'
}).withRole('arn:aws:iam::000000000000:role/my-role');

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',
  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

FAQs

Package last updated on 22 Mar 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc