Using CloudWatch to Create Alarms


Overview: CloudWatch can be used in combination SNS so you can be notified when specific events or issues occur in your Lambda function. In this case Errors in a Lambda function. Alarms can be raised if the number of errors is ever over a predefined amount and they can either be by a per function basis or overall created Lambda functions.


AWS Cost: $0.10 per alarm


Creating the SNS (Used to send emails):

  1. Navigate to the AWS SNS > Topic.
  2. Click “Create New Topic” and fill in the fields to create a topic.
  3. Once you have created the topic click on the newly created topic in the topics page.
  4. Once in the topic details page, click “Create Subscription” and add the email or emails you want the alerts to be sent to.
  5. A confirmation email will then be sent to the email endpoint which needs to be accepted to receive emails from SNS.


Creating the Alert:

  1. Navigate to AWS’s service CloudWatch > Alarms > Create Alarm
  2. Select Lambda Metric “By Function Name”.
  3. Select the Lambda Function you want to create the alarm for with the Metric Errors, select Sum from the dropdown, and then click next to further define the alarm.
  4. Give the Alarm a name and description and set the period (Usually do 1 hour).
  5. The best way to determine the what to set the threshold is for the number of error is to check the Lambda function to see how many times it is called within the time period you selected and use a percentage (10%-25%) to determine how the number of errors that will trigger the alert. (Ex Function is called 100 times and hour and you want an alert  if errors are ever 15% then you would set the threshold to 15).
  6. Lastly, in the actions section select the SNS topic you created earlier and create the Alarm.