Giter Site home page Giter Site logo

qixotic / s3-to-logstore Goto Github PK

View Code? Open in Web Editor NEW
10.0 1.0 3.0 17 KB

AWS lambda function for parsing CloudFront / S3 / Cloudtrail logs and pushing events into Papertrail or other Winston transport of choice.

License: MIT License

JavaScript 100.00%

s3-to-logstore's People

Contributors

qixotic avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

s3-to-logstore's Issues

Papertrail example fails with Lambda container reuse

Lately we've been noticing that the papertrail.js example doesn't seem to execute reliably, particularly when AWS Lambda reuses the running Node instance/container. If we test it manually, we'll generally see it work once, and then any tests after that fail, precisely because it's reusing the same environment.

The problem is that all of the initialization code (lines 10-32 in the example) is only executed the first time. All attempts after that fail, because they're trying to send data down a transport that's already closed. Here's the easiest fix:

Insert a line 13, just after the require statements:

exports.handler = function(event, context, callback) {

Change the last line (line 33) to this:

(s3ToLogstore(options))(event, context, callback); }

Even after doing this, there can still be a handful of dropped messages, but adding flushOnClose: true to the transport parameters seems to eliminate that.

It's not clear why we've only noticed this recently. Is this an appropriate fix, or is there a better answer? (It would seem more efficient to keep the connection open, but I haven't found a way to do that.)

Can't use in conjunction with winston-sns

I'm trying to parse Cloudfront logs and send it to aws sns using winston-sns, but I'm receiving lambda errors that get me stuck. Any ideas?

`var s3ToLogstore = require('s3-to-logstore');
var winston = require('winston');
require('winston-sns').SNS;

var format = 'cloudfront';
var transport = new winston.transports.SNS({
subscriber: 'subscriberid',
topic_arn: 'arnid,
subject: 'Print Report',
level:'error',
handleExceptions: true
});
var options = {
format: format,
transport: transport,
callback: function(error, lambdaCallback) {
transport.close();
lambdaCallback(error);
}
};
export.handler = s3ToLogstore(options);`

I'm getting this generic error through lambda:

Syntax error in module 'printprocess': SyntaxError at Module.load (module.js:343:32) at Function.Module._load (module.js:300:12) at Module.require (module.js:353:17) at require (internal/module.js:12:17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.