Add Monitored Entities to SQL Monitor using the Web API
Published 18 June 2018
The Web API allows you to start monitoring a monitored entity (SQL Server, machine or cluster) without having to manually do it through the SQL Monitor website.
This is useful for integrating SQL Monitor with your build processes and inventory management systems.
Download PowerShell module
You can download the PowerShell module to access the Web API with the following link:
And then load it (from directory which contains the file):
Loading Powershell module
Import-Module .\SQMAPIADDSERVER.psm1
You can see example usages from the PowerShell documentation:
Getting help for the PowerShell Module
Get-Help Add-MonitoredEntity Get-Help Add-MonitoredEntity -examples
Monitored entities supported
- Clusters
- Machines
- SQL Server instances
Step-by-step guide
- Get the Authentication token (this is the contents of %ProgramData%\Red Gate\SQL Monitor\WebApi.config on the web server machine)
- Run the following Powershell script and supply the values needed to add a monitored entity
- The script will send a JSON request to the Web API to add a monitored entity
Responses
If successful, you are going to see the following response:
Output
Success Message ------- ------- True
Known limitations
- You can add a server with invalid credentials and it will add it and return true (it doesn't test it)
- Cluster/SQL Server is still added when a non existent group is specified