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

lambda-monitor

v4.0.3

Published

Lambda log monitoring and streaming to external services.

Downloads

509

Readme

Lambda Monitoring

Build Status Test Coverage Dependabot Status Dependencies NPM Downloads Semantic-Release Gardener

Lambda log monitoring and streaming to external services.

What it does

  • Parsing and analysis of AWS Lambda CloudWatch Logs
  • Pipes AWS Lambda Logs to external logging services (i.e. Loggly, Logz or Datadog)
  • Detects and sends AWS Lambda anomalies to external monitoring service (i.e. Rollbar)
  • Fully transparent, no changes to existing Lambda functions required

Cloudwatch To Loggly

Setup

1. Create New Github Project

  • Install dev dependencies with yarn add -DE js-gardener @blackflux/robo-config-plugin eslint object-hash and
  • Dependencies with yarn add -E lambda-monitor
  • Add gardener.js containing
// eslint-disable-next-line import/no-extraneous-dependencies
import gardener from 'js-gardener';

if (require.main === module) {
  gardener().catch(() => process.exit(1));
}
  • Add .roboconfig.json containing (adjust as necessary!)
{
  "lambda-monitor": {
    "tasks": [
      "assorted/@default"
    ],
    "variables": {
      "enableCloudTrail": "FILL_IN",
      "awsRegion": "AWS_REGION"
    }
  },
  "@blackflux/robo-config-plugin": {
    "tasks": [
      "assorted/@sls-closedsource"
    ],
    "variables": {
      "repoKey": "ORG_NAME/REPO_NAME",
      "circleCiReadToken": "CIRCLE_CI_TOKEN",
      "projectName": "PROJECT_NAME",
      "owner": "GH_USER_NAME",
      "ownerName": "ORG_NAME",
      "mergeBot": "MERGE_BOT_NAME",
      "awsRegion": "AWS_REGION",
      "namespace": "com.sls.ORG_NAME"
    }
  }
}
  • Run node gardener.js
  • Then run yarn install && yarn u
  • Then enter docker container with . manage.sh
  • Then run yarn install && u && t
  • Create .depunusedignore
@blackflux/robo-config-plugin
@blackflux/eslint-plugin-rules
object-hash
  • Follow instructions of generated file HOWTO.md (and generated CONFDOCS.md)

Disable Logging for a Lambda Function

To exclude a lambda function from being monitored simply add the tag "MONITORED": "0". Note that you need to manually unsubscribe if process-log has already been subscribed to the CloudWatch stream.

How it works

While deploying this project is straight forward, there is a lot of complexity going on behind the scenes to ensure:

  • All Lambda functions are subscribed on initial deploy
  • Newly created Lambda function are immediately subscribed
  • Periodic checks for Lambda functions not subscribed (self healing)

There are four lambda function created per stage. All operations are only performed on lambda functions tagged with the corresponding stage.

batcher-handler - Listens to SQS messages to group them before writing to S3

bundler-handler - Listens to SQS messages to group them before writing to json logging service

process-logs - This lambda function is subscribed to CloudWatch and processes the logs. Anomalies are submitted to rollbar and all detected log events are sent to the configured logging services. Tagged with "MONITOR": "1" and "MONITORED": "0".

subscribe - Subscribes the process-logs lambda function (detected using the MONITOR tag) to all relevant CloudWatch Groups, excluding those functions that have the MONITORED tag set to 0.

empty-bucket - Empty CloudTrail bucket when stage is removed from AWS.