qixotic / s3-to-logstore Goto Github PK
View Code? Open in Web Editor NEWAWS lambda function for parsing CloudFront / S3 / Cloudtrail logs and pushing events into Papertrail or other Winston transport of choice.
License: MIT License
AWS lambda function for parsing CloudFront / S3 / Cloudtrail logs and pushing events into Papertrail or other Winston transport of choice.
License: MIT License
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.)
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)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.