I have about a dozen functions in a project and I’ve now added a function log-shipper which I want the other functions cloudwatch logs to be sent to. I can achieve this simply in the AWS UI by choosing the action “stream to AWS Lambda” for each function but this seems way to manual and error prone and would like to get this configuration into my
I see in the docs that there is a
cloudwatchLog event you can associate to a function but I’m struggling on how I might configure it such that all functions — other than the
log-shipper — are configured to stream to the
cloudwatchLog event source monitors log groups and then streams them to your Lambda function. So in your case, you’d want to configure your
log-shipper function with a
cloudwatchLog event for each function you want to stream to
handler: # your handler
events: # The Events that trigger this Function
This will create subscriptions to those log groups and send them all to
log-shipper. Note that you are limited to ONE subscription per log group, so this would be the only function that will monitor them.
Many thanks! Will give a try post-coffee.
If you are using the Serverless Enterprise Framework which already creates a log group subscription, how would be the best way to ingest all Lambda logs to ELK? In the past i was using the serverless-es-logs plugin, until we moved to Serverless, SLS gives us monitoring in return but not raw logs to consult. As they retrieve the logs using a IAM Role and not a lambda y can’t reuse the lambda to send logs to SLS and ELK. So how can you deal with this problem?