gib65
gib65

Reputation: 2017

How do I send a notification to Slack from AWS CloudWatch on a specific error?

I'm trying to setup notifications to be sent from our AWS Lambda instance to a Slack channel. I'm following along in this guide:

https://medium.com/analytics-vidhya/generate-slack-notifications-for-aws-cloudwatch-alarms-e46b68540133

I get stuck on step 4 however because the type of alarm I want to setup does not involve thresholds or anomalies. It involves a specific error in our code. We want to be notified when users encounter errors when attempting to login in or sign up. We have try/catch blocks in our Node.js backend to log errors to CloudWatch at various points in the login/signup flow where we think the errors are most likely happening. We would like to identify when those SPECIFIC errors are occurring and send a notification to a Slack channel built for this purpose.

So in step 4 of the article, what would I have to do to set this up? Or is the approach in this article simply the wrong one for my purposes?

Thanks.

Upvotes: 1

Views: 4292

Answers (1)

Marcin
Marcin

Reputation: 238259

The step 4 titled "Create a CloudWatch Alarm" uses CPUUtlization metric to trigger an alarm.

In your case, since you want to use CloudWatch Logs, you would create CloudWatch Metric Filters based on the logs entries of interest. This would produce custom metrics based on your error string. Subsequently, you would create CloudWatch Alarm of this metric as shown in the linked tutorial for CPUUtlization.

Upvotes: 3

Related Questions