Azure Data Studio, SQL Notebooks, and Alert Mining for SQL Sentry
When SQL Sentry is first deployed and begins to alert you to the conditions shipped with the product, you can get a lot of alert emails, which can be overwhelming. This short post is all about tuning those noisy alert conditions. If you are using Azure Data Studio, hopefully you're aware of SQL Notebooks. SQL Notebooks are great for many things and useful in certain situations. As a DBA, I created SQL Notebooks for junior or mid-level DBAs to collect certain diagnostic information for troubleshooting, or for the beginnings of root cause analysis.
SQL Notebooks allows you to save the results to the Notebook, simplifying data exchange between teams. Depending on which Kernel you use, the Notebook could also be a PowerShell Notebook. Notebooks are not only for use in Azure Data Studio. They can also be used with VS Code depending on which editor you prefer.
The Notebook attached to this post is designed for alert mining, tuning alerts from SQL Sentry. Each code block has a corresponding text block describing the expected result set. By default, SQL Sentry retains a year’s worth of alert data, so it is recommended you limit your time range to the last 30-90 days. As you go through alert tuning cycles, be sure to set the start times for each one, as the older alert data will still be there.
Here is a breakdown of each section in this SQL Notebook. These queries will return a count for each condition and will show how often those conditions have been fired. This will help you determine which conditions to target for tuning.
- Global General Condition counts with ActionType of SendEmail
- General Condition counts by target with ActionType of SendEmail
- Global Advisory Condition counts—send to Alerting Channels/Health Score
- Global Advisory Condition counts—send email
- Advisory Condition counts by target—send to Alerting Channels/Health Score
- Advisory Condition counts by target—send email
I hope this helps remove alert noise and maximizes the value of SQL Sentry.