简体   繁体   中英

Is there an acceptable way to log to multiple log groups from a single AWS Lambda Function?

We use lambda for the backend of our mobile application and we recently started using Cloudwatch Log Insights. It would be great to be able to make individual streams such as Info, Error, and Transactions that would allow us to more cost effectively query certain data instead of having to pay to parse all the data for every query. Is there a built in or otherwise acceptable way to do manage what stream a message goes to?

I know you want to create multiple log groups, but this does not seem possible by default.

However, considering your use case, it is always possible to custom build your solution. For example, configure multiple CloudWatch Logs Groups and use the API to manually publish log entries.

https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/Working-with-log-groups-and-streams.html .

Alternatively, you can also configure a downstream process that subscribes to the main log group, and performs the splitting.

You can also take a look at Lambda Extensions, especially if you want to forward the logs to one of the supported partners.

https://aws.amazon.com/blogs/compute/using-aws-lambda-extensions-to-send-logs-to-custom-destinations/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM