Skip to content

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

Notifications You must be signed in to change notification settings

jamesfairhurst/laravel-cloudwatch-logs-lambda-slack

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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

About

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

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published