{"id":28693350,"url":"https://github.com/matteogioioso/lambda-flame","last_synced_at":"2025-06-14T08:13:05.777Z","repository":{"id":55900098,"uuid":"318072986","full_name":"MatteoGioioso/lambda-flame","owner":"MatteoGioioso","description":"Extract a flame graph directly from your lambda function. Supported runtimes: Nodejs. 🔥","archived":false,"fork":false,"pushed_at":"2021-05-22T07:56:23.000Z","size":13302,"stargazers_count":13,"open_issues_count":7,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-05-01T20:08:44.633Z","etag":null,"topics":["aws","aws-lambda","flame-graph","lambda","nodejs","serverless"],"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/MatteoGioioso.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}},"created_at":"2020-12-03T04:19:45.000Z","updated_at":"2024-03-03T03:30:07.000Z","dependencies_parsed_at":"2022-08-15T09:00:47.201Z","dependency_job_id":null,"html_url":"https://github.com/MatteoGioioso/lambda-flame","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/MatteoGioioso/lambda-flame","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MatteoGioioso%2Flambda-flame","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MatteoGioioso%2Flambda-flame/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MatteoGioioso%2Flambda-flame/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MatteoGioioso%2Flambda-flame/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MatteoGioioso","download_url":"https://codeload.github.com/MatteoGioioso/lambda-flame/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MatteoGioioso%2Flambda-flame/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259783084,"owners_count":22910304,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["aws","aws-lambda","flame-graph","lambda","nodejs","serverless"],"created_at":"2025-06-14T08:13:01.621Z","updated_at":"2025-06-14T08:13:05.764Z","avatar_url":"https://github.com/MatteoGioioso.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"![lambda-flame](docs/logo.png)\n\nExtract flame graph for Nodejs directly from an AWS lambda function.\nLambda flame is a custom Nodejs runtime that collects and creates a flame graph of your lambda function process.\n\n## Usage\n\n### Deployment\n\nThe first thing is to deploy the Serverless application into your account.\nYou can do it via the AWS console: [lambda-flame](https://serverlessrepo.aws.amazon.com/applications/ap-southeast-1/164102481775/lambda-flame),\nor directly into Cloudformation: (**make sure you specify the latest version**)\n```yaml\n  lambdaflame:\n    Type: AWS::Serverless::Application\n    Properties:\n      Location:\n        ApplicationId: arn:aws:serverlessrepo:ap-southeast-1:164102481775:applications/lambda-flame\n        SemanticVersion: 1.0.0\n```\n\n### Setup\nAfter the application has been deployed go to the lambda console, \nclick on layers and copy the lambda-flame layer arn; \n\n![layers](./docs/lambda-flame-after-deploy.png)\n\n\n#### SAM/Cloudformation\nYou can now paste the layer in your SAM/Cloudformation template:\n\n```yaml\nAWSTemplateFormatVersion: \"2010-09-09\"\nTransform: \"AWS::Serverless-2016-10-31\"\nDescription: \"Lambda flame test template\"\n\nResources:\n  ExampleFunction:\n    Type: AWS::Serverless::Function\n    Properties:\n      Runtime: provided // Runtime must be set to provided\n      Timeout: 30\n      MemorySize: 1024\n      CodeUri: ./\n      Handler: handler.handler\n      Environment:\n        Variables:\n          LAMBDA_FLAME_DEST_BUCKET: !Ref FlameBucket\n          LAMBDA_FLAME_DEBUG: ALL\n      Policies:\n        - AWSLambdaBasicExecutionRole\n        - S3WritePolicy: // Or simply s3:PutObject\n            BucketName: !Ref FlameBucket\n      Layers:\n        - !Sub arn:aws:lambda:ap-southeast-1:{AWS::AccountId}:layer:lambda-flame:13 // Layer arn from the Lambda Flame application\n      Events:\n        HTTP:\n          Type: Api\n          Properties:\n            Path: /\n            Method: Get\n\n  FlameBucket:\n    Type: AWS::S3::Bucket\n    Properties:\n      BucketName: lambda-flame-graph-test\n\n```\n\n#### Serverless framework\nPaste the arn in your `serverless.yaml`:\n\n```yaml\nservice: lambda-flame-test-sls\n\nprovider:\n  name: aws\n  stackName: lambda-flame-test-sls\n  region: ap-southeast-1\n  iamRoleStatements:\n    - Effect: Allow\n      Action:\n        - s3:PutObject\n      Resource:\n        - arn:aws:s3:::lambda-flame-graph-test\n        - arn:aws:s3:::lambda-flame-graph-test/*\n\npackage:\n  individually: true\n        \nfunctions:\n  exampleFunction:\n    memorySize: 1024\n    timeout: 30\n    handler: handler.handler\n    runtime: provided\n    environment:\n      LAMBDA_FLAME_DEST_BUCKET: lambda-flame-graph-test\n      LAMBDA_FLAME_DEBUG: ALL\n    layers:\n      - !Sub arn:aws:lambda:ap-southeast-1:${AWS::AccountId}:layer:lambda-flame:13\n    events:\n      - http:\n          method: get\n          path: /\n\nresources:\n  Resources:\n    FlameBucket:\n      Type: AWS::S3::Bucket\n      Properties:\n        BucketName: lambda-flame-graph-test\n\n```\n\nIf you are using the **webpack plugin**, the custom runtime option will not work for versions \u003c 5.4.0\nJust add the `allowCustomRuntime: true` option to your function:\n\n```yaml\n  exampleFunction:\n    handler: handler.handler\n    runtime: provided\n    allowCustomRuntime: true\n    layers:\n      - !Sub arn:aws:lambda:ap-southeast-1:${AWS::AccountId}:layer:lambda-flame:13\n     ...\n```\n\n### Some important notes:\n\n- The `Runtime` property **must be set to `provided`**\n- All the result of the v8 profiling and the flamegraph creation will be sent to an S3 bucket of your choice. You **must specify a valid S3 Bucket name**. \nYou can use any bucket you want and one bucket for all your functions, \nlambda flame will name space all the output files under `s3://\u003cyour-bucket-name\u003e/lambda-flame/\u003cfunction-name\u003e/\u003cepoch timestamp\u003e/`\n- In order to send the profiling output and flame graph files to your S3 bucket **make sure you have the required write permissions `s3:PutObject`** \n- The v8 profile output processing happens outside your handler invocation therefore it won't impact your function profiling. However, is a CPU bound operation, \nif you want to make it a bit faster just temporarily add more memory\n- **This tool (for the time being) is not meant to run in a production environment, use it as a debugging purposes only**\n\n### Run\nAfter the invocation of your function has terminated, you can navigate to your S3 Bucket under `s3://\u003cyour-bucket-name\u003e/lambda-flame/\u003cfunction-name\u003e/\u003cepoch timestamp\u003e/`\nand open the `flamegraph.html`\n\n![example flamegraph.html](docs/flame-graph.png)\n\n\n## Config\nYou can set all the parameters via environmental variables\n\n| Property | Type | Description | Default |\n| -------- | ---- | ----------- | ------- |\n| LAMBDA_FLAME_DEST_BUCKET | `String` | Valid S3 bucket name **required** | `undefined` |\n| LAMBDA_FLAME_DEBUG | `String` | Activate debugging logs, they will appear in Cloudwatch, leave it empty if you don't want them | `ALL` |\n\n## Roadmap\nThere are a lot of new features I want to add, feel free to contribute, open issues and share your ideas 🙏.\n\n- Provide multiple runtimes other than nodejs (planning to support Go)\n- Add more control over via configuration\n- Automate builds of Nodejs runtimes\n- Possibility to capture a heap dump\n- Dramatically improve flame graph visualization and interactivity\n\n\n## Notice\nThis tool (for the time being) is partially using a modified version [flamebearer](https://github.com/mapbox/flamebearer) all the credits goes to the [author](https://www.mapbox.com/) of this library.\nIn the future I am planning to build a custom visualization similar to [Clinic flame](https://clinicjs.org/flame/).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatteogioioso%2Flambda-flame","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmatteogioioso%2Flambda-flame","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatteogioioso%2Flambda-flame/lists"}