JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 69059
  • Score
    100M100P100Q165057F
  • License MIT

A Serverless Framework Plugin allowing to enable Lambda Insights for entire Serverless stack or individual functions

Package Exports

  • serverless-plugin-lambda-insights

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (serverless-plugin-lambda-insights) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

serverless-plugin-lambda-insights

A Serverless Framework Plugin allowing to enable Lambda Insights

Code Style: Google GitHub Workflow Status npm npm

Enables AWS Lambda Insights (https://aws.amazon.com/blogs/mt/introducing-cloudwatch-lambda-insights/) for the entire Serverless stack or individual functions.

Why using Lambda Insights

CloudWatch Lambda Insights is a monitoring and troubleshooting solution for serverless applications running on AWS Lambda. The solution collects, aggregates, and summarizes system-level metrics including CPU time, memory, disk, and network. It also collects, aggregates, and summarizes diagnostic information such as cold starts and Lambda worker shutdowns to help you isolate issues with your Lambda functions and resolve them quickly.

AWS Documentation Example


Getting started

Installation

npm install --save-dev serverless-plugin-lambda-insights

add Plugin to your serverless.yml in the plugins section.

Minimal Usage

Example serverless.yml:

provider:
  name: aws

plugins:
  - serverless-plugin-lambda-insights

functions:
  hello:
    handler: handler.hello
    lambdaInsights: true

Functionality

The plugin will enable Lambda Insights by adding a Lambda Layer (see Layer Details and Versions) and adding necessary permissions using the arn:aws:iam::aws:policy/CloudWatchLambdaInsightsExecutionRolePolicy as a AWS IAM Managed Policy.

You can check in your AWS Console: go to AWS Lambda -> select your Lambda function -> Configuration tab -> Monitoring tools -> "CloudWatch Lambda Insights". If lambdaInsights validated to true for a function, the checkbox will be checked.

Usage

Example serverless.yml:

service: your-great-sls-service

provider:
  name: aws
  stage: dev

plugins:
  - serverless-plugin-lambda-insights

functions:
  mainFunction: #inherits tracing settings from "provider"
    lambdaInsights: true #turns on Lambda Insights for this function
    handler: src/app/index.handler
  secondFunction: #inherits tracing settings from "provider"
    lambdaInsights: false #turns off Lambda Insights for this function, will overrule custom settings
    handler: src/app/index.handler
 
custom:
  lambdaInsights: 
    defaultLambdaInsights: true #turn on Lambda Insights for all your function, if 
    attachPolicy: false #explicitly disable auto attachment Managed Policy. 
    lambdaInsightsVersion: 14 #specify the Layer Version

Example

You can find an example in the example folder of this repository. Run it with the following comment.

cd example; serverless deploy

This will deploy a hallo-world Lambda function with Lambda Insights enables.


Want to contribute?

This is your repo - just go head and create a pull request ;)

Some open Ideas and Tasks:

  • Testing with Jest
  • Add Toggle for auto policy attachment
  • Add an example

Contact

This is a project created and maintained by a private person. In case you have any suggestions, questions or remarks, please raise an issue or reach out to @cstanger.

License

This is a private project by private person, published under the MIT licence.