Save logs in S3 bucket

0

I have many lambdas and I want that all logs of them will save in a S3 bucket.

The logs must have a json format and it should conteint some custom fields.

What is the best way to do?

Should I do a program that each lambda send the data? Or Is it possible to send the logs from CloudWatch to the S3 bucket?

1 Answer
1
Accepted Answer

Hello.

Yes, it is possible to export logs from CloudWatch Logs to S3.
If you want to do it manually, you can follow the steps in the document below.
https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/S3ExportTasksConsole.html

If you want to do it automatically, you can set up a subscription filter and KinesisDataFirehose in CloudWatch Logs.
https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/SubscriptionFilters.html

Alternatively, you can automatically send logs to S3 by using the EventBridge Scheduler and executing the API "CreateExportTask".
https://docs.aws.amazon.com/scheduler/latest/UserGuide/what-is-scheduler.html

profile picture
EXPERT
answered 5 months ago
profile picture
EXPERT
reviewed 5 months ago
profile pictureAWS
EXPERT
reviewed 5 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions