Skip to content
Use AWS CloudWatch Logs & Lambda to post Laravel Log messages to Slack
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
README.md
index.js
screenshot-all-log-levels.png
screenshot-exception.png

README.md

laravel-cloudwatch-logs-lambda-slack

Use AWS CloudWatch Logs & Lambda to post Laravel Log messages to Slack.

All Log Levels

Exception Info

Setup

Step 1 - Get Your Laravel Logs into CloudWatch

I've written an article which goes through the process of getting your Laravel app logs into CloudWatch. It's relatively straight forward however like everything it depends on your experience. Hit me up if you're having trouble.

Step 2 - Create a Slack Webhook

Create a Slack Incoming Webhook which will give you a Webhook URL e.g. https://hooks.slack.com/services/xxx/xxx/xxx. Enter the URL without the hostname into the slackPostPath variable in the index.js file e.g.

slackPostPath = '/services/xxx/xxx/xxx';

Step 3 - Create a Lambda Function

Create a new Lambda function in the AWS Console and select the cloudwatch-logs-process-data blueprint as a starting point, this will ask you to select a Log Group (your Laravel log) and an optional pattern. Name your function and copy & paste the code in index.js into the inline code editor (remember to update the slackPostPath variable). I've created a more detailed walkthrough in an article.

Summary

Although there are other ways to get notified of errors e.g. external services (Bugsnag) or Laravel specific packages (lern) depending on your circumstances this could be another option. I've been wanting to delve into & learn the AWS eco-system for some time now and I've been documenting my efforts on Medium to hopefully help others & future me when I come to do things again. I'm also a Nodejs noob so if things can be improved let me know!

Todo

You can’t perform that action at this time.