Watch out your Cloudwatch logs, or it could be expensive!

Disable all unnecessary logs

  • Do NOT use console.log
  • Use one of the many solutions out there to log based on level and environment.

set up a retention period on your logs.

logRetention: isProduction ? RetentionDays.ONE_WEEK : RetentionDays.ONE_DAY
custom: logRetentionDaysByStage: production: 7 other: 1 provider: logRetentionInDays: ${self:custom.logRetentionDaysByStage.${self:provider.stage}, self:custom.logRetentionDaysByStage.other}

Check CloudWathc Metrics

  • Go to the Cloudwatch Metrics / Logs / Log Group Metrics and select the resources you want to monitor (for example your Lambda — remember to add the namespace (/aws/lambda) to filter among all of them ).
  • Adjust the dimension and period and you will have all the info and select Cloudcreate a Dashboard with
{ "storedBytes": 18670230, "metricFilterCount": 4, "creationTime": 1582203444572, "logGroupName": "/aws/lambda/YOUR-LAMBDA", "retentionInDays": 30, "arn": "arn:aws:logs:eu-west-1:YOUR_ACCOUNT:log-group:/aws/lambda/YOUR-LAMBDA:*" }
aws cloudwatch get-metric-statistics --metric-name IncomingBytes --start-time 2020-04-10T00:00:00Z --end-time 2020-04-16T23:59:59Z --period 604800 --namespace AWS/Logs --statistics Sum --region eu-west-1 --dimensions Name=LogGroupName,Value=/aws/lambda/YOUR_LAMBDA --unit Bytes
{ "Datapoints": [ { "Timestamp": "2020-04-10T00:00:00Z", "Sum": 56184051.0, "Unit": "Bytes" } ], "Label": "IncomingBytes" }

Sport addicted, productivity obsessed, avid learner, travel enthusiast, expat, 2 kids. Technical Lead (NodeJs Serverless)

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Moving Quickly: An Agile and Scrum Overview

WooCommerce Email Customizer | Email Customizer WooCommerce

How do the front end engineering teams work?

7 Resources to Understand & Reduce Nonprofit Technical Debt- Constructive

Git — Local to Remote Repo from the terminal

Technical workshop at AssoConnect

Regex: Regular Expressions in Ruby

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Davide de Paolis

Davide de Paolis

Sport addicted, productivity obsessed, avid learner, travel enthusiast, expat, 2 kids. Technical Lead (NodeJs Serverless)

More from Medium

NDA software development: Template and Best Practices

How we migrated an entire AWS Organization to a new one, with no-one noticing!

Automatic Alarms based on metrics from filtered logs in CloudWatch

SERVERLESS ARCHITECTURE