Skip to content

Commit c459e4e

Browse files
committed
Grafana Monitoring Updates
Grafana Monitoring Updates
1 parent c6dc991 commit c459e4e

32 files changed

+8244
-286
lines changed
11.5 KB
Binary file not shown.
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
SET NOCOUNT ON;
2+
-- Last updated February 26, 2019
3+
;WITH [Waits] AS (
4+
SELECT
5+
[wait_type],
6+
[wait_time_ms] / 1000.0 AS [WaitS],
7+
([wait_time_ms] - [signal_wait_time_ms]) / 1000.0 AS [ResourceS],
8+
[signal_wait_time_ms] / 1000.0 AS [SignalS],
9+
[waiting_tasks_count] AS [WaitCount],
10+
100.0 * [wait_time_ms] / SUM ([wait_time_ms]) OVER() AS [Percentage],
11+
ROW_NUMBER() OVER(ORDER BY [wait_time_ms] DESC) AS [RowNum]
12+
FROM sys.dm_os_wait_stats
13+
WHERE [wait_type] NOT IN (
14+
-- These wait types are almost 100% never a problem and so they are
15+
-- filtered out to avoid them skewing the results. Click on the URL
16+
-- for more information.
17+
N'BROKER_EVENTHANDLER', -- https://www.sqlskills.com/help/waits/BROKER_EVENTHANDLER
18+
N'BROKER_RECEIVE_WAITFOR', -- https://www.sqlskills.com/help/waits/BROKER_RECEIVE_WAITFOR
19+
N'BROKER_TASK_STOP', -- https://www.sqlskills.com/help/waits/BROKER_TASK_STOP
20+
N'BROKER_TO_FLUSH', -- https://www.sqlskills.com/help/waits/BROKER_TO_FLUSH
21+
N'BROKER_TRANSMITTER', -- https://www.sqlskills.com/help/waits/BROKER_TRANSMITTER
22+
N'CHECKPOINT_QUEUE', -- https://www.sqlskills.com/help/waits/CHECKPOINT_QUEUE
23+
N'CHKPT', -- https://www.sqlskills.com/help/waits/CHKPT
24+
N'CLR_AUTO_EVENT', -- https://www.sqlskills.com/help/waits/CLR_AUTO_EVENT
25+
N'CLR_MANUAL_EVENT', -- https://www.sqlskills.com/help/waits/CLR_MANUAL_EVENT
26+
N'CLR_SEMAPHORE', -- https://www.sqlskills.com/help/waits/CLR_SEMAPHORE
27+
N'CXCONSUMER', -- https://www.sqlskills.com/help/waits/CXCONSUMER
28+
-- Maybe comment these four out if you have mirroring issues
29+
N'DBMIRROR_DBM_EVENT', -- https://www.sqlskills.com/help/waits/DBMIRROR_DBM_EVENT
30+
N'DBMIRROR_EVENTS_QUEUE', -- https://www.sqlskills.com/help/waits/DBMIRROR_EVENTS_QUEUE
31+
N'DBMIRROR_WORKER_QUEUE', -- https://www.sqlskills.com/help/waits/DBMIRROR_WORKER_QUEUE
32+
N'DBMIRRORING_CMD', -- https://www.sqlskills.com/help/waits/DBMIRRORING_CMD
33+
N'DIRTY_PAGE_POLL', -- https://www.sqlskills.com/help/waits/DIRTY_PAGE_POLL
34+
N'DISPATCHER_QUEUE_SEMAPHORE', -- https://www.sqlskills.com/help/waits/DISPATCHER_QUEUE_SEMAPHORE
35+
N'EXECSYNC', -- https://www.sqlskills.com/help/waits/EXECSYNC
36+
N'FSAGENT', -- https://www.sqlskills.com/help/waits/FSAGENT
37+
N'FT_IFTS_SCHEDULER_IDLE_WAIT', -- https://www.sqlskills.com/help/waits/FT_IFTS_SCHEDULER_IDLE_WAIT
38+
N'FT_IFTSHC_MUTEX', -- https://www.sqlskills.com/help/waits/FT_IFTSHC_MUTEX
39+
-- Maybe comment these six out if you have AG issues
40+
N'HADR_CLUSAPI_CALL', -- https://www.sqlskills.com/help/waits/HADR_CLUSAPI_CALL
41+
N'HADR_FILESTREAM_IOMGR_IOCOMPLETION', -- https://www.sqlskills.com/help/waits/HADR_FILESTREAM_IOMGR_IOCOMPLETION
42+
N'HADR_LOGCAPTURE_WAIT', -- https://www.sqlskills.com/help/waits/HADR_LOGCAPTURE_WAIT
43+
N'HADR_NOTIFICATION_DEQUEUE', -- https://www.sqlskills.com/help/waits/HADR_NOTIFICATION_DEQUEUE
44+
N'HADR_TIMER_TASK', -- https://www.sqlskills.com/help/waits/HADR_TIMER_TASK
45+
N'HADR_WORK_QUEUE', -- https://www.sqlskills.com/help/waits/HADR_WORK_QUEUE
46+
N'KSOURCE_WAKEUP', -- https://www.sqlskills.com/help/waits/KSOURCE_WAKEUP
47+
N'LAZYWRITER_SLEEP', -- https://www.sqlskills.com/help/waits/LAZYWRITER_SLEEP
48+
N'LOGMGR_QUEUE', -- https://www.sqlskills.com/help/waits/LOGMGR_QUEUE
49+
N'MEMORY_ALLOCATION_EXT', -- https://www.sqlskills.com/help/waits/MEMORY_ALLOCATION_EXT
50+
N'ONDEMAND_TASK_QUEUE', -- https://www.sqlskills.com/help/waits/ONDEMAND_TASK_QUEUE
51+
N'PARALLEL_REDO_DRAIN_WORKER', -- https://www.sqlskills.com/help/waits/PARALLEL_REDO_DRAIN_WORKER
52+
N'PARALLEL_REDO_LOG_CACHE', -- https://www.sqlskills.com/help/waits/PARALLEL_REDO_LOG_CACHE
53+
N'PARALLEL_REDO_TRAN_LIST', -- https://www.sqlskills.com/help/waits/PARALLEL_REDO_TRAN_LIST
54+
N'PARALLEL_REDO_WORKER_SYNC', -- https://www.sqlskills.com/help/waits/PARALLEL_REDO_WORKER_SYNC
55+
N'PARALLEL_REDO_WORKER_WAIT_WORK', -- https://www.sqlskills.com/help/waits/PARALLEL_REDO_WORKER_WAIT_WORK
56+
N'PREEMPTIVE_OS_FLUSHFILEBUFFERS', -- https://www.sqlskills.com/help/waits/PREEMPTIVE_OS_FLUSHFILEBUFFERS
57+
N'PREEMPTIVE_XE_GETTARGETSTATE', -- https://www.sqlskills.com/help/waits/PREEMPTIVE_XE_GETTARGETSTATE
58+
N'PWAIT_ALL_COMPONENTS_INITIALIZED', -- https://www.sqlskills.com/help/waits/PWAIT_ALL_COMPONENTS_INITIALIZED
59+
N'PWAIT_DIRECTLOGCONSUMER_GETNEXT', -- https://www.sqlskills.com/help/waits/PWAIT_DIRECTLOGCONSUMER_GETNEXT
60+
N'QDS_PERSIST_TASK_MAIN_LOOP_SLEEP', -- https://www.sqlskills.com/help/waits/QDS_PERSIST_TASK_MAIN_LOOP_SLEEP
61+
N'QDS_ASYNC_QUEUE', -- https://www.sqlskills.com/help/waits/QDS_ASYNC_QUEUE
62+
N'QDS_CLEANUP_STALE_QUERIES_TASK_MAIN_LOOP_SLEEP',
63+
-- https://www.sqlskills.com/help/waits/QDS_CLEANUP_STALE_QUERIES_TASK_MAIN_LOOP_SLEEP
64+
N'QDS_SHUTDOWN_QUEUE', -- https://www.sqlskills.com/help/waits/QDS_SHUTDOWN_QUEUE
65+
N'REDO_THREAD_PENDING_WORK', -- https://www.sqlskills.com/help/waits/REDO_THREAD_PENDING_WORK
66+
N'REQUEST_FOR_DEADLOCK_SEARCH', -- https://www.sqlskills.com/help/waits/REQUEST_FOR_DEADLOCK_SEARCH
67+
N'RESOURCE_QUEUE', -- https://www.sqlskills.com/help/waits/RESOURCE_QUEUE
68+
N'SERVER_IDLE_CHECK', -- https://www.sqlskills.com/help/waits/SERVER_IDLE_CHECK
69+
N'SLEEP_BPOOL_FLUSH', -- https://www.sqlskills.com/help/waits/SLEEP_BPOOL_FLUSH
70+
N'SLEEP_DBSTARTUP', -- https://www.sqlskills.com/help/waits/SLEEP_DBSTARTUP
71+
N'SLEEP_DCOMSTARTUP', -- https://www.sqlskills.com/help/waits/SLEEP_DCOMSTARTUP
72+
N'SLEEP_MASTERDBREADY', -- https://www.sqlskills.com/help/waits/SLEEP_MASTERDBREADY
73+
N'SLEEP_MASTERMDREADY', -- https://www.sqlskills.com/help/waits/SLEEP_MASTERMDREADY
74+
N'SLEEP_MASTERUPGRADED', -- https://www.sqlskills.com/help/waits/SLEEP_MASTERUPGRADED
75+
N'SLEEP_MSDBSTARTUP', -- https://www.sqlskills.com/help/waits/SLEEP_MSDBSTARTUP
76+
N'SLEEP_SYSTEMTASK', -- https://www.sqlskills.com/help/waits/SLEEP_SYSTEMTASK
77+
N'SLEEP_TASK', -- https://www.sqlskills.com/help/waits/SLEEP_TASK
78+
N'SLEEP_TEMPDBSTARTUP', -- https://www.sqlskills.com/help/waits/SLEEP_TEMPDBSTARTUP
79+
N'SNI_HTTP_ACCEPT', -- https://www.sqlskills.com/help/waits/SNI_HTTP_ACCEPT
80+
N'SOS_WORK_DISPATCHER', -- https://www.sqlskills.com/help/waits/SOS_WORK_DISPATCHER
81+
N'SP_SERVER_DIAGNOSTICS_SLEEP', -- https://www.sqlskills.com/help/waits/SP_SERVER_DIAGNOSTICS_SLEEP
82+
N'SQLTRACE_BUFFER_FLUSH', -- https://www.sqlskills.com/help/waits/SQLTRACE_BUFFER_FLUSH
83+
N'SQLTRACE_INCREMENTAL_FLUSH_SLEEP', -- https://www.sqlskills.com/help/waits/SQLTRACE_INCREMENTAL_FLUSH_SLEEP
84+
N'SQLTRACE_WAIT_ENTRIES', -- https://www.sqlskills.com/help/waits/SQLTRACE_WAIT_ENTRIES
85+
N'VDI_CLIENT_OTHER', -- https://www.sqlskills.com/help/waits/VDI_CLIENT_OTHER
86+
N'WAIT_FOR_RESULTS', -- https://www.sqlskills.com/help/waits/WAIT_FOR_RESULTS
87+
N'WAITFOR', -- https://www.sqlskills.com/help/waits/WAITFOR
88+
N'WAITFOR_TASKSHUTDOWN', -- https://www.sqlskills.com/help/waits/WAITFOR_TASKSHUTDOWN
89+
N'WAIT_XTP_RECOVERY', -- https://www.sqlskills.com/help/waits/WAIT_XTP_RECOVERY
90+
N'WAIT_XTP_HOST_WAIT', -- https://www.sqlskills.com/help/waits/WAIT_XTP_HOST_WAIT
91+
N'WAIT_XTP_OFFLINE_CKPT_NEW_LOG', -- https://www.sqlskills.com/help/waits/WAIT_XTP_OFFLINE_CKPT_NEW_LOG
92+
N'WAIT_XTP_CKPT_CLOSE', -- https://www.sqlskills.com/help/waits/WAIT_XTP_CKPT_CLOSE
93+
N'XE_DISPATCHER_JOIN', -- https://www.sqlskills.com/help/waits/XE_DISPATCHER_JOIN
94+
N'XE_DISPATCHER_WAIT', -- https://www.sqlskills.com/help/waits/XE_DISPATCHER_WAIT
95+
N'XE_TIMER_EVENT' -- https://www.sqlskills.com/help/waits/XE_TIMER_EVENT
96+
)
97+
AND [waiting_tasks_count] > 0
98+
)
99+
INSERT INTO dbo.WaitStats
100+
( [Collection_Time], RowNum, [WaitType] , [Wait_S] , [Resource_S] , [Signal_S] , [WaitCount] , [Percentage] )
101+
SELECT [Collection_Time] = GETDATE(), RowNum,
102+
w.wait_type, w.WaitS, w.ResourceS, w.SignalS, w.WaitCount, w.Percentage
103+
FROM [Waits] AS w
104+
ORDER BY [Collection_Time], WaitS DESC, ResourceS DESC, SignalS DESC
105+
/*
106+
SELECT
107+
W1.[Collection_Time],
108+
MAX ([W1].[WaitType]) AS [WaitType],
109+
CAST (MAX ([W1].[Wait_S]) AS DECIMAL (16,2)) AS [Wait_S],
110+
CAST (MAX ([W1].[Resource_S]) AS DECIMAL (16,2)) AS [Resource_S],
111+
CAST (MAX ([W1].[Signal_S]) AS DECIMAL (16,2)) AS [Signal_S],
112+
MAX ([W1].[WaitCount]) AS [WaitCount],
113+
CAST (MAX ([W1].[Percentage]) AS DECIMAL (5,2)) AS [Percentage],
114+
CAST (MAX ([W1].[AvgWait_S]) AS DECIMAL (16,4)) AS [AvgWait_S],
115+
CAST (MAX ([W1].[AvgRes_S]) AS DECIMAL (16,4)) AS [AvgRes_S],
116+
CAST (MAX ([W1].[AvgSig_S]) AS DECIMAL (16,4)) AS [AvgSig_S]
117+
--,MAX([Help/Info URL]) AS [Help/Info URL]
118+
FROM dbo.WaitStats AS [W1]
119+
INNER JOIN dbo.WaitStats AS [W2] ON [W2].[RowNum] <= [W1].[RowNum] AND W1.Collection_Time = W2.Collection_Time
120+
GROUP BY W1.Collection_Time, [W1].[RowNum]
121+
HAVING SUM ([W2].[Percentage]) - MAX( [W1].[Percentage] ) < 99 -- percentage threshold
122+
ORDER BY Collection_Time, Percentage desc
123+
*/
124+
GO

Baselining/Baselining.ssmssqlproj

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@
3131
</LogicalFolder>
3232
<LogicalFolder Name="Queries" Type="0" Sorted="true">
3333
<Items>
34+
<FileNode Name="(dba) Collect Metrics - Wait Stats.sql">
35+
<AssociatedConnectionMoniker>8c91a03d-f9b4-46c0-a305-b5dcc79ff907:(local):True</AssociatedConnectionMoniker>
36+
<AssociatedConnSrvName>(local)</AssociatedConnSrvName>
37+
<AssociatedConnUserName />
38+
<FullPath>(dba) Collect Metrics - Wait Stats.sql</FullPath>
39+
</FileNode>
3440
<FileNode Name="Agent Operator [Ajay Dwivedi].sql">
3541
<AssociatedConnectionMoniker>8c91a03d-f9b4-46c0-a305-b5dcc79ff907:(local):True</AssociatedConnectionMoniker>
3642
<AssociatedConnSrvName>(local)</AssociatedConnSrvName>
@@ -145,6 +151,12 @@
145151
<AssociatedConnUserName />
146152
<FullPath>PerfMon-Dbatools-DataCollection.sql</FullPath>
147153
</FileNode>
154+
<FileNode Name="QRY-ExtendedEvents-Queries.sql">
155+
<AssociatedConnectionMoniker>8c91a03d-f9b4-46c0-a305-b5dcc79ff907:(local):True</AssociatedConnectionMoniker>
156+
<AssociatedConnSrvName>(local)</AssociatedConnSrvName>
157+
<AssociatedConnUserName />
158+
<FullPath>QRY-ExtendedEvents-Queries.sql</FullPath>
159+
</FileNode>
148160
<FileNode Name="SCH-ExtendedEvents-Queries.sql">
149161
<AssociatedConnectionMoniker>8c91a03d-f9b4-46c0-a305-b5dcc79ff907:(local):True</AssociatedConnectionMoniker>
150162
<AssociatedConnSrvName>(local)</AssociatedConnSrvName>

0 commit comments

Comments
 (0)