My stack for setting up a SQL-query-based CloudWatch alarm seems ridiculous. I need:
- A SQL Query returning what I wish to monitor (e.g.
SELECT TOP (1) is_server_screwed FROM my_table;
). - A PowerShell script that sends the result of my query to CloudWatch (e.g.
$Metric = boilerplate_here; Write-CWMetricData -Namespace SQL -MetricData $Metric
). - A SQL Server Agent Job (or equivalent Task Scheduler Task) to fire the script on a schedule.
- A CloudWatch Alarm to alert me whenever the query's results cross thresholds.
Is there any way to remove steps 2 and 3? I'm surprised that CloudWatch itself cannot query the server.