winston-cloudwatch icon indicating copy to clipboard operation
winston-cloudwatch copied to clipboard

AWS Lambda only executing first CloudWatch transport

Open bounteous17 opened this issue 5 years ago • 3 comments

Hello, I am adding two winston-cloudwatch transports to my logger. Each logger transport have a different group pool name configured. When I am executing the application on my machine, the message is being logged on both CloudWatch pools located on AWS.

The issue comes when I try the same code inside a Lambda function deployed on AWS. Then the message is only being logged on one pool stream, which it's always the the pool configured on the first Winston Transport. But the log is never written on the second CloudWatch pool.

I am following this example: https://github.com/lazywithclass/winston-cloudwatch/blob/master/examples/multiple-loggers.js

bounteous17 avatar Feb 13 '20 13:02 bounteous17

@bounteous hello and sorry for the delay.

Is this still an issue? If so, I'd need the steps to reproduce this, please confirm this would be a correct approach:

  • create two loggers, A and B, using the code in https://github.com/lazywithclass/winston-cloudwatch/blob/master/examples/multiple-loggers.js
  • host the code on an AWS Lambda
  • confirm that logs are always sent to A, never to B

Thank you

lazywithclass avatar Apr 05 '20 23:04 lazywithclass

Hello @lazywithclass , Yes, I build on that example. The problem is the intervals with which this module works. Lambdas are unable to identify that there are still jobs running in the background and the lambda is killed before writing to group B in cloudwatch.

The only solution I have found has been to use subscribers with a global variable.

Sorry I can not host the code, I don't own a personal AWS account.

bounteous17 avatar Apr 16 '20 18:04 bounteous17

Ok I see.

Thanks for your reply; yes, setInterval has been a problem since the day after I coded this 5 years ago :D This issue will have to wait for #90 to be completed, which I'm working on right now, but it will take some time. The good news is that I might be able to also get rid of setInterval. Without setInterval I imagine this issue would be solved.

lazywithclass avatar Apr 20 '20 16:04 lazywithclass