Ends in
00
days
00
hrs
00
mins
00
secs
ENROLL NOW

🚀 25% OFF All Practice Exams, Video Courses, & eBooks – Cyber Week Blowout Deals!

Monitoring Amazon SES Complaint Rates with CloudWatch Alarms and Real-Time Slack Notifications

Home » BLOG » Monitoring Amazon SES Complaint Rates with CloudWatch Alarms and Real-Time Slack Notifications

Monitoring Amazon SES Complaint Rates with CloudWatch Alarms and Real-Time Slack Notifications

Amazon Simple Email Service (SES) is a powerful tool for sending high volumes of emails quickly and efficiently. However, to maintain your email-sending capabilities and ensure high deliverability, it’s essential to monitor your sender’s reputation closely. One key metric for assessing this reputation is the Complaint Rate, which measures how often recipients mark your emails as spam. A high complaint rate can lead to your emails being filtered into spam folders, throttling, or even suspension of your SES account.

This article will guide you through setting up a system to monitor your Amazon SES Complaint Rate in real-time using Amazon CloudWatch Alarms and AWS Lambda. Additionally, we’ll integrate Slack for real-time notifications, allowing you to stay on top of any potential issues.

What is an Amazon SES Complaint Rate?

The Complaint Rate is a metric provided by SES that reflects the percentage of recipients who report your email as spam compared to the total number of emails you sent. Specifically, SES calculates the ratio of complaints (emails marked as spam) to deliveries.

For example:

  • If you sent 1,000 emails and 3 people marked those emails as spam, your complaint rate is 0.003.
  • SES automatically considers any complaint rate higher than 0.001 (1 complaint per 1,000 emails) as a red flag, which could lead to actions like limiting your sending rate or even account suspension.

SES assigns a reputation score to your account, and maintaining a low complaint rate is key to keeping that score high.

Importance of Complaint Rate

A high complaint rate can significantly affect your email-sending practices and reputation. Here’s why:

  • Impact on Email Deliverability: Email providers (like Gmail, Yahoo, etc.) use complaint rates to assess whether your emails are legitimate or spam. A high complaint rate may lead to your emails being sent directly to the spam folder, or even blocked outright.
  • Account Throttling: SES may reduce your sending capacity or throttle the rate you can send emails if it detects a high complaint rate.
  • Account Suspension: In severe cases, SES may temporarily or permanently suspend your email-sending privileges if the complaint rate exceeds a threshold for an extended period.

By monitoring your complaint rate closely, you can take proactive steps (e.g., cleaning your email lists, refining your email content, or improving engagement) before any significant issues arise.

Implementation Steps

Now that we understand the importance of the Complaint Rate, let’s dive into setting up a real-time monitoring solution.

Step 1: Start by logging into the Amazon Management Console. Once logged in, search for SNS in the search bar.Monitoring Amazon SES- SNS

Step 2: To receive notifications via email, set up an SNS (Simple Notification Service) topic.

    • On the SNS Dashboard, click on Topics in the left-hand panel.
    • Click on the Create Topic button.Monitoring Amazon SES- Create Topic
    • Select Standard as the topic type.
    • Name your topic (for example, AmazonSES_complaint_rate) and click Create Topic.Monitoring Amazon SES- Create Topic config
  • Tutorials dojo strip

Step 3: Subscribe to the SNS Topic.

    • After creating your SNS topic, click on the topic name you just created.
    • Click on Create Subscription.Monitoring Amazon SES- Create Subscription
    • Under Protocol, select Email and provide the email address (e.g., juandelacruz@email.com) that will receive the notifications.
    • Make sure to confirm the subscription by checking your email inbox and clicking on the confirmation link.Monitoring Amazon SES- Confirm Subscription

Step 4: Create a Lambda function that sends the SES complaint notifications to Slack.

      • Go to the Lambda Dashboard and click on Create Function.Monitoring Amazon SES- Create Function
      • Choose Python as the runtime, and create a new function with a descriptive name like SESComplaintNotification.Monitoring Amazon SES- Runtime
      • In the function editor, paste the following Python code. This script will process the SNS message and send it as a notification to Slack.
    import json
    import urllib3
    import base64, zlib
    from pprint import pprint
    
    http = urllib3.PoolManager()
    hook = "INSERT YOUR SLACK WEBHOOK HERE"
    
    def lambda_handler(event, context):
        
        init_message = json.loads(event["Records"][0]['Sns']["Message"])
        #debug
        print(event["Records"])
        message = init_message['AlarmName']
        msg = {
            "text": f':loudspeaker: {message}'
        }
        enc_msg = json.dumps(msg).encode('utf-8')
        response = http.request('POST', hook, body=enc_msg, headers={'Content-type': 'application/json'})
    
    • Under the Configuration tab of your Lambda function, go to Triggers and click Add Trigger.Monitoring Amazon SES- Trigger
    • Add the SNS as the trigger. Monitoring Amazon SES- SNS Trigger

Step 5: Now, configure the Lambda execution role to ensure it has the correct permissions:

    • Click on the Role Name to open the IAM console
    • Click on Add Permissions, then Create Inline Policy. Select SNS as the service and check the Publish option for allowed actions:Monitoring Amazon SES- Create inline policy

Step 6: Once the permissions are set, test the Lambda function by triggering it manually or by sending a test SNS message.

Step 7: Next, you need to create a CloudWatch alarm to monitor your SES complaint rate.

    • Go to CloudWatch in the AWS Console and make sure you’re in the right region.
    • From the CloudWatch sidebar, click All Alarms, and then click the Create Alarm button.Monitoring Amazon SES- Create Alarms
    • Under Create Alarm, click on Select metric.Monitoring Amazon SES- Select Metrics
    • In the Browse tab, search for SES.
    • Select SES > Account Metrics, and then click on Reputation.ComplaintRate.Monitoring Amazon SES- Reputation.ComplaintRate
    • In the Conditions section, set the threshold to Static.Monitoring Amazon SES- Alarm conditions
    • Set the condition to Greater/Equal and enter a threshold value of 0.003 (which corresponds to a 3% complaint rate).
    • Click Next.
    • In the Actions section, choose the SNS topic you created earlier.
    • Monitoring Amazon SES- Configure ActionsClick Next.
    • Give the alarm a descriptive name. Review the configuration and click Create Alarm. Monitoring Amazon SES- Alarm Name
    • Lastly, click Next and review the alarm configuration. Once reviewed, proceed by clicking the Create Alarm button.Monitoring Amazon SES- Alarm Creation
    • Repeat the above steps to create another alarm with a threshold value of 0.004 (4%) and 0.005 (5%).
Free AWS Courses

Once everything is set up, you should start receiving notifications in Slack whenever the complaint rate exceeds the threshold you’ve set in CloudWatch. Here’s an example of what the Slack message might look like:Monitoring Amazon SES- Slack Notification

Monitoring Amazon SES- Email Notifications

 

Conclusion

By implementing this automated solution using Amazon SES, CloudWatch, AWS Lambda, and Slack, you can efficiently monitor your email reputation and take immediate action when necessary. Keeping a close eye on your Complaint Rate ensures that your emails are well-received and improves your sender reputation over time, ultimately leading to better deliverability and successful email campaigns.

🚀 25% OFF All Practice Exams, Video Courses, & eBooks – Cyber Week Blowout Deals!

Tutorials Dojo portal

Learn AWS with our PlayCloud Hands-On Labs

Tutorials Dojo Exam Study Guide eBooks

tutorials dojo study guide eBook

FREE AWS Exam Readiness Digital Courses

FREE AWS, Azure, GCP Practice Test Samplers

Subscribe to our YouTube Channel

Tutorials Dojo YouTube Channel

Follow Us On Linkedin

Recent Posts

Written by: Nikee Tomas

Nikee is a dedicated Web Developer at Tutorials Dojo. She has a strong passion for cloud computing and contributes to the tech community as an AWS Community Builder. She is continuously striving to enhance her knowledge and expertise in the field.

AWS, Azure, and GCP Certifications are consistently among the top-paying IT certifications in the world, considering that most companies have now shifted to the cloud. Earn over $150,000 per year with an AWS, Azure, or GCP certification!

Follow us on LinkedIn, YouTube, Facebook, or join our Slack study group. More importantly, answer as many practice exams as you can to help increase your chances of passing your certification exams on your first try!

View Our AWS, Azure, and GCP Exam Reviewers Check out our FREE courses

Our Community

~98%
passing rate
Around 95-98% of our students pass the AWS Certification exams after training with our courses.
200k+
students
Over 200k enrollees choose Tutorials Dojo in preparing for their AWS Certification exams.
~4.8
ratings
Our courses are highly rated by our enrollees from all over the world.

What our students say about us?