Home icon

Automated blocking and query alerts for Amazon RDS for SQL Server

Database Blog



This article demonstrates how to build a serverless monitoring solution using AWS Lambda, CloudWatch, and SES to automatically detect and alert on blocking and long-running queries in Amazon RDS for SQL Server.

  • Uses Lambda triggered by EventBridge every 60 seconds to query SQL Server DMVs for blocking and long-running sessions
  • Employs recursive CTEs to trace blocking chains back to root blocker and filters long-running queries to exclude system processes
  • Publishes custom CloudWatch metrics and sends HTML-formatted email alerts via SES with session details and wait times
  • Requires dedicated monitoring user with VIEW SERVER STATE and VIEW ANY DEFINITION permissions for security
  • Stores RDS credentials securely in AWS Secrets Manager and deploys Lambda with pytds library in same VPC as RDS
  • Includes step-by-step setup, test scenarios for blocking and long-running queries, and cost estimate of ~$2.57/month

The solution provides automated, cost-effective monitoring for SQL Server performance issues without manual checks or third-party tools.



Go to article

The AWS News Feed is currently looking for gold sponsors. If you want to support the AWS community and reach a large audience of AWS professionals, consider sponsoring the AWS News Feed.

Related articles

Oct 14
2026
Amazon RDS Proxy now supports SQL Server 2022
Oct 2
2025
Set up proactive monitoring for Amazon RDS for SQL Server with real-time Slack notifications
Sep 2
2026
Amazon RDS for SQL Server supports additional SQL trace flags
Feb 11
2026
Essential tools for monitoring and optimizing Amazon RDS for SQL Server

The AWS News Feed is currently looking for silver sponsors. If you want to support the AWS community and reach a large audience of AWS professionals, consider sponsoring the AWS News Feed.