{"id":22369537,"url":"https://github.com/20minutes/serverless-provisioned-memory-report","last_synced_at":"2026-05-03T19:33:30.741Z","repository":{"id":58312588,"uuid":"531129137","full_name":"20minutes/serverless-provisioned-memory-report","owner":"20minutes","description":"⚡ Analyse logs from Lambdas to determine the provisioned memory usage (defined, max \u0026 over) and post them to Slack.","archived":false,"fork":false,"pushed_at":"2026-04-22T10:18:18.000Z","size":7347,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":5,"default_branch":"master","last_synced_at":"2026-04-22T12:25:28.954Z","etag":null,"topics":["20minutes","aws-lambda","memory","serverless","serverless-framework","slack"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/20minutes.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2022-08-31T14:48:32.000Z","updated_at":"2026-04-22T10:18:23.000Z","dependencies_parsed_at":"2025-12-16T08:01:20.454Z","dependency_job_id":null,"html_url":"https://github.com/20minutes/serverless-provisioned-memory-report","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/20minutes/serverless-provisioned-memory-report","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/20minutes%2Fserverless-provisioned-memory-report","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/20minutes%2Fserverless-provisioned-memory-report/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/20minutes%2Fserverless-provisioned-memory-report/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/20minutes%2Fserverless-provisioned-memory-report/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/20minutes","download_url":"https://codeload.github.com/20minutes/serverless-provisioned-memory-report/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/20minutes%2Fserverless-provisioned-memory-report/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32582748,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-03T06:36:36.687Z","status":"ssl_error","status_checked_at":"2026-05-03T06:36:09.306Z","response_time":103,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["20minutes","aws-lambda","memory","serverless","serverless-framework","slack"],"created_at":"2024-12-04T19:26:20.596Z","updated_at":"2026-05-03T19:33:30.736Z","avatar_url":"https://github.com/20minutes.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Serverless Provisioned Memory Report\n\n[![Build Status](https://github.com/20minutes/serverless-provisioned-memory-report/actions/workflows/tests.yml/badge.svg)](https://github.com/20minutes/serverless-provisioned-memory-report/actions/workflows/tests.yml)\n\nAnalyse logs from Lambdas to determine the provisioned memory usage (defined, max \u0026 over) and post them to Slack. You'll then be able to adjust the memory size of your lambdas and _hopefully_ save money 💸\n\n![Example](https://user-images.githubusercontent.com/62333/181353176-6325fb25-8675-4012-b049-771e287a5bde.png)\n\n## How it works\n\n1. We first fetch all your lambdas\n2. For each lambda, we run a custom CloudWatchLogs query to determine: provisoned memory, max used memory and over provisioned memory\n3. Once all queries are complete, we send the report to your Slack\n\nHere is the Step Functions definition:\n\n![Step Functions definition](https://user-images.githubusercontent.com/62333/192753793-5c6d0a03-4033-4f5a-b091-16dcd1ed3217.png)\n\n## Analyse the report\n\nOnce you got the report, you can take action from it based on the _over_ column:\n- if the value is negative, it means you must increase the memory size of that lambda because it often hit the limit\n- if the value is high (compared to the defined memory), it means you can decrease the memory to something more that the max used\n- if the value is between ~50 \u0026 ~100, the defined memory is fine!\n\nFor example, take that report:\n\n```\nFunction              Defined Provisioned      Max     Over\n-----------------------------------------------------------\nfunction1                 768         732      733       -1\nfunction2                1024         977       95      881\nfunction3                 300         286      214       72\n```\n\nHere are the actions you might take:\n\n1. `function1` must have more memory, define it to `1024` (or at least to something more that `768`)\n2. `function2` is over provisioned by a lot, lower it to `128`\n3. `function3` is fine\n\n## Prerequisites\n\n- Node.js 24\n- OSS Serverless (`npm install -g osls`)\n- An AWS account\n- Defined [provider credentials](https://serverless.com/framework/docs/providers/aws/guide/credentials/)\n- An [Incoming Webhook URL](https://api.slack.com/messaging/webhooks) from Slack\n\n## Deploy the code\n\nCreate the `.env`: `cp .env.dist .env` and then update the Slack webhook url in the file.\n\nDeploy the service using: `serverless deploy`\n\nBy default\n\n- it'll use the AWS profile `default`, but you can use your own using (be sure it's defined in your `~/.aws/credentials`): `serverless deploy --aws-profile myprofile`\n- it'll be deployed to the AWS region `eu-west-1` but you can change it using: `serverless deploy --region us-east-1`\n\n## Trigger the Step Function\n\nYou can trigger it manually by sending an empty json. It'll then fetch all your lambdas but it'll keep only the first 30 of them (because there can be only 30 CloudWatchLogs query in parallel). You can use pagination to fetch the rest of functions.\n\nYou can also provide some options:\n\n- `prefix`: to keep only lambdas starting with that value (empty by default)\n- `channel`: the Slack channel ID or name to post the report (default to `#general`)\n- `days`: number of days to fetch log (default to `7`)\n- `page`: page to retrieve (based on 30 functions per page) (default to `1`)\n\nFor example:\n\n```json\n{\n  \"prefix\": \"prod-\",\n  \"channel\": \"C03PE644XH8\",\n  \"days\": 2,\n  \"page\": 2\n}\n```\n\n## How we are using it\n\nWe defined some CloudWatch events to trigger the Step Function every monday with predefined options to fetch from the past 7 days all lambdas from all our projects.\n\nSo we have configured around 10 _cron_ to have report from the past week to quickly adjust the memory. And all reports are posted to a dedicated project Slack channel.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F20minutes%2Fserverless-provisioned-memory-report","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F20minutes%2Fserverless-provisioned-memory-report","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F20minutes%2Fserverless-provisioned-memory-report/lists"}