All Projects → CloudSnorkel → CloudWatch2S3

CloudSnorkel / CloudWatch2S3

Licence: MIT License
Logging infrastructure for exporting all CloudWatch logs from multiple accounts to a single S3 bucket

Projects that are alternatives of or similar to CloudWatch2S3

Awesome Aws
A curated list of awesome Amazon Web Services (AWS) libraries, open source repos, guides, blogs, and other resources. Featuring the Fiery Meter of AWSome.
Stars: ✭ 9,895 (+31819.35%)
Mutual labels:  lambda, cloudformation, kinesis
Lambstatus
[Maintenance mode] Serverless Status Page System
Stars: ✭ 1,323 (+4167.74%)
Mutual labels:  lambda, cloudformation
Aws Iot Certificate Vending Machine
The CVM allows a device to apply for its own certificate and installation.
Stars: ✭ 64 (+106.45%)
Mutual labels:  lambda, cloudformation
Hands-On-Serverless-Applications-with-Go
Hands-On Serverless Applications with Go, published by Packt.
Stars: ✭ 92 (+196.77%)
Mutual labels:  lambda, cloudformation
Aws Toolkit Vscode
AWS Toolkit for Visual Studio Code, an extension for working with AWS services including AWS Lambda.
Stars: ✭ 823 (+2554.84%)
Mutual labels:  lambda, cloudformation
Serverless Application
🍤 ALIS Media - Serverless Application
Stars: ✭ 52 (+67.74%)
Mutual labels:  lambda, cloudformation
go-localstack
Go Wrapper for using localstack
Stars: ✭ 56 (+80.65%)
Mutual labels:  lambda, cloudformation
Auto Tag
Automatically tag AWS resources on creation, for cost assignment
Stars: ✭ 322 (+938.71%)
Mutual labels:  lambda, cloudformation
aws-cloudformation-cognito-identity-pool
A Lambda-backed Custom Resource for a Cognito Identity Pool in CloudFormation
Stars: ✭ 35 (+12.9%)
Mutual labels:  lambda, cloudformation
aws-maven-plugin
Deploys resources to AWS using maven
Stars: ✭ 25 (-19.35%)
Mutual labels:  lambda, cloudformation
cim
CIM takes the pain out of Infrastructure as Code and CloudFormation
Stars: ✭ 51 (+64.52%)
Mutual labels:  lambda, cloudformation
Serverless Domain Manager
Serverless plugin for managing custom domains with API Gateways.
Stars: ✭ 783 (+2425.81%)
Mutual labels:  lambda, cloudformation
Dawson Cli
A serverless web framework for Node.js on AWS (CloudFormation, CloudFront, API Gateway, Lambda)
Stars: ✭ 721 (+2225.81%)
Mutual labels:  lambda, cloudformation
Cloudformation templates
AWS - CloudFormation Templates
Stars: ✭ 505 (+1529.03%)
Mutual labels:  lambda, cloudformation
SecretsManagerwithCloudFormation
Implements a Lambda-backed CloudFormation Custom Resource for AWS Secrets Manager
Stars: ✭ 20 (-35.48%)
Mutual labels:  lambda, cloudformation
Streamalert
StreamAlert is a serverless, realtime data analysis framework which empowers you to ingest, analyze, and alert on data from any environment, using datasources and alerting logic you define.
Stars: ✭ 2,634 (+8396.77%)
Mutual labels:  lambda, kinesis
cfn-encrypt
🔑🔐☁️ Cloudformation custom resource that enables creation of KMS encrypted strings and SSM secure parameters
Stars: ✭ 13 (-58.06%)
Mutual labels:  lambda, cloudformation
lambda-smush-py
Gain additional code space via cheeky compression for Python AWS Lambda functions defined in-line to CloudFormation templates.
Stars: ✭ 17 (-45.16%)
Mutual labels:  lambda, cloudformation
aws-node-custom-user-pool
Serverless AWS Cognito Custom User Pool Example
Stars: ✭ 15 (-51.61%)
Mutual labels:  lambda, cloudformation
terraform-aws-lambda
A Terraform module to create AWS Lambda ressources.
Stars: ✭ 40 (+29.03%)
Mutual labels:  lambda, kinesis

AWS CloudWatch to S3

Logging infrastructure for exporting all CloudWatch logs from multiple accounts to a single S3 bucket.

Available on AWS Serverless Application Repository for easy deployment:

Overview

Architecture diagram

This project supplies a CloudFormation template that setups Kinesis stream that takes log records from CloudWatch and writes them to a specific S3 bucket as they are arrive. Log records can be retrieved from multiple AWS accounts using the second CloudFormation template.

Log records are batched together across log groups and partitioned into folders based on time of ingestion. Log format can be configured to either be raw log lines or compressed CloudWatch JSON. The raw log format is:

LOG_GROUP:LOG_STREAM\tTIMESTAMP\tRAW_LOG_LINE

For example:

/aws/lambda/SomeLambdaFunction:2019/02/05/[$LATEST]b346f603d7bb4b6aa77b53bc4050bc37 1549428326  INFO hello world

Subscription of CloudWatch log groups is done in two ways. If CloudTrail is enabled, every new log group will immediacy be subscribed. In addition, every hour a subscription Lambda is executed to look for new log groups and subscribe them. Finally, the same subscription Lambda is executed during deployment of the CloudFormation stack so all log groups matching the configured prefix will be subscribed immediately on deployment.

If CloudTrail is not enabled, it may take up to an hour for new log groups to be subscribed. This time can be configured in the CloudFormation stack using the SubscribeSchedule parameter. In CloudFormation UI it may be named Look for New Logs Schedule.

Deploy

If you have just one AWS account, simply deploy CloudWatch2S3.template in CloudFormation.

If you have multiple AWS accounts, choose a central account where all logs will be stored in S3 and deploy CloudWatch2S3.template in CloudFormation. Once done, go to the outputs tab and copy the value of LogDestination. Then go to the other accounts and deploy CloudWatch2S3-additional-account.template in CloudFormation. You will need to supply the value you copied as the LogDestination parameter.

Parameters

There are a lot of parameters to play with, but the defaults should be good enough for most. If you have a lot of log records coming in (more than 1000/s or 1MB/s), you might want to increase Kinesis shard count.

Known Limitations

Cross region export is not supported by CloudWatch Logs. If you need to gather logs from multiple regions, create the CloudFormation stack in each required region. You can use CloudFormation Stack Sets to deploy to all regions at once.

Single CloudWatch records can't be over 6MB when using anything else but raw log format. Kinesis uses Lambda to convert data and Lambda output is limited to 6MB. Note that data comes in compressed from CloudWatch but has to come out decompressed from Lambda. So the decompressed record can't be over 6MB. You will see record failures in CloudWatch metrics for the Kinesis stream for this and errors in the log for the processor Lambda function.

Troubleshooting

  • Make sure the right CloudWatch log groups are subscribed
  • Look for errors in CloudWatch log group /aws/kinesisfirehose/<STACK NAME>-DeliveryStream
  • Look for errors in CloudWatch log group /aws/lambda/<STACK NAME>-LogProcessor-<RANDOM>
  • Make sure Kinesis, Firehose and S3 can using your KMS key when using encryption
  • Increase Kinesis shard count with ShardCount (Kinesis Shard Count) CloudFormation parameter

Origin

This project is based on Amazon's Stream Amazon CloudWatch Logs to a Centralized Account for Audit and Analysis but adds:

  • One step installation
  • Zero scripts
  • Works out of the box
  • Easier configuration without editing files
  • No hard dependency on CloudTrail
  • Optional unpacking of CloudWatch JSON format
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].