npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

serverless-plugin-lambda-insights

v2.0.0

Published

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

Downloads

149,217

Readme

serverless-plugin-lambda-insights

A Serverless Framework Plugin allowing to enable Lambda Insights

npm npm

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

Why use 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

This Plugin requires a Serverless Framework version of >= 2.0.0.

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 #enables Lambda Insights for this function
    handler: src/app/index.handler
  secondFunction: #inherits tracing settings from "provider"
    lambdaInsights: false #disables Lambda Insights for this function, will overrule custom settings
    handler: src/app/index.handler

custom:
  lambdaInsights:
    defaultLambdaInsights: true #enables Lambda Insights for all your functions, 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 command.

cd example; serverless deploy

This will deploy a hello-world Lambda function with Lambda Insights enabled.


Want to contribute?

This is your repo - just go head and create a pull request. See also CONTRIBUTING for more introductions.

Some open Ideas and Tasks:

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

Security

See CONTRIBUTING for more information.

License

This library is licensed under the MIT-0 License. See the LICENSE file.