CloudWatch logs custom format

0

Is it feasible to export CloudWatch logs to an s3 bucket in a certain format? To be specific, I want the logs to be .csv files in a GZIP format without a header.

asked 7 months ago444 views
2 Answers
0

Hi,

You have a detailled walk-through of the entire process to export from logs from CloudWatch to S3 at https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/S3ExportTasksConsole.html

This page will also provide you with some advanced options:

  • export those logs in an encrypted form
  • export the logs in a S3 bucket located in another account

You can than zip those logs via AWS CloudShell to avoid the setup of any compute resource (ECS/Fargeate), EC2) : zip is part of pre-installed utilities in CloudShell. See https://docs.aws.amazon.com/cloudshell/latest/userguide/multiple-files-upload-download.html.

With the zip/unzip utilities, you can compress multiple files in an archive that can be 
treated as a single file. The utilities are pre-installed in the CloudShell compute environment.

Alternatively, you may want to give a try to AWS CloudWatch Log Insights to directly analyze your logs in place (i.e. in CloudWatch) and finally extract the minimum number of most interesting records. This video will show you how: https://www.youtube.com/watch?v=2s2xcwm8QrM

Best,

Didier

profile pictureAWS
EXPERT
answered 7 months ago
  • Hi Didier, As far as I can understand, this implementation is straightforward and valid when we just need to export logs once. However, using this approach, I cannot move CloudWatch logs to S3 in an automatic way. By leveraging a Lambda function and event bridge trigger I think that the process of exporting a CloudWatch log group to an S3 bucket could be easily automated. What do you think? Is there any existing implementation (cloudformation template) for this purpose?

0

is there any option we can moved cloudwatch logs in to s3 and then we can read these logs same way as we query in cloudwatch insight ?

profile picture
answered 2 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