Jump to content

Lesson Learned #262: Database Wait Stats and Log Analytics.


Recommended Posts

Guest Jose_Manuel_Jurado
Posted

Yesterday, we received a question from our customer that needs to know if it is possible to receive an email or alert about the main database wait stats usage for performance monitoring. Following, I would like to share an example how to do it.

 

 

 

Once we have enabled in our database the option of diagnostics setting to capture the database wait statistics this information will be saved in a specific table AutoDiagnostics in the Category DatabaseWaitStatistics.

 

 

 

Basically, we need to filter by the resource that we want to monitor and add some logic to calculate the delta.

 

 

 

 

 

AzureDiagnostics

| where Category == "DatabaseWaitStatistics"

| where ResourceId =~ '/SUBSCRIPTIONS/XXXX-XXXX-XXX-XXX-D6C13FEF4316/RESOURCEGROUPS/ResourceGroupName/PROVIDERS/MICROSOFT.SQL/SERVERS/Servername/DATABASES/DatabaseName'

| where TimeGenerated >= ago(10m)

| project delta_wait_time_ms_d, wait_type_s

| summarize total_wait_time_in_ms = sum(delta_wait_time_ms_d) / 1000

by wait_type_s

| sort by total_wait_time_in_ms desc

| extend Rank=row_rank(total_wait_time_in_ms)

 

 

 

 

 

Once we run this query we have:

 

 

 

672x482vv2.png.8827f622b0905efc834f457537660874.png

 

 

 

With this Kusto Query already implemented, basically, we could create an alert using the button New alert rule:

 

 

 

710x340vv2.png.8835dffcb73737b9d2c17c66e22aa605.png

 

 

 

and configure the alert and the details needed:

 

 

 

740x577vv2.png.3f9d36702a4685934f3244c55ce5bf45.png

 

 

 

 

 

Enjoy!

 

Continue reading...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...