Custom Monitoring Queries
Summary
Custom Monitoring Queries let you define your own T-SQL queries that WISdom runs against your monitored instances. Use them to monitor conditions specific to your environment that are not covered by standard WISdom alert types.
Once a query is created and validated, it can be used as the data source for a Custom Alert.
Applies to: WISdom v26.1.0 and later
Audience: WISdom administrators, monitoring owners, MSPs
Permissions required: Access to Admin Console → Monitoring
Accessing Custom Monitoring Queries
- Open the Admin Console.
- Go to Monitoring.
- Select Custom Monitoring Queries.
The query list displays the following for each entry:
- Name – the friendly name of the query.
- Description – what the query checks.
- Validation Status – whether the query has passed validation.
- Target Instances – how many instances this query can run on.
- Alert Types – how many Custom Alerts use this query.
You can sort, search, and filter this list. Use the action menu on each row to edit or delete a query.
Note: Queries must be validated before they can be used in a Custom Alert.
Creating a Custom Monitoring Query
Step 1 – Start a new query
- Go to Admin Console → Monitoring → Custom Monitoring Queries.
- Click Create New Query.
A side panel opens to configure your new query.
Step 2 – Enter basic information
Provide the following:
-
Name (required) – Choose a clear and descriptive name.
Example:AG Redo Queue Size by Database -
Description (recommended) – Describe what the query checks and why it is useful.
Example:Monitors AlwaysOn redo queue size per database to detect replication delays.
Step 3 – Select target instances
Use the Target Instances selector to choose where this query is allowed to run. You can select one or more instances. WISdom will only run this query on the instances you select, both for validation and for ongoing alert evaluations.
Step 4 – Write the SQL query
In the SQL editor, paste or type your T-SQL. The query must meet the following requirements:
- Read-only – no
INSERT,UPDATE,DELETE,DROP, or other write operations. - Returns a result set – a table of rows and columns.
- Includes at least one numeric column to use as the alert value.
- Optionally includes one or more identifier columns such as database name or disk name.
Example:
SELECT
a.name AS AvailabilityGroupName,
d.name AS DatabaseName,
SUM(s.redo_queue_size) AS RedoQueueSizeKB
FROM sys.availability_groups a
JOIN sys.dm_hadr_database_replica_states s ON s.group_id = a.group_id
JOIN sys.databases d ON d.database_id = s.database_id
WHERE s.is_local = 1
GROUP BY a.name, d.name;
In this example, you would later map RedoQueueSizeKB as the Value Column and DatabaseName as the Object Column when creating a Custom Alert.
Tip: Test your query directly in SQL Server first to confirm performance and results before adding it to WISdom.
Step 5 – Choose an instance for validation
Before saving, select an instance to use for validation. This should be one of the Target Instances you selected. WISdom will run the query on this instance to confirm it executes successfully, returns a valid result set, and passes safety checks.
Step 6 – Save and validate
Click Save. WISdom will save the query definition and run validation against the selected instance. The Validation Status field will update once validation completes.
Understanding Validation Status
Each Custom Monitoring Query has a validation status:
-
Validated – The query ran successfully, returned a usable result set, and passed safety checks. It can now be used by Custom Alerts.
-
Failed – The query failed to run, returned an invalid result, or failed safety checks (for example, it contained disallowed operations). Adjust the SQL and save again to re-run validation.
-
Not Validated / Pending – The query has not yet been successfully validated. It is not available for use in Custom Alerts.
Important: Only Validated queries appear when configuring a Custom Alert.
Editing a Custom Monitoring Query
- Go to Admin Console → Monitoring → Custom Monitoring Queries.
- Click the query row, or open the row's action menu and choose Edit.
What you can change depends on whether the query is in use:
Query is not used by any Custom Alert:
You can modify the Name, Description, Target Instances, and SQL text. Any change to the SQL text will trigger re-validation when you save.
Query is already used by one or more Custom Alerts:
The SQL text is locked (read-only). You can still change the Name, Description, and Target Instances. This prevents breaking existing alerts that depend on the query.
Best practice: To significantly change the logic of a query that is in use, create a new Custom Monitoring Query, update your Custom Alerts to reference the new query, and then remove the old query when no alerts depend on it.
Related Topics
- Creating Custom Alerts
- Managing Alert Profiles and Rules
- Configuring Silencing Windows