- Newest
- Most votes
- Most comments
Setting up CloudWatch alarms for SQL Server Agent job failure notifications in AWS RDS can be challenging, as RDS for SQL Server doesn't natively support SQL Server Agent operators or notifications. However, there are some workarounds you can try:
-
First, ensure that the SQL Server Agent error log is being correctly published to CloudWatch. You may need to verify the configuration of your RDS instance to make sure it's properly sending these logs.
-
Instead of using the Agent log, you might have better luck focusing on the SQL Server error log. SQL Server Agent job failures are often recorded there as well.
-
For your metric filter, try using a more specific pattern that matches the exact wording of job failure messages. For example: "The job failed. The Job was invoked by User"
-
If you're still not seeing the job failures in CloudWatch, you may need to modify your SQL Server Agent jobs to explicitly log their failures in a way that CloudWatch can detect. One approach is to add a final step to your jobs that runs only on failure and writes a specific message to the SQL Server error log.
-
Another option is to use the sp_send_dbmail stored procedure within your SQL Server Agent jobs to send email notifications directly when a job fails. This bypasses CloudWatch but still provides notifications.
-
If you want to stick with CloudWatch, you could create a custom metric by having your jobs write to a specific table when they fail, then use a scheduled task to check this table and publish a custom metric to CloudWatch.
-
As a last resort, you might consider using AWS EventBridge (formerly CloudWatch Events) to monitor for RDS events related to SQL Server Agent job failures. This could be more reliable than trying to parse log files.
Remember, these are workarounds due to the limitations of SQL Server Agent in RDS. The most reliable solution would be to redesign your jobs to handle their own error reporting, either by writing to a custom log table that you can monitor, or by directly integrating with SNS or another notification service.
Sources
Add support for Agent Operators and email notifications in RDS for SQL Server. | AWS re:Post
Cloudwatch Alarm for Glue Job Failures | AWS re:Post
answered 2 years ago
Relevant content
asked 3 years ago
