Bulk configuring alerts using PowerShell
Published 14 February 2023
The SQL Monitor PowerShell API currently allows you to perform “bulk configuration” of alerts. The intent is to make it much easier to implement and then fine-tune an alerting strategy for a large set of monitored servers, such as all servers and instances in a SQL Monitor Group.
You can script any type of alert, and their notifications, for any monitored object (Machine, SQL Instance, Cluster, Availability Group, Azure SQL Server, Azure SQL Database, Job and Azure Elastic Pool). So, for example, you can script out which alerts will be enabled for any machine in a Group, their threshold settings, and who should be notified of each type of alert, and where to send alerts for each severity level.
Each monitored object has its own object type, so in PowerShell you must get them from their parent MonitoredObject
. This means that the Base Monitor is always the starting point. From the Base Monitor you can fetch collections of groups, clusters, machines and Azure SQL Servers. From one of these four types of MonitoredObject
, you can get the instances, disks, elastic pools and availability groups. You get the jobs and databases from the instance.
To get you started, you can find various example PowerShell scripts for configuring alerts within the API section of the Configuration page (see: https://monitor.red-gate.com/Configuration/ExampleScripts).