Skip to content

Subscribes to tagged Lambdas in your account and forwards their errors to a specified Slack channel

Notifications You must be signed in to change notification settings

Parana-Games/lambda-errors-to-slack-sar

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Lambda Monitoring to Slack Stack

This stack is designed to allow you to monitor your AWS Lambda errors and send alerts to a specified slack channel. There are plenty of paid services (and even some free ones) that offer the same functionality, but the largest drawback is that it requires you to send your logs to a vendor's AWS account. This solution allows you to keep the logs in your account and customize which Lambda's forward their logs to slack.

Error Types

The current implementation picks up and Lambda Error, Timeout, and any message written with console.error().

Resources

Subscriber

The subscriber lambda is invoked any time you update tags on a Lambda function. The subscriber looks for a tag named monitoring and looks for that tag value to evaluate to true. If the subscriber finds the monitoring tag is set to true then it creates a new log subscription on the updated lambda. This log subscription subscribes the Alerter lambda to the modified lambda's log group. Monitoring Tag

If the monitoring tag does not exist or is set to false, this Lambda will check if the Alerter function is subscribed to the log groups and remove the subscription if so. This allows you to toggle on and off the subscriptions as needed.

Alerter

This lambda is invoked by Cloudwatch Logs when a lambda with the monitoring tag writes logs. This lambda then parses the log event to find out if it is a function error or a console.error(). It then relays this information to a specified slack channel.

Configuring Slack Settings

At this time, this app requires you to specify a Slack Webhook URL. To generate a Slack Webhook URL, follow the Create The Slack App portion of this Medium post. Once you have a Webhook URL, you need to add it to the serverless.yml file in the alerter function's environment settings. If your Slack Webhook URL looks like this: https://hooks.slack.com/services/ABCDEF123/12345ABCDEF/XXXXYYYYXXXXYYYYXXXXYYYY then update the environment variable to look like this:

alerter:
    handler: alerter/index.main
    environment:
	    SLACK_WEBHOOK_URL: ABCDEF123/12345ABCDEF/XXXXYYYYXXXXYYYYXXXXYYYY

About

Subscribes to tagged Lambdas in your account and forwards their errors to a specified Slack channel

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%