| '+convert(varchar,DATEADD(mi, DATEDIFF(mi, GETUTCDATE(), GETDATE()), collection_time_utc),120)+' | ' + +''+sql_instance+' | ' + +''+(case when data_size_mb < 1024 then convert(varchar,data_size_mb)+' mb' + when data_size_mb < 1024*1024 then convert(varchar,floor(data_size_mb/1024))+' gb' + when data_size_mb >= 1024*1024 then convert(varchar,floor(data_size_mb/(1024*1024)))+' tb' + else 'xx' end)+' | ' + +''+(case when data_used_mb < 1024 then convert(varchar,data_used_mb)+' mb' + when data_used_mb < 1024*1024 then convert(varchar,floor(data_used_mb/1024))+' gb' + when data_used_mb >= 1024*1024 then convert(varchar,floor(data_used_mb/(1024*1024)))+' tb' + else 'xx' end)+' | ' + +''+convert(varchar,data_used_pct)+' | ' + +''+(case when log_size_mb < 1024 then convert(varchar,log_size_mb)+' mb' + when log_size_mb < 1024*1024 then convert(varchar,floor(log_size_mb/1024))+' gb' + when log_size_mb >= 1024*1024 then convert(varchar,floor(log_size_mb/(1024*1024)))+' tb' + else 'xx' end)+' | ' + +''+(case when log_used_mb < 1024 then convert(varchar,log_used_mb)+' mb' + when log_used_mb < 1024*1024 then convert(varchar,floor(log_used_mb/1024))+' gb' + when log_used_mb >= 1024*1024 then convert(varchar,floor(log_used_mb/(1024*1024)))+' tb' + else 'xx' end)+' | ' + +''+convert(varchar,log_used_pct)+' | ' + +''+(case when version_store_mb < 1024 then convert(varchar,version_store_mb)+' mb' + when version_store_mb < 1024*1024 then convert(varchar,floor(version_store_mb/1024))+' gb' + when version_store_mb >= 1024*1024 then convert(varchar,floor(version_store_mb/(1024*1024)))+' tb' + else 'xx' end)+' | ' + +''+convert(varchar,version_store_pct)+' | ' + +'|
| '+convert(varchar,DATEADD(mi, DATEDIFF(mi, GETUTCDATE(), GETDATE()), collection_time_utc),120)+' | ' - +''+sql_instance+' | ' - +''+(case when data_size_mb < 1024 then convert(varchar,data_size_mb)+' mb' - when data_size_mb < 1024*1024 then convert(varchar,floor(data_size_mb/1024))+' gb' - when data_size_mb >= 1024*1024 then convert(varchar,floor(data_size_mb/(1024*1024)))+' tb' - else 'xx' end)+' | ' - +''+(case when data_used_mb < 1024 then convert(varchar,data_used_mb)+' mb' - when data_used_mb < 1024*1024 then convert(varchar,floor(data_used_mb/1024))+' gb' - when data_used_mb >= 1024*1024 then convert(varchar,floor(data_used_mb/(1024*1024)))+' tb' - else 'xx' end)+' | ' - +''+convert(varchar,data_used_pct)+' | ' - +''+(case when log_size_mb < 1024 then convert(varchar,log_size_mb)+' mb' - when log_size_mb < 1024*1024 then convert(varchar,floor(log_size_mb/1024))+' gb' - when log_size_mb >= 1024*1024 then convert(varchar,floor(log_size_mb/(1024*1024)))+' tb' - else 'xx' end)+' | ' - +''+(case when log_used_mb < 1024 then convert(varchar,log_used_mb)+' mb' - when log_used_mb < 1024*1024 then convert(varchar,floor(log_used_mb/1024))+' gb' - when log_used_mb >= 1024*1024 then convert(varchar,floor(log_used_mb/(1024*1024)))+' tb' - else 'xx' end)+' | ' - +''+convert(varchar,log_used_pct)+' | ' - +''+(case when version_store_mb < 1024 then convert(varchar,version_store_mb)+' mb' - when version_store_mb < 1024*1024 then convert(varchar,floor(version_store_mb/1024))+' gb' - when version_store_mb >= 1024*1024 then convert(varchar,floor(version_store_mb/(1024*1024)))+' tb' - else 'xx' end)+' | ' - +''+convert(varchar,version_store_pct)+' | ' - +'|
| No alert qualifying data found. Latest collection @ '+convert(varchar,@_collection_time_tempdb_health,120)+' | ||||||||||
| '+convert(varchar,DATEADD(mi, DATEDIFF(mi, GETUTCDATE(), GETDATE()), collection_time_utc),120)+' | ' + +''+sql_instance+' | ' + +''+[database_name]+' | ' + +''+recovery_model+' | ' + +''+log_reuse_wait_desc+' | ' + +''+(case when log_size_mb < 1024 then convert(varchar,log_size_mb)+' mb' + when log_size_mb < 1024*1024 then convert(varchar,floor(log_size_mb/1024))+' gb' + when log_size_mb >= 1024*1024 then convert(varchar,floor(log_size_mb/(1024*1024)))+' tb' + else 'xx' end)+' | ' + +''+convert(varchar,exists_valid_autogrowing_file)+' | ' + +''+(case when log_used_mb < 1024 then convert(varchar,log_used_mb)+' mb' + when log_used_mb < 1024*1024 then convert(varchar,floor(log_used_mb/1024))+' gb' + when log_used_mb >= 1024*1024 then convert(varchar,floor(log_used_mb/(1024*1024)))+' tb' + else 'xx' end)+' | ' + +''+convert(varchar,log_used_pct)+' | ' + +''+coalesce([login_name],'')+' | ' + +''+coalesce([program_name],'')+' | ' + +'
| ''+convert(varchar,DATEADD(mi, DATEDIFF(mi, GETUTCDATE(), GETDATE()), collection_time_utc),120)+'' | '' - +''''+sql_instance+'' | '' - +''''+[database_name]+'' | '' - +''''+recovery_model+'' | '' - +''''+log_reuse_wait_desc+'' | '' - +''''+(case when log_size_mb < 1024 then convert(varchar,log_size_mb)+'' mb'' - when log_size_mb < 1024*1024 then convert(varchar,floor(log_size_mb/1024))+'' gb'' - when log_size_mb >= 1024*1024 then convert(varchar,floor(log_size_mb/(1024*1024)))+'' tb'' - else ''xx'' end)+'' | '' - +''''+convert(varchar,exists_valid_autogrowing_file)+'' | '' - +''''+(case when log_used_mb < 1024 then convert(varchar,log_used_mb)+'' mb'' - when log_used_mb < 1024*1024 then convert(varchar,floor(log_used_mb/1024))+'' gb'' - when log_used_mb >= 1024*1024 then convert(varchar,floor(log_used_mb/(1024*1024)))+'' tb'' - else ''xx'' end)+'' | '' - +''''+convert(varchar,log_used_pct)+'' | '' - +''''+coalesce([login_name],'''')+'' | '' - +''''+coalesce([program_name],'''')+'' | '' - +''
| No alert qualifying data found. Latest collection @ '+convert(varchar,@_collection_time_log_space_health,120)+' | ||||||||||
| '+sql_instance+' | ' - +''+replica_database+' | ' - +''+convert(varchar,is_primary_replica)+' | ' - +''+isnull(ag_listener,'')+' | ' - +''+convert(varchar,is_local)+' | ' - +''+isnull(synchronization_state_desc,'')+' | ' - +''+isnull(synchronization_health_desc,'')+' | ' - +''+isnull((case when latency_seconds < 60 then convert(varchar,floor(latency_seconds))+' sec' - when latency_seconds < 3600 then convert(varchar,floor(latency_seconds/60))+' min' - when latency_seconds < 86400 then convert(varchar,floor(latency_seconds/3600))+' hrs' - when latency_seconds >= 86400 then convert(varchar,floor(latency_seconds/86400))+' days' - else '' end),' ')+' | ' - +''+ - isnull((case when log_send_queue_size < 1024 then convert(varchar,log_send_queue_size)+' kb' - when log_send_queue_size < 1024*1024 then convert(varchar,log_send_queue_size/1024)+' mb' - when log_send_queue_size < 1024*1024*1024 then convert(varchar,floor(log_send_queue_size/(1024*1024)))+' gb' - when log_send_queue_size >= 1024*1024*1024 then convert(varchar,floor(log_send_queue_size/(1024*1024*1024)))+' tb' - else '' end),' ')+' | ' - +'' - +isnull((case when redo_queue_size < 1024 then convert(varchar,redo_queue_size)+' kb' - when redo_queue_size < 1024*1024 then convert(varchar,redo_queue_size/1024)+' mb' - when redo_queue_size < 1024*1024*1024 then convert(varchar,floor(redo_queue_size/(1024*1024)))+' gb' - when redo_queue_size >= 1024*1024*1024 then convert(varchar,floor(redo_queue_size/(1024*1024*1024)))+' tb' + + -- Decide if alert data is present, or add empty info row + if exists (select * from #aghs) + begin + ;with t_cte as ( + select ' | |
| '+sql_instance+' | ' + +''+replica_database+' | ' + +''+convert(varchar,is_primary_replica)+' | ' + +''+isnull(ag_listener,'')+' | ' + +''+convert(varchar,is_local)+' | ' + +''+isnull(synchronization_state_desc,'')+' | ' + +''+isnull(synchronization_health_desc,'')+' | ' + +''+isnull((case when latency_seconds < 60 then convert(varchar,floor(latency_seconds))+' sec' + when latency_seconds < 3600 then convert(varchar,floor(latency_seconds/60))+' min' + when latency_seconds < 86400 then convert(varchar,floor(latency_seconds/3600))+' hrs' + when latency_seconds >= 86400 then convert(varchar,floor(latency_seconds/86400))+' days' else '' end),' ')+' | ' - +''+convert(varchar,is_suspended)+' | ' - +''+ + isnull((case when log_send_queue_size < 1024 then convert(varchar,log_send_queue_size)+' kb' + when log_send_queue_size < 1024*1024 then convert(varchar,log_send_queue_size/1024)+' mb' + when log_send_queue_size < 1024*1024*1024 then convert(varchar,floor(log_send_queue_size/(1024*1024)))+' gb' + when log_send_queue_size >= 1024*1024*1024 then convert(varchar,floor(log_send_queue_size/(1024*1024*1024)))+' tb' + else '' end),' ')+' | ' + +'' + +isnull((case when redo_queue_size < 1024 then convert(varchar,redo_queue_size)+' kb' + when redo_queue_size < 1024*1024 then convert(varchar,redo_queue_size/1024)+' mb' + when redo_queue_size < 1024*1024*1024 then convert(varchar,floor(redo_queue_size/(1024*1024)))+' gb' + when redo_queue_size >= 1024*1024*1024 then convert(varchar,floor(redo_queue_size/(1024*1024*1024)))+' tb' + else '' end),' ')+' | ' + +''+convert(varchar,is_suspended)+' | ' + +'' as [table_row] + from #aghs + where 1=1 + ) + --select * from t_cte; + select @_table_data = coalesce(@_table_data+' '+[table_row],[table_row]) + from t_cte; + end + else + begin + if @hide_row_if_no_data = 1 + set @collect_ag_latency = 0; + + select top 1 @_collection_time_ag_health = DATEADD(mi, DATEDIFF(mi, GETUTCDATE(), GETDATE()), updated_date_utc) + from dbo.ag_health_state_all_servers aghs + order by updated_date_utc desc; + + set @_table_data = '
| No alert qualifying data found. Latest collection @ '+convert(varchar,@_collection_time_ag_health,120)+' | ||||||||||
| '+sql_instance+' | ' + +''+[host_name]+' | ' + +''+disk_volume+' | ' + +''+(case when capacity_mb < 1024 then convert(varchar,capacity_mb)+' mb' + when capacity_mb < 1024*1024 then convert(varchar,floor(capacity_mb/1024))+' gb' + when capacity_mb >= 1024*1024 then convert(varchar,floor(capacity_mb/(1024*1024)))+' tb' + else 'xx' end)+' | ' + +''+(case when free_mb < 1024 then convert(varchar,free_mb)+' mb' + when free_mb < 1024*1024 then convert(varchar,floor(free_mb/1024))+' gb' + when free_mb >= 1024*1024 then convert(varchar,floor(free_mb/(1024*1024)))+' tb' + else 'xx' end)+' | ' + +''+[state]+' | ' + +''+convert(varchar,used_pct)+' | ' + +'||||
| '+sql_instance+' | ' - +''+[host_name]+' | ' - +''+disk_volume+' | ' - +''+(case when capacity_mb < 1024 then convert(varchar,capacity_mb)+' mb' - when capacity_mb < 1024*1024 then convert(varchar,floor(capacity_mb/1024))+' gb' - when capacity_mb >= 1024*1024 then convert(varchar,floor(capacity_mb/(1024*1024)))+' tb' - else 'xx' end)+' | ' - +''+(case when free_mb < 1024 then convert(varchar,free_mb)+' mb' - when free_mb < 1024*1024 then convert(varchar,floor(free_mb/1024))+' gb' - when free_mb >= 1024*1024 then convert(varchar,floor(free_mb/(1024*1024)))+' tb' - else 'xx' end)+' | ' - +''+[state]+' | ' - +''+convert(varchar,used_pct)+' | ' - +'||||
| No alert qualifying data found. Latest collection @ '+convert(varchar,@_collection_time_disk_health,120)+' | ||||||||||
| Report Time | ' set @_table_data = NULL; + -- Get temp table with alert data + if object_id('tempdb..#offline_servers') is not null + drop table #offline_servers; + select sql_instance, [host_name], + is_available, + is_linked_server_working = case when is_available = 0 then null else is_linked_server_working end, + [tsql jobs server] = collector_tsql_jobs_server, + [powershell jobs server] = collector_powershell_jobs_server, + [perfmon data server] = data_destination_sql_instance, + last_unavailability_time_utc + into #offline_servers + from dbo.instance_details id + where is_enabled = 1 + and (is_available = 0 or is_linked_server_working = 0); + if @verbose > 1 begin - ;with t_cte as ( - select sql_instance, [host_name], - is_available, - is_linked_server_working = case when is_available = 0 then null else is_linked_server_working end, - [tsql jobs server] = collector_tsql_jobs_server, - [powershell jobs server] = collector_powershell_jobs_server, - [perfmon data server] = data_destination_sql_instance, - last_unavailability_time_utc - from dbo.instance_details id - where is_enabled = 1 - and (is_available = 0 or is_linked_server_working = 0) - ) select [RunningQuery], t_cte.* - from t_cte + from #offline_servers t_cte full outer join (select [RunningQuery] = 'Offline Servers') rq on 1=1; end - ;with tsu as ( - select sql_instance, [host_name], - is_available, - is_linked_server_working = case when is_available = 0 then null else is_linked_server_working end, - [tsql jobs server] = collector_tsql_jobs_server, - [powershell jobs server] = collector_powershell_jobs_server, - [perfmon data server] = data_destination_sql_instance, - last_unavailability_time_utc - from dbo.instance_details id - where is_enabled = 1 - and (is_available = 0 or is_linked_server_working = 0) - ) - ,t_cte as ( - select '||||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| '+sql_instance+' | ' - +''+[host_name]+' | ' - +''+convert(varchar,is_available)+' | ' - +''+isnull(convert(varchar,is_linked_server_working),'')+' | ' - +''+[tsql jobs server]+' | ' - +''+[powershell jobs server]+' | ' - +''+[perfmon data server]+' | ' - +''+isnull(convert(varchar,last_unavailability_time_utc,120),'')+' | ' - +'|||
| '+sql_instance+' | ' + +''+[host_name]+' | ' + +''+convert(varchar,is_available)+' | ' + +''+isnull(convert(varchar,is_linked_server_working),'')+' | ' + +''+[tsql jobs server]+' | ' + +''+[powershell jobs server]+' | ' + +''+[perfmon data server]+' | ' + +''+isnull(convert(varchar,last_unavailability_time_utc,120),'')+' | ' + +'|||
| No alert qualifying data found. Latest collection @ '+convert(varchar,@_collection_time_offline_servers,120)+' | ||||||||||
| '+convert(varchar,DATEADD(mi, DATEDIFF(mi, GETUTCDATE(), GETDATE()), CollectionTimeUTC),120)+' | ' - +''+sql_instance+' | ' - +''+JobName+' | ' - +'' - +isnull((case when [Job-Delay-Minutes] < 60 then convert(varchar,floor([Job-Delay-Minutes]))+' min' - when [Job-Delay-Minutes] < 60*24 then convert(varchar,floor([Job-Delay-Minutes]/60))+' hrs' - when [Job-Delay-Minutes] >= 60*24 then convert(varchar,floor([Job-Delay-Minutes]/(60*24)))+' days' - else convert(varchar,[Job-Delay-Minutes]) end),'')+' | ' - +''+convert(varchar,Last_RunTime,120)+' | ' - +''+isnull((case when Last_Run_Duration_Seconds < 60 then convert(varchar,floor(Last_Run_Duration_Seconds))+' sec' - when Last_Run_Duration_Seconds < 3600 then convert(varchar,floor(Last_Run_Duration_Seconds/60))+' min' - when Last_Run_Duration_Seconds < 86400 then convert(varchar,floor(Last_Run_Duration_Seconds/3600))+' hrs' - when Last_Run_Duration_Seconds >= 86400 then convert(varchar,floor(Last_Run_Duration_Seconds/86400))+' days' - else convert(varchar,Last_Run_Duration_Seconds) end),'')+' | ' - +''+Last_Run_Outcome+' | ' - +''+isnull((case when Successfull_Execution_ClockTime_Threshold_Minutes < 60 then convert(varchar,floor(Successfull_Execution_ClockTime_Threshold_Minutes))+' min' - when Successfull_Execution_ClockTime_Threshold_Minutes < 1440 then convert(varchar,floor(Successfull_Execution_ClockTime_Threshold_Minutes/60))+' hrs' - when Successfull_Execution_ClockTime_Threshold_Minutes >= 86400 then convert(varchar,floor(Successfull_Execution_ClockTime_Threshold_Minutes/1440))+' days' - else '' end),0)+' | ' - +''+convert(varchar,Last_Successful_ExecutionTime,120)+' | ' - +'||
| '+convert(varchar,DATEADD(mi, DATEDIFF(mi, GETUTCDATE(), GETDATE()), CollectionTimeUTC),120)+' | ' + +''+sql_instance+' | ' + +''+JobName+' | ' + +'' + +isnull((case when [Job-Delay-Minutes] < 60 then convert(varchar,floor([Job-Delay-Minutes]))+' min' + when [Job-Delay-Minutes] < 60*24 then convert(varchar,floor([Job-Delay-Minutes]/60))+' hrs' + when [Job-Delay-Minutes] >= 60*24 then convert(varchar,floor([Job-Delay-Minutes]/(60*24)))+' days' + else convert(varchar,[Job-Delay-Minutes]) end),'')+' | ' + +''+convert(varchar,Last_RunTime,120)+' | ' + +''+isnull((case when Last_Run_Duration_Seconds < 60 then convert(varchar,floor(Last_Run_Duration_Seconds))+' sec' + when Last_Run_Duration_Seconds < 3600 then convert(varchar,floor(Last_Run_Duration_Seconds/60))+' min' + when Last_Run_Duration_Seconds < 86400 then convert(varchar,floor(Last_Run_Duration_Seconds/3600))+' hrs' + when Last_Run_Duration_Seconds >= 86400 then convert(varchar,floor(Last_Run_Duration_Seconds/86400))+' days' + else convert(varchar,Last_Run_Duration_Seconds) end),'')+' | ' + +''+Last_Run_Outcome+' | ' + +''+isnull((case when Successfull_Execution_ClockTime_Threshold_Minutes < 60 then convert(varchar,floor(Successfull_Execution_ClockTime_Threshold_Minutes))+' min' + when Successfull_Execution_ClockTime_Threshold_Minutes < 1440 then convert(varchar,floor(Successfull_Execution_ClockTime_Threshold_Minutes/60))+' hrs' + when Successfull_Execution_ClockTime_Threshold_Minutes >= 86400 then convert(varchar,floor(Successfull_Execution_ClockTime_Threshold_Minutes/1440))+' days' + else '' end),0)+' | ' + +''+convert(varchar,Last_Successful_ExecutionTime,120)+' | ' + +'||
| No alert qualifying data found. Latest collection @ '+convert(varchar,@_collection_time_sqlmonitor_jobs,120)+' | ||||||||||
| '+convert(varchar,DATEADD(mi, DATEDIFF(mi, GETUTCDATE(), GETDATE()), CollectionTimeUTC),120)+' | ' - +''+sql_instance+' | ' - +''+[database_name]+' | ' - +''+isnull(recovery_model,'')+' | ' - +''+isnull(convert(varchar,full_latency_days),'')+' days'+' | ' - +'' - +isnull((case when diff_latency_hours < 24 then convert(varchar,floor(diff_latency_hours))+' hrs' - when diff_latency_hours >= 24 then convert(varchar,convert(numeric(20,2),diff_latency_hours/24))+' days' - else convert(varchar,diff_latency_hours) end),'')+' | ' - +'' - +isnull((case when tlog_latency_minutes < 60 then convert(varchar,floor(tlog_latency_minutes))+' min' - when tlog_latency_minutes < 60*24 then convert(varchar,convert(numeric(20,2),tlog_latency_minutes/60))+' hrs' - when tlog_latency_minutes >= 60*24 then convert(varchar,convert(numeric(20,2),tlog_latency_minutes/(60*24)))+' days' - else convert(varchar,tlog_latency_minutes) end),'')+' | ' - +''+isnull(convert(varchar,DATEADD(mi, DATEDIFF(mi, GETUTCDATE(), GETDATE()), full_backup_time_utc),120),'')+' | ' - +''+isnull(convert(varchar,DATEADD(mi, DATEDIFF(mi, GETUTCDATE(), GETDATE()), diff_backup_time_utc),120),'')+' | ' - +''+isnull(convert(varchar,DATEADD(mi, DATEDIFF(mi, GETUTCDATE(), GETDATE()), tlog_backup_time_utc),120),'')+' | ' - +''+isnull(convert(varchar,DATEADD(mi, DATEDIFF(mi, GETUTCDATE(), GETDATE()), database_creation_date_utc),120),'')+' | ' - +'
| '+convert(varchar,DATEADD(mi, DATEDIFF(mi, GETUTCDATE(), GETDATE()), CollectionTimeUTC),120)+' | ' + +''+sql_instance+' | ' + +''+[database_name]+' | ' + +''+isnull(recovery_model,'')+' | ' + +''+isnull(convert(varchar,full_latency_days),'')+' days'+' | ' + +'' + +isnull((case when diff_latency_hours < 24 then convert(varchar,floor(diff_latency_hours))+' hrs' + when diff_latency_hours >= 24 then convert(varchar,convert(numeric(20,2),diff_latency_hours/24))+' days' + else convert(varchar,diff_latency_hours) end),'')+' | ' + +'' + +isnull((case when tlog_latency_minutes < 60 then convert(varchar,floor(tlog_latency_minutes))+' min' + when tlog_latency_minutes < 60*24 then convert(varchar,convert(numeric(20,2),tlog_latency_minutes/60))+' hrs' + when tlog_latency_minutes >= 60*24 then convert(varchar,convert(numeric(20,2),tlog_latency_minutes/(60*24)))+' days' + else convert(varchar,tlog_latency_minutes) end),'')+' | ' + +''+isnull(convert(varchar,DATEADD(mi, DATEDIFF(mi, GETUTCDATE(), GETDATE()), full_backup_time_utc),120),'')+' | ' + +''+isnull(convert(varchar,DATEADD(mi, DATEDIFF(mi, GETUTCDATE(), GETDATE()), diff_backup_time_utc),120),'')+' | ' + +''+isnull(convert(varchar,DATEADD(mi, DATEDIFF(mi, GETUTCDATE(), GETDATE()), tlog_backup_time_utc),120),'')+' | ' + +''+isnull(convert(varchar,DATEADD(mi, DATEDIFF(mi, GETUTCDATE(), GETDATE()), database_creation_date_utc),120),'')+' | ' + +'
| No alert qualifying data found. Latest collection @ '+convert(varchar,@_collection_time_backup_history,120)+' | ||||||||||
| Error Number | Severity | Error Message (Generic) | [sql_instance | occurrences | last_occurred] | |||||||
|---|---|---|---|---|---|---|---|---|---|---|
| '+convert(varchar(20),ah.[error_number])+' | ' + +''+convert(varchar(20),ah.[error_severity])+' | ' + +''+ah.[error_message]+' | ' + +''+ah.[sql_instance | occurrences | last_occurred]+' | ' + +'|||||||
| No alert qualifying data found. Latest collection @ '+convert(varchar,@_collection_time_alert_history,120)+' | ||||||||||
'+@_html_log_space_health+'
' else '' end) +(case when @collect_ag_latency = 1 then N''+@_html_ag_health+'
' else '' end) +(case when @collect_disk_space = 1 then N''+@_html_disk_health+'
' else '' end) + +(case when @collect_alert_history = 1 then N''+@_html_alert_history+'
' else '' end) +(case when @collect_offline_servers = 1 then N''+@_html_offline_servers+'
' else '' end) +(case when @collect_sqlmonitor_jobs = 1 then N''+@_html_sqlmonitor_jobs+'
' else '' end) +(case when @collect_backup_history = 1 then N''+@_html_backup_history+'
' else '' end) diff --git a/DDLs/SCH-usp_GetAllServerInfo.sql b/DDLs/SCH-usp_GetAllServerInfo.sql index 67a7dce..ce53193 100644 --- a/DDLs/SCH-usp_GetAllServerInfo.sql +++ b/DDLs/SCH-usp_GetAllServerInfo.sql @@ -79,23 +79,22 @@ BEGIN DECLARE @_sql NVARCHAR(max); DECLARE @_isLocalHost bit = 0; create table #server_details ( - srv_name varchar(125), at_server_name varchar(125), machine_name varchar(125), server_name varchar(125), - ip varchar(30), domain varchar(125), host_name varchar(125), fqdn varchar(255), host_distribution varchar(200), - processor_name varchar(200), product_version varchar(30), edition varchar(50), sqlserver_start_time_utc datetime2, - os_cpu decimal(20,2), sql_cpu decimal(20,2), pcnt_kernel_mode decimal(20,2), page_faults_kb decimal(20,2), - blocked_counts int, blocked_duration_max_seconds bigint, total_physical_memory_kb bigint, - available_physical_memory_kb bigint, system_high_memory_signal_state varchar(20), - physical_memory_in_use_kb decimal(20,2), memory_grants_pending int, connection_count int, + srv_name varchar(125), at_server_name varchar(125), machine_name varchar(125), server_name varchar(125), + ip varchar(30), domain varchar(125), host_name varchar(125), fqdn varchar(255), host_distribution varchar(200), + processor_name varchar(200), product_version varchar(30), edition varchar(50), sqlserver_start_time_utc datetime2, + os_cpu decimal(20,2), sql_cpu decimal(20,2), pcnt_kernel_mode decimal(20,2), page_faults_kb decimal(20,2), + blocked_counts int, blocked_duration_max_seconds bigint, total_physical_memory_kb bigint, + available_physical_memory_kb bigint, system_high_memory_signal_state varchar(20), + physical_memory_in_use_kb decimal(20,2), memory_grants_pending int, connection_count int, active_requests_count int, waits_per_core_per_minute decimal(20,2), avg_disk_wait_ms decimal(20,2), [avg_disk_latency_ms] int, - os_start_time_utc datetime2, cpu_count smallint, scheduler_count smallint, major_version_number smallint, - minor_version_number smallint, max_server_memory_mb int, page_life_expectancy int, memory_consumers int, + os_start_time_utc datetime2, cpu_count smallint, scheduler_count smallint, major_version_number smallint, + minor_version_number smallint, max_server_memory_mb int, page_life_expectancy int, memory_consumers int, target_server_memory_kb bigint, total_server_memory_kb bigint, performance_counters__latency_minutes int, xevent_metrics__latency_minutes int, WhoIsActive__latency_minutes int, - os_task_list__latency_minutes int, disk_space__latency_minutes int, file_io_stats__latency_minutes int, - sql_agent_job_stats__latency_minutes int, memory_clerks__latency_minutes int, wait_stats__latency_minutes int, - BlitzIndex__latency_days int, BlitzIndex_Mode0__latency_days int, BlitzIndex_Mode1__latency_days int, - BlitzIndex_Mode4__latency_days int + disk_space__latency_minutes int, file_io_stats__latency_minutes int, sql_agent_job_stats__latency_minutes int, + memory_clerks__latency_minutes int, wait_stats__latency_minutes int, BlitzIndex__latency_days int, + BlitzIndex_Mode0__latency_days int, BlitzIndex_Mode1__latency_days int, BlitzIndex_Mode4__latency_days int ); declare @_srv_name nvarchar (125); @@ -146,7 +145,6 @@ BEGIN declare @_file_io_stats__latency_minutes int; declare @_sql_agent_job_stats__latency_minutes int; declare @_memory_clerks__latency_minutes int; - declare @_os_task_list__latency_minutes int; declare @_performance_counters__latency_minutes int; declare @_xevent_metrics__latency_minutes int; declare @_xevent_metrics_queries__latency_minutes int; @@ -321,7 +319,6 @@ BEGIN set @_file_io_stats__latency_minutes = NULL; set @_sql_agent_job_stats__latency_minutes = NULL; set @_memory_clerks__latency_minutes = NULL; - set @_os_task_list__latency_minutes = NULL; set @_performance_counters__latency_minutes = NULL; set @_xevent_metrics__latency_minutes = NULL; set @_xevent_metrics_queries__latency_minutes = NULL; @@ -2344,57 +2341,6 @@ on 1=1"; end - -- [os_task_list__latency_minutes] => Create SQL Statement to Execute - if @_linked_server_failed = 0 and ( @output is null or exists (select * from @_tbl_output_columns where column_name = 'os_task_list__latency_minutes') ) - begin - delete from @_result; - set @_sql = " -"+(case when @enable_lock_timeout = 1 then '' else '--' end)+"SET LOCK_TIMEOUT 60000; -SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; -select [latency_minutes] = coalesce(latency_minutes,dummy_latency_minutes) -from -( select top 1 [latency_minutes] = datediff(minute,collection_time_utc,getutcdate()) from dbo.vw_os_task_list - where 1=1 - and collection_time_utc >= dateadd(minute,-120,getutcdate()) - --and [host_name] = CONVERT(varchar(125),COALESCE(SERVERPROPERTY('ComputerNamePhysicalNetBIOS'),SERVERPROPERTY('ServerName'))) - order by collection_time_utc desc -) od -full outer join (select [dummy_latency_minutes] = 10080) dmy -- 7 days -on 1=1"; - -- Decorate for remote query if LinkedServer - if @_isLocalHost = 0 - set @_sql = 'select * from openquery(' + QUOTENAME(@_srv_name) + ', "'+ @_sql + '")'; - - begin try - insert @_result (col_int) - exec (@_sql); - - -- set @_ip - select @_os_task_list__latency_minutes = col_int from @_result; - end try - begin catch - select @_errorNumber = Error_Number() - ,@_errorSeverity = Error_Severity() - ,@_errorState = Error_State() - ,@_errorLine = Error_Line() - ,@_errorMessage = Error_Message(); - - insert [dbo].[sma_errorlog] - ([collection_time], [function_name], [function_call_arguments], [server], [error], [remark], [executed_by], [executor_program_name]) - select [collection_time] = @_start_time, [function_name] = 'usp_GetAllServerInfo', - [function_call_arguments] = 'os_task_list__latency_minutes', [server] = @_srv_name, [error] = @_errorMessage, - [remark] = null, [executed_by] = SUSER_NAME(), [executor_program_name] = @_caller_program; - - set @_errorMessage = 'Error Details => Severity: '+CONVERT(varchar(125),isnull(@_errorSeverity,''))+ - '. State: '+CONVERT(varchar(125),isnull(@_errorState,'')) + - '. Error Line: '+CONVERT(varchar(125),isnull(@_errorLine,'')) + - '. Error Message::: '+ @_errorMessage; - - print @_crlf+@_long_star_line+@_crlf+'Error occurred while executing below query on ['+@_srv_name+'].'+@_crlf+@_errorMessage+@_crlf+' '+@_sql+@_long_star_line+@_crlf; - end catch - end - - -- [disk_space__latency_minutes] => Create SQL Statement to Execute if @_linked_server_failed = 0 and ( @output is null or exists (select * from @_tbl_output_columns where column_name = 'disk_space__latency_minutes') ) begin @@ -2842,10 +2788,10 @@ on 1=1"; [connection_count], [active_requests_count], [waits_per_core_per_minute], [avg_disk_wait_ms], [avg_disk_latency_ms], [os_start_time_utc], [cpu_count], [scheduler_count], [major_version_number], [minor_version_number], [max_server_memory_mb], [page_life_expectancy], [memory_consumers], [target_server_memory_kb], [total_server_memory_kb], [performance_counters__latency_minutes], - [xevent_metrics__latency_minutes], [WhoIsActive__latency_minutes], [os_task_list__latency_minutes], - [disk_space__latency_minutes], [file_io_stats__latency_minutes], [sql_agent_job_stats__latency_minutes], - [memory_clerks__latency_minutes], [wait_stats__latency_minutes], [BlitzIndex__latency_days], - [BlitzIndex_Mode0__latency_days], [BlitzIndex_Mode1__latency_days], [BlitzIndex_Mode4__latency_days] + [xevent_metrics__latency_minutes], [WhoIsActive__latency_minutes], [disk_space__latency_minutes], + [file_io_stats__latency_minutes], [sql_agent_job_stats__latency_minutes], [memory_clerks__latency_minutes], + [wait_stats__latency_minutes], [BlitzIndex__latency_days], [BlitzIndex_Mode0__latency_days], + [BlitzIndex_Mode1__latency_days], [BlitzIndex_Mode4__latency_days] ) select [srv_name] = @_srv_name ,[@@servername] = @_at_server_name @@ -2889,7 +2835,6 @@ on 1=1"; ,[performance_counters__latency_minutes] = @_performance_counters__latency_minutes ,[xevent_metrics__latency_minutes] = @_xevent_metrics__latency_minutes ,[WhoIsActive__latency_minutes] = @_WhoIsActive__latency_minutes - ,[os_task_list__latency_minutes] = @_os_task_list__latency_minutes ,[disk_space__latency_minutes] = @_disk_space__latency_minutes ,[file_io_stats__latency_minutes] = @_file_io_stats__latency_minutes ,[sql_agent_job_stats__latency_minutes] = @_sql_agent_job_stats__latency_minutes diff --git a/DDLs/SCH-usp_collect_performance_metrics.sql b/DDLs/SCH-usp_collect_performance_metrics.sql index 8256272..7ffec29 100644 --- a/DDLs/SCH-usp_collect_performance_metrics.sql +++ b/DDLs/SCH-usp_collect_performance_metrics.sql @@ -21,8 +21,9 @@ alter procedure [dbo].[usp_collect_performance_metrics] as begin /* Created By: Ajay Dwivedi (https://ajaydwivedi.com/go/sqlmonitor) - Version: 1.0 - Modification: 2025-Jan-30 - Integrate in SQLMonitor + Version: 2026-Jan-31 + Modification: 2026-Jan-31 - Cleanup RingBuffer Code + 2025-Jan-30 - Integrate in SQLMonitor exec dbo.[usp_collect_performance_metrics] @verbose = 2; exec dbo.[usp_collect_performance_metrics] @metrics = 'dm_os_sys_memory'; @@ -33,6 +34,8 @@ begin exec dbo.[usp_collect_performance_metrics] @metrics = 'dm_os_memory_clerks'; exec dbo.[usp_collect_performance_metrics] @metrics = 'dm_os_performance_counters_deprecated_features'; + MS Docs -> https://learn.microsoft.com/en-us/sql/relational-databases/performance-monitor/use-sql-server-objects?view=sql-server-ver17#SQLServerPOs + PERF_COUNTER_RAWCOUNT | Decimal | 65536 -> Raw counter value that does not require calculations, and represents one sample. -> Could not find any records for this type in sys.dm_os_performance_counters @@ -206,14 +209,11 @@ begin from ( SELECT top 1 [collection_time_utc] = DATEADD(mi, DATEDIFF(mi, getdate(), getutcdate()), collection_time), - [system_cpu_utilization] = CASE WHEN system_cpu_utilization_post_sp2 IS NOT NULL THEN system_cpu_utilization_post_sp2 ELSE system_cpu_utilization_pre_sp2 END, - [sql_cpu_utilization] = CASE WHEN sql_cpu_utilization_post_sp2 IS NOT NULL THEN sql_cpu_utilization_post_sp2 ELSE sql_cpu_utilization_pre_sp2 END + [system_cpu_utilization], [sql_cpu_utilization] FROM ( SELECT record.value('(Record/@id)[1]', 'int') AS record_id, DATEADD (ms, -1 * (ts_now - [timestamp]), SYSDATETIME()) AS collection_time, - 100-record.value('(Record/SchedulerMonitorEvent/SystemHealth/SystemIdle)[1]', 'int') AS system_cpu_utilization_post_sp2, - record.value('(Record/SchedulerMonitorEvent/SystemHealth/ProcessUtilization)[1]', 'int') AS sql_cpu_utilization_post_sp2, - 100-record.value('(Record/SchedluerMonitorEvent/SystemHealth/SystemIdle)[1]', 'int') AS system_cpu_utilization_pre_sp2, - record.value('(Record/SchedluerMonitorEvent/SystemHealth/ProcessUtilization)[1]', 'int') AS sql_cpu_utilization_pre_sp2 + 100-record.value('(Record/SchedulerMonitorEvent/SystemHealth/SystemIdle)[1]', 'int') AS system_cpu_utilization, + record.value('(Record/SchedulerMonitorEvent/SystemHealth/ProcessUtilization)[1]', 'int') AS sql_cpu_utilization FROM ( SELECT timestamp, CONVERT (xml, record) AS record, cpu_ticks / (cpu_ticks/ms_ticks) as ts_now FROM sys.dm_os_ring_buffers cross apply sys.dm_os_sys_info WHERE ring_buffer_type = 'RING_BUFFER_SCHEDULER_MONITOR' diff --git a/DDLs/SCH-usp_create_agent_alerts.sql b/DDLs/SCH-usp_create_agent_alerts.sql index 5b69b61..5d70cd7 100644 --- a/DDLs/SCH-usp_create_agent_alerts.sql +++ b/DDLs/SCH-usp_create_agent_alerts.sql @@ -15,7 +15,8 @@ IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_NAME = 'u GO ALTER PROCEDURE dbo.usp_create_agent_alerts -( @verbose tinyint = 0, /* 0 - no messages, 1 - debug messages, 2 = debug messages + table results */ +( @drop_create_alert bit = 0, /* When enabled, drop the alert, and recreate */ + @verbose tinyint = 0, /* 0 - no messages, 1 - debug messages, 2 = debug messages + table results */ @alert_operator_name varchar(255) = null ) AS @@ -23,9 +24,11 @@ BEGIN /* https://learn.microsoft.com/en-us/sql/ssms/agent/use-tokens-in-job-steps?view=sql-server-ver16 - Version: 1.0.0 Pre-requisites: dbo.alert_categories, dbo.alert_history, dbo.usp_capture_alert_messages, job [(dba) Capture-AlertMessages] - Date: 2024-05-23 - Updated to include Sev 19-25 + + Version -> 2026-01-31 + 2026-01-31 - #3 - Infra to Track Server and Database Configuration Changes + 2024-05-23 - Updated to include Sev 19-25 EXEC dbo.usp_create_agent_alerts */ @@ -72,7 +75,15 @@ BEGIN WHILE @@fetch_status = 0 BEGIN - IF NOT EXISTS ( SELECT 1/0 FROM msdb.dbo.sysalerts WHERE name = @c_alert_name ) + IF ( @drop_create_alert = 1 + OR EXISTS ( SELECT 1/0 FROM msdb.dbo.sysalerts WHERE name = @c_alert_name + AND job_id = '00000000-0000-0000-0000-000000000000' ) + ) + BEGIN + EXECUTE msdb.dbo.sp_delete_alert @name = @c_alert_name; + END + + IF NOT EXISTS ( SELECT 1/0 FROM msdb.dbo.sysalerts WHERE name = @c_alert_name ) BEGIN EXECUTE msdb.dbo.sp_add_alert @name = @c_alert_name, @message_id = @c_alert_error_number, @severity = @c_error_severity, @enabled = 1, @delay_between_responses = 0, @include_event_description_in = 1, @job_name = N'(dba) Capture-AlertMessages'; diff --git a/DDLs/SCH-usp_enable_page_compression.sql b/DDLs/SCH-usp_enable_page_compression.sql index 7a9f19d..1039720 100644 --- a/DDLs/SCH-usp_enable_page_compression.sql +++ b/DDLs/SCH-usp_enable_page_compression.sql @@ -45,11 +45,6 @@ BEGIN select table_name, index_name from (values ('dbo.performance_counters',NULL), ('dbo.performance_counters','nci_counter_collection_time_utc'), - ('dbo.os_task_list',NULL), - ('dbo.os_task_list','nci_cpu_time_seconds'), - ('dbo.os_task_list','nci_memory_kb'), - ('dbo.os_task_list','nci_user_name'), - ('dbo.os_task_list','nci_window_title'), ('dbo.wait_stats',NULL), ('dbo.xevent_metrics', NULL), ('dbo.xevent_metrics','uq_xevent_metrics'), diff --git a/DDLs/SCH-usp_wrapper_GetAllServerCollectedData.sql b/DDLs/SCH-usp_wrapper_GetAllServerCollectedData.sql index d67d914..9df30e3 100644 --- a/DDLs/SCH-usp_wrapper_GetAllServerCollectedData.sql +++ b/DDLs/SCH-usp_wrapper_GetAllServerCollectedData.sql @@ -29,8 +29,9 @@ AS BEGIN /* - Version: 2024-02-10 - Date: 2024-02-10 - #26 Track Status of SQLAgent Service + Version: 2026-01-31 + Date: 2026-01-31 - #3 Infra to Track Server and Database Configuration Changes + 2024-02-10 - #26 Track Status of SQLAgent Service 2024-01-08 - Backup History 2023-10-17 - Add Latency Dashboard for AG 2023-08-30 - Adding @schedule_minutes parameter @@ -69,6 +70,17 @@ BEGIN DECLARE @recipients varchar(500); /* Folks who receive the failure mail */ DECLARE @send_error_mail bit; /* Send mail on failure */ + DECLARE @_parallelize_collection bit = 0; + DECLARE @_parallel_threads int = 1; + DECLARE @_thread_counter int = 1; + DECLARE @_parallel_job_command nvarchar(max); + DECLARE @_parallel_job_name nvarchar(255); + DECLARE @_parallel_job_id BINARY(16); + DECLARE @_parallel_job_step_name nvarchar(125); + DECLARE @_parallel_job_database nvarchar(125) = DB_NAME(); + DECLARE @_tbl_parallel_jobs table (job_name nvarchar(125)); + DECLARE @_is_job_running bit = 0; + set @_caller_program = case when HOST_NAME() like '(dba) Get-AllServerCollectedData%' then HOST_NAME() else PROGRAM_NAME() @@ -84,7 +96,7 @@ BEGIN IF @step_name NOT IN ('dbo.sql_agent_jobs_all_servers','dbo.disk_space_all_servers','dbo.log_space_consumers_all_servers', 'dbo.tempdb_space_usage_all_servers','dbo.ag_health_state_all_servers','dbo.backups_all_servers', - 'dbo.services_all_servers') + 'dbo.services_all_servers','dbo.alert_history_all_servers') THROW 50001, '''step_name'' Parameter value is invalid.', 1; -- Variables for Try/Catch Block @@ -247,6 +259,200 @@ else EXEC sp_executesql @_sql, @_params, @verbose, @truncate_table, @has_staging_table, @schedule_minutes; END + IF @step_name = 'dbo.alert_history_all_servers' + BEGIN + SET @_parallelize_collection = 0; + SET @_parallel_threads = 1; + SET @_thread_counter = 1; + SET @_parallel_job_command = NULL; + SET @_parallel_job_name = NULL; + SET @_parallel_job_id = NULL; + SET @_parallel_job_step_name = NULL; + SET @_parallel_job_database = DB_NAME(); + DELETE FROM @_tbl_parallel_jobs; + SET @_is_job_running = 0; + + -- Fetch params related to parallelization of jobs + select @_parallelize_collection = convert(bit, case when param_value = 'yes' then 1 else 0 end) + from dbo.sma_params p where p.param_key = 'alert_history_all_servers-parallelize'; + if @_parallelize_collection = 1 + select @_parallel_threads = convert(int, param_value) from dbo.sma_params p where p.param_key = 'alert_history_all_servers-parallel-threads'; + + IF @_parallelize_collection = 0 + BEGIN + IF @verbose > 0 + PRINT 'Populate dbo.alert_history_all_servers in serial manner.'; + SET @_sql = N'-- Collect Latest Alert details from All Servers Every 2 Minutes + if ( (select isnull(max(collection_time_utc),''2023-01-01 00:00'') from dbo.alert_history_all_servers) < dateadd(minute, -@schedule_minutes, getutcdate()) ) + begin + exec dbo.usp_GetAllServerCollectedData + @result_to_table = ''dbo.alert_history_all_servers'', + @verbose = @verbose, + @truncate_table = @truncate_table, + @has_staging_table = @has_staging_table + end + else + print ''Did not meet schedule requirement.''+char(13);'; + IF @verbose > 0 + PRINT @_sql; + EXEC sp_executesql @_sql, @_params, @verbose, @truncate_table, @has_staging_table, @schedule_minutes; + END + ELSE + BEGIN -- Parallelize + IF @verbose > 0 + PRINT 'Populate dbo.alert_history_all_servers in Parallel threads'; + + WHILE @_thread_counter <= @_parallel_threads + BEGIN + IF @verbose > 0 + PRINT 'Loop '+convert(varchar,@_thread_counter)+' of '+convert(varchar,@_parallel_threads)+'..'; + + SET @_parallel_job_id = NULL; + SET @_parallel_job_name = '(dba) Get-AllServerAlertHistory - '+convert(varchar,@_parallel_threads)+'-Threaded-Job-'+convert(varchar,@_thread_counter); + SET @_parallel_job_step_name = 'Get-AllServerAlertHistory - '+convert(varchar,@_parallel_threads)+'-Threaded-Job-'+convert(varchar,@_thread_counter); + + BEGIN TRY + -- Create temporary parallel jobs if required + IF NOT EXISTS (SELECT * FROM msdb.dbo.sysjobs_view WHERE name = @_parallel_job_name) + BEGIN + IF @verbose > 0 + PRINT 'Creating temp job '+QUOTENAME(@_parallel_job_name)+'..' + SET @_parallel_job_command = N'EXEC dbo.usp_GetAllServerCollectedData @result_to_table = ''dbo.alert_history_all_servers'', @has_staging_table = 0, @truncate_table = 0, @verbose = 0, + @paginate = 1, @page_count = '+convert(varchar,@_parallel_threads)+', @page_no = '+convert(varchar,@_thread_counter)+';'; + + EXEC msdb.dbo.sp_add_job @job_name=@_parallel_job_name, @category_name=N'(dba) SQLMonitor', @enabled=1, @job_id = @_parallel_job_id OUTPUT, @notify_level_eventlog=0, + @description=N'Job created as part of [(dba) Get-AllServerAlertHistory] to collect VolatileInfo in parallel threads. https://ajaydwivedi.com/github/sqlmonitor'; + + IF @verbose > 0 + PRINT 'adding step to job '+QUOTENAME(@_parallel_job_name)+'..' + EXEC msdb.dbo.sp_add_jobstep @job_id=@_parallel_job_id, @step_name=@_parallel_job_step_name, @step_id=1, @subsystem=N'TSQL', @command=@_parallel_job_command, @database_name=@_parallel_job_database, @flags=12; + + IF @verbose > 0 + PRINT 'set starting step for job '+QUOTENAME(@_parallel_job_name)+'..' + EXEC msdb.dbo.sp_update_job @job_id = @_parallel_job_id, @start_step_id = 1; + IF @verbose > 0 + PRINT 'set jobserver for job '+QUOTENAME(@_parallel_job_name)+'..' + EXEC msdb.dbo.sp_add_jobserver @job_id = @_parallel_job_id, @server_name = N'(local)'; + END + + -- Start job if not running + set @_is_job_running = dbo.fn_IsJobRunning(@_parallel_job_name); + insert @_tbl_parallel_jobs select @_parallel_job_name; + if @_is_job_running = 0 + exec msdb.dbo.sp_start_job @job_name = @_parallel_job_name; + END TRY + BEGIN CATCH + IF @verbose > 0 + PRINT 'Start Catch Block of dbo.alert_history_all_servers in Parallel threads.' + + SELECT @_errorNumber = Error_Number() + ,@_errorSeverity = Error_Severity() + ,@_errorState = Error_State() + ,@_errorLine = Error_Line() + ,@_errorMessage = Error_Message(); + + IF @verbose >= 1 + BEGIN + PRINT CHAR(13); + PRINT '@_errorNumber => '+convert(varchar,@_errorNumber); + PRINT '@_errorState => '+convert(varchar,@_errorState); + PRINT '@_errorMessage => '+@_errorMessage; + PRINT CHAR(13); + END + + set @_errorMessage = 'Error Details => Severity: '+convert(varchar,isnull(@_errorSeverity,''))+ + '. State: '+convert(varchar,isnull(@_errorState,'')) + + '. Error Line: '+convert(varchar,isnull(@_errorLine,'')) + + '. Error Message::: '+ @_errorMessage; + insert [dbo].[sma_errorlog] + ([collection_time], [function_name], [function_call_arguments], [server], [error], [remark], [executed_by], [executor_program_name]) + select [collection_time] = @_collection_time, [function_name] = 'usp_wrapper_GetAllServerCollectedData', + [function_call_arguments] = @step_name+'-Parallel', [server] = null, [error] = @_errorMessage, + [remark] = null, [executed_by] = SUSER_NAME(), [executor_program_name] = @_caller_program; + END CATCH + + SET @_thread_counter += 1; + END + + -- Once parallel jobs are started, then wait for them to finish + if @verbose >= 2 + select [RunningQuery] = '@_tbl_parallel_jobs', job_name from @_tbl_parallel_jobs; + print 'Wait for 5 seconds before checking status'; + + WAITFOR DELAY '00:00:10'; + + SELECT j.name AS job_name, + ja.start_execution_date AS StartTime, + COALESCE(CONVERT(VARCHAR(5),ABS(DATEDIFF(DAY,(GETDATE()-ja.start_execution_date),'1900-01-01'))) + ' ' + +CONVERT(VARCHAR(10),(GETDATE()-ja.start_execution_date),108),'00 00:00:00') AS [Duration] + FROM msdb.dbo.sysjobactivity ja + LEFT JOIN msdb.dbo.sysjobhistory jh ON ja.job_history_id = jh.instance_id + JOIN msdb.dbo.sysjobs j ON ja.job_id = j.job_id + WHERE ja.session_id = (SELECT TOP 1 session_id FROM msdb.dbo.syssessions ORDER BY session_id DESC) + AND start_execution_date is not null + AND stop_execution_date is null; + + while 1=1 + begin + -- Get one job & check its running status + set @_parallel_job_name = null; + set @_is_job_running = 0; + select top 1 @_parallel_job_name = job_name from @_tbl_parallel_jobs; + + -- If no jobs to process, then exit loop + if @_parallel_job_name is null + begin + if @verbose > 0 + print '@_parallel_job_name is null is null. So exit loop' + break; + end + else + begin -- if job to process is found, then check its running status + if @verbose > 0 + print ' Checking running status for job '+quotename(@_parallel_job_name); + --exec dbo.usp_get_job_running_status @job_name = @_parallel_job_name, @is_running_OUTPUT = @_is_job_running; + set @_is_job_running = dbo.fn_IsJobRunning(@_parallel_job_name); + if @_is_job_running = 0 -- if job is not running, then delete its entry, and proceed for next job + begin + if @verbose > 0 + print ' Job '+quotename(@_parallel_job_name)+' is not running. So delete its entry from @_tbl_parallel_jobs'; + delete from @_tbl_parallel_jobs where job_name = @_parallel_job_name; + continue; + end + else + begin + if @verbose > 0 + print ' Job '+quotename(@_parallel_job_name)+' is running. So wait for another 2 seconds'; + waitfor delay '00:00:02'; + end + end + end + + /* + BEGIN TRAN + if exists (select * from sys.tables where name = 'all_server_volatile_info' and is_memory_optimized = 0) + exec ('truncate table dbo.all_server_volatile_info'); + else + delete from dbo.all_server_volatile_info; + + set @_sql = N' + ;with cte_volatile_info as ( + select '+@_output_columns+', row_id = row_number()over(partition by srv_name order by srv_name) + from dbo.all_server_volatile_info__staging + ) + insert dbo.all_server_volatile_info + ('+@_output_columns+') + select '+@_output_columns+' from cte_volatile_info where row_id = 1; + '; + if @verbose > 0 + print @_sql; + exec (@_sql); + COMMIT TRAN + */ + END + END + + END TRY -- Perform main logic inside Try/Catch BEGIN CATCH IF @verbose > 0 diff --git a/DDLs/SCH-usp_wrapper_GetAllServerInfo.sql b/DDLs/SCH-usp_wrapper_GetAllServerInfo.sql index 081a58c..531f4d6 100644 --- a/DDLs/SCH-usp_wrapper_GetAllServerInfo.sql +++ b/DDLs/SCH-usp_wrapper_GetAllServerInfo.sql @@ -302,7 +302,7 @@ else if @schedule_minutes = 0 or not exists (select 1/0 from dbo.all_server_collection_latency_info where collection_time >= dateadd(minute,-@schedule_minutes,getdate())) begin exec dbo.usp_GetAllServerInfo @result_to_table = ''dbo.all_server_collection_latency_info'', @verbose = @verbose, - @output = ''srv_name, host_name, performance_counters__latency_minutes, xevent_metrics__latency_minutes, WhoIsActive__latency_minutes, os_task_list__latency_minutes, disk_space__latency_minutes, file_io_stats__latency_minutes, sql_agent_job_stats__latency_minutes, memory_clerks__latency_minutes, wait_stats__latency_minutes, BlitzIndex__latency_days, BlitzIndex_Mode0__latency_days, BlitzIndex_Mode1__latency_days, BlitzIndex_Mode4__latency_days''; + @output = ''srv_name, host_name, performance_counters__latency_minutes, xevent_metrics__latency_minutes, WhoIsActive__latency_minutes, disk_space__latency_minutes, file_io_stats__latency_minutes, sql_agent_job_stats__latency_minutes, memory_clerks__latency_minutes, wait_stats__latency_minutes, BlitzIndex__latency_days, BlitzIndex_Mode0__latency_days, BlitzIndex_Mode1__latency_days, BlitzIndex_Mode4__latency_days''; end else print ''Did not meet schedule requirement.''+char(13);'; diff --git a/Grafana-Dashboards/Alert-Engine/Alert-Rules-SQLMonitor.yaml b/Grafana-Dashboards/Alert-Engine/Alert-Rules-SQLMonitor.yaml deleted file mode 100644 index 5d82562..0000000 --- a/Grafana-Dashboards/Alert-Engine/Alert-Rules-SQLMonitor.yaml +++ /dev/null @@ -1,46 +0,0 @@ -apiVersion: 1 -groups: - - orgId: 1 - name: SQLMonitor - folder: SQLServer - interval: 2m - rules: - - uid: 6gZECDEVz - title: Blocking - condition: Blockings - data: - - refId: Blockings - relativeTimeRange: - from: 300 - to: 0 - datasourceUid: ygPVA4snk - model: - datasource: - type: mssql - uid: ygPVA4snk - editorMode: code - format: table - hide: false - intervalMs: 1000 - maxDataPoints: 43200 - rawQuery: true - rawSql: "declare @blocked_counts_threshold int = 2;\r\ndeclare @blocked_duration_max_seconds_threshold bigint = 300;\r\ndeclare @connection_count_threshold int = 300;\r\ndeclare @sql nvarchar(max);\r\ndeclare @params nvarchar(max);\r\nset @params = N'@blocked_counts_threshold int, @blocked_duration_max_seconds_threshold bigint, @connection_count_threshold int';\r\nset quoted_identifier off;\r\nset @sql = \"\r\n;with t_cte as (\r\n\tselect\tsrv_name, blocked_counts, blocked_duration_max_seconds, connection_count\r\n\tfrom dbo.all_server_volatile_info_history h\r\n\twhere h.collection_time = (select max(i.collection_time) from dbo.all_server_volatile_info_history i)\r\n)\r\nselect srv_name, blocked_counts, \r\n [details] = quotename(srv_name) +' has '+ convert(varchar,blocked_counts)+' blocking(s) for over '+ convert(varchar,blocked_duration_max_seconds) + ' seconds'\r\nfrom t_cte cte\r\nwhere 1=1\r\nand ( -- Condition 01 -> Blocked over 4 hours\r\n\t\t(\tblocked_counts > 0\r\n\t\t\tand blocked_duration_max_seconds >= (4*60*60) -- 4 hours\r\n\t\t)\r\n\t\t-- Condition 02 -> More than @blocked_counts_threshold blockings for over @blocked_duration_max_seconds_threshold\r\n\tor\t(\tblocked_counts >= @blocked_counts_threshold\r\n\t\t\tand blocked_duration_max_seconds >= @blocked_duration_max_seconds_threshold\r\n\t\t)\r\n\t\t-- Condition 03 -> 50% blockings of @blocked_duration_max_seconds_threshold for over @blocked_duration_max_seconds_threshold when connections are over @connection_count_threshold \r\n or (\tconnection_count >= @connection_count_threshold \r\n\t\t\tand blocked_duration_max_seconds >= @blocked_duration_max_seconds_threshold/2\r\n\t\t\tand blocked_counts >= @blocked_counts_threshold\r\n\t\t)\r\n)\r\n\";\r\nset quoted_identifier off;\r\n--print @sql\r\nexec dbo.sp_executesql @sql, @params, @blocked_counts_threshold, @blocked_duration_max_seconds_threshold, @connection_count_threshold;" - refId: Blockings - sql: - columns: - - parameters: [] - type: function - groupBy: - - property: - type: string - type: groupBy - limit: 50 - noDataState: OK - execErrState: Error - for: 0s - annotations: - summary: '{{ $labels.details }}' - labels: - name: Blocking-SQLMonitor - target: sqlmonitor-slack - isPaused: false diff --git a/Grafana-Dashboards/Alert-Engine/Contact-Points-SQLMonitor.yaml b/Grafana-Dashboards/Alert-Engine/Contact-Points-SQLMonitor.yaml deleted file mode 100644 index d54d3a9..0000000 --- a/Grafana-Dashboards/Alert-Engine/Contact-Points-SQLMonitor.yaml +++ /dev/null @@ -1,20 +0,0 @@ -apiVersion: 1 -contactPoints: - - orgId: 1 - name: sqlmonitor-email - receivers: - - uid: xYXjjvEVz - type: email - settings: - addresses: sqlagentservice@gmail.com - singleEmail: false - disableResolveMessage: false - - orgId: 1 - name: sqlmonitor-slack - receivers: - - uid: udz8I1PVk - type: slack - settings: - recipient: '#sqlmonitor-alerts' - url: https://hooks.slack.com/services/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 - disableResolveMessage: false diff --git a/Grafana-Dashboards/Alert-Engine/Notification-Policies-SQLMonitor.yaml b/Grafana-Dashboards/Alert-Engine/Notification-Policies-SQLMonitor.yaml deleted file mode 100644 index 275f4b8..0000000 --- a/Grafana-Dashboards/Alert-Engine/Notification-Policies-SQLMonitor.yaml +++ /dev/null @@ -1,23 +0,0 @@ -apiVersion: 1 -policies: - - orgId: 1 - receiver: sqlmonitor-email - group_by: - - alertname - routes: - - receiver: sqlmonitor-slack - group_by: - - srv_name - - alertname - object_matchers: - - - target - - = - - sqlmonitor-slack - - receiver: sqlmonitor-email - group_by: - - srv_name - - alertname - object_matchers: - - - target - - = - - sqlmonitor-email diff --git a/Grafana-Dashboards/For-Internal-Use-Only/Monitoring - Live - All Servers - INTERNAL.json b/Grafana-Dashboards/For-Internal-Use-Only/Monitoring - Live - All Servers - INTERNAL.json index cabca20..ee75fa8 100644 --- a/Grafana-Dashboards/For-Internal-Use-Only/Monitoring - Live - All Servers - INTERNAL.json +++ b/Grafana-Dashboards/For-Internal-Use-Only/Monitoring - Live - All Servers - INTERNAL.json @@ -673,18 +673,6 @@ } ] }, - { - "matcher": { - "id": "byName", - "options": "os_task_list__latency_minutes" - }, - "properties": [ - { - "id": "displayName", - "value": "os_task_list_latency" - } - ] - }, { "matcher": { "id": "byName", @@ -806,7 +794,7 @@ "h": 10, "w": 24, "x": 0, - "y": 20 + "y": 2 }, "id": 850, "options": { @@ -823,7 +811,7 @@ "showHeader": true, "sortBy": [] }, - "pluginVersion": "11.2.0", + "pluginVersion": "11.3.1", "targets": [ { "datasource": { @@ -834,7 +822,7 @@ "format": "table", "hide": false, "rawQuery": true, - "rawSql": "declare @_latency_minutes_threshold int = 20;\r\ndeclare @_latency_days_threshold int = 3;\r\ndeclare @t_servers_exception table (srv_name varchar(125));\r\n\r\ninsert @t_servers_exception -- list of servers that have permanent issues\r\nvalues ('192.168.1.21'),('192.168.1.22');\r\n\r\nselect\tcli.srv_name, id.jobs_server,\r\n\t\tcli.performance_counters__latency_minutes,\r\n\t\txevent_metrics__latency_minutes = case when (cli.xevent_metrics__latency_minutes > @_latency_minutes_threshold*2 and vi.sql_cpu > 20 and si.major_version_number >= 11) then cli.xevent_metrics__latency_minutes \r\n\t\t\t\t\t\t\t\t\t\t\t\t\twhen cli.xevent_metrics__latency_minutes > @_latency_minutes_threshold then @_latency_minutes_threshold-1\r\n\t\t\t\t\t\t\t\t\t\t\t\t\telse cli.xevent_metrics__latency_minutes end,\r\n\t\tWhoIsActive__latency_minutes = case when cli.WhoIsActive__latency_minutes > @_latency_minutes_threshold*2 and vi.sql_cpu > 20 then cli.WhoIsActive__latency_minutes \r\n\t\t\t\t\t\t\t\t\t\t\t\t\twhen cli.WhoIsActive__latency_minutes > @_latency_minutes_threshold then @_latency_minutes_threshold-1\r\n\t\t\t\t\t\t\t\t\t\t\t\t\telse cli.WhoIsActive__latency_minutes end,\r\n\t\tcli.os_task_list__latency_minutes,\r\n\t\tcli.disk_space__latency_minutes, \r\n\t\tcli.file_io_stats__latency_minutes,\r\n\t\tcli.sql_agent_job_stats__latency_minutes,\r\n\t\tcli.memory_clerks__latency_minutes,\r\n\t\tcli.wait_stats__latency_minutes,\r\n\t\tcli.BlitzIndex__latency_days,\r\n\t\tcli.BlitzIndex_Mode0__latency_days,\r\n\t\t--cli.BlitzIndex_Mode1__latency_days,\r\n\t\t--cli.BlitzIndex_Mode4__latency_days,\r\n\t\t--collection_time = DATEADD(mi, DATEDIFF(mi, getdate(), getutcdate()), cli.collection_time)\r\n\t\t[Issues] = (case when cli.performance_counters__latency_minutes > @_latency_minutes_threshold then 'performance_counters,' else '' end)+\r\n\t\t\t\t\t(case when cli.xevent_metrics__latency_minutes > @_latency_minutes_threshold*2 and vi.sql_cpu > 20 and si.major_version_number >= 11 then 'xevent_metrics' else '' end)+\r\n\t\t\t\t\t(case when cli.WhoIsActive__latency_minutes > @_latency_minutes_threshold*2 and vi.sql_cpu > 20 then 'WhoIsActive,' else '' end)+\r\n\t\t\t\t\t(case when cli.os_task_list__latency_minutes > @_latency_minutes_threshold then 'os_task_list,' else '' end)+\r\n\t\t\t\t\t(case when cli.disk_space__latency_minutes > @_latency_minutes_threshold*3 then 'disk_space,' else '' end)+\r\n\t\t\t\t\t(case when cli.file_io_stats__latency_minutes > @_latency_minutes_threshold*3 then 'file_io_stats,' else '' end)+\r\n\t\t\t\t\t(case when cli.wait_stats__latency_minutes > @_latency_minutes_threshold*2 then 'wait_stats,' else '' end)+\r\n\t\t\t\t\t(case when cli.sql_agent_job_stats__latency_minutes > @_latency_minutes_threshold*1.5 then 'sql_agent_job_stats,' else '' end)+\r\n\t\t\t\t\t(case when cli.memory_clerks__latency_minutes > @_latency_minutes_threshold then 'memory_clerks,' else '' end)+\r\n\t\t\t\t\t(case when cli.BlitzIndex__latency_days > @_latency_days_threshold then 'BlitzIndex,' else '' end)+\r\n\t\t\t\t\t(case when cli.BlitzIndex_Mode0__latency_days > @_latency_days_threshold*4 then 'BlitzIndex_Mode0,' else '' end)+\r\n\t\t\t\t\t(case when cli.BlitzIndex_Mode1__latency_days > @_latency_days_threshold*4 then 'BlitzIndex_Mode1,' else '' end)+\r\n\t\t\t\t\t(case when cli.BlitzIndex_Mode4__latency_days > @_latency_days_threshold*4 then 'BlitzIndex_Mode4,' else '' end)\r\n\t\t--,cli.host_name ,si.major_version_number ,si.product_version ,si.edition, vi.os_cpu, vi.sql_cpu\r\nfrom dbo.all_server_collection_latency_info cli\r\njoin dbo.all_server_stable_info si on si.srv_name = cli.srv_name\r\njoin dbo.all_server_volatile_info vi on vi.srv_name = cli.srv_name\r\nouter apply (select STUFF((select ', '+id.collector_powershell_jobs_server from (select distinct id.collector_powershell_jobs_server from dbo.instance_details id where id.sql_instance = cli.srv_name and id.host_name = cli.host_name) id for xml path('')), 1, 1, '') as jobs_server ) id\r\nwhere 1=1\r\nand (\tcli.performance_counters__latency_minutes > @_latency_minutes_threshold\r\n\t\tor (cli.xevent_metrics__latency_minutes > @_latency_minutes_threshold*2 and vi.sql_cpu > 20 and si.major_version_number >= 11)\r\n\t\tor (cli.WhoIsActive__latency_minutes > @_latency_minutes_threshold*2 and vi.sql_cpu > 20)\r\n\t\tor cli.os_task_list__latency_minutes > @_latency_minutes_threshold\r\n\t\tor cli.disk_space__latency_minutes > @_latency_minutes_threshold*3\r\n\t\tor cli.file_io_stats__latency_minutes > @_latency_minutes_threshold*3\r\n\t\tor cli.wait_stats__latency_minutes > @_latency_minutes_threshold*2\r\n\t\tor cli.BlitzIndex__latency_days > @_latency_days_threshold\r\n\t\tor cli.BlitzIndex_Mode0__latency_days > @_latency_days_threshold*4\r\n\t\t--or cli.BlitzIndex_Mode1__latency_days > @_latency_days_threshold*4\r\n\t\t--or cli.BlitzIndex_Mode4__latency_days > @_latency_days_threshold*4\r\n\t\tor cli.sql_agent_job_stats__latency_minutes > @_latency_minutes_threshold*1.5\r\n\t\tor cli.memory_clerks__latency_minutes > @_latency_minutes_threshold\r\n\t)\r\nand cli.srv_name not in (select e.srv_name from @t_servers_exception e)\r\n\r\n", + "rawSql": "declare @_latency_minutes_threshold int = 20;\r\ndeclare @_latency_days_threshold int = 3;\r\ndeclare @t_servers_exception table (srv_name varchar(125));\r\n\r\ninsert @t_servers_exception -- list of servers that have permanent issues\r\nvalues ('192.168.1.21'),('192.168.1.22');\r\n\r\nselect\tcli.srv_name, id.jobs_server,\r\n\t\tcli.performance_counters__latency_minutes,\r\n\t\txevent_metrics__latency_minutes = case when (cli.xevent_metrics__latency_minutes > @_latency_minutes_threshold*2 and vi.sql_cpu > 20 and si.major_version_number >= 11) then cli.xevent_metrics__latency_minutes \r\n\t\t\t\t\t\t\t\t\t\t\t\t\twhen cli.xevent_metrics__latency_minutes > @_latency_minutes_threshold then @_latency_minutes_threshold-1\r\n\t\t\t\t\t\t\t\t\t\t\t\t\telse cli.xevent_metrics__latency_minutes end,\r\n\t\tWhoIsActive__latency_minutes = case when cli.WhoIsActive__latency_minutes > @_latency_minutes_threshold*2 and vi.sql_cpu > 20 then cli.WhoIsActive__latency_minutes \r\n\t\t\t\t\t\t\t\t\t\t\t\t\twhen cli.WhoIsActive__latency_minutes > @_latency_minutes_threshold then @_latency_minutes_threshold-1\r\n\t\t\t\t\t\t\t\t\t\t\t\t\telse cli.WhoIsActive__latency_minutes end,\r\n\t\tcli.disk_space__latency_minutes, \r\n\t\tcli.file_io_stats__latency_minutes,\r\n\t\tcli.sql_agent_job_stats__latency_minutes,\r\n\t\tcli.memory_clerks__latency_minutes,\r\n\t\tcli.wait_stats__latency_minutes,\r\n\t\tcli.BlitzIndex__latency_days,\r\n\t\tcli.BlitzIndex_Mode0__latency_days,\r\n\t\t--cli.BlitzIndex_Mode1__latency_days,\r\n\t\t--cli.BlitzIndex_Mode4__latency_days,\r\n\t\t--collection_time = DATEADD(mi, DATEDIFF(mi, getdate(), getutcdate()), cli.collection_time)\r\n\t\t[Issues] = (case when cli.performance_counters__latency_minutes > @_latency_minutes_threshold then 'performance_counters,' else '' end)+\r\n\t\t\t\t\t(case when cli.xevent_metrics__latency_minutes > @_latency_minutes_threshold*2 and vi.sql_cpu > 20 and si.major_version_number >= 11 then 'xevent_metrics' else '' end)+\r\n\t\t\t\t\t(case when cli.WhoIsActive__latency_minutes > @_latency_minutes_threshold*2 and vi.sql_cpu > 20 then 'WhoIsActive,' else '' end)+\r\n\t\t\t\t\t(case when cli.disk_space__latency_minutes > @_latency_minutes_threshold*3 then 'disk_space,' else '' end)+\r\n\t\t\t\t\t(case when cli.file_io_stats__latency_minutes > @_latency_minutes_threshold*3 then 'file_io_stats,' else '' end)+\r\n\t\t\t\t\t(case when cli.wait_stats__latency_minutes > @_latency_minutes_threshold*2 then 'wait_stats,' else '' end)+\r\n\t\t\t\t\t(case when cli.sql_agent_job_stats__latency_minutes > @_latency_minutes_threshold*1.5 then 'sql_agent_job_stats,' else '' end)+\r\n\t\t\t\t\t(case when cli.memory_clerks__latency_minutes > @_latency_minutes_threshold then 'memory_clerks,' else '' end)+\r\n\t\t\t\t\t(case when cli.BlitzIndex__latency_days > @_latency_days_threshold then 'BlitzIndex,' else '' end)+\r\n\t\t\t\t\t(case when cli.BlitzIndex_Mode0__latency_days > @_latency_days_threshold*4 then 'BlitzIndex_Mode0,' else '' end)+\r\n\t\t\t\t\t(case when cli.BlitzIndex_Mode1__latency_days > @_latency_days_threshold*4 then 'BlitzIndex_Mode1,' else '' end)+\r\n\t\t\t\t\t(case when cli.BlitzIndex_Mode4__latency_days > @_latency_days_threshold*4 then 'BlitzIndex_Mode4,' else '' end)\r\n\t\t--,cli.host_name ,si.major_version_number ,si.product_version ,si.edition, vi.os_cpu, vi.sql_cpu\r\nfrom dbo.all_server_collection_latency_info cli\r\njoin dbo.all_server_stable_info si on si.srv_name = cli.srv_name\r\njoin dbo.all_server_volatile_info vi on vi.srv_name = cli.srv_name\r\nouter apply (select STUFF((select ', '+id.collector_powershell_jobs_server from (select distinct id.collector_powershell_jobs_server from dbo.instance_details id where id.sql_instance = cli.srv_name and id.host_name = cli.host_name) id for xml path('')), 1, 1, '') as jobs_server ) id\r\nwhere 1=1\r\nand (\tcli.performance_counters__latency_minutes > @_latency_minutes_threshold\r\n\t\tor (cli.xevent_metrics__latency_minutes > @_latency_minutes_threshold*2 and vi.sql_cpu > 20 and si.major_version_number >= 11)\r\n\t\tor (cli.WhoIsActive__latency_minutes > @_latency_minutes_threshold*2 and vi.sql_cpu > 20)\r\n\t\tor cli.disk_space__latency_minutes > @_latency_minutes_threshold*3\r\n\t\tor cli.file_io_stats__latency_minutes > @_latency_minutes_threshold*3\r\n\t\tor cli.wait_stats__latency_minutes > @_latency_minutes_threshold*2\r\n\t\tor cli.BlitzIndex__latency_days > @_latency_days_threshold\r\n\t\tor cli.BlitzIndex_Mode0__latency_days > @_latency_days_threshold*4\r\n\t\t--or cli.BlitzIndex_Mode1__latency_days > @_latency_days_threshold*4\r\n\t\t--or cli.BlitzIndex_Mode4__latency_days > @_latency_days_threshold*4\r\n\t\tor cli.sql_agent_job_stats__latency_minutes > @_latency_minutes_threshold*1.5\r\n\t\tor cli.memory_clerks__latency_minutes > @_latency_minutes_threshold\r\n\t)\r\nand cli.srv_name not in (select e.srv_name from @t_servers_exception e)\r\n\r\n", "refId": "A", "sql": { "columns": [ @@ -1091,7 +1079,7 @@ "h": 5, "w": 24, "x": 0, - "y": 21 + "y": 3 }, "id": 844, "options": { @@ -1108,7 +1096,7 @@ "showHeader": true, "sortBy": [] }, - "pluginVersion": "11.2.0", + "pluginVersion": "11.3.1", "targets": [ { "alias": "", @@ -1397,7 +1385,7 @@ "h": 7, "w": 24, "x": 0, - "y": 26 + "y": 8 }, "id": 887, "options": { @@ -1414,7 +1402,7 @@ "showHeader": true, "sortBy": [] }, - "pluginVersion": "11.2.0", + "pluginVersion": "11.3.1", "targets": [ { "alias": "", @@ -1640,7 +1628,7 @@ "h": 6, "w": 24, "x": 0, - "y": 30 + "y": 408 }, "id": 871, "options": { @@ -2136,7 +2124,7 @@ "h": 8, "w": 24, "x": 0, - "y": 23 + "y": 401 }, "id": 874, "options": { @@ -2618,7 +2606,7 @@ "h": 10, "w": 24, "x": 0, - "y": 31 + "y": 409 }, "id": 888, "options": { @@ -3053,7 +3041,7 @@ "h": 8, "w": 24, "x": 0, - "y": 24 + "y": 402 }, "id": 864, "options": { @@ -3448,7 +3436,7 @@ "h": 12, "w": 24, "x": 0, - "y": 33 + "y": 411 }, "id": 852, "options": { @@ -4306,7 +4294,7 @@ "h": 7, "w": 24, "x": 0, - "y": 34 + "y": 412 }, "id": 867, "options": { @@ -4903,7 +4891,7 @@ "h": 8, "w": 24, "x": 0, - "y": 35 + "y": 413 }, "id": 856, "options": { @@ -5395,7 +5383,7 @@ "h": 8, "w": 24, "x": 0, - "y": 36 + "y": 316 }, "id": 860, "options": { @@ -5411,7 +5399,7 @@ }, "showHeader": true }, - "pluginVersion": "11.1.4", + "pluginVersion": "11.3.1", "targets": [ { "datasource": { @@ -5472,7 +5460,8 @@ "custom": { "align": "auto", "cellOptions": { - "type": "auto" + "type": "auto", + "wrapText": true }, "filterable": true, "inspect": true @@ -5482,22 +5471,503 @@ "mode": "absolute", "steps": [ { - "color": "green" + "color": "green", + "value": null + } + ] + } + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "error_number" + }, + "properties": [ + { + "id": "custom.width", + "value": 120 }, { - "color": "red", - "value": 80 + "id": "custom.cellOptions", + "value": { + "type": "color-text" + } + }, + { + "id": "links", + "value": [ + { + "targetBlank": true, + "title": "Error KB", + "url": "https://learn.microsoft.com/en-us/sql/relational-databases/errors-events/mssqlserver-${__data.fields.error_number}-database-engine-error" + } + ] + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "red", + "value": null + } + ] + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "error_severity" + }, + "properties": [ + { + "id": "custom.width", + "value": 128 + }, + { + "id": "custom.cellOptions", + "value": { + "type": "color-text" + } + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "orange", + "value": null + }, + { + "color": "red", + "value": 20 + } + ] + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "error_message" + }, + "properties": [ + { + "id": "custom.align", + "value": "left" + }, + { + "id": "custom.cellOptions", + "value": { + "type": "color-background" + } + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "sql_instance | occurrences | last_occurred" + }, + "properties": [ + { + "id": "custom.align", + "value": "left" + }, + { + "id": "custom.cellOptions", + "value": { + "type": "color-background" + } + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "super-light-blue", + "value": null + } + ] + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "sql_instances" + }, + "properties": [ + { + "id": "custom.hidden", + "value": true } ] } + ] + }, + "gridPos": { + "h": 10, + "w": 24, + "x": 0, + "y": 11 + }, + "id": 890, + "options": { + "cellHeight": "sm", + "footer": { + "countRows": false, + "fields": "", + "reducer": [ + "sum" + ], + "show": false }, - "overrides": [] + "showHeader": true, + "sortBy": [] + }, + "pluginVersion": "11.3.1", + "targets": [ + { + "dataset": "AdventureWorks2019", + "datasource": { + "type": "mssql", + "uid": "${sqlmonitor_datasource}" + }, + "editorMode": "code", + "expr": "", + "format": "table", + "legendFormat": "__auto", + "range": true, + "rawQuery": true, + "rawSql": "declare @sql nvarchar(max);\r\ndeclare @params nvarchar(max);\r\ndeclare @sql_instance varchar(max);\r\ndeclare @start_time_utc datetime2;\r\ndeclare @end_time_utc datetime2;\r\ndeclare @_has_inventory bit = 0;\r\nset @_has_inventory = convert(bit,'${has_inventory}');\r\n\r\n--set @sql_instance = case when ltrim(rtrim(@database)) = '__All__' then null else @database end;\r\n\r\nset @start_time_utc = $__timeFrom();\r\nset @end_time_utc = $__timeTo();\r\n\r\nset @params = N'@start_time_utc datetime2, @end_time_utc datetime2';\r\n\r\nset quoted_identifier off;\r\nset @sql = \"/* SQLMonitor - All Server Alert History */\r\nset nocount on;\r\n;with t_aggregated_messages as (\r\nselect a.sql_instance, a.error_number, a.error_severity, occurrences = count(*), last_occurred = max(a.collection_time_utc), error_message = coalesce(max(m.text), max(a.error_message))\r\n --a.collection_time_utc, a.sql_instance, a.server_name, a.database_name, a.error_number, \r\n --a.error_severity, a.error_message, a.host_instance, a.updated_time_utc\r\nfrom dbo.alert_history_all_servers a\r\nleft join sys.messages m \r\n on m.language_id = 1033 and m.message_id = a.error_number\r\nwhere 1 = 1\r\nand a.collection_time_utc between @start_time_utc and @end_time_utc\r\nand (case when a.error_number = 50000 and error_severity = 20 and a.error_message like '%application intent is set to read only%'\r\n then 0\r\n when a.error_number = 1204 then 0\r\n when a.error_number = 50000 and error_severity = 20 and a.error_message like 'Error: 50000 Severity: 20 State: 1 Could not create constraint or index. See previous errors. '\r\n then 0\r\n when a.error_number = 50000 and error_severity = 20 and a.error_message like 'Error: 50000 Severity: 20 State: 1 The instance of the SQL Server Database Engine cannot obtain a LOCK resource at this time%'\r\n then 0\r\n when a.error_number = 17806 and error_severity = 20 and a.error_message like 'SSPI handshake failed with error code 0x8009030c%'\r\n then 0\r\n when a.error_number = 50000 and error_severity = 20 and a.error_message like 'Error: 50000 Severity: 20 State: 1 Lock request time out period exceeded. '\r\n then 0\r\n when a.error_number = 976 and error_severity = 14 and a.error_message like '%Either data movement is suspended or the availability replica is not enabled for read access%'\r\n then 0\r\n when a.error_number = 5084 and error_severity = 10 and a.error_message like 'Setting database option MULTI_USER to ON%'\r\n then 0\r\n when a.error_number = 5084 and error_severity = 10 and a.error_message like 'Setting database option SINGLE_USER to ON%'\r\n then 0\r\n when a.error_number = 14151 and error_severity = 18 and a.error_message like '%Named Pipes Provider: Could not open a connection to SQL Server%'\r\n then 0\r\n when a.error_number = 17828 and error_severity = 20\r\n then 0\r\n when a.error_number in (17832, 17836)\r\n then 0\r\n else 1\r\n end\r\n ) = 1\r\n\"+(case when @_has_inventory = 0 then '--' else '' end)+\"and exists (select * from dbo.sma_servers s where s.is_decommissioned = 0 and s.is_onboarded = 1 and s.server = a.sql_instance)\r\ngroup by a.sql_instance, a.error_number, a.error_severity\r\n--order by error_severity desc, occurrences desc, sql_instance\r\n)\r\n,t_unique_errors as (\r\nselect error_number, error_severity, error_message\r\n --,sql_instance, occurrences, last_occurred\r\nfrom t_aggregated_messages\r\ngroup by error_number, error_severity, error_message\r\n)\r\nselect error_number, error_severity, error_message,\r\n [sql_instance | occurrences | last_occurred] = \r\n stuff(( SELECT ', ' + cc.[sql_instance | occurrences | last_occurred]\r\n FROM t_aggregated_messages am\r\n outer apply (select [last_occurred_localtime] = DATEADD(mi, DATEDIFF(mi, GETUTCDATE(), GETDATE()), last_occurred) ) lt\r\n outer apply (select [sql_instance | occurrences | last_occurred] = '('+sql_instance+' | '+convert(varchar(10),occurrences)+' | '+convert(varchar,lt.last_occurred_localtime,120)+')') cc\r\n where am.error_number = ue.error_number and am.error_severity = ue.error_severity\r\n order by occurrences desc\r\n FOR XML PATH('')\r\n ), 1, 2, ''),\r\n [sql_instances] = \r\n stuff(( SELECT ', ' + cc.sql_instance_quoted\r\n FROM t_aggregated_messages am\r\n outer apply (select sql_instance_quoted = quotename(sql_instance,'''')) cc\r\n where am.error_number = ue.error_number and am.error_severity = ue.error_severity\r\n FOR XML PATH('')\r\n ), 1, 2, '')\r\nfrom t_unique_errors ue\r\n\"\r\nset quoted_identifier on;\r\n\r\nexec dbo.sp_executesql @sql, @params, @start_time_utc, @end_time_utc;", + "refId": "A", + "sql": { + "columns": [ + { + "parameters": [], + "type": "function" + } + ], + "groupBy": [ + { + "property": { + "type": "string" + }, + "type": "groupBy" + } + ], + "limit": 50 + } + } + ], + "title": "Alerts Aggregated by Type - \"${alert_history_aggregated_row_count}\" Total - Between ____${__from:date:YYYY-MM-DD HH.mm}___to___${__to:date:YYYY-MM-DD HH.mm}____", + "type": "table" + }, + { + "datasource": { + "type": "mssql", + "uid": "${sqlmonitor_datasource}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "custom": { + "align": "auto", + "cellOptions": { + "type": "auto", + "wrapText": false + }, + "filterable": true, + "inspect": true + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + } + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "collection_time_utc" + }, + "properties": [ + { + "id": "displayName", + "value": "collection_time" + }, + { + "id": "custom.cellOptions", + "value": { + "type": "color-background", + "wrapText": true + } + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "dark-blue", + "value": null + } + ] + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "sql_instance" + }, + "properties": [ + { + "id": "custom.cellOptions", + "value": { + "type": "color-background", + "wrapText": true + } + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "blue", + "value": null + } + ] + } + }, + { + "id": "custom.width", + "value": 218 + }, + { + "id": "links", + "value": [ + { + "targetBlank": true, + "title": "Live Server Health Dashboard", + "url": "d/distributed_live_dashboard?var-server=${__data.fields.sql_instance}" + } + ] + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "server_name" + }, + "properties": [ + { + "id": "custom.hidden", + "value": true + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "database_name" + }, + "properties": [ + { + "id": "custom.cellOptions", + "value": { + "type": "color-background", + "wrapText": true + } + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "super-light-blue", + "value": null + } + ] + } + }, + { + "id": "custom.width", + "value": 189 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "error_number" + }, + "properties": [ + { + "id": "custom.cellOptions", + "value": { + "type": "color-text" + } + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "red", + "value": null + } + ] + } + }, + { + "id": "custom.width", + "value": 124 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "error_severity" + }, + "properties": [ + { + "id": "custom.cellOptions", + "value": { + "type": "color-text" + } + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "yellow", + "value": null + }, + { + "color": "red", + "value": 20 + } + ] + } + }, + { + "id": "custom.width", + "value": 126 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "error_message" + }, + "properties": [ + { + "id": "custom.cellOptions", + "value": { + "type": "color-background", + "wrapText": false + } + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "super-light-yellow", + "value": null + } + ] + } + }, + { + "id": "custom.minWidth", + "value": 400 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "host_instance" + }, + "properties": [ + { + "id": "custom.hidden", + "value": true + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "updated_time_utc" + }, + "properties": [ + { + "id": "custom.hidden", + "value": true + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "collection_time" + }, + "properties": [ + { + "id": "custom.width", + "value": 152 + } + ] + } + ] }, "gridPos": { - "h": 8, + "h": 12, "w": 24, "x": 0, - "y": 29 + "y": 21 }, "id": 873, "options": { @@ -5510,20 +5980,21 @@ ], "show": false }, - "showHeader": true + "showHeader": true, + "sortBy": [] }, - "pluginVersion": "11.2.0", + "pluginVersion": "11.3.1", "targets": [ { "dataset": "AdventureWorks2019", "datasource": { "type": "mssql", - "uid": "ygPVA4snk" + "uid": "${sqlmonitor_datasource}" }, "editorMode": "code", "format": "table", "rawQuery": true, - "rawSql": "declare @sql nvarchar(max);\r\ndeclare @params nvarchar(max);\r\ndeclare @sql_instance varchar(max);\r\ndeclare @start_time_utc datetime2;\r\ndeclare @end_time_utc datetime2;\r\ndeclare @_has_inventory bit = 0;\r\nset @_has_inventory = convert(bit,'${has_inventory}');\r\n\r\n--set @sql_instance = case when ltrim(rtrim(@database)) = '__All__' then null else @database end;\r\n\r\nset @start_time_utc = $__timeFrom();\r\nset @end_time_utc = $__timeTo();\r\n\r\nset @params = N'@start_time_utc datetime2, @end_time_utc datetime2';\r\n\r\nset quoted_identifier off;\r\nset @sql = \"/* SQLMonitor - All Server Alert History */\r\nset nocount on;\r\nselect a.collection_time_utc, a.sql_instance, a.server_name, a.database_name, a.error_number, \r\n a.error_severity, a.error_message, a.host_instance, a.updated_time_utc\r\nfrom dbo.alert_history_all_servers a\r\nwhere 1 = 1\r\nand a.collection_time_utc between @start_time_utc and @end_time_utc\r\n\"+(case when @_has_inventory = 0 then '--' else '' end)+\"and exists (select * from dbo.sma_servers s where s.is_decommissioned = 0 and s.is_onboarded = 1 and s.server = a.sql_instance)\r\n\"\r\nset quoted_identifier on;\r\n\r\nexec dbo.sp_executesql @sql, @params, @start_time_utc, @end_time_utc;", + "rawSql": "declare @sql nvarchar(max);\r\ndeclare @params nvarchar(max);\r\ndeclare @sql_instance varchar(max);\r\ndeclare @start_time_utc datetime2;\r\ndeclare @end_time_utc datetime2;\r\ndeclare @_has_inventory bit = 0;\r\nset @_has_inventory = convert(bit,'${has_inventory}');\r\n\r\n--set @sql_instance = case when ltrim(rtrim(@database)) = '__All__' then null else @database end;\r\n\r\nset @start_time_utc = $__timeFrom();\r\nset @end_time_utc = $__timeTo();\r\n\r\nset @params = N'@start_time_utc datetime2, @end_time_utc datetime2';\r\n\r\nset quoted_identifier off;\r\nset @sql = \"/* SQLMonitor - All Server Alert History */\r\nset nocount on;\r\nselect a.collection_time_utc, a.sql_instance, a.database_name, a.error_number, \r\n a.error_severity, a.error_message \r\n --, a.host_instance, a.updated_time_utc, a.server_name\r\nfrom dbo.alert_history_all_servers a\r\nwhere 1 = 1\r\nand a.collection_time_utc between @start_time_utc and @end_time_utc\r\nand (case when a.error_number = 50000 and error_severity = 20 and a.error_message like '%application intent is set to read only%'\r\n then 0\r\n when a.error_number = 1204 then 0\r\n when a.error_number = 50000 and error_severity = 20 and a.error_message like 'Error: 50000 Severity: 20 State: 1 Could not create constraint or index. See previous errors. '\r\n then 0\r\n when a.error_number = 50000 and error_severity = 20 and a.error_message like 'Error: 50000 Severity: 20 State: 1 The instance of the SQL Server Database Engine cannot obtain a LOCK resource at this time%'\r\n then 0\r\n when a.error_number = 17806 and error_severity = 20 and a.error_message like 'SSPI handshake failed with error code 0x8009030c%'\r\n then 0\r\n when a.error_number = 50000 and error_severity = 20 and a.error_message like 'Error: 50000 Severity: 20 State: 1 Lock request time out period exceeded. '\r\n then 0\r\n when a.error_number = 976 and error_severity = 14 and a.error_message like '%Either data movement is suspended or the availability replica is not enabled for read access%'\r\n then 0\r\n else 1\r\n end\r\n ) = 1\r\n\"+(case when @_has_inventory = 0 then '--' else '' end)+\"and exists (select * from dbo.sma_servers s where s.is_decommissioned = 0 and s.is_onboarded = 1 and s.server = a.sql_instance)\r\norder by 1 desc, 2\r\n\"\r\nset quoted_identifier on;\r\n\r\nexec dbo.sp_executesql @sql, @params, @start_time_utc, @end_time_utc;", "refId": "A", "sql": { "columns": [ @@ -5548,7 +6019,7 @@ "type": "table" } ], - "title": "All Servers - Alert History - \"${alert_history_row_count}\" Total - Between ____${__from:date:YYYY-MM-DD HH.mm}___to___${__to:date:YYYY-MM-DD HH.mm}____", + "title": "All Servers - Alert History - \"${alert_history_aggregated_row_count}/${alert_history_row_count}\" Total - Between ____${__from:date:YYYY-MM-DD HH.mm}___to___${__to:date:YYYY-MM-DD HH.mm}____", "type": "row" }, { @@ -5578,7 +6049,8 @@ "custom": { "align": "center", "cellOptions": { - "type": "auto" + "type": "auto", + "wrapText": true }, "filterable": true, "inspect": false @@ -6329,7 +6801,7 @@ "h": 7, "w": 24, "x": 0, - "y": 84 + "y": 462 }, "id": 119, "options": { @@ -6426,8 +6898,8 @@ }, { "current": { - "text": "1763105370478", - "value": "1763105370478" + "text": "1770179641409", + "value": "1770179641409" }, "datasource": { "type": "mssql", @@ -7167,8 +7639,8 @@ }, { "current": { - "text": "0", - "value": "0" + "text": "5", + "value": "5" }, "datasource": { "type": "mssql", @@ -7187,8 +7659,8 @@ }, { "current": { - "text": "10", - "value": "10" + "text": "11", + "value": "11" }, "datasource": { "type": "mssql", @@ -7247,8 +7719,8 @@ }, { "current": { - "text": "0", - "value": "0" + "text": "1", + "value": "1" }, "datasource": { "type": "mssql", @@ -7267,8 +7739,8 @@ }, { "current": { - "text": "1", - "value": "1" + "text": "0", + "value": "0" }, "datasource": { "type": "mssql", @@ -7367,8 +7839,8 @@ }, { "current": { - "text": "0", - "value": "0" + "text": "348", + "value": "348" }, "datasource": { "type": "mssql", @@ -7388,8 +7860,8 @@ }, { "current": { - "text": "1763105402382", - "value": "1763105402382" + "text": "1770179408610", + "value": "1770179408610" }, "datasource": { "type": "mssql", @@ -7408,8 +7880,8 @@ }, { "current": { - "text": "1763105408692", - "value": "1763105408692" + "text": "1770179641409", + "value": "1770179641409" }, "datasource": { "type": "mssql", @@ -7428,8 +7900,8 @@ }, { "current": { - "text": "1763105407949", - "value": "1763105407949" + "text": "1770179409128", + "value": "1770179409128" }, "datasource": { "type": "mssql", @@ -7448,8 +7920,8 @@ }, { "current": { - "text": "1763105402336", - "value": "1763105402336" + "text": "1770179403606", + "value": "1770179403606" }, "datasource": { "type": "mssql", @@ -7468,8 +7940,8 @@ }, { "current": { - "text": "1763105403443", - "value": "1763105403443" + "text": "1770179404163", + "value": "1770179404163" }, "datasource": { "type": "mssql", @@ -7488,8 +7960,8 @@ }, { "current": { - "text": "1763105406053", - "value": "1763105406053" + "text": "1770179408173", + "value": "1770179408173" }, "datasource": { "type": "mssql", @@ -7508,8 +7980,8 @@ }, { "current": { - "text": "1763104501666", - "value": "1763104501666" + "text": "1769063700910", + "value": "1769063700910" }, "datasource": { "type": "mssql", @@ -7545,8 +8017,8 @@ }, { "current": { - "text": "1763105341333", - "value": "1763105341333" + "text": "1770179641070", + "value": "1770179641070" }, "datasource": { "type": "mssql", @@ -7565,8 +8037,8 @@ }, { "current": { - "text": "1763105341303", - "value": "1763105341303" + "text": "1770179641096", + "value": "1770179641096" }, "datasource": { "type": "mssql", @@ -7602,11 +8074,31 @@ "refresh": 1, "regex": "", "type": "query" + }, + { + "current": { + "text": "1", + "value": "1" + }, + "datasource": { + "type": "mssql", + "uid": "${sqlmonitor_datasource}" + }, + "definition": "-- alert_history_aggregated_row_count\ndeclare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(max);\ndeclare @start_time_utc datetime2;\ndeclare @end_time_utc datetime2;\ndeclare @_has_inventory bit = 0;\nset @_has_inventory = convert(bit,'${has_inventory}');\n\n--set @sql_instance = case when ltrim(rtrim(@database)) = '__All__' then null else @database end;\n\nset @start_time_utc = $__timeFrom();\nset @end_time_utc = $__timeTo();\n\nset @params = N'@start_time_utc datetime2, @end_time_utc datetime2';\n\nset quoted_identifier off;\nset @sql = \"/* SQLMonitor - All Server Alert History */\nset nocount on;\n;with cte_aggregated as (\n select a.sql_instance, a.error_number, a.error_severity, occurrences = count(*), error_message = max(m.text)\n --a.collection_time_utc, a.sql_instance, a.server_name, a.database_name, a.error_number, \n --a.error_severity, a.error_message, a.host_instance, a.updated_time_utc\n from dbo.alert_history_all_servers a\n left join sys.messages m \n on m.language_id = 1033 and m.message_id = a.error_number\n where 1 = 1\n and a.collection_time_utc between @start_time_utc and @end_time_utc\n and (case when a.error_number = 50000 and error_severity = 20 and a.error_message like '%application intent is set to read only%'\n then 0\n when a.error_number = 1204 then 0\n when a.error_number = 50000 and error_severity = 20 and a.error_message like 'Error: 50000 Severity: 20 State: 1 Could not create constraint or index. See previous errors. '\n then 0\n when a.error_number = 50000 and error_severity = 20 and a.error_message like 'Error: 50000 Severity: 20 State: 1 The instance of the SQL Server Database Engine cannot obtain a LOCK resource at this time%'\n then 0\n when a.error_number = 17806 and error_severity = 20 and a.error_message like 'SSPI handshake failed with error code 0x8009030c%'\n then 0\n when a.error_number = 50000 and error_severity = 20 and a.error_message like 'Error: 50000 Severity: 20 State: 1 Lock request time out period exceeded. '\n then 0\n when a.error_number = 976 and error_severity = 14 and a.error_message like '%Either data movement is suspended or the availability replica is not enabled for read access%'\n then 0\n else 1\n end\n ) = 1\n \"+(case when @_has_inventory = 0 then '--' else '' end)+\"and exists (select * from dbo.sma_servers s where s.is_decommissioned = 0 and s.is_onboarded = 1 and s.server = a.sql_instance)\n group by a.sql_instance, a.error_number, a.error_severity\n)\nselect count(*) from cte_aggregated\n\"\nset quoted_identifier on;\n\nexec dbo.sp_executesql @sql, @params, @start_time_utc, @end_time_utc;", + "description": "Alert History Aggregated Row Count", + "hide": 2, + "label": "Alert History Aggregated Row Count", + "name": "alert_history_aggregated_row_count", + "options": [], + "query": "-- alert_history_aggregated_row_count\ndeclare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(max);\ndeclare @start_time_utc datetime2;\ndeclare @end_time_utc datetime2;\ndeclare @_has_inventory bit = 0;\nset @_has_inventory = convert(bit,'${has_inventory}');\n\n--set @sql_instance = case when ltrim(rtrim(@database)) = '__All__' then null else @database end;\n\nset @start_time_utc = $__timeFrom();\nset @end_time_utc = $__timeTo();\n\nset @params = N'@start_time_utc datetime2, @end_time_utc datetime2';\n\nset quoted_identifier off;\nset @sql = \"/* SQLMonitor - All Server Alert History */\nset nocount on;\n;with cte_aggregated as (\n select a.sql_instance, a.error_number, a.error_severity, occurrences = count(*), error_message = max(m.text)\n --a.collection_time_utc, a.sql_instance, a.server_name, a.database_name, a.error_number, \n --a.error_severity, a.error_message, a.host_instance, a.updated_time_utc\n from dbo.alert_history_all_servers a\n left join sys.messages m \n on m.language_id = 1033 and m.message_id = a.error_number\n where 1 = 1\n and a.collection_time_utc between @start_time_utc and @end_time_utc\n and (case when a.error_number = 50000 and error_severity = 20 and a.error_message like '%application intent is set to read only%'\n then 0\n when a.error_number = 1204 then 0\n when a.error_number = 50000 and error_severity = 20 and a.error_message like 'Error: 50000 Severity: 20 State: 1 Could not create constraint or index. See previous errors. '\n then 0\n when a.error_number = 50000 and error_severity = 20 and a.error_message like 'Error: 50000 Severity: 20 State: 1 The instance of the SQL Server Database Engine cannot obtain a LOCK resource at this time%'\n then 0\n when a.error_number = 17806 and error_severity = 20 and a.error_message like 'SSPI handshake failed with error code 0x8009030c%'\n then 0\n when a.error_number = 50000 and error_severity = 20 and a.error_message like 'Error: 50000 Severity: 20 State: 1 Lock request time out period exceeded. '\n then 0\n when a.error_number = 976 and error_severity = 14 and a.error_message like '%Either data movement is suspended or the availability replica is not enabled for read access%'\n then 0\n else 1\n end\n ) = 1\n \"+(case when @_has_inventory = 0 then '--' else '' end)+\"and exists (select * from dbo.sma_servers s where s.is_decommissioned = 0 and s.is_onboarded = 1 and s.server = a.sql_instance)\n group by a.sql_instance, a.error_number, a.error_severity\n)\nselect count(*) from cte_aggregated\n\"\nset quoted_identifier on;\n\nexec dbo.sp_executesql @sql, @params, @start_time_utc, @end_time_utc;", + "refresh": 2, + "regex": "", + "type": "query" } ] }, "time": { - "from": "now-2h", + "from": "now-4h", "to": "now" }, "timepicker": { @@ -7621,6 +8113,6 @@ "timezone": "browser", "title": "Monitoring - Live - All Servers", "uid": "distributed_live_dashboard_all_servers", - "version": 8, + "version": 28, "weekStart": "" } \ No newline at end of file diff --git a/Grafana-Dashboards/For-Internal-Use-Only/Monitoring - Live - Distributed - INTERNAL.json b/Grafana-Dashboards/For-Internal-Use-Only/Monitoring - Live - Distributed - INTERNAL.json index ed0f0ac..5c30b6b 100644 --- a/Grafana-Dashboards/For-Internal-Use-Only/Monitoring - Live - Distributed - INTERNAL.json +++ b/Grafana-Dashboards/For-Internal-Use-Only/Monitoring - Live - Distributed - INTERNAL.json @@ -373,22 +373,34 @@ "mode": "absolute", "steps": [ { - "color": "dark-blue", + "color": "green", "value": null + }, + { + "color": "yellow", + "value": 70 + }, + { + "color": "orange", + "value": 80 + }, + { + "color": "red", + "value": 90 } ] }, - "unit": "s" + "unit": "percent" }, "overrides": [] }, "gridPos": { - "h": 2, - "w": 5, + "h": 3, + "w": 3, "x": 11, "y": 1 }, - "id": 83, + "id": 158, "options": { "colorMode": "value", "graphMode": "none", @@ -396,17 +408,11 @@ "orientation": "auto", "percentChangeColorMode": "standard", "reduceOptions": { - "calcs": [ - "last" - ], + "calcs": [], "fields": "/.*/", - "values": true + "values": false }, "showPercentChange": false, - "text": { - "titleSize": 8, - "valueSize": 18 - }, "textMode": "auto", "wideLayout": true }, @@ -418,31 +424,72 @@ "type": "mssql", "uid": "${sqlmonitor_datasource}" }, - "editorMode": "code", "format": "table", - "rawQuery": true, - "rawSql": "select [processor_info] = '$processor_name'", - "refId": "A", - "sql": { - "columns": [ - { - "parameters": [], - "type": "function" - } - ], - "groupBy": [ + "rawSql": "SELECT $ring_buffer_os_cpu;", + "refId": "A" + } + ], + "title": "OS CPU @ ${ring_buffer_event_time:date:YYYY-MM-DD}", + "type": "stat" + }, + { + "datasource": { + "type": "mssql", + "uid": "${sqlmonitor_datasource}" + }, + "description": "", + "fieldConfig": { + "defaults": { + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ { - "property": { - "type": "string" - }, - "type": "groupBy" + "color": "green", + "value": null } - ], - "limit": 50 - } + ] + }, + "unit": "percent" + }, + "overrides": [] + }, + "gridPos": { + "h": 3, + "w": 3, + "x": 14, + "y": 1 + }, + "id": 161, + "options": { + "colorMode": "value", + "graphMode": "none", + "justifyMode": "center", + "orientation": "auto", + "percentChangeColorMode": "standard", + "reduceOptions": { + "calcs": [], + "fields": "/.*/", + "values": false + }, + "showPercentChange": false, + "textMode": "auto", + "wideLayout": true + }, + "pluginVersion": "11.3.1", + "targets": [ + { + "alias": "", + "datasource": { + "type": "mssql", + "uid": "${sqlmonitor_datasource}" + }, + "format": "table", + "rawSql": "SELECT $ring_buffer_idle_cpu;", + "refId": "A" } ], - "title": "Processor Info", + "title": "Idle CPU @ ${ring_buffer_event_time:date:HH.mm}", "type": "stat" }, { @@ -453,14 +500,29 @@ "description": "", "fieldConfig": { "defaults": { - "decimals": 2, "mappings": [], "thresholds": { "mode": "absolute", "steps": [ { - "color": "dark-blue", + "color": "dark-red", "value": null + }, + { + "color": "yellow", + "value": 300 + }, + { + "color": "orange", + "value": 600 + }, + { + "color": "light-green", + "value": 601 + }, + { + "color": "dark-green", + "value": 1200 } ] }, @@ -469,12 +531,12 @@ "overrides": [] }, "gridPos": { - "h": 2, - "w": 3, - "x": 16, + "h": 3, + "w": 2, + "x": 17, "y": 1 }, - "id": 69, + "id": 15, "options": { "colorMode": "value", "graphMode": "none", @@ -482,17 +544,11 @@ "orientation": "auto", "percentChangeColorMode": "standard", "reduceOptions": { - "calcs": [ - "last" - ], + "calcs": [], "fields": "/.*/", - "values": true + "values": false }, "showPercentChange": false, - "text": { - "titleSize": 8, - "valueSize": 18 - }, "textMode": "auto", "wideLayout": true }, @@ -504,12 +560,31 @@ "type": "mssql", "uid": "${sqlmonitor_datasource}" }, + "editorMode": "code", "format": "table", - "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @params = N'@perfmon_host_name varchar(255)';\n\nset quoted_identifier off;\nset @sql = \"\nselect virtual_machine_type_desc\nfrom sys.dm_os_sys_info as osi\n\"\nset quoted_identifier on;\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nif ($is_local = 1)\n exec dbo.sp_executesql @sql , @params, @perfmon_host_name;\nelse\n exec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name;", - "refId": "A" + "rawQuery": true, + "rawSql": "select $ple;", + "refId": "A", + "sql": { + "columns": [ + { + "parameters": [], + "type": "function" + } + ], + "groupBy": [ + { + "property": { + "type": "string" + }, + "type": "groupBy" + } + ], + "limit": 50 + } } ], - "title": "Machine Type", + "title": "PLE", "type": "stat" }, { @@ -870,12 +945,31 @@ "type": "mssql", "uid": "${sqlmonitor_datasource}" }, + "editorMode": "code", "format": "table", - "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @params = N'@perfmon_host_name varchar(255)';\n\nset quoted_identifier off;\nset @sql = \"\nselect count(*) as counts\nfrom $os_task_list_table_name otl with (nolock)\nwhere collection_time_utc = (select top 1 i.collection_time_utc from $os_task_list_table_name i with (nolock)\n where i.host_name = @perfmon_host_name order by i.collection_time_utc desc)\nand otl.host_name = @perfmon_host_name\n\"\nset quoted_identifier on;\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nif ($is_local = 1)\n exec dbo.sp_executesql @sql , @params, @perfmon_host_name;\nelse\n exec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name;", - "refId": "A" + "rawQuery": true, + "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\ndeclare @start_time_utc datetime2;\ndeclare @end_time_utc datetime2;\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @start_time_utc = $__timeFrom();\nset @end_time_utc = $__timeTo();\nset @params = N'@perfmon_host_name varchar(255), @start_time_utc datetime2, @end_time_utc datetime2';\n\nset quoted_identifier off;\nset @sql = \"\nselect proc_counts = count(*)\nfrom $perfmon_table_name pc\nwhere 1=1\n--and collection_time_utc between @start_time_utc and @end_time_utc\nand collection_time_utc = (\n select max(i.collection_time_utc) from $perfmon_table_name i \n where i.collection_time_utc >= dateadd(minute, -15, getutcdate())\n and i.host_name = @perfmon_host_name and object = 'process' and counter = '% processor time'\n )\nand pc.host_name = @perfmon_host_name\nand object = 'process' and counter = '% processor time'\nand pc.instance not in ('_total','idle')\n\"\nset quoted_identifier on;\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nif ($is_local = 1)\n exec dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;\nelse\n exec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;", + "refId": "A", + "sql": { + "columns": [ + { + "parameters": [], + "type": "function" + } + ], + "groupBy": [ + { + "property": { + "type": "string" + }, + "type": "groupBy" + } + ], + "limit": 50 + } } ], - "title": "OS Processes @ ${os_task_list_collection_time_utc:date:YYYY-MM-DD HH.mm}", + "title": "OS Processes @ ${perfmon_collection_time_utc:date:YYYY-MM-DD HH.mm}", "type": "stat" }, { @@ -956,34 +1050,22 @@ "mode": "absolute", "steps": [ { - "color": "green", + "color": "dark-blue", "value": null - }, - { - "color": "yellow", - "value": 70 - }, - { - "color": "orange", - "value": 80 - }, - { - "color": "red", - "value": 90 } ] }, - "unit": "percent" + "unit": "s" }, "overrides": [] }, "gridPos": { - "h": 3, - "w": 3, + "h": 2, + "w": 5, "x": 11, - "y": 3 + "y": 4 }, - "id": 158, + "id": 83, "options": { "colorMode": "value", "graphMode": "none", @@ -991,11 +1073,17 @@ "orientation": "auto", "percentChangeColorMode": "standard", "reduceOptions": { - "calcs": [], + "calcs": [ + "last" + ], "fields": "/.*/", - "values": false + "values": true }, "showPercentChange": false, + "text": { + "titleSize": 8, + "valueSize": 18 + }, "textMode": "auto", "wideLayout": true }, @@ -1007,12 +1095,31 @@ "type": "mssql", "uid": "${sqlmonitor_datasource}" }, + "editorMode": "code", "format": "table", - "rawSql": "SELECT $ring_buffer_os_cpu;", - "refId": "A" + "rawQuery": true, + "rawSql": "select [processor_info] = '$processor_name'", + "refId": "A", + "sql": { + "columns": [ + { + "parameters": [], + "type": "function" + } + ], + "groupBy": [ + { + "property": { + "type": "string" + }, + "type": "groupBy" + } + ], + "limit": 50 + } } ], - "title": "OS CPU @ ${ring_buffer_event_time:date:YYYY-MM-DD}", + "title": "Processor Info", "type": "stat" }, { @@ -1023,27 +1130,28 @@ "description": "", "fieldConfig": { "defaults": { + "decimals": 2, "mappings": [], "thresholds": { "mode": "absolute", "steps": [ { - "color": "green", + "color": "dark-blue", "value": null } ] }, - "unit": "percent" + "unit": "s" }, "overrides": [] }, "gridPos": { - "h": 3, + "h": 2, "w": 3, - "x": 14, - "y": 3 + "x": 16, + "y": 4 }, - "id": 161, + "id": 69, "options": { "colorMode": "value", "graphMode": "none", @@ -1051,87 +1159,17 @@ "orientation": "auto", "percentChangeColorMode": "standard", "reduceOptions": { - "calcs": [], + "calcs": [ + "last" + ], "fields": "/.*/", - "values": false + "values": true }, "showPercentChange": false, - "textMode": "auto", - "wideLayout": true - }, - "pluginVersion": "11.3.1", - "targets": [ - { - "alias": "", - "datasource": { - "type": "mssql", - "uid": "${sqlmonitor_datasource}" - }, - "format": "table", - "rawSql": "SELECT $ring_buffer_idle_cpu;", - "refId": "A" - } - ], - "title": "Idle CPU @ ${ring_buffer_event_time:date:HH.mm}", - "type": "stat" - }, - { - "datasource": { - "type": "mssql", - "uid": "${sqlmonitor_datasource}" - }, - "description": "", - "fieldConfig": { - "defaults": { - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "dark-red", - "value": null - }, - { - "color": "yellow", - "value": 300 - }, - { - "color": "orange", - "value": 600 - }, - { - "color": "light-green", - "value": 601 - }, - { - "color": "dark-green", - "value": 1200 - } - ] - }, - "unit": "s" - }, - "overrides": [] - }, - "gridPos": { - "h": 3, - "w": 2, - "x": 17, - "y": 3 - }, - "id": 15, - "options": { - "colorMode": "value", - "graphMode": "none", - "justifyMode": "center", - "orientation": "auto", - "percentChangeColorMode": "standard", - "reduceOptions": { - "calcs": [], - "fields": "/.*/", - "values": false + "text": { + "titleSize": 8, + "valueSize": 18 }, - "showPercentChange": false, "textMode": "auto", "wideLayout": true }, @@ -1143,31 +1181,12 @@ "type": "mssql", "uid": "${sqlmonitor_datasource}" }, - "editorMode": "code", "format": "table", - "rawQuery": true, - "rawSql": "select $ple;", - "refId": "A", - "sql": { - "columns": [ - { - "parameters": [], - "type": "function" - } - ], - "groupBy": [ - { - "property": { - "type": "string" - }, - "type": "groupBy" - } - ], - "limit": 50 - } + "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @params = N'@perfmon_host_name varchar(255)';\n\nset quoted_identifier off;\nset @sql = \"\nselect virtual_machine_type_desc\nfrom sys.dm_os_sys_info as osi\n\"\nset quoted_identifier on;\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nif ($is_local = 1)\n exec dbo.sp_executesql @sql , @params, @perfmon_host_name;\nelse\n exec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name;", + "refId": "A" } ], - "title": "PLE", + "title": "Machine Type", "type": "stat" }, { @@ -1642,7 +1661,7 @@ { "matcher": { "id": "byName", - "options": "IsClustered" + "options": "IsHadrEnabled" }, "properties": [ { @@ -1662,7 +1681,7 @@ "x": 14, "y": 7 }, - "id": 74, + "id": 168, "options": { "colorMode": "value", "graphMode": "none", @@ -1690,11 +1709,11 @@ "uid": "${sqlmonitor_datasource}" }, "format": "table", - "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @params = N'@perfmon_host_name varchar(255)';\n\nset quoted_identifier off;\nset @sql = \"\n--select CONVERT(varchar,SERVERPROPERTY('IsClustered'))+' / '+CONVERT(varchar,SERVERPROPERTY('IsHadrEnabled'))\nselect CONVERT(bit,SERVERPROPERTY('IsClustered')) as IsClustered --, CONVERT(bit,SERVERPROPERTY('IsHadrEnabled')) as IsHadrEnabled\n\"\nset quoted_identifier on;\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nif ($is_local = 1)\n exec dbo.sp_executesql @sql , @params, @perfmon_host_name;\nelse\n exec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name;", + "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @params = N'@perfmon_host_name varchar(255)';\n\nset quoted_identifier off;\nset @sql = \"\n--select CONVERT(varchar,SERVERPROPERTY('IsClustered'))+' / '+CONVERT(varchar,SERVERPROPERTY('IsHadrEnabled'))\nselect CONVERT(bit,SERVERPROPERTY('IsHadrEnabled')) as IsHadrEnabled\n\"\nset quoted_identifier on;\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nif ($is_local = 1)\n exec dbo.sp_executesql @sql , @params, @perfmon_host_name;\nelse\n exec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name;", "refId": "A" } ], - "title": "IsClustered", + "title": "IsHadrEnabled", "type": "stat" }, { @@ -1721,7 +1740,7 @@ { "matcher": { "id": "byName", - "options": "IsHadrEnabled" + "options": "IsClustered" }, "properties": [ { @@ -1741,7 +1760,7 @@ "x": 16, "y": 7 }, - "id": 168, + "id": 74, "options": { "colorMode": "value", "graphMode": "none", @@ -1769,11 +1788,11 @@ "uid": "${sqlmonitor_datasource}" }, "format": "table", - "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @params = N'@perfmon_host_name varchar(255)';\n\nset quoted_identifier off;\nset @sql = \"\n--select CONVERT(varchar,SERVERPROPERTY('IsClustered'))+' / '+CONVERT(varchar,SERVERPROPERTY('IsHadrEnabled'))\nselect CONVERT(bit,SERVERPROPERTY('IsHadrEnabled')) as IsHadrEnabled\n\"\nset quoted_identifier on;\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nif ($is_local = 1)\n exec dbo.sp_executesql @sql , @params, @perfmon_host_name;\nelse\n exec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name;", + "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @params = N'@perfmon_host_name varchar(255)';\n\nset quoted_identifier off;\nset @sql = \"\n--select CONVERT(varchar,SERVERPROPERTY('IsClustered'))+' / '+CONVERT(varchar,SERVERPROPERTY('IsHadrEnabled'))\nselect CONVERT(bit,SERVERPROPERTY('IsClustered')) as IsClustered --, CONVERT(bit,SERVERPROPERTY('IsHadrEnabled')) as IsHadrEnabled\n\"\nset quoted_identifier on;\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nif ($is_local = 1)\n exec dbo.sp_executesql @sql , @params, @perfmon_host_name;\nelse\n exec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name;", "refId": "A" } ], - "title": "IsHadrEnabled", + "title": "IsClustered", "type": "stat" }, { @@ -3243,7 +3262,7 @@ "h": 9, "w": 24, "x": 0, - "y": 18 + "y": 632 }, "id": 181, "options": { @@ -3358,7 +3377,8 @@ "mode": "absolute", "steps": [ { - "color": "transparent" + "color": "transparent", + "value": null } ] }, @@ -3370,14 +3390,14 @@ "h": 8, "w": 24, "x": 0, - "y": 28 + "y": 62 }, "id": 16, "options": { "legend": { "calcs": [ "lastNotNull", - "p99" + "p98" ], "displayMode": "table", "placement": "right", @@ -3424,10 +3444,129 @@ ], "title": "CPU - @ ${perfmon_collection_time_utc:date:YYYY-MM-DD HH.mm}", "type": "timeseries" + }, + { + "datasource": { + "type": "mssql", + "uid": "${sqlmonitor_datasource}" + }, + "description": "https://sqlperformance.com/2014/10/sql-performance/knee-jerk-page-life-expectancy", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "% CPU", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 10, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": true, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "line+area" + } + }, + "mappings": [], + "max": 100, + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "transparent", + "value": null + } + ] + }, + "unit": "percent" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 24, + "x": 0, + "y": 240 + }, + "id": 193, + "options": { + "legend": { + "calcs": [ + "lastNotNull", + "p98" + ], + "displayMode": "table", + "placement": "right", + "showLegend": true, + "sortBy": "98th %", + "sortDesc": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.3.1", + "targets": [ + { + "alias": "", + "datasource": { + "type": "mssql", + "uid": "${sqlmonitor_datasource}" + }, + "editorMode": "code", + "format": "time_series", + "rawQuery": true, + "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\ndeclare @start_time_utc datetime2;\ndeclare @end_time_utc datetime2;\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @start_time_utc = $__timeFrom();\nset @end_time_utc = $__timeTo();\nset @params = N'@perfmon_host_name varchar(255), @start_time_utc datetime2, @end_time_utc datetime2';\n\nset quoted_identifier off;\nset @sql = \"\n;with cte_process_cpu as (\n\tselect pc.collection_time_utc, pc.host_name, pc.object, pc.counter,\n\t\t\tpc.value, \n\t\t\tpc.instance,\n\t\t\tprocess = case when CHARINDEX('#',s1.instance) > 0 then left(s1.instance, CHARINDEX('#',s1.instance)-1) else s1.instance end\n\tfrom $perfmon_table_name pc\n\touter apply (select instance = case when CHARINDEX('$',pc.instance) > 0 then left(pc.instance, CHARINDEX('$',pc.instance)-1) else pc.instance end ) s1\n\twhere collection_time_utc between @start_time_utc and @end_time_utc\n\tand pc.host_name = @perfmon_host_name\n\t--and collection_time_utc = (select max(i.collection_time_utc) from dbo.performance_counters i)\n\tand object = 'process' and counter = '% processor time'\n\tand pc.instance not in ('_total','idle')\n)\nselect\t[time] = collection_time_utc, --p.host_name, p.object, p.counter, \n\t\t[metric] = p.process,\n\t\t[value] = ceiling(sum(p.value)*1.0/si.cpu_count)\nfrom cte_process_cpu p\nouter apply (select si.cpu_count from sys.dm_os_sys_info si) si\ngroup by collection_time_utc, p.process, si.cpu_count\nhaving ceiling(sum(p.value)*1.0/si.cpu_count) > 0\norder by [time]\n\"\nset quoted_identifier on;\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nif ($is_local = 1)\n exec dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;\nelse\n exec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;", + "refId": "A", + "sql": { + "columns": [ + { + "parameters": [], + "type": "function" + } + ], + "groupBy": [ + { + "property": { + "type": "string" + }, + "type": "groupBy" + } + ], + "limit": 50 + } + } + ], + "title": "OS Processes CPU Utilization - @ ${perfmon_collection_time_utc:date:YYYY-MM-DD HH.mm}", + "type": "timeseries" } ], "repeat": "datasource", - "title": "Trend - CPU Utilization", + "title": "Trend - CPU Utilization @ ${perfmon_collection_time_utc:date:YYYY-MM-DD HH.mm}", "type": "row" }, { @@ -3438,180 +3577,91 @@ "x": 0, "y": 19 }, - "id": 113, + "id": 195, "panels": [ { "datasource": { + "default": false, "type": "mssql", "uid": "${sqlmonitor_datasource}" }, - "description": "Blocking Details____In Selected Time Duration____Since____${__from:date:YYYY-MM-DD HH.mm}___till___${whoisactive_collection_time_utc:date:YYYY-MM-DD HH.mm}____", + "description": "select physical_memory_in_use_kb from sys.dm_os_process_memory", "fieldConfig": { "defaults": { "color": { - "mode": "thresholds" + "mode": "palette-classic" }, "custom": { - "align": "auto", - "cellOptions": { - "type": "auto" + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 10, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false }, - "filterable": true, - "inspect": false + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": true, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } }, "mappings": [], "thresholds": { "mode": "absolute", "steps": [ { - "color": "green" - } - ] - } - }, - "overrides": [ - { - "matcher": { - "id": "byName", - "options": "BLOCKING_TREE" - }, - "properties": [ - { - "id": "custom.width", - "value": 308 - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "CPU" - }, - "properties": [ - { - "id": "unit", - "value": "ms" - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "writes" - }, - "properties": [ - { - "id": "unit", - "value": "short" - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "used_memory_kb" - }, - "properties": [ - { - "id": "unit", - "value": "kbytes" - }, - { - "id": "displayName", - "value": "used_memory" - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "reads_kb" - }, - "properties": [ - { - "id": "unit", - "value": "kbytes" - }, - { - "id": "displayName", - "value": "reads" - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "tempdb_allocations_kb" - }, - "properties": [ - { - "id": "unit", - "value": "kbytes" - }, - { - "id": "displayName", - "value": "tempdb_allocations" - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "tempdb_current_kb" - }, - "properties": [ - { - "id": "unit", - "value": "kbytes" - }, - { - "id": "displayName", - "value": "tempdb_current" + "color": "green", + "value": null } ] }, - { - "matcher": { - "id": "byName", - "options": "granted_memory_kb" - }, - "properties": [ - { - "id": "unit", - "value": "kbytes" - }, - { - "id": "displayName", - "value": "granted_memory" - } - ] - } - ] + "unit": "kbytes" + }, + "overrides": [] }, "gridPos": { - "h": 8, + "h": 10, "w": 24, "x": 0, - "y": 251 + "y": 305 }, - "id": 111, + "id": 194, "options": { - "cellHeight": "sm", - "footer": { - "countRows": false, - "fields": "", - "reducer": [ - "sum" + "legend": { + "calcs": [ + "last", + "max", + "mean" ], - "show": false + "displayMode": "table", + "placement": "bottom", + "showLegend": true, + "sortBy": "Mean", + "sortDesc": true }, - "showHeader": true, - "sortBy": [ - { - "desc": false, - "displayName": "collection_time" - } - ] + "tooltip": { + "mode": "multi", + "sort": "desc" + } }, "pluginVersion": "11.3.1", "targets": [ @@ -3622,9 +3672,9 @@ "uid": "${sqlmonitor_datasource}" }, "editorMode": "code", - "format": "table", + "format": "time_series", "rawQuery": true, - "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\ndeclare @start_time_utc datetime2;\ndeclare @end_time_utc datetime2;\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @start_time_utc = $__timeFrom();\nset @end_time_utc = $__timeTo();\nset @params = N'@perfmon_host_name varchar(255), @start_time_utc datetime2, @end_time_utc datetime2';\n\nset quoted_identifier off;\nset @sql = \"\nset nocount on;\n\ndeclare @collection_time datetime;\nselect @collection_time = max(l.collection_time) from dbo.WhoIsActive l;\n\n-- Get Blocking Tree\nif exists (select 1/0 from dbo.WhoIsActive w with (nolock) where w.collection_time = @collection_time and (blocking_session_id is not null or blocked_session_count > 0))\nbegin\n\t;WITH T_BLOCKERS AS (\n\t\t-- Find block Leaders\n\t\tSELECT\t[duration_s] = datediff(SECOND, start_time, r.collection_time), [collection_time], [session_id], \n\t\t\t\t[sql_text] = REPLACE(REPLACE(REPLACE(REPLACE(CAST(COALESCE([sql_command],[sql_text]) AS VARCHAR(MAX)),char(13),''),CHAR(10),''),'',''), \n\t\t\t\tcommand = additional_info.value('(/additional_info/command_type)[1]','varchar(125)'), [login_name], wait_info, [blocking_session_id], [blocked_session_count] = replace(blocked_session_count,',',''),\n\t\t\t\t[status], open_tran_count, [host_name], [database_name], [program_name], tasks, granted_memory, r.CPU, r.used_memory, r.[tempdb_allocations], r.[tempdb_current], r.[reads], r.[writes], r.[physical_io], additional_info,\n\t\t\t\t[LEVEL] = CAST (REPLICATE ('0', 4-LEN (CAST (r.session_id AS VARCHAR))) + CAST (r.session_id AS VARCHAR) AS VARCHAR (1000))\n\t\t\t\t,[head_blocker] = session_id ,query_plan\n\t\tFROM\tdbo.WhoIsActive AS r with (nolock) WHERE r.collection_time = @collection_time and (r.blocking_session_id IS NULL AND blocked_session_count > 0)\n\t\t--\t\n\t\tUNION ALL\n\t\t--\n\t\tSELECT\t[duration_s] = datediff(SECOND, r.start_time, r.collection_time), r.[collection_time], r.[session_id], \n\t\t\t\t[sql_text] = REPLACE(REPLACE(REPLACE(REPLACE(CAST(COALESCE(r.[sql_command],r.[sql_text]) AS VARCHAR(MAX)),char(13),''),CHAR(10),''),'',''), \n\t\t\t\tcommand = r.additional_info.value('(/additional_info/command_type)[1]','varchar(125)'), r.[login_name], r.wait_info, r.[blocking_session_id], [blocked_session_count] = replace(r.blocked_session_count,',',''),\n\t\t\t\tr.[status], r.open_tran_count, r.[host_name], r.[database_name], r.[program_name], r.tasks, r.granted_memory, r.CPU, r.used_memory, r.[tempdb_allocations], r.[tempdb_current], r.[reads], r.[writes], r.[physical_io], r.additional_info,\n\t\t\t\tCAST (B.LEVEL + RIGHT (CAST ((1000 + r.session_id) AS VARCHAR (100)), 4) AS VARCHAR (1000)) AS LEVEL\n\t\t\t\t,[head_blocker] = case when B.[head_blocker] is null then B.session_id else B.[head_blocker] end ,r.query_plan\n\t\tFROM\tdbo.WhoIsActive AS r with (nolock)\n\t\tINNER JOIN T_BLOCKERS AS B ON\tr.collection_time = B.collection_time AND r.blocking_session_id = B.session_id\n\t\tWHERE\t r.blocking_session_id <> r.session_id\n\t)\n\tSELECT\t[collection_time] = DATEADD(mi, DATEDIFF(mi, getdate(), getutcdate()), [collection_time]), \n\t\t\t[ddd hh:mm:ss] = right('0000'+convert(varchar, duration_s/86400),3)+ ' '+convert(varchar,dateadd(SECOND,duration_s,'1900-01-01 00:00:00'),108), \n\t\t\t[session_id], \n\t\t\t[BLOCKING_TREE] = N' ' + REPLICATE (N'| ', LEN (LEVEL)/4 - 1) \n\t\t\t\t\t\t\t+\tCASE\tWHEN (LEN(LEVEL)/4 - 1) = 0\n\t\t\t\t\t\t\t\t\t\tTHEN 'HEAD - '\n\t\t\t\t\t\t\t\t\t\tELSE '|------ ' \n\t\t\t\t\t\t\t\tEND\n\t\t\t\t\t\t\t+\tCAST (r.session_id AS NVARCHAR (10)) + N' ' + ISNULL((CASE WHEN LEFT(ISNULL(r.[sql_text],''),1) = '(' THEN SUBSTRING(ISNULL(r.[sql_text],''),CHARINDEX('exec',ISNULL(r.[sql_text],'')),LEN(ISNULL(r.[sql_text],''))) ELSE ISNULL(r.[sql_text],'') END),''),\n\t\t\t[blocking_session_id], [blocked_session_count] = case when [blocked_session_count] = 0 then null else [blocked_session_count] end, r.wait_info, [login_name], [program_name], [host_name], tasks, command, [database_name], status, r.open_tran_count, r.CPU, [used_memory_kb] = (r.used_memory*8.0), [reads_kb] = (r.[reads]*8.0), r.[writes], [tempdb_allocations_kb] = tempdb_allocations*8.0, tempdb_current_kb = tempdb_current*8.0, granted_memory_kb = granted_memory * 8.0\n\t\t\t--,r.query_plan ,r.additional_info\n\tFROM\tT_BLOCKERS AS r ORDER BY collection_time, LEVEL;\nend\nelse\n select 'No Blocking Found for Time Window' as [No Result]\n\"\nset quoted_identifier on;\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nif ($is_local = 1)\n exec dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;\nelse\n exec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;", + "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @start_time_utc datetime2;\ndeclare @end_time_utc datetime2;\n\nset @sql_instance = '$server';\nset @start_time_utc = $__timeFrom();\nset @end_time_utc = $__timeTo();\nset @params = N'@sql_instance varchar(255), @start_time_utc datetime2, @end_time_utc datetime2';\n\nset quoted_identifier off;\nset @sql = \"\nset nocount on;\nselect\t[time] = DATEADD(mi, DATEDIFF(mi, getdate(), getutcdate()), h.collection_time),\n\t\t\t\t[SqlServer] = h.physical_memory_in_use_kb,\n\t\t\t\t[Total_Ram] = asi.total_physical_memory_kb,\n\t\t\t\t[Available_Memory] = h.available_physical_memory_kb\nfrom dbo.all_server_volatile_info_history h\njoin dbo.all_server_stable_info asi\ton asi.srv_name = h.srv_name\nwhere h.collection_time between DATEADD(mi, DATEDIFF(mi, GETUTCDATE(), GETDATE()), @start_time_utc) and DATEADD(mi, DATEDIFF(mi, GETUTCDATE(), GETDATE()), @end_time_utc)\nand h.srv_name = @sql_instance\norder by time\n\"\nset quoted_identifier on;\n\nexec dbo.sp_executesql @sql , @params, @sql_instance, @start_time_utc, @end_time_utc;", "refId": "A", "sql": { "columns": [ @@ -3645,30 +3695,15 @@ } } ], - "title": "Blocking Details - ACTIVE - [sp_WhoIsActive] @ ${whoisactive_collection_time_utc:date:YYYY-MM-DD HH.mm}", - "type": "table" - } - ], - "repeat": "datasource", - "title": "Blocking Tree (Queries) - ACTIVE - [sp_WhoIsActive] @ ${whoisactive_collection_time_utc:date:YYYY-MM-DD HH.mm}", - "type": "row" - }, - { - "collapsed": true, - "gridPos": { - "h": 1, - "w": 24, - "x": 0, - "y": 20 - }, - "id": 151, - "panels": [ + "title": "SQL Server Process Memory", + "type": "timeseries" + }, { "datasource": { "type": "mssql", "uid": "${sqlmonitor_datasource}" }, - "description": "select * from $whoisactive_table_name\nwhere (w.blocking_session_id is null and blocked_session_count > 0)", + "description": "https://sqlperformance.com/2014/10/sql-performance/knee-jerk-page-life-expectancy", "fieldConfig": { "defaults": { "color": { @@ -3678,12 +3713,12 @@ "axisBorderShow": false, "axisCenteredZero": false, "axisColorMode": "text", - "axisLabel": "", + "axisLabel": "% CPU", "axisPlacement": "auto", "barAlignment": 0, "barWidthFactor": 0.6, "drawStyle": "line", - "fillOpacity": 0, + "fillOpacity": 10, "gradientMode": "none", "hideFrom": { "legend": false, @@ -3692,23 +3727,19 @@ }, "insertNulls": false, "lineInterpolation": "linear", - "lineStyle": { - "fill": "solid" - }, "lineWidth": 1, "pointSize": 5, "scaleDistribution": { - "log": 10, - "type": "log" + "type": "linear" }, - "showPoints": "always", - "spanNulls": false, + "showPoints": "never", + "spanNulls": true, "stacking": { "group": "A", - "mode": "normal" + "mode": "none" }, "thresholdsStyle": { - "mode": "off" + "mode": "line+area" } }, "mappings": [], @@ -3716,31 +3747,33 @@ "mode": "absolute", "steps": [ { - "color": "green" + "color": "transparent", + "value": null } ] }, - "unit": "short" + "unit": "mbytes" }, "overrides": [] }, "gridPos": { - "h": 11, + "h": 10, "w": 24, "x": 0, - "y": 252 + "y": 315 }, - "id": 149, + "id": 196, "options": { "legend": { "calcs": [ - "mean", + "lastNotNull", + "p98", "max" ], "displayMode": "table", "placement": "right", "showLegend": true, - "sortBy": "Mean", + "sortBy": "98th %", "sortDesc": true }, "tooltip": { @@ -3756,115 +3789,35 @@ "type": "mssql", "uid": "${sqlmonitor_datasource}" }, + "editorMode": "code", "format": "time_series", - "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\ndeclare @start_time_utc datetime2;\ndeclare @end_time_utc datetime2;\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @start_time_utc = $__timeFrom();\nset @end_time_utc = $__timeTo();\nset @params = N'@perfmon_host_name varchar(255), @start_time_utc datetime2, @end_time_utc datetime2';\n\nset quoted_identifier off;\nset @sql = \"\nset nocount on;\nselect DATEADD(mi, DATEDIFF(mi, getdate(), getutcdate()), collection_time) as [time], w.login_name as metric, sum(convert(int,replace(w.blocked_session_count,',',''))) as [value]\nfrom $whoisactive_table_name w with (nolock)\nwhere (collection_time between DATEADD(mi, DATEDIFF(mi, GETUTCDATE(), GETDATE()), @start_time_utc) and DATEADD(mi, DATEDIFF(mi, GETUTCDATE(), GETDATE()), @end_time_utc))\nand (w.blocking_session_id is null and replace(w.blocked_session_count,',','') > 0) -- get lead blockers only\ngroup by collection_time, w.login_name\norder by time\n\"\nset quoted_identifier on;\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nif ($is_local = 1)\n exec dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;\nelse\n exec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;", - "refId": "A" - } - ], - "title": "[${server}] - Lead Blockers - Logins - Blocked Count", - "type": "timeseries" - }, - { - "datasource": { - "type": "mssql", - "uid": "${sqlmonitor_datasource}" - }, - "description": "select * from $whoisactive_table_name\nwhere (w.blocking_session_id is null and blocked_session_count > 0)", - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisCenteredZero": false, - "axisColorMode": "text", - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 0, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "linear", - "lineStyle": { - "fill": "solid" - }, - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "log": 10, - "type": "log" - }, - "showPoints": "always", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "normal" - }, - "thresholdsStyle": { - "mode": "off" - } - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ + "rawQuery": true, + "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\ndeclare @start_time_utc datetime2;\ndeclare @end_time_utc datetime2;\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @start_time_utc = $__timeFrom();\nset @end_time_utc = $__timeTo();\nset @params = N'@perfmon_host_name varchar(255), @start_time_utc datetime2, @end_time_utc datetime2';\n\nset quoted_identifier off;\nset @sql = \"\n;with cte_process_cpu as (\n\tselect pc.collection_time_utc, pc.host_name, pc.object, pc.counter,\n\t\t\tpc.value, \n\t\t\tpc.instance,\n\t\t\tprocess = case when CHARINDEX('#',s1.instance) > 0 then left(s1.instance, CHARINDEX('#',s1.instance)-1) else s1.instance end\n\tfrom $perfmon_table_name pc\n\touter apply (select instance = case when CHARINDEX('$',pc.instance) > 0 then left(pc.instance, CHARINDEX('$',pc.instance)-1) else pc.instance end ) s1\n\twhere collection_time_utc between @start_time_utc and @end_time_utc\n\tand pc.host_name = @perfmon_host_name\n\tand object = 'process' and counter = 'working set'\n\tand pc.instance not in ('_total','idle')\n)\nselect\t[time] = collection_time_utc, --p.host_name, p.object, p.counter, \n\t\t[metric] = p.process,\n\t\t[value] = floor(sum(p.value)*1.0/1024.0/1024.0)\nfrom cte_process_cpu p\ngroup by collection_time_utc, p.process\nhaving floor(sum(p.value)*1.0/1024.0/1024.0) > 0\norder by [time]\n\"\nset quoted_identifier on;\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nif ($is_local = 1)\n exec dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;\nelse\n exec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;", + "refId": "A", + "sql": { + "columns": [ { - "color": "green" + "parameters": [], + "type": "function" } - ] - }, - "unit": "short" - }, - "overrides": [] - }, - "gridPos": { - "h": 11, - "w": 24, - "x": 0, - "y": 410 - }, - "id": 152, - "options": { - "legend": { - "calcs": [ - "mean", - "max" - ], - "displayMode": "table", - "placement": "right", - "showLegend": true, - "sortBy": "Mean", - "sortDesc": true - }, - "tooltip": { - "mode": "multi", - "sort": "desc" - } - }, - "pluginVersion": "8.4.4", - "targets": [ - { - "alias": "", - "datasource": { - "type": "mssql", - "uid": "${sqlmonitor_datasource}" - }, - "format": "time_series", - "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\ndeclare @start_time_utc datetime2;\ndeclare @end_time_utc datetime2;\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @start_time_utc = $__timeFrom();\nset @end_time_utc = $__timeTo();\nset @params = N'@perfmon_host_name varchar(255), @start_time_utc datetime2, @end_time_utc datetime2';\n\nset quoted_identifier off;\nset @sql = \"\nset nocount on;\nselect DATEADD(mi, DATEDIFF(mi, getdate(), getutcdate()), collection_time) as [time], \n w.login_name+' {{'+(case when len(w.program_name)>35 then left(w.program_name,35)+'..' else w.program_name end)+'}}' as metric, sum(convert(int,replace(w.blocked_session_count,',',''))) as [value]\nfrom $whoisactive_table_name w with (nolock)\nwhere (collection_time between DATEADD(mi, DATEDIFF(mi, GETUTCDATE(), GETDATE()), @start_time_utc) and DATEADD(mi, DATEDIFF(mi, GETUTCDATE(), GETDATE()), @end_time_utc))\nand (w.blocking_session_id is null and replace(w.blocked_session_count,',','') > 0) -- get lead blockers only\ngroup by collection_time, w.login_name, w.program_name\norder by time\n\"\nset quoted_identifier on;\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nif ($is_local = 1)\n exec dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;\nelse\n exec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;", - "refId": "A" + ], + "groupBy": [ + { + "property": { + "type": "string" + }, + "type": "groupBy" + } + ], + "limit": 50 + } } ], - "title": "[${server}] - Lead Blockers - Programs - Blocked Count", + "title": "OS Processes Memory Utilization - @ ${perfmon_collection_time_utc:date:YYYY-MM-DD HH.mm}", "type": "timeseries" } ], - "repeat": "datasource", - "title": "Lead Blockers - @ ${perfmon_collection_time_utc:date:YYYY-MM-DD HH.mm}", + "title": "Trend - Memory Utilization @ ${perfmon_collection_time_utc:date:YYYY-MM-DD HH.mm}", "type": "row" }, { @@ -3873,111 +3826,101 @@ "h": 1, "w": 24, "x": 0, - "y": 21 + "y": 20 }, - "id": 59, + "id": 198, "panels": [ { "datasource": { "type": "mssql", "uid": "${sqlmonitor_datasource}" }, + "description": "select * from dbo.alert_history where error_number = 15457;", "fieldConfig": { "defaults": { "color": { - "mode": "palette-classic" + "mode": "thresholds" }, "custom": { - "axisBorderShow": false, - "axisCenteredZero": false, - "axisColorMode": "text", - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "barWidthFactor": 0.6, - "drawStyle": "line", - "fillOpacity": 10, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "insertNulls": false, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "log": 2, - "type": "log" - }, - "showPoints": "never", - "spanNulls": true, - "stacking": { - "group": "A", - "mode": "none" + "align": "center", + "cellOptions": { + "type": "auto", + "wrapText": false }, - "thresholdsStyle": { - "mode": "line+area" - } + "filterable": true, + "inspect": true }, "mappings": [], "thresholds": { "mode": "absolute", "steps": [ { - "color": "transparent" - }, - { - "color": "orange", - "value": 0 - }, + "color": "green", + "value": null + } + ] + } + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "time" + }, + "properties": [ { - "color": "red", - "value": 2 + "id": "custom.width", + "value": 227 } ] }, - "unit": "short" - }, - "overrides": [] + { + "matcher": { + "id": "byName", + "options": "error_number" + }, + "properties": [ + { + "id": "custom.width", + "value": 172 + } + ] + } + ] }, "gridPos": { - "h": 7, + "h": 8, "w": 24, "x": 0, - "y": 31 + "y": 44 }, - "id": 57, + "id": 197, "options": { - "legend": { - "calcs": [ - "mean", - "lastNotNull", - "max" + "cellHeight": "sm", + "footer": { + "countRows": false, + "enablePagination": false, + "fields": "", + "reducer": [ + "sum" ], - "displayMode": "table", - "placement": "bottom", - "showLegend": true + "show": false }, - "tooltip": { - "mode": "multi", - "sort": "desc" - } + "showHeader": true, + "sortBy": [] }, "pluginVersion": "11.3.1", "targets": [ { - "alias": "", + "dataset": "AdventureWorks2019", "datasource": { "type": "mssql", "uid": "${sqlmonitor_datasource}" }, "editorMode": "code", - "format": "time_series", - "hide": false, + "format": "table", "rawQuery": true, - "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\ndeclare @start_time_utc datetime2;\ndeclare @end_time_utc datetime2;\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @start_time_utc = $__timeFrom();\nset @end_time_utc = $__timeTo();\nset @params = N'@perfmon_host_name varchar(255), @start_time_utc datetime2, @end_time_utc datetime2';\n\nset quoted_identifier off;\nset @sql = \"\nset nocount on;\ndeclare @object_name varchar(255);\nset @object_name = (case when '$perfmon_service_name' = 'MSSQLSERVER' then 'sqlserver' else LOWER('$perfmon_service_name') end);\nselect pc.collection_time_utc as time, \n\tcounter as metric\n\t--,instance,\n\t,pc.value\nfrom $perfmon_table_name pc with (nolock)\nwhere collection_time_utc between @start_time_utc and @end_time_utc\nand pc.host_name = @perfmon_host_name\nand (\t(pc.object = (@object_name+':memory manager')\n\t\tand pc.counter in ('memory grants outstanding','memory grants pending'))\n\t)\norder by time\n\"\nset quoted_identifier on;\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nif ($is_local = 1)\n exec dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;\nelse\n exec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;", + "rawSql": "declare @sql nvarchar(max);\r\ndeclare @params nvarchar(max);\r\ndeclare @sql_instance varchar(255);\r\ndeclare @perfmon_host_name varchar(255);\r\ndeclare @start_time_utc datetime2;\r\ndeclare @end_time_utc datetime2;\r\n\r\nset @sql_instance = '$server';\r\nset @perfmon_host_name = '$perfmon_host_name';\r\nset @start_time_utc = $__timeFrom();\r\nset @end_time_utc = $__timeTo();\r\nset @params = N'@perfmon_host_name varchar(255), @start_time_utc datetime2, @end_time_utc datetime2';\r\n\r\nset quoted_identifier off;\r\nset @sql = \"\r\nselect\t[time] = collection_time_utc, ah.error_number,\r\n\t\t--[database] = case when ah.error_number = 15457 then null else database_name end,\r\n\t\t[remarks] = ah.[error_message]\r\nfrom dbo.alert_history ah\r\nwhere collection_time_utc between @start_time_utc and @end_time_utc\r\nand ah.error_number in (15457)\r\n--and ah.error_number in (5084)\r\norder by time\r\n\"\r\nset quoted_identifier on;\r\n\r\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\r\nif ($is_local = 1)\r\n exec dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;\r\nelse\r\n exec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;", "refId": "A", "sql": { "columns": [ @@ -3998,52 +3941,36 @@ } } ], - "title": "Memory Grants Pending", - "type": "timeseries" - } - ], - "repeat": "datasource", - "title": "Trend - Memory Grants Pending", - "type": "row" - }, - { - "collapsed": true, - "gridPos": { - "h": 1, - "w": 24, - "x": 0, - "y": 22 - }, - "id": 179, - "panels": [ + "title": "Server Configuration Changes", + "type": "table" + }, { "datasource": { "type": "mssql", "uid": "${sqlmonitor_datasource}" }, + "description": "select * from dbo.alert_history where error_number = 5084;", "fieldConfig": { "defaults": { "color": { "mode": "thresholds" }, "custom": { - "align": "auto", + "align": "center", "cellOptions": { - "type": "auto" + "type": "auto", + "wrapText": false }, "filterable": true, - "inspect": false + "inspect": true }, "mappings": [], "thresholds": { "mode": "absolute", "steps": [ { - "color": "green" - }, - { - "color": "red", - "value": 80 + "color": "green", + "value": null } ] } @@ -4052,71 +3979,193 @@ { "matcher": { "id": "byName", - "options": "sql_command" + "options": "time" }, "properties": [ { "id": "custom.width", - "value": 352 + "value": 173 } ] }, { "matcher": { "id": "byName", - "options": "program_name" + "options": "error_number" }, "properties": [ { "id": "custom.width", - "value": 169 + "value": 133 } ] }, { "matcher": { "id": "byName", - "options": "session_id" + "options": "database" }, "properties": [ { "id": "custom.width", - "value": 105 + "value": 227 } ] }, { "matcher": { "id": "byName", - "options": "CPU" + "options": "remarks" }, "properties": [ { - "id": "unit", - "value": "ms" + "id": "custom.align", + "value": "left" } ] - }, - { - "matcher": { - "id": "byName", - "options": "granted_memory_kb" - }, - "properties": [ - { - "id": "unit", - "value": "kbytes" - }, + } + ] + }, + "gridPos": { + "h": 8, + "w": 24, + "x": 0, + "y": 52 + }, + "id": 199, + "options": { + "cellHeight": "sm", + "footer": { + "countRows": false, + "enablePagination": false, + "fields": "", + "reducer": [ + "sum" + ], + "show": false + }, + "showHeader": true, + "sortBy": [] + }, + "pluginVersion": "11.3.1", + "targets": [ + { + "dataset": "AdventureWorks2019", + "datasource": { + "type": "mssql", + "uid": "${sqlmonitor_datasource}" + }, + "editorMode": "code", + "format": "table", + "rawQuery": true, + "rawSql": "declare @sql nvarchar(max);\r\ndeclare @params nvarchar(max);\r\ndeclare @sql_instance varchar(255);\r\ndeclare @perfmon_host_name varchar(255);\r\ndeclare @start_time_utc datetime2;\r\ndeclare @end_time_utc datetime2;\r\n\r\nset @sql_instance = '$server';\r\nset @perfmon_host_name = '$perfmon_host_name';\r\nset @start_time_utc = $__timeFrom();\r\nset @end_time_utc = $__timeTo();\r\nset @params = N'@perfmon_host_name varchar(255), @start_time_utc datetime2, @end_time_utc datetime2';\r\n\r\nset quoted_identifier off;\r\nset @sql = \"\r\nselect\t[time] = collection_time_utc, ah.error_number,\r\n\t\t[database] = database_name,\r\n\t\t[remarks] = ah.[error_message]\r\nfrom dbo.alert_history ah\r\nwhere collection_time_utc between @start_time_utc and @end_time_utc\r\n--and ah.error_number in (15457)\r\nand ah.error_number in (5084)\r\norder by time\r\n\"\r\nset quoted_identifier on;\r\n\r\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\r\nif ($is_local = 1)\r\n exec dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;\r\nelse\r\n exec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;", + "refId": "A", + "sql": { + "columns": [ { - "id": "displayName", - "value": "granted_memory" + "parameters": [], + "type": "function" + } + ], + "groupBy": [ + { + "property": { + "type": "string" + }, + "type": "groupBy" + } + ], + "limit": 50 + } + } + ], + "title": "Database Configuration Changes", + "type": "table" + } + ], + "title": "Server & Database Config Changes", + "type": "row" + }, + { + "collapsed": true, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 21 + }, + "id": 113, + "panels": [ + { + "datasource": { + "type": "mssql", + "uid": "${sqlmonitor_datasource}" + }, + "description": "Blocking Details____In Selected Time Duration____Since____${__from:date:YYYY-MM-DD HH.mm}___till___${whoisactive_collection_time_utc:date:YYYY-MM-DD HH.mm}____", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "custom": { + "align": "auto", + "cellOptions": { + "type": "auto" + }, + "filterable": true, + "inspect": false + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + } + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "BLOCKING_TREE" + }, + "properties": [ + { + "id": "custom.width", + "value": 308 } ] }, { "matcher": { "id": "byName", - "options": "reads_kb" + "options": "CPU" + }, + "properties": [ + { + "id": "unit", + "value": "ms" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "writes" + }, + "properties": [ + { + "id": "unit", + "value": "short" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "used_memory_kb" }, "properties": [ { @@ -4125,19 +4174,23 @@ }, { "id": "displayName", - "value": "reads" + "value": "used_memory" } ] }, { "matcher": { "id": "byName", - "options": "writes" + "options": "reads_kb" }, "properties": [ { "id": "unit", - "value": "short" + "value": "kbytes" + }, + { + "id": "displayName", + "value": "reads" } ] }, @@ -4176,7 +4229,7 @@ { "matcher": { "id": "byName", - "options": "used_memory_kb" + "options": "granted_memory_kb" }, "properties": [ { @@ -4185,19 +4238,19 @@ }, { "id": "displayName", - "value": "used_memory" + "value": "granted_memory" } ] } ] }, "gridPos": { - "h": 11, + "h": 8, "w": 24, "x": 0, - "y": 439 + "y": 982 }, - "id": 177, + "id": 111, "options": { "cellHeight": "sm", "footer": { @@ -4209,9 +4262,14 @@ "show": false }, "showHeader": true, - "sortBy": [] + "sortBy": [ + { + "desc": false, + "displayName": "collection_time" + } + ] }, - "pluginVersion": "10.1.0", + "pluginVersion": "11.3.1", "targets": [ { "alias": "", @@ -4222,7 +4280,7 @@ "editorMode": "code", "format": "table", "rawQuery": true, - "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\ndeclare @start_time_utc datetime2;\ndeclare @end_time_utc datetime2;\ndeclare @crlf nchar(2) = nchar(13)+nchar(10);\n\n--declare @delta_minutes int;\ndeclare @program_name nvarchar(500);\ndeclare @login_name nvarchar(255);\ndeclare @database nvarchar(500) = '$database';\ndeclare @session_id int;\ndeclare @session_host_name nvarchar(125);\ndeclare @query_pattern nvarchar(500);\ndeclare @duration int;\ndeclare @memory_grant_threshold_mb int = $memory_grant_threshold_mb;\n\nset @database = case when ltrim(rtrim(@database)) = '__All__' then null else @database end;\nset @duration = case when ltrim(rtrim('$duration')) <> '' then $duration else 0 end;\nif len(ltrim(rtrim('$program_name'))) > 0\n set @program_name = '$program_name'\nif len(ltrim(rtrim('$login_name'))) > 0\n set @login_name = '$login_name'\nif len(ltrim(rtrim('$session_host_name'))) > 0\n set @session_host_name = '$session_host_name'\nif len(ltrim(rtrim('$query_pattern'))) > 0\n set @query_pattern = '$query_pattern'\nif len(ltrim(rtrim('$session_id'))) > 0 and (case when '$session_id' like '%[^0-9.]%' then 'invalid' when '$session_id' like '%.%.%' then 'invalid' else 'valid' end) = 'valid'\n set @session_id = convert(int,'$session_id');\n\nset @sql_instance = '$server';\n--set @perfmon_host_name = '$perfmon_host_name';\nset @start_time_utc = $__timeFrom();\n--set @start_time_utc = dateadd(second,$sqlserver_start_time_utc/1000,'1970-01-01 00:00:00');\nset @end_time_utc = $__timeTo();\n--set @end_time_utc = $__timeFrom();\n--set @delta_minutes = $cpu_delta_minutes;\nset @params = N'@perfmon_host_name varchar(255), @start_time_utc datetime2, @end_time_utc datetime2,\n\t\t\t\t@program_name nvarchar(500), @login_name nvarchar(255), @database nvarchar(500),\n\t\t\t\t@session_id int, @session_host_name nvarchar(125), @query_pattern nvarchar(500),\n\t\t\t\t@duration int, @memory_grant_threshold_mb int';\n\nset quoted_identifier off;\nset @sql = \"/* SQLMonitor Dashboard $__dashboard: LongRunningQueries */\nset nocount on;\t\t\t\nif exists ( select * from $whoisactive_table_name w with (nolock)\n where w.collection_time = (select max(i.collection_time) from $whoisactive_table_name i with (nolock)) \n and granted_memory >= (@memory_grant_threshold_mb*1024/8) )\nbegin\n ;with t_WhoIsActive as (\n select [collection_time] = convert(varchar,w.collection_time,120), w.session_id, \n w.program_name, w.login_name, w.database_name, w.host_name,\n w.status, w.CPU, w.used_memory, w.open_tran_count, [duration_ms] = datediff(MILLISECOND, start_time, w.collection_time),\n w.wait_info, granted_memory, tempdb_current,\n sql_command = case when w.sql_command is not null then left(replace(replace(convert(nvarchar(max),w.sql_command),char(13)+char(10),''),'= (@memory_grant_threshold_mb*1024/8)\n )\n select [collection_time] = DATEADD(mi, DATEDIFF(mi, getdate(), getutcdate()), [collection_time]), w.session_id,\n [ddd hh:mm:ss.mss] = right('0000'+convert(varchar, duration_ms/86400000),3)+ ' '+convert(varchar,dateadd(MILLISECOND,duration_ms,'1900-01-01 00:00:00'),114), \n w.program_name, w.login_name, w.database_name, w.host_name, w.status, w.CPU, \n granted_memory_kb = (w.granted_memory * 8.0), w.open_tran_count, w.wait_info, w.sql_command, w.blocked_session_count, \n w.blocking_session_id, [reads_kb] = (w.[reads]*8.0), w.writes, [tempdb_allocations_kb] = (w.tempdb_allocations*8.0), \n tempdb_current_kb = (tempdb_current*8.0), w.tasks, w.percent_complete, [used_memory_kb] = (w.used_memory*8.0),\n start_time = DATEADD(mi, DATEDIFF(mi, getdate(), getutcdate()), [start_time])\n from t_WhoIsActive w\n order by granted_memory desc, used_memory desc, collection_time\nend\nELSE\n select 'No long running query found for time window' as [No Result]\n\"\nset quoted_identifier on;\n--print @sql\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nif ($is_local = 1)\n exec dbo.sp_executesql @sql, @params, @perfmon_host_name, @start_time_utc, @end_time_utc, \n\t\t\t\t\t@program_name, @login_name, @database, @session_id, @session_host_name, \n\t\t\t\t\t@query_pattern, @duration, @memory_grant_threshold_mb;\nelse\n exec [$server].[$dba_db].dbo.sp_executesql @sql, @params, @perfmon_host_name, @start_time_utc, @end_time_utc,\n\t\t\t\t\t@program_name, @login_name, @database, @session_id, @session_host_name, \n\t\t\t\t\t@query_pattern, @duration, @memory_grant_threshold_mb;", + "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\ndeclare @start_time_utc datetime2;\ndeclare @end_time_utc datetime2;\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @start_time_utc = $__timeFrom();\nset @end_time_utc = $__timeTo();\nset @params = N'@perfmon_host_name varchar(255), @start_time_utc datetime2, @end_time_utc datetime2';\n\nset quoted_identifier off;\nset @sql = \"\nset nocount on;\n\ndeclare @collection_time datetime;\nselect @collection_time = max(l.collection_time) from dbo.WhoIsActive l;\n\n-- Get Blocking Tree\nif exists (select 1/0 from dbo.WhoIsActive w with (nolock) where w.collection_time = @collection_time and (blocking_session_id is not null or blocked_session_count > 0))\nbegin\n\t;WITH T_BLOCKERS AS (\n\t\t-- Find block Leaders\n\t\tSELECT\t[duration_s] = datediff(SECOND, start_time, r.collection_time), [collection_time], [session_id], \n\t\t\t\t[sql_text] = REPLACE(REPLACE(REPLACE(REPLACE(CAST(COALESCE([sql_command],[sql_text]) AS VARCHAR(MAX)),char(13),''),CHAR(10),''),'',''), \n\t\t\t\tcommand = additional_info.value('(/additional_info/command_type)[1]','varchar(125)'), [login_name], wait_info, [blocking_session_id], [blocked_session_count] = replace(blocked_session_count,',',''),\n\t\t\t\t[status], open_tran_count, [host_name], [database_name], [program_name], tasks, granted_memory, r.CPU, r.used_memory, r.[tempdb_allocations], r.[tempdb_current], r.[reads], r.[writes], r.[physical_io], additional_info,\n\t\t\t\t[LEVEL] = CAST (REPLICATE ('0', 4-LEN (CAST (r.session_id AS VARCHAR))) + CAST (r.session_id AS VARCHAR) AS VARCHAR (1000))\n\t\t\t\t,[head_blocker] = session_id ,query_plan\n\t\tFROM\tdbo.WhoIsActive AS r with (nolock) WHERE r.collection_time = @collection_time and (r.blocking_session_id IS NULL AND blocked_session_count > 0)\n\t\t--\t\n\t\tUNION ALL\n\t\t--\n\t\tSELECT\t[duration_s] = datediff(SECOND, r.start_time, r.collection_time), r.[collection_time], r.[session_id], \n\t\t\t\t[sql_text] = REPLACE(REPLACE(REPLACE(REPLACE(CAST(COALESCE(r.[sql_command],r.[sql_text]) AS VARCHAR(MAX)),char(13),''),CHAR(10),''),'',''), \n\t\t\t\tcommand = r.additional_info.value('(/additional_info/command_type)[1]','varchar(125)'), r.[login_name], r.wait_info, r.[blocking_session_id], [blocked_session_count] = replace(r.blocked_session_count,',',''),\n\t\t\t\tr.[status], r.open_tran_count, r.[host_name], r.[database_name], r.[program_name], r.tasks, r.granted_memory, r.CPU, r.used_memory, r.[tempdb_allocations], r.[tempdb_current], r.[reads], r.[writes], r.[physical_io], r.additional_info,\n\t\t\t\tCAST (B.LEVEL + RIGHT (CAST ((1000 + r.session_id) AS VARCHAR (100)), 4) AS VARCHAR (1000)) AS LEVEL\n\t\t\t\t,[head_blocker] = case when B.[head_blocker] is null then B.session_id else B.[head_blocker] end ,r.query_plan\n\t\tFROM\tdbo.WhoIsActive AS r with (nolock)\n\t\tINNER JOIN T_BLOCKERS AS B ON\tr.collection_time = B.collection_time AND r.blocking_session_id = B.session_id\n\t\tWHERE\t r.blocking_session_id <> r.session_id\n\t)\n\tSELECT\t[collection_time] = DATEADD(mi, DATEDIFF(mi, getdate(), getutcdate()), [collection_time]), \n\t\t\t[ddd hh:mm:ss] = right('0000'+convert(varchar, duration_s/86400),3)+ ' '+convert(varchar,dateadd(SECOND,duration_s,'1900-01-01 00:00:00'),108), \n\t\t\t[session_id], \n\t\t\t[BLOCKING_TREE] = N' ' + REPLICATE (N'| ', LEN (LEVEL)/4 - 1) \n\t\t\t\t\t\t\t+\tCASE\tWHEN (LEN(LEVEL)/4 - 1) = 0\n\t\t\t\t\t\t\t\t\t\tTHEN 'HEAD - '\n\t\t\t\t\t\t\t\t\t\tELSE '|------ ' \n\t\t\t\t\t\t\t\tEND\n\t\t\t\t\t\t\t+\tCAST (r.session_id AS NVARCHAR (10)) + N' ' + ISNULL((CASE WHEN LEFT(ISNULL(r.[sql_text],''),1) = '(' THEN SUBSTRING(ISNULL(r.[sql_text],''),CHARINDEX('exec',ISNULL(r.[sql_text],'')),LEN(ISNULL(r.[sql_text],''))) ELSE ISNULL(r.[sql_text],'') END),''),\n\t\t\t[blocking_session_id], [blocked_session_count] = case when [blocked_session_count] = 0 then null else [blocked_session_count] end, r.wait_info, [login_name], [program_name], [host_name], tasks, command, [database_name], status, r.open_tran_count, r.CPU, [used_memory_kb] = (r.used_memory*8.0), [reads_kb] = (r.[reads]*8.0), r.[writes], [tempdb_allocations_kb] = tempdb_allocations*8.0, tempdb_current_kb = tempdb_current*8.0, granted_memory_kb = granted_memory * 8.0\n\t\t\t--,r.query_plan ,r.additional_info\n\tFROM\tT_BLOCKERS AS r ORDER BY collection_time, LEVEL;\nend\nelse\n select 'No Blocking Found for Time Window' as [No Result]\n\"\nset quoted_identifier on;\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nif ($is_local = 1)\n exec dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;\nelse\n exec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;", "refId": "A", "sql": { "columns": [ @@ -4243,11 +4301,12 @@ } } ], - "title": "Memory Consumers Over __ $memory_grant_threshold_mb MB__ \"- WhoIsActive Data @ ${whoisactive_collection_time_utc:date:YYYY-MM-DD HH.mm}", + "title": "Blocking Details - ACTIVE - [sp_WhoIsActive] @ ${whoisactive_collection_time_utc:date:YYYY-MM-DD HH.mm}", "type": "table" } ], - "title": "M/r Consumers - ACTIVE - [sp_WhoIsActive] @ ${whoisactive_collection_time_utc:date:YYYY-MM-DD HH.mm}", + "repeat": "datasource", + "title": "Blocking Tree (Queries) - ACTIVE - [sp_WhoIsActive] @ ${whoisactive_collection_time_utc:date:YYYY-MM-DD HH.mm}", "type": "row" }, { @@ -4256,28 +4315,57 @@ "h": 1, "w": 24, "x": 0, - "y": 23 + "y": 22 }, - "id": 188, + "id": 151, "panels": [ { "datasource": { "type": "mssql", "uid": "${sqlmonitor_datasource}" }, - "description": "select [collection_time], [data_size_mb], [data_used_mb], [data_used_pct], [log_size_mb], [log_used_mb], [log_used_pct], [version_store_mb], [version_store_pct]\nfrom dbo.tempdb_space_usage tsu\nwhere 1=1\nand tsu.collection_time = (select top 1 i.collection_time from dbo.tempdb_space_usage i order by i.collection_time desc)", + "description": "select * from $whoisactive_table_name\nwhere (w.blocking_session_id is null and blocked_session_count > 0)", "fieldConfig": { "defaults": { "color": { - "mode": "thresholds" + "mode": "palette-classic" }, "custom": { - "align": "center", - "cellOptions": { - "type": "auto" + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false }, - "filterable": false, - "inspect": true + "insertNulls": false, + "lineInterpolation": "linear", + "lineStyle": { + "fill": "solid" + }, + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "log": 10, + "type": "log" + }, + "showPoints": "always", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "normal" + }, + "thresholdsStyle": { + "mode": "off" + } }, "mappings": [], "thresholds": { @@ -4285,359 +4373,506 @@ "steps": [ { "color": "green" - }, - { - "color": "red", - "value": 80 - } - ] - } - }, - "overrides": [ - { - "matcher": { - "id": "byName", - "options": "collection_time_utc" - }, - "properties": [ - { - "id": "displayName", - "value": "Collection Time" - }, - { - "id": "custom.cellOptions", - "value": { - "type": "color-background" - } - }, - { - "id": "thresholds", - "value": { - "mode": "absolute", - "steps": [ - { - "color": "super-light-purple" - } - ] - } } ] }, - { - "matcher": { - "id": "byName", - "options": "data_size_mb" - }, - "properties": [ + "unit": "short" + }, + "overrides": [] + }, + "gridPos": { + "h": 11, + "w": 24, + "x": 0, + "y": 983 + }, + "id": 149, + "options": { + "legend": { + "calcs": [ + "mean", + "max" + ], + "displayMode": "table", + "placement": "right", + "showLegend": true, + "sortBy": "Mean", + "sortDesc": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.3.1", + "targets": [ + { + "alias": "", + "datasource": { + "type": "mssql", + "uid": "${sqlmonitor_datasource}" + }, + "format": "time_series", + "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\ndeclare @start_time_utc datetime2;\ndeclare @end_time_utc datetime2;\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @start_time_utc = $__timeFrom();\nset @end_time_utc = $__timeTo();\nset @params = N'@perfmon_host_name varchar(255), @start_time_utc datetime2, @end_time_utc datetime2';\n\nset quoted_identifier off;\nset @sql = \"\nset nocount on;\nselect DATEADD(mi, DATEDIFF(mi, getdate(), getutcdate()), collection_time) as [time], w.login_name as metric, sum(convert(int,replace(w.blocked_session_count,',',''))) as [value]\nfrom $whoisactive_table_name w with (nolock)\nwhere (collection_time between DATEADD(mi, DATEDIFF(mi, GETUTCDATE(), GETDATE()), @start_time_utc) and DATEADD(mi, DATEDIFF(mi, GETUTCDATE(), GETDATE()), @end_time_utc))\nand (w.blocking_session_id is null and replace(w.blocked_session_count,',','') > 0) -- get lead blockers only\ngroup by collection_time, w.login_name\norder by time\n\"\nset quoted_identifier on;\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nif ($is_local = 1)\n exec dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;\nelse\n exec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;", + "refId": "A" + } + ], + "title": "[${server}] - Lead Blockers - Logins - Blocked Count", + "type": "timeseries" + }, + { + "datasource": { + "type": "mssql", + "uid": "${sqlmonitor_datasource}" + }, + "description": "select * from $whoisactive_table_name\nwhere (w.blocking_session_id is null and blocked_session_count > 0)", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "linear", + "lineStyle": { + "fill": "solid" + }, + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "log": 10, + "type": "log" + }, + "showPoints": "always", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "normal" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ { - "id": "displayName", - "value": "Data Size" + "color": "green" + } + ] + }, + "unit": "short" + }, + "overrides": [] + }, + "gridPos": { + "h": 11, + "w": 24, + "x": 0, + "y": 1141 + }, + "id": 152, + "options": { + "legend": { + "calcs": [ + "mean", + "max" + ], + "displayMode": "table", + "placement": "right", + "showLegend": true, + "sortBy": "Mean", + "sortDesc": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "8.4.4", + "targets": [ + { + "alias": "", + "datasource": { + "type": "mssql", + "uid": "${sqlmonitor_datasource}" + }, + "format": "time_series", + "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\ndeclare @start_time_utc datetime2;\ndeclare @end_time_utc datetime2;\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @start_time_utc = $__timeFrom();\nset @end_time_utc = $__timeTo();\nset @params = N'@perfmon_host_name varchar(255), @start_time_utc datetime2, @end_time_utc datetime2';\n\nset quoted_identifier off;\nset @sql = \"\nset nocount on;\nselect DATEADD(mi, DATEDIFF(mi, getdate(), getutcdate()), collection_time) as [time], \n w.login_name+' {{'+(case when len(w.program_name)>35 then left(w.program_name,35)+'..' else w.program_name end)+'}}' as metric, sum(convert(int,replace(w.blocked_session_count,',',''))) as [value]\nfrom $whoisactive_table_name w with (nolock)\nwhere (collection_time between DATEADD(mi, DATEDIFF(mi, GETUTCDATE(), GETDATE()), @start_time_utc) and DATEADD(mi, DATEDIFF(mi, GETUTCDATE(), GETDATE()), @end_time_utc))\nand (w.blocking_session_id is null and replace(w.blocked_session_count,',','') > 0) -- get lead blockers only\ngroup by collection_time, w.login_name, w.program_name\norder by time\n\"\nset quoted_identifier on;\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nif ($is_local = 1)\n exec dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;\nelse\n exec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;", + "refId": "A" + } + ], + "title": "[${server}] - Lead Blockers - Programs - Blocked Count", + "type": "timeseries" + } + ], + "repeat": "datasource", + "title": "Lead Blockers - @ ${perfmon_collection_time_utc:date:YYYY-MM-DD HH.mm}", + "type": "row" + }, + { + "collapsed": true, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 23 + }, + "id": 59, + "panels": [ + { + "datasource": { + "type": "mssql", + "uid": "${sqlmonitor_datasource}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 10, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "log": 2, + "type": "log" + }, + "showPoints": "never", + "spanNulls": true, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "line+area" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "transparent", + "value": null }, { - "id": "unit", - "value": "mbytes" + "color": "orange", + "value": 0 }, { - "id": "links", - "value": [ - { - "targetBlank": true, - "title": "Perfmon - Data File Growth Trend", - "url": "d/distributed_perfmon?var-server=${server}&var-database=tempdb&viewPanel=115" - } - ] + "color": "red", + "value": 2 } ] }, + "unit": "short" + }, + "overrides": [] + }, + "gridPos": { + "h": 7, + "w": 24, + "x": 0, + "y": 444 + }, + "id": 57, + "options": { + "legend": { + "calcs": [ + "mean", + "lastNotNull", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.3.1", + "targets": [ + { + "alias": "", + "datasource": { + "type": "mssql", + "uid": "${sqlmonitor_datasource}" + }, + "editorMode": "code", + "format": "time_series", + "hide": false, + "rawQuery": true, + "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\ndeclare @start_time_utc datetime2;\ndeclare @end_time_utc datetime2;\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @start_time_utc = $__timeFrom();\nset @end_time_utc = $__timeTo();\nset @params = N'@perfmon_host_name varchar(255), @start_time_utc datetime2, @end_time_utc datetime2';\n\nset quoted_identifier off;\nset @sql = \"\nset nocount on;\ndeclare @object_name varchar(255);\nset @object_name = (case when '$perfmon_service_name' = 'MSSQLSERVER' then 'sqlserver' else LOWER('$perfmon_service_name') end);\nselect pc.collection_time_utc as time, \n\tcounter as metric\n\t--,instance,\n\t,pc.value\nfrom $perfmon_table_name pc with (nolock)\nwhere collection_time_utc between @start_time_utc and @end_time_utc\nand pc.host_name = @perfmon_host_name\nand (\t(pc.object = (@object_name+':memory manager')\n\t\tand pc.counter in ('memory grants outstanding','memory grants pending'))\n\t)\norder by time\n\"\nset quoted_identifier on;\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nif ($is_local = 1)\n exec dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;\nelse\n exec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;", + "refId": "A", + "sql": { + "columns": [ + { + "parameters": [], + "type": "function" + } + ], + "groupBy": [ + { + "property": { + "type": "string" + }, + "type": "groupBy" + } + ], + "limit": 50 + } + } + ], + "title": "Memory Grants Pending", + "type": "timeseries" + } + ], + "repeat": "datasource", + "title": "Trend - Memory Grants Pending", + "type": "row" + }, + { + "collapsed": true, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 24 + }, + "id": 179, + "panels": [ + { + "datasource": { + "type": "mssql", + "uid": "${sqlmonitor_datasource}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "custom": { + "align": "auto", + "cellOptions": { + "type": "auto" + }, + "filterable": true, + "inspect": false + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [ { "matcher": { "id": "byName", - "options": "data_used_mb" + "options": "sql_command" }, "properties": [ { - "id": "displayName", - "value": "Data Used" - }, - { - "id": "unit", - "value": "mbytes" - }, - { - "id": "links", - "value": [ - { - "targetBlank": true, - "title": "Perfmon - Tempdb Free Space Trend", - "url": "d/distributed_perfmon?var-server=$server&var-database=tempdb&viewPanel=89" - } - ] + "id": "custom.width", + "value": 352 } ] }, { "matcher": { "id": "byName", - "options": "data_used_pct" + "options": "program_name" }, "properties": [ { - "id": "displayName", - "value": "Data Used %" - }, + "id": "custom.width", + "value": 169 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "session_id" + }, + "properties": [ { - "id": "custom.cellOptions", - "value": { - "type": "color-background" - } - }, + "id": "custom.width", + "value": 105 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "CPU" + }, + "properties": [ { "id": "unit", - "value": "percent" - }, - { - "id": "thresholds", - "value": { - "mode": "absolute", - "steps": [ - { - "color": "green" - }, - { - "color": "#EAB839", - "value": 70 - }, - { - "color": "#EF843C", - "value": 80 - }, - { - "color": "super-light-red", - "value": 90 - }, - { - "color": "red", - "value": 95 - } - ] - } - }, - { - "id": "links", - "value": [ - { - "targetBlank": true, - "title": "Perfmon - Tempdb % Free Trend", - "url": "d/distributed_perfmon?var-server=$server&var-database=tempdb&viewPanel=89" - } - ] + "value": "ms" } ] }, { "matcher": { "id": "byName", - "options": "log_size_mb" + "options": "granted_memory_kb" }, "properties": [ - { - "id": "displayName", - "value": "Log Size" - }, { "id": "unit", - "value": "mbytes" + "value": "kbytes" }, { - "id": "links", - "value": [ - { - "targetBlank": true, - "title": "Perfmon - Log Usage Trend", - "url": "d/distributed_perfmon?var-server=$server&var-database=tempdb&viewPanel=38" - } - ] + "id": "displayName", + "value": "granted_memory" } ] }, { "matcher": { "id": "byName", - "options": "log_used_mb" + "options": "reads_kb" }, "properties": [ { - "id": "displayName", - "value": "Log Used" + "id": "unit", + "value": "kbytes" }, { - "id": "links", - "value": [ - { - "targetBlank": true, - "title": "Perfmon - Log Usage Trend", - "url": "d/distributed_perfmon?var-server=$server&var-database=tempdb&viewPanel=38" - } - ] - }, + "id": "displayName", + "value": "reads" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "writes" + }, + "properties": [ { "id": "unit", - "value": "mbytes" + "value": "short" } ] }, { "matcher": { "id": "byName", - "options": "log_used_pct" + "options": "tempdb_allocations_kb" }, "properties": [ - { - "id": "displayName", - "value": "Log Used %" - }, { "id": "unit", - "value": "percent" - }, - { - "id": "custom.cellOptions", - "value": { - "type": "color-background" - } + "value": "kbytes" }, { - "id": "thresholds", - "value": { - "mode": "absolute", - "steps": [ - { - "color": "green" - }, - { - "color": "#EAB839", - "value": 70 - }, - { - "color": "orange", - "value": 80 - }, - { - "color": "red", - "value": 90 - } - ] - } + "id": "displayName", + "value": "tempdb_allocations" } ] }, { "matcher": { "id": "byName", - "options": "version_store_mb" + "options": "tempdb_current_kb" }, "properties": [ - { - "id": "displayName", - "value": "Version Store" - }, { "id": "unit", - "value": "mbytes" + "value": "kbytes" }, { - "id": "links", - "value": [ - { - "targetBlank": true, - "title": "Perfmon - Version Store Usage Trend", - "url": "d/distributed_perfmon?var-server=$server&var-database=tempdb&viewPanel=90" - } - ] + "id": "displayName", + "value": "tempdb_current" } ] }, { "matcher": { "id": "byName", - "options": "version_store_pct" + "options": "used_memory_kb" }, "properties": [ - { - "id": "displayName", - "value": "Version Store %" - }, { "id": "unit", - "value": "percent" - }, - { - "id": "custom.cellOptions", - "value": { - "type": "color-background" - } - }, - { - "id": "thresholds", - "value": { - "mode": "absolute", - "steps": [ - { - "color": "green" - }, - { - "color": "#EAB839", - "value": 70 - }, - { - "color": "orange", - "value": 80 - }, - { - "color": "red", - "value": 90 - } - ] - } + "value": "kbytes" }, { - "id": "links", - "value": [ - { - "targetBlank": true, - "title": "Perfmon - VersionStore Usage Trend", - "url": "d/distributed_perfmon?var-server=$server&var-database=tempdb&viewPanel=90" - } - ] + "id": "displayName", + "value": "used_memory" } ] } ] }, "gridPos": { - "h": 4, + "h": 11, "w": 24, "x": 0, - "y": 255 + "y": 67 }, - "id": 189, + "id": 177, "options": { "cellHeight": "sm", "footer": { "countRows": false, - "enablePagination": false, "fields": "", "reducer": [ "sum" ], "show": false }, - "showHeader": true + "showHeader": true, + "sortBy": [] }, "pluginVersion": "11.3.1", "targets": [ { - "dataset": "AdventureWorks2019", + "alias": "", "datasource": { "type": "mssql", "uid": "${sqlmonitor_datasource}" @@ -4645,7 +4880,7 @@ "editorMode": "code", "format": "table", "rawQuery": true, - "rawSql": "declare @sql nvarchar(max);\r\ndeclare @params nvarchar(max);\r\ndeclare @sql_instance varchar(255);\r\ndeclare @crlf nchar(2) = nchar(13)+nchar(10);\r\n\r\nset @sql_instance = '$server';\r\n\r\n--set @params = N'';\r\n\r\nset quoted_identifier off;\r\nset @sql = \"/* SQLMonitor Dashboard Monitoring - Live - Distributed: TempdbSaver - tempdb_space_usage */\r\nset nocount on;\t\t\t\r\nselect [collection_time_utc] = DATEADD(mi, DATEDIFF(mi, getdate(), getutcdate()), collection_time), [data_size_mb], [data_used_mb], [data_used_pct], [log_size_mb], [log_used_mb], [log_used_pct], [version_store_mb], [version_store_pct]\r\nfrom dbo.tempdb_space_usage tsu\r\nwhere 1=1\r\nand tsu.collection_time = (select top 1 i.collection_time from dbo.tempdb_space_usage i order by i.collection_time desc)\r\n\"\r\nset quoted_identifier on;\r\n--print @sql\r\n\r\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\r\nif ($is_local = 1)\r\n exec dbo.sp_executesql @sql, @params;\r\nelse\r\n exec [$server].[$dba_db].dbo.sp_executesql @sql, @params;", + "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\ndeclare @start_time_utc datetime2;\ndeclare @end_time_utc datetime2;\ndeclare @crlf nchar(2) = nchar(13)+nchar(10);\n\n--declare @delta_minutes int;\ndeclare @program_name nvarchar(500);\ndeclare @login_name nvarchar(255);\ndeclare @database nvarchar(500) = '$database';\ndeclare @session_id int;\ndeclare @session_host_name nvarchar(125);\ndeclare @query_pattern nvarchar(500);\ndeclare @duration int;\ndeclare @memory_grant_threshold_mb int = $memory_grant_threshold_mb;\n\nset @database = case when ltrim(rtrim(@database)) = '__All__' then null else @database end;\nset @duration = case when ltrim(rtrim('$duration')) <> '' then $duration else 0 end;\nif len(ltrim(rtrim('$program_name'))) > 0\n set @program_name = '$program_name'\nif len(ltrim(rtrim('$login_name'))) > 0\n set @login_name = '$login_name'\nif len(ltrim(rtrim('$session_host_name'))) > 0\n set @session_host_name = '$session_host_name'\nif len(ltrim(rtrim('$query_pattern'))) > 0\n set @query_pattern = '$query_pattern'\nif len(ltrim(rtrim('$session_id'))) > 0 and (case when '$session_id' like '%[^0-9.]%' then 'invalid' when '$session_id' like '%.%.%' then 'invalid' else 'valid' end) = 'valid'\n set @session_id = convert(int,'$session_id');\n\nset @sql_instance = '$server';\n--set @perfmon_host_name = '$perfmon_host_name';\nset @start_time_utc = $__timeFrom();\n--set @start_time_utc = dateadd(second,$sqlserver_start_time_utc/1000,'1970-01-01 00:00:00');\nset @end_time_utc = $__timeTo();\n--set @end_time_utc = $__timeFrom();\n--set @delta_minutes = $cpu_delta_minutes;\nset @params = N'@perfmon_host_name varchar(255), @start_time_utc datetime2, @end_time_utc datetime2,\n\t\t\t\t@program_name nvarchar(500), @login_name nvarchar(255), @database nvarchar(500),\n\t\t\t\t@session_id int, @session_host_name nvarchar(125), @query_pattern nvarchar(500),\n\t\t\t\t@duration int, @memory_grant_threshold_mb int';\n\nset quoted_identifier off;\nset @sql = \"/* SQLMonitor Dashboard $__dashboard: LongRunningQueries */\nset nocount on;\t\t\t\nif exists ( select * from $whoisactive_table_name w with (nolock)\n where w.collection_time = (select max(i.collection_time) from $whoisactive_table_name i with (nolock)) \n and granted_memory >= (@memory_grant_threshold_mb*1024/8) )\nbegin\n ;with t_WhoIsActive as (\n select [collection_time] = convert(varchar,w.collection_time,120), w.session_id, \n w.program_name, w.login_name, w.database_name, w.host_name,\n w.status, w.CPU, w.used_memory, w.open_tran_count, [duration_ms] = datediff(MILLISECOND, start_time, w.collection_time),\n w.wait_info, granted_memory, tempdb_current,\n sql_command = case when w.sql_command is not null then left(replace(replace(convert(nvarchar(max),w.sql_command),char(13)+char(10),''),'= (@memory_grant_threshold_mb*1024/8)\n )\n select [collection_time] = DATEADD(mi, DATEDIFF(mi, getdate(), getutcdate()), [collection_time]), w.session_id,\n [ddd hh:mm:ss.mss] = right('0000'+convert(varchar, duration_ms/86400000),3)+ ' '+convert(varchar,dateadd(MILLISECOND,duration_ms,'1900-01-01 00:00:00'),114), \n w.program_name, w.login_name, w.database_name, w.host_name, w.status, w.CPU, \n granted_memory_kb = (w.granted_memory * 8.0), w.open_tran_count, w.wait_info, w.sql_command, w.blocked_session_count, \n w.blocking_session_id, [reads_kb] = (w.[reads]*8.0), w.writes, [tempdb_allocations_kb] = (w.tempdb_allocations*8.0), \n tempdb_current_kb = (tempdb_current*8.0), w.tasks, w.percent_complete, [used_memory_kb] = (w.used_memory*8.0),\n start_time = DATEADD(mi, DATEDIFF(mi, getdate(), getutcdate()), [start_time])\n from t_WhoIsActive w\n order by granted_memory desc, used_memory desc, collection_time\nend\nELSE\n select 'No long running query found for time window' as [No Result]\n\"\nset quoted_identifier on;\n--print @sql\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nif ($is_local = 1)\n exec dbo.sp_executesql @sql, @params, @perfmon_host_name, @start_time_utc, @end_time_utc, \n\t\t\t\t\t@program_name, @login_name, @database, @session_id, @session_host_name, \n\t\t\t\t\t@query_pattern, @duration, @memory_grant_threshold_mb;\nelse\n exec [$server].[$dba_db].dbo.sp_executesql @sql, @params, @perfmon_host_name, @start_time_utc, @end_time_utc,\n\t\t\t\t\t@program_name, @login_name, @database, @session_id, @session_host_name, \n\t\t\t\t\t@query_pattern, @duration, @memory_grant_threshold_mb;", "refId": "A", "sql": { "columns": [ @@ -4666,15 +4901,29 @@ } } ], - "title": "TempdbSaver - tempdb_space_usage", + "title": "Memory Consumers Over __ $memory_grant_threshold_mb MB__ \"- WhoIsActive Data @ ${whoisactive_collection_time_utc:date:YYYY-MM-DD HH.mm}", "type": "table" - }, + } + ], + "title": "M/r Consumers - ACTIVE - [sp_WhoIsActive] @ ${whoisactive_collection_time_utc:date:YYYY-MM-DD HH.mm}", + "type": "row" + }, + { + "collapsed": true, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 25 + }, + "id": 188, + "panels": [ { "datasource": { "type": "mssql", "uid": "${sqlmonitor_datasource}" }, - "description": "select [collection_time], [usage_rank], [spid], [login_name], [program_name], [host_name], [host_process_id], [is_active_session], [open_transaction_count], [transaction_isolation_level], [size_bytes], [transaction_begin_time], [is_snapshot], [log_bytes], [log_rsvd], [action_taken] \nfrom dbo.tempdb_space_consumers tsc \nwhere 1=1 \nand tsc.collection_time = (select top 1 i.collection_time from dbo.tempdb_space_usage i order by i.collection_time desc)\nand (tsc.size_bytes > 0 or tsc.is_snapshot = 1)", + "description": "select [collection_time], [data_size_mb], [data_used_mb], [data_used_pct], [log_size_mb], [log_used_mb], [log_used_pct], [version_store_mb], [version_store_pct]\nfrom dbo.tempdb_space_usage tsu\nwhere 1=1\nand tsu.collection_time = (select top 1 i.collection_time from dbo.tempdb_space_usage i order by i.collection_time desc)", "fieldConfig": { "defaults": { "color": { @@ -4693,7 +4942,8 @@ "mode": "absolute", "steps": [ { - "color": "green" + "color": "green", + "value": null }, { "color": "red", @@ -4725,7 +4975,8 @@ "mode": "absolute", "steps": [ { - "color": "super-light-purple" + "color": "super-light-purple", + "value": null } ] } @@ -4810,7 +5061,8 @@ "mode": "absolute", "steps": [ { - "color": "green" + "color": "green", + "value": null }, { "color": "#EAB839", @@ -4921,7 +5173,8 @@ "mode": "absolute", "steps": [ { - "color": "green" + "color": "green", + "value": null }, { "color": "#EAB839", @@ -4992,7 +5245,8 @@ "mode": "absolute", "steps": [ { - "color": "green" + "color": "green", + "value": null }, { "color": "#EAB839", @@ -5027,9 +5281,9 @@ "h": 4, "w": 24, "x": 0, - "y": 391 + "y": 68 }, - "id": 190, + "id": 189, "options": { "cellHeight": "sm", "footer": { @@ -5054,7 +5308,7 @@ "editorMode": "code", "format": "table", "rawQuery": true, - "rawSql": "declare @sql nvarchar(max);\r\ndeclare @params nvarchar(max);\r\ndeclare @sql_instance varchar(255);\r\ndeclare @crlf nchar(2) = nchar(13)+nchar(10);\r\n\r\nset @sql_instance = '$server';\r\n\r\n--set @params = N'';\r\n\r\nset quoted_identifier off;\r\nset @sql = \"/* SQLMonitor Dashboard Monitoring - Live - Distributed: TempdbSaver - tempdb_space_usage */\r\nset nocount on;\r\nif exists ( select 1/0 from dbo.tempdb_space_consumers tsc with (nolock)\r\n where 1=1 \r\n and tsc.collection_time = (select top 1 tsu.collection_time from tempdb_space_usage tsu order by tsu.collection_time desc)\r\n and (tsc.size_bytes > 0 or tsc.is_snapshot = 1)\r\n )\r\nbegin\t\r\n select [collection_time_utc] = DATEADD(mi, DATEDIFF(mi, getdate(), getutcdate()), collection_time), [usage_rank], [spid], [login_name], \r\n [program_name], [host_name], [host_process_id], [is_active_session], [open_transaction_count], [transaction_isolation_level], [size_bytes], \r\n [transaction_begin_time] = DATEADD(mi, DATEDIFF(mi, getdate(), getutcdate()), transaction_begin_time), [is_snapshot], [log_bytes], [log_rsvd], [action_taken] \r\n from dbo.tempdb_space_consumers tsc \r\n where 1=1 \r\n and tsc.collection_time = (select top 1 tsu.collection_time from tempdb_space_usage tsu order by tsu.collection_time desc)\r\n and (tsc.size_bytes > 0 or tsc.is_snapshot = 1)\r\nend\r\nELSE\r\n select 'No tempdb consumers record in latest snapshot.' as [No Result]\r\n\"\r\nset quoted_identifier on;\r\n--print @sql\r\n\r\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\r\nif ($is_local = 1)\r\n exec dbo.sp_executesql @sql, @params;\r\nelse\r\n exec [$server].[$dba_db].dbo.sp_executesql @sql, @params;", + "rawSql": "declare @sql nvarchar(max);\r\ndeclare @params nvarchar(max);\r\ndeclare @sql_instance varchar(255);\r\ndeclare @crlf nchar(2) = nchar(13)+nchar(10);\r\n\r\nset @sql_instance = '$server';\r\n\r\n--set @params = N'';\r\n\r\nset quoted_identifier off;\r\nset @sql = \"/* SQLMonitor Dashboard Monitoring - Live - Distributed: TempdbSaver - tempdb_space_usage */\r\nset nocount on;\t\t\t\r\nselect [collection_time_utc] = DATEADD(mi, DATEDIFF(mi, getdate(), getutcdate()), collection_time), [data_size_mb], [data_used_mb], [data_used_pct], [log_size_mb], [log_used_mb], [log_used_pct], [version_store_mb], [version_store_pct]\r\nfrom dbo.tempdb_space_usage tsu\r\nwhere 1=1\r\nand tsu.collection_time = (select top 1 i.collection_time from dbo.tempdb_space_usage i order by i.collection_time desc)\r\n\"\r\nset quoted_identifier on;\r\n--print @sql\r\n\r\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\r\nif ($is_local = 1)\r\n exec dbo.sp_executesql @sql, @params;\r\nelse\r\n exec [$server].[$dba_db].dbo.sp_executesql @sql, @params;", "refId": "A", "sql": { "columns": [ @@ -5075,29 +5329,15 @@ } } ], - "title": "TempdbSaver - tempdb_space_consumers", + "title": "TempdbSaver - tempdb_space_usage", "type": "table" - } - ], - "title": "TempdbSaver - Latest @ ${tempdb_space_usage_collection_time_utc:date:YYYY-MM-DD HH.mm}", - "type": "row" - }, - { - "collapsed": true, - "gridPos": { - "h": 1, - "w": 24, - "x": 0, - "y": 24 - }, - "id": 191, - "panels": [ + }, { "datasource": { "type": "mssql", "uid": "${sqlmonitor_datasource}" }, - "description": "select [collection_time], [database_name], [recovery_model], [log_reuse_wait_desc], [log_size_mb], [log_used_mb], [exists_valid_autogrowing_file], [log_used_pct], [log_used_pct_threshold], [log_used_gb_threshold], [spid], [transaction_start_time], [login_name], [program_name], [host_name], [host_process_id], [command], [additional_info], [action_taken], [sql_text], [is_pct_threshold_valid], [is_gb_threshold_valid], [threshold_condition], [thresholds_validated]\nfrom dbo.log_space_consumers lsc\nwhere 1=1\nand lsc.collection_time = (select top 1 i.collection_time from dbo.log_space_consumers i order by i.collection_time desc)", + "description": "select [collection_time], [usage_rank], [spid], [login_name], [program_name], [host_name], [host_process_id], [is_active_session], [open_transaction_count], [transaction_isolation_level], [size_bytes], [transaction_begin_time], [is_snapshot], [log_bytes], [log_rsvd], [action_taken] \nfrom dbo.tempdb_space_consumers tsc \nwhere 1=1 \nand tsc.collection_time = (select top 1 i.collection_time from dbo.tempdb_space_usage i order by i.collection_time desc)\nand (tsc.size_bytes > 0 or tsc.is_snapshot = 1)", "fieldConfig": { "defaults": { "color": { @@ -5108,7 +5348,7 @@ "cellOptions": { "type": "auto" }, - "filterable": true, + "filterable": false, "inspect": true }, "mappings": [], @@ -5116,7 +5356,8 @@ "mode": "absolute", "steps": [ { - "color": "green" + "color": "green", + "value": null }, { "color": "red", @@ -5148,7 +5389,8 @@ "mode": "absolute", "steps": [ { - "color": "super-light-purple" + "color": "super-light-purple", + "value": null } ] } @@ -5158,12 +5400,12 @@ { "matcher": { "id": "byName", - "options": "log_size_mb" + "options": "data_size_mb" }, "properties": [ { "id": "displayName", - "value": "Log Size" + "value": "Data Size" }, { "id": "unit", @@ -5174,8 +5416,8 @@ "value": [ { "targetBlank": true, - "title": "Perfmon - Log Usage Trend", - "url": "d/distributed_perfmon?var-server=$server&var-database=tempdb&viewPanel=38" + "title": "Perfmon - Data File Growth Trend", + "url": "d/distributed_perfmon?var-server=${server}&var-database=tempdb&viewPanel=115" } ] } @@ -5184,42 +5426,38 @@ { "matcher": { "id": "byName", - "options": "log_used_mb" + "options": "data_used_mb" }, "properties": [ { "id": "displayName", - "value": "Log Used" + "value": "Data Used" + }, + { + "id": "unit", + "value": "mbytes" }, { "id": "links", "value": [ { "targetBlank": true, - "title": "Perfmon - Log Usage Trend", - "url": "d/distributed_perfmon?var-server=$server&var-database=tempdb&viewPanel=38" + "title": "Perfmon - Tempdb Free Space Trend", + "url": "d/distributed_perfmon?var-server=$server&var-database=tempdb&viewPanel=89" } ] - }, - { - "id": "unit", - "value": "mbytes" } ] }, { "matcher": { "id": "byName", - "options": "log_used_pct" + "options": "data_used_pct" }, "properties": [ { "id": "displayName", - "value": "Log Used %" - }, - { - "id": "unit", - "value": "percent" + "value": "Data Used %" }, { "id": "custom.cellOptions", @@ -5227,121 +5465,45 @@ "type": "color-background" } }, + { + "id": "unit", + "value": "percent" + }, { "id": "thresholds", "value": { "mode": "absolute", "steps": [ { - "color": "green" + "color": "green", + "value": null }, { "color": "#EAB839", "value": 70 }, { - "color": "orange", + "color": "#EF843C", "value": 80 }, { - "color": "red", + "color": "super-light-red", "value": 90 - } - ] - } - }, - { - "id": "links", - "value": [ - { - "targetBlank": true, - "title": "Perfmon - Log % Usage Trend", - "url": "d/distributed_perfmon?var-server=$server&var-database=${__data.fields.database_name}&viewPanel=123" - } - ] - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "database_name" - }, - "properties": [ - { - "id": "displayName", - "value": "Database" - }, - { - "id": "custom.cellOptions", - "value": { - "type": "color-text" - } - }, - { - "id": "custom.align", - "value": "left" - }, - { - "id": "thresholds", - "value": { - "mode": "absolute", - "steps": [ + }, { - "color": "blue" + "color": "red", + "value": 95 } ] } }, { "id": "links", - "value": [ - { - "targetBlank": true, - "title": "Disk Space - Database Files Usage", - "url": "d/disk_space?var-server=${server}&var-database=${__data.fields.database_name}&viewPanel=30" - } - ] - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "recovery_model" - }, - "properties": [ - { - "id": "displayName", - "value": "Recovery Model" - }, - { - "id": "custom.cellOptions", - "value": { - "type": "color-text" - } - }, - { - "id": "mappings", - "value": [ - { - "options": { - "SIMPLE": { - "color": "green", - "index": 0 - } - }, - "type": "value" - }, + "value": [ { - "options": { - "pattern": "^((?!SIMPLE).)*$", - "result": { - "color": "yellow", - "index": 1 - } - }, - "type": "regex" + "targetBlank": true, + "title": "Perfmon - Tempdb % Free Trend", + "url": "d/distributed_perfmon?var-server=$server&var-database=tempdb&viewPanel=89" } ] } @@ -5350,107 +5512,68 @@ { "matcher": { "id": "byName", - "options": "log_reuse_wait_desc" + "options": "log_size_mb" }, "properties": [ { "id": "displayName", - "value": "Log Reuse Wait Desc" + "value": "Log Size" }, { - "id": "custom.cellOptions", - "value": { - "type": "color-text" - } + "id": "unit", + "value": "mbytes" }, { - "id": "mappings", + "id": "links", "value": [ { - "options": { - "NOTHING": { - "color": "green", - "index": 0 - } - }, - "type": "value" - }, - { - "options": { - "pattern": "^((?!NOTHING).)*$", - "result": { - "color": "yellow", - "index": 1 - } - }, - "type": "regex" + "targetBlank": true, + "title": "Perfmon - Log Usage Trend", + "url": "d/distributed_perfmon?var-server=$server&var-database=tempdb&viewPanel=38" } ] - }, - { - "id": "custom.minWidth", - "value": 180 } ] }, { "matcher": { "id": "byName", - "options": "exists_valid_autogrowing_file" + "options": "log_used_mb" }, "properties": [ { "id": "displayName", - "value": "Autogrow" - }, - { - "id": "custom.cellOptions", - "value": { - "type": "color-text" - } - }, - { - "id": "unit", - "value": "bool_on_off" + "value": "Log Used" }, { - "id": "mappings", + "id": "links", "value": [ { - "options": { - "match": "true", - "result": { - "color": "green", - "index": 0, - "text": "Yes" - } - }, - "type": "special" - }, - { - "options": { - "match": "false", - "result": { - "color": "yellow", - "index": 1, - "text": "No" - } - }, - "type": "special" + "targetBlank": true, + "title": "Perfmon - Log Usage Trend", + "url": "d/distributed_perfmon?var-server=$server&var-database=tempdb&viewPanel=38" } ] + }, + { + "id": "unit", + "value": "mbytes" } ] }, { "matcher": { "id": "byName", - "options": "thresholds_validated" + "options": "log_used_pct" }, "properties": [ { "id": "displayName", - "value": "Attention Needed" + "value": "Log Used %" + }, + { + "id": "unit", + "value": "percent" }, { "id": "custom.cellOptions", @@ -5459,246 +5582,147 @@ } }, { - "id": "unit", - "value": "bool" - }, - { - "id": "mappings", - "value": [ - { - "options": { - "match": "true", - "result": { - "color": "yellow", - "index": 1, - "text": "Yes" - } - }, - "type": "special" - }, - { - "options": { - "match": "false", - "result": { - "color": "green", - "index": 2, - "text": "No" - } + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null }, - "type": "special" - } - ] - } - ] - } - ] - }, - "gridPos": { - "h": 11, - "w": 24, - "x": 0, - "y": 441 - }, - "id": 192, - "options": { - "cellHeight": "sm", - "footer": { - "countRows": false, - "enablePagination": true, - "fields": "", - "reducer": [ - "sum" - ], - "show": false - }, - "showHeader": true - }, - "pluginVersion": "10.1.0", - "targets": [ - { - "dataset": "AdventureWorks2019", - "datasource": { - "type": "mssql", - "uid": "${sqlmonitor_datasource}" - }, - "editorMode": "code", - "format": "table", - "rawQuery": true, - "rawSql": "declare @sql nvarchar(max);\r\ndeclare @params nvarchar(max);\r\ndeclare @sql_instance varchar(255);\r\ndeclare @crlf nchar(2) = nchar(13)+nchar(10);\r\n\r\nset @sql_instance = '$server';\r\n\r\n--set @params = N'';\r\n\r\nset quoted_identifier off;\r\nset @sql = \"/* SQLMonitor Dashboard Monitoring - Live - Distributed: TempdbSaver - log_space_consumers */\r\nset nocount on;\t\t\t\r\nselect [collection_time_utc] = DATEADD(mi, DATEDIFF(mi, getdate(), getutcdate()), collection_time), [database_name], [recovery_model], [log_reuse_wait_desc], [log_size_mb], [log_used_mb], [exists_valid_autogrowing_file], [log_used_pct], \r\n --[log_used_pct_threshold], [log_used_gb_threshold], [spid], [transaction_start_time], [login_name], [program_name], [host_name], [host_process_id], [command], [additional_info], [action_taken], [sql_text], [is_pct_threshold_valid], [is_gb_threshold_valid], [threshold_condition], */\r\n [thresholds_validated]\r\nfrom dbo.log_space_consumers lsc\r\nwhere 1=1\r\nand lsc.collection_time = (select top 1 i.collection_time from dbo.log_space_consumers i order by i.collection_time desc)\r\norder by [log_size_mb] desc, database_name\r\n\"\r\nset quoted_identifier on;\r\n--print @sql\r\n\r\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\r\nif ($is_local = 1)\r\n exec dbo.sp_executesql @sql, @params;\r\nelse\r\n exec [$server].[$dba_db].dbo.sp_executesql @sql, @params;", - "refId": "A", - "sql": { - "columns": [ - { - "parameters": [], - "type": "function" - } - ], - "groupBy": [ - { - "property": { - "type": "string" - }, - "type": "groupBy" - } - ], - "limit": 50 - } - } - ], - "title": "LogSaver - log_space_consumers", - "type": "table" - } - ], - "title": "LogSaver - Latest @ ${log_space_consumers_collection_time_utc:date:YYYY-MM-DD HH.mm}", - "type": "row" - }, - { - "collapsed": true, - "gridPos": { - "h": 1, - "w": 24, - "x": 0, - "y": 25 - }, - "id": 140, - "panels": [ - { - "datasource": { - "type": "mssql", - "uid": "${sqlmonitor_datasource}" - }, - "description": "", - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisBorderShow": false, - "axisCenteredZero": false, - "axisColorMode": "text", - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "barWidthFactor": 0.6, - "drawStyle": "line", - "fillOpacity": 10, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "insertNulls": false, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "never", - "spanNulls": true, - "stacking": { - "group": "A", - "mode": "none" - }, - "thresholdsStyle": { - "mode": "off" - } - }, - "mappings": [], - "min": 0, - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "transparent" + { + "color": "#EAB839", + "value": 70 + }, + { + "color": "orange", + "value": 80 + }, + { + "color": "red", + "value": 90 + } + ] + } } ] }, - "unit": "short" - }, - "overrides": [ { "matcher": { "id": "byName", - "options": "winsock rejected connections/sec" + "options": "version_store_mb" }, "properties": [ { - "id": "color", - "value": { - "fixedColor": "red", - "mode": "fixed" - } + "id": "displayName", + "value": "Version Store" + }, + { + "id": "unit", + "value": "mbytes" + }, + { + "id": "links", + "value": [ + { + "targetBlank": true, + "title": "Perfmon - Version Store Usage Trend", + "url": "d/distributed_perfmon?var-server=$server&var-database=tempdb&viewPanel=90" + } + ] } ] }, { "matcher": { "id": "byName", - "options": "user connections" + "options": "version_store_pct" }, "properties": [ + { + "id": "displayName", + "value": "Version Store %" + }, + { + "id": "unit", + "value": "percent" + }, + { + "id": "custom.cellOptions", + "value": { + "type": "color-background" + } + }, { "id": "thresholds", "value": { "mode": "absolute", "steps": [ { - "color": "green" + "color": "green", + "value": null }, { "color": "#EAB839", - "value": 500 + "value": 70 + }, + { + "color": "orange", + "value": 80 }, { "color": "red", - "value": 1000 + "value": 90 } ] } + }, + { + "id": "links", + "value": [ + { + "targetBlank": true, + "title": "Perfmon - VersionStore Usage Trend", + "url": "d/distributed_perfmon?var-server=$server&var-database=tempdb&viewPanel=90" + } + ] } ] } ] }, "gridPos": { - "h": 8, + "h": 4, "w": 24, "x": 0, - "y": 257 + "y": 72 }, - "id": 138, + "id": 190, "options": { - "legend": { - "calcs": [ - "max", - "p99" + "cellHeight": "sm", + "footer": { + "countRows": false, + "enablePagination": false, + "fields": "", + "reducer": [ + "sum" ], - "displayMode": "table", - "placement": "right", - "showLegend": true, - "sortBy": "Mean", - "sortDesc": true + "show": false }, - "tooltip": { - "mode": "multi", - "sort": "desc" - } + "showHeader": true }, "pluginVersion": "11.3.1", "targets": [ { - "alias": "", + "dataset": "AdventureWorks2019", "datasource": { "type": "mssql", "uid": "${sqlmonitor_datasource}" }, "editorMode": "code", - "format": "time_series", + "format": "table", "rawQuery": true, - "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\ndeclare @start_time_utc datetime2;\ndeclare @end_time_utc datetime2;\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @start_time_utc = $__timeFrom();\nset @end_time_utc = $__timeTo();\nset @params = N'@perfmon_host_name varchar(255), @start_time_utc datetime2, @end_time_utc datetime2';\n\nset quoted_identifier off;\nset @sql = \"\nset nocount on;\ndeclare @object_name varchar(255);\nset @object_name = (case when '$perfmon_service_name' = 'MSSQLSERVER' then 'sqlserver' else LOWER('$perfmon_service_name') end);\n\nselect pc.collection_time_utc as time, \n\t\t(case when counter = 'rejected connections/sec' then 'winsock rejected connections/sec' else counter end) as metric,\n\t--object, counter as metric, instance\n\tpc.value\nfrom $perfmon_table_name pc with (nolock)\nwhere collection_time_utc between @start_time_utc and @end_time_utc\nand host_name = '$perfmon_host_name' \n and ( (object = 'microsoft winsock bsp' and counter = 'rejected connections/sec')\n or (pc.object = (@object_name+':general statistics') and pc.counter in ('user connections'))\n\t ) \norder by time\n\"\nset quoted_identifier on;\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nif ($is_local = 1)\n exec dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;\nelse\n exec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;", + "rawSql": "declare @sql nvarchar(max);\r\ndeclare @params nvarchar(max);\r\ndeclare @sql_instance varchar(255);\r\ndeclare @crlf nchar(2) = nchar(13)+nchar(10);\r\n\r\nset @sql_instance = '$server';\r\n\r\n--set @params = N'';\r\n\r\nset quoted_identifier off;\r\nset @sql = \"/* SQLMonitor Dashboard Monitoring - Live - Distributed: TempdbSaver - tempdb_space_usage */\r\nset nocount on;\r\nif exists ( select 1/0 from dbo.tempdb_space_consumers tsc with (nolock)\r\n where 1=1 \r\n and tsc.collection_time = (select top 1 tsu.collection_time from tempdb_space_usage tsu order by tsu.collection_time desc)\r\n and (tsc.size_bytes > 0 or tsc.is_snapshot = 1)\r\n )\r\nbegin\t\r\n select [collection_time_utc] = DATEADD(mi, DATEDIFF(mi, getdate(), getutcdate()), collection_time), [usage_rank], [spid], [login_name], \r\n [program_name], [host_name], [host_process_id], [is_active_session], [open_transaction_count], [transaction_isolation_level], [size_bytes], \r\n [transaction_begin_time] = DATEADD(mi, DATEDIFF(mi, getdate(), getutcdate()), transaction_begin_time), [is_snapshot], [log_bytes], [log_rsvd], [action_taken] \r\n from dbo.tempdb_space_consumers tsc \r\n where 1=1 \r\n and tsc.collection_time = (select top 1 tsu.collection_time from tempdb_space_usage tsu order by tsu.collection_time desc)\r\n and (tsc.size_bytes > 0 or tsc.is_snapshot = 1)\r\nend\r\nELSE\r\n select 'No tempdb consumers record in latest snapshot.' as [No Result]\r\n\"\r\nset quoted_identifier on;\r\n--print @sql\r\n\r\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\r\nif ($is_local = 1)\r\n exec dbo.sp_executesql @sql, @params;\r\nelse\r\n exec [$server].[$dba_db].dbo.sp_executesql @sql, @params;", "refId": "A", "sql": { "columns": [ @@ -5719,12 +5743,11 @@ } } ], - "title": "microsoft winsock bsp -> rejected connections/sec", - "type": "timeseries" + "title": "TempdbSaver - tempdb_space_consumers", + "type": "table" } ], - "repeat": "datasource", - "title": "SQL Connections & Winsock Rejections", + "title": "TempdbSaver - Latest @ ${tempdb_space_usage_collection_time_utc:date:YYYY-MM-DD HH.mm}", "type": "row" }, { @@ -5735,32 +5758,34 @@ "x": 0, "y": 26 }, - "id": 117, + "id": 191, "panels": [ { "datasource": { "type": "mssql", "uid": "${sqlmonitor_datasource}" }, + "description": "select [collection_time], [database_name], [recovery_model], [log_reuse_wait_desc], [log_size_mb], [log_used_mb], [exists_valid_autogrowing_file], [log_used_pct], [log_used_pct_threshold], [log_used_gb_threshold], [spid], [transaction_start_time], [login_name], [program_name], [host_name], [host_process_id], [command], [additional_info], [action_taken], [sql_text], [is_pct_threshold_valid], [is_gb_threshold_valid], [threshold_condition], [thresholds_validated]\nfrom dbo.log_space_consumers lsc\nwhere 1=1\nand lsc.collection_time = (select top 1 i.collection_time from dbo.log_space_consumers i order by i.collection_time desc)", "fieldConfig": { "defaults": { "color": { "mode": "thresholds" }, "custom": { - "align": "auto", + "align": "center", "cellOptions": { "type": "auto" }, "filterable": true, - "inspect": false + "inspect": true }, "mappings": [], "thresholds": { "mode": "absolute", "steps": [ { - "color": "green" + "color": "green", + "value": null }, { "color": "red", @@ -5773,310 +5798,405 @@ { "matcher": { "id": "byName", - "options": "sql_command" + "options": "collection_time_utc" }, "properties": [ { - "id": "custom.width", - "value": 352 + "id": "displayName", + "value": "Collection Time" + }, + { + "id": "custom.cellOptions", + "value": { + "type": "color-background" + } + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "super-light-purple", + "value": null + } + ] + } } ] }, { "matcher": { "id": "byName", - "options": "program_name" + "options": "log_size_mb" }, "properties": [ { - "id": "custom.width", - "value": 169 + "id": "displayName", + "value": "Log Size" + }, + { + "id": "unit", + "value": "mbytes" + }, + { + "id": "links", + "value": [ + { + "targetBlank": true, + "title": "Perfmon - Log Usage Trend", + "url": "d/distributed_perfmon?var-server=$server&var-database=tempdb&viewPanel=38" + } + ] } ] }, { "matcher": { "id": "byName", - "options": "session_id" + "options": "log_used_mb" }, "properties": [ { - "id": "custom.width", - "value": 108 + "id": "displayName", + "value": "Log Used" + }, + { + "id": "links", + "value": [ + { + "targetBlank": true, + "title": "Perfmon - Log Usage Trend", + "url": "d/distributed_perfmon?var-server=$server&var-database=tempdb&viewPanel=38" + } + ] + }, + { + "id": "unit", + "value": "mbytes" } ] }, { "matcher": { "id": "byName", - "options": "CPU" + "options": "log_used_pct" }, "properties": [ + { + "id": "displayName", + "value": "Log Used %" + }, { "id": "unit", - "value": "ms" + "value": "percent" + }, + { + "id": "custom.cellOptions", + "value": { + "type": "color-background" + } + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "#EAB839", + "value": 70 + }, + { + "color": "orange", + "value": 80 + }, + { + "color": "red", + "value": 90 + } + ] + } + }, + { + "id": "links", + "value": [ + { + "targetBlank": true, + "title": "Perfmon - Log % Usage Trend", + "url": "d/distributed_perfmon?var-server=$server&var-database=${__data.fields.database_name}&viewPanel=123" + } + ] } ] }, { "matcher": { "id": "byName", - "options": "granted_memory_kb" + "options": "database_name" }, "properties": [ { - "id": "unit", - "value": "kbytes" + "id": "displayName", + "value": "Database" + }, + { + "id": "custom.cellOptions", + "value": { + "type": "color-text" + } + }, + { + "id": "custom.align", + "value": "left" + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "blue", + "value": null + } + ] + } }, { - "id": "displayName", - "value": "granted_memory" + "id": "links", + "value": [ + { + "targetBlank": true, + "title": "Disk Space - Database Files Usage", + "url": "d/disk_space?var-server=${server}&var-database=${__data.fields.database_name}&viewPanel=30" + } + ] } ] }, { "matcher": { "id": "byName", - "options": "reads_kb" + "options": "recovery_model" }, "properties": [ { - "id": "unit", - "value": "kbytes" + "id": "displayName", + "value": "Recovery Model" }, { - "id": "displayName", - "value": "reads" - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "writes" - }, - "properties": [ + "id": "custom.cellOptions", + "value": { + "type": "color-text" + } + }, { - "id": "unit", - "value": "short" + "id": "mappings", + "value": [ + { + "options": { + "SIMPLE": { + "color": "green", + "index": 0 + } + }, + "type": "value" + }, + { + "options": { + "pattern": "^((?!SIMPLE).)*$", + "result": { + "color": "yellow", + "index": 1 + } + }, + "type": "regex" + } + ] } ] }, { "matcher": { "id": "byName", - "options": "tempdb_allocations_kb" + "options": "log_reuse_wait_desc" }, "properties": [ { - "id": "unit", - "value": "kbytes" + "id": "displayName", + "value": "Log Reuse Wait Desc" }, { - "id": "displayName", - "value": "tempdb_allocations" - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "tempdb_current_kb" - }, - "properties": [ + "id": "custom.cellOptions", + "value": { + "type": "color-text" + } + }, { - "id": "unit", - "value": "kbytes" + "id": "mappings", + "value": [ + { + "options": { + "NOTHING": { + "color": "green", + "index": 0 + } + }, + "type": "value" + }, + { + "options": { + "pattern": "^((?!NOTHING).)*$", + "result": { + "color": "yellow", + "index": 1 + } + }, + "type": "regex" + } + ] }, { - "id": "displayName", - "value": "tempdb_current" + "id": "custom.minWidth", + "value": 180 } ] }, { "matcher": { "id": "byName", - "options": "used_memory_kb" + "options": "exists_valid_autogrowing_file" }, "properties": [ { - "id": "unit", - "value": "kbytes" + "id": "displayName", + "value": "Autogrow" }, { - "id": "displayName", - "value": "used_memory" - } - ] - } - ] - }, - "gridPos": { - "h": 7, - "w": 24, - "x": 0, - "y": 258 - }, - "id": 115, - "options": { - "cellHeight": "sm", - "footer": { - "countRows": false, - "fields": "", - "reducer": [ - "sum" - ], - "show": false - }, - "showHeader": true, - "sortBy": [] - }, - "pluginVersion": "11.3.1", - "targets": [ - { - "alias": "", - "datasource": { - "type": "mssql", - "uid": "${sqlmonitor_datasource}" - }, - "editorMode": "code", - "format": "table", - "rawQuery": true, - "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\ndeclare @start_time_utc datetime2;\ndeclare @end_time_utc datetime2;\ndeclare @duration int;\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @start_time_utc = $__timeFrom();\nset @end_time_utc = $__timeTo();\nset @duration = case when ltrim(rtrim('$duration')) <> '' then $duration else 0 end; \nset @params = N'@perfmon_host_name varchar(255), @start_time_utc datetime2, @end_time_utc datetime2, @duration int';\n\nset quoted_identifier off;\nset @sql = \"\nset nocount on;\nif exists ( select * from dbo.WhoIsActive w with (nolock)\n where w.collection_time = (select max(i.collection_time) from dbo.WhoIsActive i) \n and datediff(minute,start_time,collection_time) >= @duration )\nbegin\n ;with t_WhoIsActive as (\n select [collection_time], w.session_id, /* = convert(varchar,w.collection_time,120) */\n w.program_name, w.login_name, w.database_name, w.host_name, w.status, w.CPU, w.granted_memory, w.used_memory, w.open_tran_count, w.wait_info,\n sql_command = case when w.sql_command is not null then left(replace(replace(convert(nvarchar(max),w.sql_command),char(13)+char(10),''),'= @duration\n )\n select [collection_time] = DATEADD(mi, DATEDIFF(mi, getdate(), getutcdate()), [collection_time]), w.session_id,\n [ddd hh:mm:ss] = right('0000'+convert(varchar, duration_s/86400),3)+ ' '+convert(varchar,dateadd(SECOND,duration_s,'1900-01-01 00:00:00'),108), \n w.program_name, w.login_name, w.database_name, w.host_name, w.status, w.CPU, \n granted_memory_kb = (w.granted_memory * 8.0), w.open_tran_count, w.wait_info, w.sql_command, w.blocked_session_count, \n w.blocking_session_id, [reads_kb] = (w.[reads]*8.0), w.writes, [tempdb_allocations_kb] = (w.tempdb_allocations*8.0), \n tempdb_current_kb = (tempdb_current*8.0), w.tasks, w.percent_complete, [used_memory_kb] = (w.used_memory*8.0),\n start_time = DATEADD(mi, DATEDIFF(mi, getdate(), getutcdate()), [start_time])\n\t\t\t \n from t_WhoIsActive w\n order by w.collection_time DESC, w.start_time ASC\nend\nELSE\n select 'No long running query found for time window' as [No Result]\n\"\nset quoted_identifier on;\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nif ($is_local = 1)\n exec dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc, @duration;\nelse\n exec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc, @duration;", - "refId": "A", - "sql": { - "columns": [ + "id": "custom.cellOptions", + "value": { + "type": "color-text" + } + }, { - "parameters": [], - "type": "function" - } - ], - "groupBy": [ + "id": "unit", + "value": "bool_on_off" + }, { - "property": { - "type": "string" - }, - "type": "groupBy" - } - ], - "limit": 50 - } - } - ], - "title": "WhoIsActive Data", - "type": "table" - } - ], - "repeat": "datasource", - "title": "Long Running Queries", - "type": "row" - }, - { - "collapsed": true, - "gridPos": { - "h": 1, - "w": 24, - "x": 0, - "y": 27 - }, - "id": 29, - "panels": [ - { - "datasource": { - "type": "mssql", - "uid": "${sqlmonitor_datasource}" - }, - "description": "https://sqlperformance.com/2014/10/sql-performance/knee-jerk-page-life-expectancy", - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisBorderShow": false, - "axisCenteredZero": false, - "axisColorMode": "text", - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "barWidthFactor": 0.6, - "drawStyle": "line", - "fillOpacity": 10, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "insertNulls": false, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "never", - "spanNulls": true, - "stacking": { - "group": "A", - "mode": "none" - }, - "thresholdsStyle": { - "mode": "line+area" - } + "id": "mappings", + "value": [ + { + "options": { + "match": "true", + "result": { + "color": "green", + "index": 0, + "text": "Yes" + } + }, + "type": "special" + }, + { + "options": { + "match": "false", + "result": { + "color": "yellow", + "index": 1, + "text": "No" + } + }, + "type": "special" + } + ] + } + ] }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ + { + "matcher": { + "id": "byName", + "options": "thresholds_validated" + }, + "properties": [ { - "color": "red" + "id": "displayName", + "value": "Attention Needed" }, { - "color": "transparent", - "value": 600 + "id": "custom.cellOptions", + "value": { + "type": "color-background" + } + }, + { + "id": "unit", + "value": "bool" + }, + { + "id": "mappings", + "value": [ + { + "options": { + "match": "true", + "result": { + "color": "yellow", + "index": 1, + "text": "Yes" + } + }, + "type": "special" + }, + { + "options": { + "match": "false", + "result": { + "color": "green", + "index": 2, + "text": "No" + } + }, + "type": "special" + } + ] } ] - }, - "unit": "s" - }, - "overrides": [] + } + ] }, "gridPos": { - "h": 10, + "h": 11, "w": 24, "x": 0, - "y": 259 + "y": 77 }, - "id": 8, + "id": 192, "options": { - "legend": { - "calcs": [ - "lastNotNull", - "min" + "cellHeight": "sm", + "footer": { + "countRows": false, + "enablePagination": true, + "fields": "", + "reducer": [ + "sum" ], - "displayMode": "table", - "placement": "bottom", - "showLegend": true + "show": false }, - "tooltip": { - "mode": "multi", - "sort": "desc" - } + "showHeader": true }, "pluginVersion": "11.3.1", "targets": [ { - "alias": "", + "dataset": "AdventureWorks2019", "datasource": { "type": "mssql", "uid": "${sqlmonitor_datasource}" }, "editorMode": "code", - "format": "time_series", + "format": "table", "rawQuery": true, - "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\ndeclare @start_time_utc datetime2;\ndeclare @end_time_utc datetime2;\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @start_time_utc = $__timeFrom();\nset @end_time_utc = $__timeTo();\nset @params = N'@perfmon_host_name varchar(255), @start_time_utc datetime2, @end_time_utc datetime2';\n\nset quoted_identifier off;\nset @sql = \"\nset nocount on;\ndeclare @object_name varchar(255);\nset @object_name = (case when '$perfmon_service_name' = 'MSSQLSERVER' \n\t\t\t\t\t\t then 'sqlserver' else LOWER('$perfmon_service_name') end);\n\nselect pc.collection_time_utc as time\n\t,counter as metric\n\t--,object, counter, instance\n\t,pc.value\nfrom $perfmon_table_name pc with (nolock)\nwhere collection_time_utc between @start_time_utc and @end_time_utc \nand host_name = @perfmon_host_name and pc.object = (@object_name+':buffer manager')\nand pc.counter = 'page life expectancy'\norder by time\n\"\nset quoted_identifier on;\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nif ($is_local = 1)\n exec dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;\nelse\n exec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;", + "rawSql": "declare @sql nvarchar(max);\r\ndeclare @params nvarchar(max);\r\ndeclare @sql_instance varchar(255);\r\ndeclare @crlf nchar(2) = nchar(13)+nchar(10);\r\n\r\nset @sql_instance = '$server';\r\n\r\n--set @params = N'';\r\n\r\nset quoted_identifier off;\r\nset @sql = \"/* SQLMonitor Dashboard Monitoring - Live - Distributed: TempdbSaver - log_space_consumers */\r\nset nocount on;\t\t\t\r\nselect [collection_time_utc] = DATEADD(mi, DATEDIFF(mi, getdate(), getutcdate()), collection_time), [database_name], [recovery_model], [log_reuse_wait_desc], [log_size_mb], [log_used_mb], [exists_valid_autogrowing_file], [log_used_pct], \r\n --[log_used_pct_threshold], [log_used_gb_threshold], [spid], [transaction_start_time], [login_name], [program_name], [host_name], [host_process_id], [command], [additional_info], [action_taken], [sql_text], [is_pct_threshold_valid], [is_gb_threshold_valid], [threshold_condition], */\r\n [thresholds_validated]\r\nfrom dbo.log_space_consumers lsc\r\nwhere 1=1\r\nand lsc.collection_time = (select top 1 i.collection_time from dbo.log_space_consumers i order by i.collection_time desc)\r\norder by [log_size_mb] desc, database_name\r\n\"\r\nset quoted_identifier on;\r\n--print @sql\r\n\r\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\r\nif ($is_local = 1)\r\n exec dbo.sp_executesql @sql, @params;\r\nelse\r\n exec [$server].[$dba_db].dbo.sp_executesql @sql, @params;", "refId": "A", "sql": { "columns": [ @@ -6097,12 +6217,11 @@ } } ], - "title": "Page Life Expectancy", - "type": "timeseries" + "title": "LogSaver - log_space_consumers", + "type": "table" } ], - "repeat": "datasource", - "title": "Trend - Page Life Expectancy", + "title": "LogSaver - Latest @ ${log_space_consumers_collection_time_utc:date:YYYY-MM-DD HH.mm}", "type": "row" }, { @@ -6111,16 +6230,16 @@ "h": 1, "w": 24, "x": 0, - "y": 28 + "y": 27 }, - "id": 27, + "id": 140, "panels": [ { "datasource": { "type": "mssql", "uid": "${sqlmonitor_datasource}" }, - "description": "https://sqlperformance.com/2014/10/sql-performance/knee-jerk-page-life-expectancy", + "description": "", "fieldConfig": { "defaults": { "color": { @@ -6130,7 +6249,6 @@ "axisBorderShow": false, "axisCenteredZero": false, "axisColorMode": "text", - "axisGridShow": true, "axisLabel": "", "axisPlacement": "auto", "barAlignment": 0, @@ -6148,8 +6266,7 @@ "lineWidth": 1, "pointSize": 5, "scaleDistribution": { - "log": 10, - "type": "log" + "type": "linear" }, "showPoints": "never", "spanNulls": true, @@ -6162,39 +6279,80 @@ } }, "mappings": [], + "min": 0, "thresholds": { "mode": "absolute", "steps": [ { - "color": "green" - }, - { - "color": "red", - "value": 80 + "color": "transparent" } ] }, "unit": "short" }, - "overrides": [] + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "winsock rejected connections/sec" + }, + "properties": [ + { + "id": "color", + "value": { + "fixedColor": "red", + "mode": "fixed" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "user connections" + }, + "properties": [ + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "#EAB839", + "value": 500 + }, + { + "color": "red", + "value": 1000 + } + ] + } + } + ] + } + ] }, "gridPos": { - "h": 7, + "h": 8, "w": 24, "x": 0, - "y": 260 + "y": 988 }, - "id": 18, + "id": 138, "options": { "legend": { "calcs": [ - "lastNotNull", "max", "p99" ], "displayMode": "table", - "placement": "bottom", - "showLegend": true + "placement": "right", + "showLegend": true, + "sortBy": "Mean", + "sortDesc": true }, "tooltip": { "mode": "multi", @@ -6212,7 +6370,7 @@ "editorMode": "code", "format": "time_series", "rawQuery": true, - "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\ndeclare @start_time_utc datetime2;\ndeclare @end_time_utc datetime2;\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @start_time_utc = $__timeFrom();\nset @end_time_utc = $__timeTo();\nset @params = N'@perfmon_host_name varchar(255), @start_time_utc datetime2, @end_time_utc datetime2';\n\nset quoted_identifier off;\nset @sql = \"\nset nocount on;\ndeclare @object_name varchar(255);\nset @object_name = (case when '$perfmon_service_name' = 'MSSQLSERVER' then 'sqlserver' else LOWER('$perfmon_service_name') end);\nselect pc.collection_time_utc as time, \n\tcounter as metric\n\t--,instance,\n\t,pc.value\nfrom $perfmon_table_name pc with (nolock)\nwhere collection_time_utc between @start_time_utc and @end_time_utc \nand host_name = @perfmon_host_name and pc.object = (@object_name+':sql statistics') \nand pc.counter = 'batch requests/sec'\nand pc.value <> 0.0\norder by time\n\"\nset quoted_identifier on;\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nif ($is_local = 1)\n exec dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;\nelse\n exec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;", + "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\ndeclare @start_time_utc datetime2;\ndeclare @end_time_utc datetime2;\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @start_time_utc = $__timeFrom();\nset @end_time_utc = $__timeTo();\nset @params = N'@perfmon_host_name varchar(255), @start_time_utc datetime2, @end_time_utc datetime2';\n\nset quoted_identifier off;\nset @sql = \"\nset nocount on;\ndeclare @object_name varchar(255);\nset @object_name = (case when '$perfmon_service_name' = 'MSSQLSERVER' then 'sqlserver' else LOWER('$perfmon_service_name') end);\n\nselect pc.collection_time_utc as time, \n\t\t(case when counter = 'rejected connections/sec' then 'winsock rejected connections/sec' else counter end) as metric,\n\t--object, counter as metric, instance\n\tpc.value\nfrom $perfmon_table_name pc with (nolock)\nwhere collection_time_utc between @start_time_utc and @end_time_utc\nand host_name = '$perfmon_host_name' \n and ( (object = 'microsoft winsock bsp' and counter = 'rejected connections/sec')\n or (pc.object = (@object_name+':general statistics') and pc.counter in ('user connections'))\n\t ) \norder by time\n\"\nset quoted_identifier on;\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nif ($is_local = 1)\n exec dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;\nelse\n exec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;", "refId": "A", "sql": { "columns": [ @@ -6233,12 +6391,12 @@ } } ], - "title": "Batch Requests Per Second", + "title": "microsoft winsock bsp -> rejected connections/sec", "type": "timeseries" } ], "repeat": "datasource", - "title": "Trend - Batch Request/Sec", + "title": "SQL Connections & Winsock Rejections", "type": "row" }, { @@ -6247,16 +6405,15 @@ "h": 1, "w": 24, "x": 0, - "y": 29 + "y": 28 }, - "id": 126, + "id": 117, "panels": [ { "datasource": { "type": "mssql", "uid": "${sqlmonitor_datasource}" }, - "description": "select * from sys.dm_exec_requests r where blocking_session_id <> 0", "fieldConfig": { "defaults": { "color": { @@ -6267,11 +6424,10 @@ "cellOptions": { "type": "auto" }, + "filterable": true, "inspect": false }, "mappings": [], - "max": 100, - "min": 0, "thresholds": { "mode": "absolute", "steps": [ @@ -6279,118 +6435,162 @@ "color": "green" }, { - "color": "dark-orange", - "value": 500 + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "sql_command" + }, + "properties": [ + { + "id": "custom.width", + "value": 352 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "program_name" + }, + "properties": [ + { + "id": "custom.width", + "value": 169 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "session_id" + }, + "properties": [ + { + "id": "custom.width", + "value": 108 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "CPU" + }, + "properties": [ + { + "id": "unit", + "value": "ms" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "granted_memory_kb" + }, + "properties": [ + { + "id": "unit", + "value": "kbytes" }, { - "color": "dark-red", - "value": 700 + "id": "displayName", + "value": "granted_memory" } ] }, - "unit": "none" - }, - "overrides": [] - }, - "gridPos": { - "h": 7, - "w": 24, - "x": 0, - "y": 261 - }, - "id": 124, - "options": { - "cellHeight": "sm", - "footer": { - "countRows": false, - "fields": "", - "reducer": [ - "sum" - ], - "show": false - }, - "showHeader": true - }, - "pluginVersion": "11.3.1", - "targets": [ - { - "alias": "", - "datasource": { - "type": "mssql", - "uid": "${sqlmonitor_datasource}" - }, - "format": "table", - "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\ndeclare @start_time_utc datetime2;\ndeclare @end_time_utc datetime2;\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @start_time_utc = $__timeFrom();\nset @end_time_utc = $__timeTo();\nset @params = N'@perfmon_host_name varchar(255), @start_time_utc datetime2, @end_time_utc datetime2';\n\nset quoted_identifier off;\nset @sql = \"\nset nocount on;\nselect host_name, login_name, status, client_net_address, client_interface_name, count(*) as counts\nfrom sys.dm_exec_connections as dec with (nolock) \njoin sys.dm_exec_sessions as des on des.session_id = dec.session_id\ngroup by host_name, login_name, status, client_net_address, client_interface_name\norder by counts desc, login_name\n\"\nset quoted_identifier on;\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nif ($is_local = 1)\n exec dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;\nelse\n exec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;", - "refId": "A" - } - ], - "title": "Connections", - "type": "table" - }, - { - "datasource": { - "type": "mssql", - "uid": "${sqlmonitor_datasource}" - }, - "description": "select * from sys.dm_exec_connections", - "fieldConfig": { - "defaults": { - "color": { - "mode": "thresholds" + { + "matcher": { + "id": "byName", + "options": "reads_kb" + }, + "properties": [ + { + "id": "unit", + "value": "kbytes" + }, + { + "id": "displayName", + "value": "reads" + } + ] }, - "custom": { - "align": "auto", - "cellOptions": { - "type": "auto" + { + "matcher": { + "id": "byName", + "options": "writes" }, - "filterable": true, - "inspect": false + "properties": [ + { + "id": "unit", + "value": "short" + } + ] }, - "mappings": [], - "min": 0, - "thresholds": { - "mode": "absolute", - "steps": [ + { + "matcher": { + "id": "byName", + "options": "tempdb_allocations_kb" + }, + "properties": [ { - "color": "green" + "id": "unit", + "value": "kbytes" + }, + { + "id": "displayName", + "value": "tempdb_allocations" } ] }, - "unit": "none" - }, - "overrides": [ { "matcher": { - "id": "byType", - "options": "string" + "id": "byName", + "options": "tempdb_current_kb" }, "properties": [ { - "id": "custom.width" + "id": "unit", + "value": "kbytes" + }, + { + "id": "displayName", + "value": "tempdb_current" } ] }, { "matcher": { - "id": "byType", - "options": "number" + "id": "byName", + "options": "used_memory_kb" }, "properties": [ { - "id": "custom.width", - "value": 100 + "id": "unit", + "value": "kbytes" + }, + { + "id": "displayName", + "value": "used_memory" } ] } ] }, "gridPos": { - "h": 6, - "w": 8, + "h": 7, + "w": 24, "x": 0, - "y": 309 + "y": 989 }, - "id": 131, + "id": 115, "options": { "cellHeight": "sm", "footer": { @@ -6412,90 +6612,130 @@ "type": "mssql", "uid": "${sqlmonitor_datasource}" }, + "editorMode": "code", "format": "table", - "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\ndeclare @start_time_utc datetime2;\ndeclare @end_time_utc datetime2;\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @start_time_utc = $__timeFrom();\nset @end_time_utc = $__timeTo();\nset @params = N'@perfmon_host_name varchar(255), @start_time_utc datetime2, @end_time_utc datetime2';\n\nset quoted_identifier off;\nset @sql = \"\nset nocount on;\nselect client_interface_name, count(*) as counts\nfrom sys.dm_exec_connections as dec with (nolock) \njoin sys.dm_exec_sessions as des with (nolock) on des.session_id = dec.session_id\nwhere len(ltrim(rtrim(client_interface_name))) > 0\ngroup by client_interface_name\norder by counts desc, client_interface_name\n\"\nset quoted_identifier on;\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nif ($is_local = 1)\n exec dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;\nelse\n exec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;", - "refId": "A" + "rawQuery": true, + "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\ndeclare @start_time_utc datetime2;\ndeclare @end_time_utc datetime2;\ndeclare @duration int;\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @start_time_utc = $__timeFrom();\nset @end_time_utc = $__timeTo();\nset @duration = case when ltrim(rtrim('$duration')) <> '' then $duration else 0 end; \nset @params = N'@perfmon_host_name varchar(255), @start_time_utc datetime2, @end_time_utc datetime2, @duration int';\n\nset quoted_identifier off;\nset @sql = \"\nset nocount on;\nif exists ( select * from dbo.WhoIsActive w with (nolock)\n where w.collection_time = (select max(i.collection_time) from dbo.WhoIsActive i) \n and datediff(minute,start_time,collection_time) >= @duration )\nbegin\n ;with t_WhoIsActive as (\n select [collection_time], w.session_id, /* = convert(varchar,w.collection_time,120) */\n w.program_name, w.login_name, w.database_name, w.host_name, w.status, w.CPU, w.granted_memory, w.used_memory, w.open_tran_count, w.wait_info,\n sql_command = case when w.sql_command is not null then left(replace(replace(convert(nvarchar(max),w.sql_command),char(13)+char(10),''),'= @duration\n )\n select [collection_time] = DATEADD(mi, DATEDIFF(mi, getdate(), getutcdate()), [collection_time]), w.session_id,\n [ddd hh:mm:ss] = right('0000'+convert(varchar, duration_s/86400),3)+ ' '+convert(varchar,dateadd(SECOND,duration_s,'1900-01-01 00:00:00'),108), \n w.program_name, w.login_name, w.database_name, w.host_name, w.status, w.CPU, \n granted_memory_kb = (w.granted_memory * 8.0), w.open_tran_count, w.wait_info, w.sql_command, w.blocked_session_count, \n w.blocking_session_id, [reads_kb] = (w.[reads]*8.0), w.writes, [tempdb_allocations_kb] = (w.tempdb_allocations*8.0), \n tempdb_current_kb = (tempdb_current*8.0), w.tasks, w.percent_complete, [used_memory_kb] = (w.used_memory*8.0),\n start_time = DATEADD(mi, DATEDIFF(mi, getdate(), getutcdate()), [start_time])\n\t\t\t \n from t_WhoIsActive w\n order by w.collection_time DESC, w.start_time ASC\nend\nELSE\n select 'No long running query found for time window' as [No Result]\n\"\nset quoted_identifier on;\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nif ($is_local = 1)\n exec dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc, @duration;\nelse\n exec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc, @duration;", + "refId": "A", + "sql": { + "columns": [ + { + "parameters": [], + "type": "function" + } + ], + "groupBy": [ + { + "property": { + "type": "string" + }, + "type": "groupBy" + } + ], + "limit": 50 + } } ], - "title": "Connections by Interface", + "title": "WhoIsActive Data", "type": "table" - }, + } + ], + "repeat": "datasource", + "title": "Long Running Queries", + "type": "row" + }, + { + "collapsed": true, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 29 + }, + "id": 29, + "panels": [ { "datasource": { "type": "mssql", "uid": "${sqlmonitor_datasource}" }, - "description": "select * from sys.dm_exec_connections", + "description": "https://sqlperformance.com/2014/10/sql-performance/knee-jerk-page-life-expectancy", "fieldConfig": { "defaults": { "color": { - "mode": "thresholds" + "mode": "palette-classic" }, "custom": { - "align": "auto", - "cellOptions": { - "type": "auto" + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 10, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false }, - "filterable": true, - "inspect": false + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": true, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "line+area" + } }, "mappings": [], - "min": 0, "thresholds": { "mode": "absolute", "steps": [ { - "color": "green" - } - ] - }, - "unit": "none" - }, - "overrides": [ - { - "matcher": { - "id": "byType", - "options": "string" - }, - "properties": [ + "color": "red" + }, { - "id": "custom.width" + "color": "transparent", + "value": 600 } ] }, - { - "matcher": { - "id": "byType", - "options": "number" - }, - "properties": [ - { - "id": "custom.width", - "value": 100 - } - ] - } - ] + "unit": "s" + }, + "overrides": [] }, "gridPos": { - "h": 12, - "w": 8, - "x": 8, - "y": 309 + "h": 10, + "w": 24, + "x": 0, + "y": 990 }, - "id": 128, + "id": 8, "options": { - "cellHeight": "sm", - "footer": { - "countRows": false, - "fields": "", - "reducer": [ - "sum" + "legend": { + "calcs": [ + "lastNotNull", + "min" ], - "show": false + "displayMode": "table", + "placement": "bottom", + "showLegend": true }, - "showHeader": true, - "sortBy": [] + "tooltip": { + "mode": "multi", + "sort": "desc" + } }, "pluginVersion": "11.3.1", "targets": [ @@ -6505,90 +6745,133 @@ "type": "mssql", "uid": "${sqlmonitor_datasource}" }, - "format": "table", - "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\ndeclare @start_time_utc datetime2;\ndeclare @end_time_utc datetime2;\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @start_time_utc = $__timeFrom();\nset @end_time_utc = $__timeTo();\nset @params = N'@perfmon_host_name varchar(255), @start_time_utc datetime2, @end_time_utc datetime2';\n\nset quoted_identifier off;\nset @sql = \"\nset nocount on;\nselect host_name, count(*) as counts\nfrom sys.dm_exec_connections as dec with (nolock) \njoin sys.dm_exec_sessions as des with (nolock) on des.session_id = dec.session_id\ngroup by host_name\norder by counts desc, host_name\n\"\nset quoted_identifier on;\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nif ($is_local = 1)\n exec dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;\nelse\n exec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;", - "refId": "A" + "editorMode": "code", + "format": "time_series", + "rawQuery": true, + "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\ndeclare @start_time_utc datetime2;\ndeclare @end_time_utc datetime2;\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @start_time_utc = $__timeFrom();\nset @end_time_utc = $__timeTo();\nset @params = N'@perfmon_host_name varchar(255), @start_time_utc datetime2, @end_time_utc datetime2';\n\nset quoted_identifier off;\nset @sql = \"\nset nocount on;\ndeclare @object_name varchar(255);\nset @object_name = (case when '$perfmon_service_name' = 'MSSQLSERVER' \n\t\t\t\t\t\t then 'sqlserver' else LOWER('$perfmon_service_name') end);\n\nselect pc.collection_time_utc as time\n\t,counter as metric\n\t--,object, counter, instance\n\t,pc.value\nfrom $perfmon_table_name pc with (nolock)\nwhere collection_time_utc between @start_time_utc and @end_time_utc \nand host_name = @perfmon_host_name and pc.object = (@object_name+':buffer manager')\nand pc.counter = 'page life expectancy'\norder by time\n\"\nset quoted_identifier on;\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nif ($is_local = 1)\n exec dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;\nelse\n exec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;", + "refId": "A", + "sql": { + "columns": [ + { + "parameters": [], + "type": "function" + } + ], + "groupBy": [ + { + "property": { + "type": "string" + }, + "type": "groupBy" + } + ], + "limit": 50 + } } ], - "title": "Host Connections", - "type": "table" - }, + "title": "Page Life Expectancy", + "type": "timeseries" + } + ], + "repeat": "datasource", + "title": "Trend - Page Life Expectancy", + "type": "row" + }, + { + "collapsed": true, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 30 + }, + "id": 27, + "panels": [ { "datasource": { "type": "mssql", "uid": "${sqlmonitor_datasource}" }, - "description": "select * from sys.dm_exec_connections", + "description": "https://sqlperformance.com/2014/10/sql-performance/knee-jerk-page-life-expectancy", "fieldConfig": { "defaults": { "color": { - "mode": "thresholds" + "mode": "palette-classic" }, "custom": { - "align": "auto", - "cellOptions": { - "type": "auto" + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisGridShow": true, + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 10, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false }, - "filterable": true, - "inspect": false + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "log": 10, + "type": "log" + }, + "showPoints": "never", + "spanNulls": true, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } }, "mappings": [], - "min": 0, "thresholds": { "mode": "absolute", "steps": [ { "color": "green" - } - ] - }, - "unit": "none" - }, - "overrides": [ - { - "matcher": { - "id": "byName", - "options": "login_name" - }, - "properties": [ + }, { - "id": "custom.width" + "color": "red", + "value": 80 } ] }, - { - "matcher": { - "id": "byName", - "options": "counts" - }, - "properties": [ - { - "id": "custom.width", - "value": 100 - } - ] - } - ] + "unit": "short" + }, + "overrides": [] }, "gridPos": { - "h": 12, - "w": 8, - "x": 16, - "y": 309 + "h": 7, + "w": 24, + "x": 0, + "y": 991 }, - "id": 129, + "id": 18, "options": { - "cellHeight": "sm", - "footer": { - "countRows": false, - "fields": "", - "reducer": [ - "sum" + "legend": { + "calcs": [ + "lastNotNull", + "max", + "p99" ], - "show": false + "displayMode": "table", + "placement": "bottom", + "showLegend": true }, - "showHeader": true, - "sortBy": [] + "tooltip": { + "mode": "multi", + "sort": "desc" + } }, "pluginVersion": "11.3.1", "targets": [ @@ -6598,20 +6881,54 @@ "type": "mssql", "uid": "${sqlmonitor_datasource}" }, - "format": "table", - "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\ndeclare @start_time_utc datetime2;\ndeclare @end_time_utc datetime2;\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @start_time_utc = $__timeFrom();\nset @end_time_utc = $__timeTo();\nset @params = N'@perfmon_host_name varchar(255), @start_time_utc datetime2, @end_time_utc datetime2';\n\nset quoted_identifier off;\nset @sql = \"\nset nocount on;\nselect login_name, count(*) as counts\nfrom sys.dm_exec_connections as dec with (nolock) \njoin sys.dm_exec_sessions as des with (nolock) on des.session_id = dec.session_id\ngroup by login_name\norder by counts desc, login_name\n\"\nset quoted_identifier on;\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nif ($is_local = 1)\n exec dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;\nelse\n exec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;", - "refId": "A" + "editorMode": "code", + "format": "time_series", + "rawQuery": true, + "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\ndeclare @start_time_utc datetime2;\ndeclare @end_time_utc datetime2;\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @start_time_utc = $__timeFrom();\nset @end_time_utc = $__timeTo();\nset @params = N'@perfmon_host_name varchar(255), @start_time_utc datetime2, @end_time_utc datetime2';\n\nset quoted_identifier off;\nset @sql = \"\nset nocount on;\ndeclare @object_name varchar(255);\nset @object_name = (case when '$perfmon_service_name' = 'MSSQLSERVER' then 'sqlserver' else LOWER('$perfmon_service_name') end);\nselect pc.collection_time_utc as time, \n\tcounter as metric\n\t--,instance,\n\t,pc.value\nfrom $perfmon_table_name pc with (nolock)\nwhere collection_time_utc between @start_time_utc and @end_time_utc \nand host_name = @perfmon_host_name and pc.object = (@object_name+':sql statistics') \nand pc.counter = 'batch requests/sec'\nand pc.value <> 0.0\norder by time\n\"\nset quoted_identifier on;\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nif ($is_local = 1)\n exec dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;\nelse\n exec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;", + "refId": "A", + "sql": { + "columns": [ + { + "parameters": [], + "type": "function" + } + ], + "groupBy": [ + { + "property": { + "type": "string" + }, + "type": "groupBy" + } + ], + "limit": 50 + } } ], - "title": "Login Connections", - "type": "table" - }, + "title": "Batch Requests Per Second", + "type": "timeseries" + } + ], + "repeat": "datasource", + "title": "Trend - Batch Request/Sec", + "type": "row" + }, + { + "collapsed": true, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 31 + }, + "id": 126, + "panels": [ { "datasource": { "type": "mssql", "uid": "${sqlmonitor_datasource}" }, - "description": "select * from sys.dm_exec_connections", + "description": "select * from sys.dm_exec_requests r where blocking_session_id <> 0", "fieldConfig": { "defaults": { "color": { @@ -6622,43 +6939,38 @@ "cellOptions": { "type": "auto" }, - "filterable": true, "inspect": false }, "mappings": [], + "max": 100, "min": 0, "thresholds": { "mode": "absolute", "steps": [ { "color": "green" + }, + { + "color": "dark-orange", + "value": 500 + }, + { + "color": "dark-red", + "value": 700 } ] }, "unit": "none" }, - "overrides": [ - { - "matcher": { - "id": "byName", - "options": "counts" - }, - "properties": [ - { - "id": "custom.width", - "value": 100 - } - ] - } - ] + "overrides": [] }, "gridPos": { - "h": 6, - "w": 8, + "h": 7, + "w": 24, "x": 0, - "y": 315 + "y": 992 }, - "id": 130, + "id": 124, "options": { "cellHeight": "sm", "footer": { @@ -6669,8 +6981,7 @@ ], "show": false }, - "showHeader": true, - "sortBy": [] + "showHeader": true }, "pluginVersion": "11.3.1", "targets": [ @@ -6681,73 +6992,34 @@ "uid": "${sqlmonitor_datasource}" }, "format": "table", - "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\ndeclare @start_time_utc datetime2;\ndeclare @end_time_utc datetime2;\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @start_time_utc = $__timeFrom();\nset @end_time_utc = $__timeTo();\nset @params = N'@perfmon_host_name varchar(255), @start_time_utc datetime2, @end_time_utc datetime2';\n\nset quoted_identifier off;\nset @sql = \"\nset nocount on;\nselect status, count(*) as counts\nfrom sys.dm_exec_connections as dec with (nolock) \njoin sys.dm_exec_sessions as des with (nolock) on des.session_id = dec.session_id\ngroup by status\norder by counts desc, status\n\"\nset quoted_identifier on;\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nif ($is_local = 1)\n exec dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;\nelse\n exec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;", + "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\ndeclare @start_time_utc datetime2;\ndeclare @end_time_utc datetime2;\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @start_time_utc = $__timeFrom();\nset @end_time_utc = $__timeTo();\nset @params = N'@perfmon_host_name varchar(255), @start_time_utc datetime2, @end_time_utc datetime2';\n\nset quoted_identifier off;\nset @sql = \"\nset nocount on;\nselect host_name, login_name, status, client_net_address, client_interface_name, count(*) as counts\nfrom sys.dm_exec_connections as dec with (nolock) \njoin sys.dm_exec_sessions as des on des.session_id = dec.session_id\ngroup by host_name, login_name, status, client_net_address, client_interface_name\norder by counts desc, login_name\n\"\nset quoted_identifier on;\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nif ($is_local = 1)\n exec dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;\nelse\n exec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;", "refId": "A" } ], - "title": "Connections By Status", + "title": "Connections", "type": "table" - } - ], - "repeat": "datasource", - "title": "SQL Connections - Distribution", - "type": "row" - }, - { - "collapsed": true, - "gridPos": { - "h": 1, - "w": 24, - "x": 0, - "y": 30 - }, - "id": 79, - "panels": [ + }, { "datasource": { "type": "mssql", "uid": "${sqlmonitor_datasource}" }, - "description": "select * from [$inventory_db].$os_task_list_table_name", + "description": "select * from sys.dm_exec_connections", "fieldConfig": { "defaults": { "color": { - "mode": "palette-classic" + "mode": "thresholds" }, "custom": { - "axisBorderShow": false, - "axisCenteredZero": false, - "axisColorMode": "text", - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "barWidthFactor": 0.6, - "drawStyle": "bars", - "fillOpacity": 100, - "gradientMode": "hue", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "insertNulls": false, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 1, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "auto", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "normal" + "align": "auto", + "cellOptions": { + "type": "auto" }, - "thresholdsStyle": { - "mode": "off" - } + "filterable": true, + "inspect": false }, "mappings": [], + "min": 0, "thresholds": { "mode": "absolute", "steps": [ @@ -6756,46 +7028,53 @@ } ] }, - "unit": "s" + "unit": "none" }, "overrides": [ { "matcher": { - "id": "byFrameRefID", - "options": "A" + "id": "byType", + "options": "string" }, "properties": [ { - "id": "unit", - "value": "s" + "id": "custom.width" + } + ] + }, + { + "matcher": { + "id": "byType", + "options": "number" + }, + "properties": [ + { + "id": "custom.width", + "value": 100 } ] } ] }, "gridPos": { - "h": 11, - "w": 24, + "h": 6, + "w": 8, "x": 0, - "y": 40 + "y": 1040 }, - "id": 144, + "id": 131, "options": { - "legend": { - "calcs": [ - "last", - "mean" + "cellHeight": "sm", + "footer": { + "countRows": false, + "fields": "", + "reducer": [ + "sum" ], - "displayMode": "table", - "placement": "right", - "showLegend": true, - "sortBy": "Mean", - "sortDesc": false + "show": false }, - "tooltip": { - "mode": "multi", - "sort": "none" - } + "showHeader": true, + "sortBy": [] }, "pluginVersion": "11.3.1", "targets": [ @@ -6805,81 +7084,35 @@ "type": "mssql", "uid": "${sqlmonitor_datasource}" }, - "editorMode": "code", - "format": "time_series", - "rawQuery": true, - "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\ndeclare @start_time_utc datetime2;\ndeclare @end_time_utc datetime2;\ndeclare @delta_minutes int;\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @start_time_utc = $__timeFrom();\nset @end_time_utc = $__timeTo();\nset @delta_minutes = $cpu_delta_minutes;\nset @params = N'@perfmon_host_name varchar(255), @start_time_utc datetime2, @end_time_utc datetime2, @delta_minutes int';\n\nset quoted_identifier off;\nset @sql = \"\nset nocount on;\ndeclare @TopRowFilter tinyint = 100;\n\nif object_id('tempdb..#dates') is not null\n\tdrop table #dates;\ncreate table #dates (collection_time_utc datetime2 not null primary key);\ndeclare @_collection_time_utc datetime2;\ndeclare @_collection_time_utc_prev datetime2;\n\ndeclare cur_dates cursor local fast_forward for\n\tselect collection_time_utc\n\tfrom $os_task_list_table_name\n\twhere host_name = @perfmon_host_name\n\tand collection_time_utc between @start_time_utc and @end_time_utc\n\tgroup by collection_time_utc\n\torder by collection_time_utc\n\toption(recompile);\n\nopen cur_dates;\nfetch next from cur_dates into @_collection_time_utc;\n\nwhile @@fetch_status = 0\nbegin\n\t-- Set start timestamp\n\tif(@_collection_time_utc_prev is null)\n\tbegin\n\t\tinsert #dates values (@_collection_time_utc);\n\t\tset @_collection_time_utc_prev = @_collection_time_utc;\n\tend\n\t\n\t-- Choose next timestamp based on @delta_minutes\n\tif (@_collection_time_utc_prev is not null)\n\t\tand (@_collection_time_utc >= dateadd(minute,@delta_minutes,@_collection_time_utc_prev))\n\tbegin\n\t\tinsert #dates values (@_collection_time_utc);\n\t\tset @_collection_time_utc_prev = @_collection_time_utc;\n\tend\n\t\n\tfetch next from cur_dates into @_collection_time_utc;\nend\n\nclose cur_dates;\ndeallocate cur_dates;\n\n--select *\n--from #dates;\n\nif object_id('tempdb..#os_task_list') is not null\n\tdrop table #os_task_list;\nwith cte_tasks as (\n\tselect tl.collection_time_utc, tl.task_name, [cpu_s] = sum(cpu_time_seconds), [counts] = count(*)\n\tfrom $os_task_list_table_name tl join #dates d on d.collection_time_utc = tl.collection_time_utc\n\twhere (tl.collection_time_utc between @start_time_utc and @end_time_utc)\n\tand tl.host_name = @perfmon_host_name\n\tand task_name not in ('System Idle Process','') -- add other harmless processes here\n\tgroup by tl.collection_time_utc, tl.task_name\n)\nselect\tcollection_time_utc, task_name, cpu_s, counts\n\t\t,[cpu_s__delta] = isnull(cpu_s - (lag(cpu_s) over (partition by task_name order by collection_time_utc)),0)\n\t\t,[CpuRank] = ROW_NUMBER() OVER(PARTITION BY [collection_time_utc] ORDER BY cpu_s DESC)\ninto #os_task_list\nfrom cte_tasks;\n\n\nselect collection_time_utc as time, task_name as metric, (case when [cpu_s__delta] < 0 then 0 else [cpu_s__delta] end) as value\nfrom #os_task_list\nwhere CpuRank <= @TopRowFilter\nand collection_time_utc > (select min(m.collection_time_utc) from #os_task_list m)\norder by collection_time_utc, CpuRank, cpu_s desc;\n\"\nset quoted_identifier on;\n\nif '$InstanceScopeFeaturesOnly' = 'true'\n\tselect [time], remarks as metric, [value]\n\tfrom (values ('This feature is not available for this SQLInstance',getutcdate(), 0)) dummy(remarks, [time], value)\n\torder by [time]\nelse\nbegin\n\tif ($is_local = 1)\n\t\texec dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc, @delta_minutes;\n\telse\n\t\texec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc, @delta_minutes;\nend", - "refId": "A", - "sql": { - "columns": [ - { - "parameters": [], - "type": "function" - } - ], - "groupBy": [ - { - "property": { - "type": "string" - }, - "type": "groupBy" - } - ], - "limit": 50 - } + "format": "table", + "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\ndeclare @start_time_utc datetime2;\ndeclare @end_time_utc datetime2;\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @start_time_utc = $__timeFrom();\nset @end_time_utc = $__timeTo();\nset @params = N'@perfmon_host_name varchar(255), @start_time_utc datetime2, @end_time_utc datetime2';\n\nset quoted_identifier off;\nset @sql = \"\nset nocount on;\nselect client_interface_name, count(*) as counts\nfrom sys.dm_exec_connections as dec with (nolock) \njoin sys.dm_exec_sessions as des with (nolock) on des.session_id = dec.session_id\nwhere len(ltrim(rtrim(client_interface_name))) > 0\ngroup by client_interface_name\norder by counts desc, client_interface_name\n\"\nset quoted_identifier on;\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nif ($is_local = 1)\n exec dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;\nelse\n exec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;", + "refId": "A" } ], - "title": "[${server}] - OS Process - CPU Time - Histrogram - $cpu_delta_minutes Minute Interval", - "type": "timeseries" + "title": "Connections by Interface", + "type": "table" }, { "datasource": { "type": "mssql", "uid": "${sqlmonitor_datasource}" }, - "description": "select * from [$inventory_db].$os_task_list_table_name", + "description": "select * from sys.dm_exec_connections", "fieldConfig": { "defaults": { "color": { - "mode": "palette-classic" + "mode": "thresholds" }, "custom": { - "axisBorderShow": false, - "axisCenteredZero": false, - "axisColorMode": "text", - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "barWidthFactor": 0.6, - "drawStyle": "line", - "fillOpacity": 0, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "insertNulls": false, - "lineInterpolation": "linear", - "lineStyle": { - "fill": "solid" - }, - "lineWidth": 1, - "pointSize": 3, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "auto", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "normal" + "align": "auto", + "cellOptions": { + "type": "auto" }, - "thresholdsStyle": { - "mode": "off" - } + "filterable": true, + "inspect": false }, "mappings": [], + "min": 0, "thresholds": { "mode": "absolute", "steps": [ @@ -6888,46 +7121,53 @@ } ] }, - "unit": "s" + "unit": "none" }, "overrides": [ { "matcher": { - "id": "byFrameRefID", - "options": "A" + "id": "byType", + "options": "string" }, "properties": [ { - "id": "unit", - "value": "s" + "id": "custom.width" + } + ] + }, + { + "matcher": { + "id": "byType", + "options": "number" + }, + "properties": [ + { + "id": "custom.width", + "value": 100 } ] } ] }, "gridPos": { - "h": 10, - "w": 24, - "x": 0, - "y": 118 + "h": 12, + "w": 8, + "x": 8, + "y": 1040 }, - "id": 145, + "id": 128, "options": { - "legend": { - "calcs": [ - "last", - "mean" + "cellHeight": "sm", + "footer": { + "countRows": false, + "fields": "", + "reducer": [ + "sum" ], - "displayMode": "table", - "placement": "right", - "showLegend": true, - "sortBy": "Mean", - "sortDesc": true + "show": false }, - "tooltip": { - "mode": "multi", - "sort": "none" - } + "showHeader": true, + "sortBy": [] }, "pluginVersion": "11.3.1", "targets": [ @@ -6937,93 +7177,35 @@ "type": "mssql", "uid": "${sqlmonitor_datasource}" }, - "editorMode": "code", - "format": "time_series", - "rawQuery": true, - "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\ndeclare @start_time_utc datetime2;\ndeclare @end_time_utc datetime2;\ndeclare @delta_minutes int;\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @start_time_utc = $__timeFrom();\nset @end_time_utc = $__timeTo();\nset @delta_minutes = $cpu_delta_minutes;\nset @params = N'@perfmon_host_name varchar(255), @start_time_utc datetime2, @end_time_utc datetime2, @delta_minutes int';\n\nset quoted_identifier off;\nset @sql = \"\nset nocount on;\ndeclare @TopRowFilter tinyint = 100;\n\nif object_id('tempdb..#dates') is not null\n\tdrop table #dates;\ncreate table #dates (collection_time_utc datetime2 not null primary key);\ndeclare @_collection_time_utc datetime2;\ndeclare @_collection_time_utc_prev datetime2;\n\ndeclare cur_dates cursor local fast_forward for\n\tselect collection_time_utc\n\tfrom $os_task_list_table_name\n\twhere host_name = @perfmon_host_name\n\tand collection_time_utc between @start_time_utc and @end_time_utc\n\tgroup by collection_time_utc\n\torder by collection_time_utc;\n\nopen cur_dates;\nfetch next from cur_dates into @_collection_time_utc;\n\nwhile @@fetch_status = 0\nbegin\n\t-- Set start timestamp\n\tif(@_collection_time_utc_prev is null)\n\tbegin\n\t\tinsert #dates values (@_collection_time_utc);\n\t\tset @_collection_time_utc_prev = @_collection_time_utc;\n\tend\n\t\n\t-- Choose next timestamp based on @delta_minutes\n\tif (@_collection_time_utc_prev is not null)\n\t\tand (@_collection_time_utc >= dateadd(minute,@delta_minutes,@_collection_time_utc_prev))\n\tbegin\n\t\tinsert #dates values (@_collection_time_utc);\n\t\tset @_collection_time_utc_prev = @_collection_time_utc;\n\tend\n\t\n\tfetch next from cur_dates into @_collection_time_utc;\nend\n\nclose cur_dates;\ndeallocate cur_dates;\n\n--select *\n--from #dates;\n\nif object_id('tempdb..#os_task_list') is not null\n\tdrop table #os_task_list;\nwith cte_tasks as (\n\tselect tl.collection_time_utc, tl.task_name, [cpu_s] = sum(cpu_time_seconds), [counts] = count(*)\n\tfrom $os_task_list_table_name tl join #dates d on d.collection_time_utc = tl.collection_time_utc\n\twhere (tl.collection_time_utc between @start_time_utc and @end_time_utc)\n\tand tl.host_name = @perfmon_host_name\n\tand task_name not in ('System Idle Process','') -- add other harmless processes here\n\tgroup by tl.collection_time_utc, tl.task_name\n)\nselect\tcollection_time_utc, task_name, cpu_s, counts\n\t\t,[cpu_s__delta] = isnull(cpu_s - (lag(cpu_s) over (partition by task_name order by collection_time_utc)),0)\n\t\t,[CpuRank] = ROW_NUMBER() OVER(PARTITION BY [collection_time_utc] ORDER BY cpu_s DESC)\ninto #os_task_list\nfrom cte_tasks;\n\n\nselect collection_time_utc as time, task_name as metric, (case when [cpu_s__delta] < 0 then 0 else [cpu_s__delta] end) as value\nfrom #os_task_list\nwhere CpuRank <= @TopRowFilter\nand collection_time_utc > (select min(m.collection_time_utc) from #os_task_list m)\norder by collection_time_utc, CpuRank, cpu_s desc;\n\"\nset quoted_identifier on;\n\nif '$InstanceScopeFeaturesOnly' = 'true'\n\tselect [time], remarks as metric, [value]\n\tfrom (values ('This feature is not available for this SQLInstance',getutcdate(), 0)) dummy(remarks, [time], value)\n\torder by [time]\nelse\nbegin\n\tif ($is_local = 1)\n\t\texec dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc, @delta_minutes;\n\telse\n\t\texec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc, @delta_minutes;\nend", - "refId": "A", - "sql": { - "columns": [ - { - "parameters": [], - "type": "function" - } - ], - "groupBy": [ - { - "property": { - "type": "string" - }, - "type": "groupBy" - } - ], - "limit": 50 - } + "format": "table", + "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\ndeclare @start_time_utc datetime2;\ndeclare @end_time_utc datetime2;\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @start_time_utc = $__timeFrom();\nset @end_time_utc = $__timeTo();\nset @params = N'@perfmon_host_name varchar(255), @start_time_utc datetime2, @end_time_utc datetime2';\n\nset quoted_identifier off;\nset @sql = \"\nset nocount on;\nselect host_name, count(*) as counts\nfrom sys.dm_exec_connections as dec with (nolock) \njoin sys.dm_exec_sessions as des with (nolock) on des.session_id = dec.session_id\ngroup by host_name\norder by counts desc, host_name\n\"\nset quoted_identifier on;\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nif ($is_local = 1)\n exec dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;\nelse\n exec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;", + "refId": "A" } ], - "title": "[${server}] - OS Process - CPU Time - Utilization - $cpu_delta_minutes Minute Interval", - "type": "timeseries" - } - ], - "repeat": "datasource", - "title": "OS Tasks (Processes) - CPU Utilization", - "type": "row" - }, - { - "collapsed": true, - "gridPos": { - "h": 1, - "w": 24, - "x": 0, - "y": 31 - }, - "id": 82, - "panels": [ + "title": "Host Connections", + "type": "table" + }, { "datasource": { "type": "mssql", "uid": "${sqlmonitor_datasource}" }, - "description": "select * from [$inventory_db].$os_task_list_table_name", + "description": "select * from sys.dm_exec_connections", "fieldConfig": { "defaults": { "color": { - "mode": "palette-classic" + "mode": "thresholds" }, "custom": { - "axisBorderShow": false, - "axisCenteredZero": false, - "axisColorMode": "text", - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "barWidthFactor": 0.6, - "drawStyle": "bars", - "fillOpacity": 100, - "gradientMode": "hue", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "insertNulls": false, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 1, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "auto", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "normal" + "align": "auto", + "cellOptions": { + "type": "auto" }, - "thresholdsStyle": { - "mode": "off" - } + "filterable": true, + "inspect": false }, "mappings": [], + "min": 0, "thresholds": { "mode": "absolute", "steps": [ @@ -7032,46 +7214,53 @@ } ] }, - "unit": "kbytes" + "unit": "none" }, "overrides": [ { "matcher": { - "id": "byFrameRefID", - "options": "A" + "id": "byName", + "options": "login_name" }, "properties": [ { - "id": "unit", - "value": "kbytes" + "id": "custom.width" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "counts" + }, + "properties": [ + { + "id": "custom.width", + "value": 100 } ] } ] }, "gridPos": { - "h": 10, - "w": 24, - "x": 0, - "y": 41 + "h": 12, + "w": 8, + "x": 16, + "y": 1040 }, - "id": 146, + "id": 129, "options": { - "legend": { - "calcs": [ - "mean", - "max" + "cellHeight": "sm", + "footer": { + "countRows": false, + "fields": "", + "reducer": [ + "sum" ], - "displayMode": "table", - "placement": "right", - "showLegend": true, - "sortBy": "Mean", - "sortDesc": true + "show": false }, - "tooltip": { - "mode": "multi", - "sort": "none" - } + "showHeader": true, + "sortBy": [] }, "pluginVersion": "11.3.1", "targets": [ @@ -7081,81 +7270,35 @@ "type": "mssql", "uid": "${sqlmonitor_datasource}" }, - "editorMode": "code", - "format": "time_series", - "rawQuery": true, - "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\ndeclare @start_time_utc datetime2;\ndeclare @end_time_utc datetime2;\ndeclare @delta_minutes int;\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @start_time_utc = $__timeFrom();\nset @end_time_utc = $__timeTo();\nset @delta_minutes = $cpu_delta_minutes;\nset @params = N'@perfmon_host_name varchar(255), @start_time_utc datetime2, @end_time_utc datetime2, @delta_minutes int';\n\nset quoted_identifier off;\nset @sql = \"\nset nocount on;\ndeclare @TopRowFilter tinyint = 10;\n\nif object_id('tempdb..#dates') is not null\n\tdrop table #dates;\ncreate table #dates (collection_time_utc datetime2 not null primary key);\ndeclare @_collection_time_utc datetime2;\ndeclare @_collection_time_utc_prev datetime2;\n\ndeclare cur_dates cursor local fast_forward for\n\tselect collection_time_utc\n\tfrom $os_task_list_table_name\n\twhere host_name = @perfmon_host_name\n\tand collection_time_utc between @start_time_utc and @end_time_utc\n\tgroup by collection_time_utc\n\torder by collection_time_utc\n\toption(recompile);\n\nopen cur_dates;\nfetch next from cur_dates into @_collection_time_utc;\n\nwhile @@fetch_status = 0\nbegin\n\t-- Set start timestamp\n\tif(@_collection_time_utc_prev is null)\n\tbegin\n\t\tinsert #dates values (@_collection_time_utc);\n\t\tset @_collection_time_utc_prev = @_collection_time_utc;\n\tend\n\t\n\t-- Choose next timestamp based on @delta_minutes\n\tif (@_collection_time_utc_prev is not null)\n\t\tand (@_collection_time_utc >= dateadd(minute,@delta_minutes,@_collection_time_utc_prev))\n\tbegin\n\t\tinsert #dates values (@_collection_time_utc);\n\t\tset @_collection_time_utc_prev = @_collection_time_utc;\n\tend\n\t\n\tfetch next from cur_dates into @_collection_time_utc;\nend\n\nclose cur_dates;\ndeallocate cur_dates;\n\n--select * from #dates;\n\nif object_id('tempdb..#os_task_list') is not null\n\tdrop table #os_task_list;\nwith cte_tasks as (\n\tselect tl.collection_time_utc, tl.task_name, [memory_kb] = sum([memory_kb]), [counts] = count(*)\n\tfrom $os_task_list_table_name tl join #dates d on d.collection_time_utc = tl.collection_time_utc\n\twhere (tl.collection_time_utc between @start_time_utc and @end_time_utc)\n\tand tl.host_name = @perfmon_host_name\n\tand task_name not in ('System Idle Process','') -- add other harmless processes here\n\tgroup by tl.collection_time_utc, tl.task_name\n)\nselect\tcollection_time_utc, task_name, [memory_kb], counts\n\t\t--,[cpu_s__delta] = isnull(cpu_s - (lag(cpu_s) over (partition by task_name order by collection_time_utc)),0)\n\t\t,[RowRank] = ROW_NUMBER() OVER(PARTITION BY [collection_time_utc] ORDER BY [memory_kb] DESC)\ninto #os_task_list\nfrom cte_tasks;\n\n\nselect collection_time_utc as time, task_name as metric, [memory_kb] as value\nfrom #os_task_list\nwhere [RowRank] <= @TopRowFilter\nand collection_time_utc > (select min(m.collection_time_utc) from #os_task_list m)\norder by [time], [RowRank], [memory_kb] desc;\n\"\nset quoted_identifier on;\n\nif '$InstanceScopeFeaturesOnly' = 'true'\n\tselect [time], remarks as metric, [value]\n\tfrom (values ('This feature is not available for this SQLInstance',getutcdate(), 0)) dummy(remarks, [time], value)\n\torder by [time]\nelse\nbegin\n\tif ($is_local = 1)\n\t\texec dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc, @delta_minutes;\n\telse\n\t\texec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc, @delta_minutes;\nend", - "refId": "A", - "sql": { - "columns": [ - { - "parameters": [], - "type": "function" - } - ], - "groupBy": [ - { - "property": { - "type": "string" - }, - "type": "groupBy" - } - ], - "limit": 50 - } + "format": "table", + "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\ndeclare @start_time_utc datetime2;\ndeclare @end_time_utc datetime2;\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @start_time_utc = $__timeFrom();\nset @end_time_utc = $__timeTo();\nset @params = N'@perfmon_host_name varchar(255), @start_time_utc datetime2, @end_time_utc datetime2';\n\nset quoted_identifier off;\nset @sql = \"\nset nocount on;\nselect login_name, count(*) as counts\nfrom sys.dm_exec_connections as dec with (nolock) \njoin sys.dm_exec_sessions as des with (nolock) on des.session_id = dec.session_id\ngroup by login_name\norder by counts desc, login_name\n\"\nset quoted_identifier on;\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nif ($is_local = 1)\n exec dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;\nelse\n exec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;", + "refId": "A" } ], - "title": "[${server}] - OS Processes - Memory - Histrogram - $cpu_delta_minutes Minute Interval", - "type": "timeseries" + "title": "Login Connections", + "type": "table" }, { "datasource": { "type": "mssql", "uid": "${sqlmonitor_datasource}" }, - "description": "select * from [$inventory_db].$os_task_list_table_name", + "description": "select * from sys.dm_exec_connections", "fieldConfig": { "defaults": { "color": { - "mode": "palette-classic" + "mode": "thresholds" }, "custom": { - "axisBorderShow": false, - "axisCenteredZero": false, - "axisColorMode": "text", - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "barWidthFactor": 0.6, - "drawStyle": "line", - "fillOpacity": 0, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "insertNulls": false, - "lineInterpolation": "linear", - "lineStyle": { - "fill": "solid" - }, - "lineWidth": 1, - "pointSize": 3, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "auto", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "normal" + "align": "auto", + "cellOptions": { + "type": "auto" }, - "thresholdsStyle": { - "mode": "off" - } + "filterable": true, + "inspect": false }, "mappings": [], + "min": 0, "thresholds": { "mode": "absolute", "steps": [ @@ -7164,46 +7307,42 @@ } ] }, - "unit": "kbytes" + "unit": "none" }, "overrides": [ { "matcher": { - "id": "byFrameRefID", - "options": "A" + "id": "byName", + "options": "counts" }, "properties": [ { - "id": "unit", - "value": "kbytes" + "id": "custom.width", + "value": 100 } ] } ] }, "gridPos": { - "h": 10, - "w": 24, + "h": 6, + "w": 8, "x": 0, - "y": 98 + "y": 1046 }, - "id": 147, + "id": 130, "options": { - "legend": { - "calcs": [ - "mean", - "max" + "cellHeight": "sm", + "footer": { + "countRows": false, + "fields": "", + "reducer": [ + "sum" ], - "displayMode": "table", - "placement": "right", - "showLegend": true, - "sortBy": "Mean", - "sortDesc": true + "show": false }, - "tooltip": { - "mode": "multi", - "sort": "none" - } + "showHeader": true, + "sortBy": [] }, "pluginVersion": "11.3.1", "targets": [ @@ -7213,36 +7352,17 @@ "type": "mssql", "uid": "${sqlmonitor_datasource}" }, - "editorMode": "code", - "format": "time_series", - "rawQuery": true, - "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\ndeclare @start_time_utc datetime2;\ndeclare @end_time_utc datetime2;\ndeclare @delta_minutes int;\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @start_time_utc = $__timeFrom();\nset @end_time_utc = $__timeTo();\nset @delta_minutes = $cpu_delta_minutes;\nset @params = N'@perfmon_host_name varchar(255), @start_time_utc datetime2, @end_time_utc datetime2, @delta_minutes int';\n\nset quoted_identifier off;\nset @sql = \"\nset nocount on;\ndeclare @TopRowFilter tinyint = 10;\n\nif object_id('tempdb..#dates') is not null\n\tdrop table #dates;\ncreate table #dates (collection_time_utc datetime2 not null primary key);\ndeclare @_collection_time_utc datetime2;\ndeclare @_collection_time_utc_prev datetime2;\n\ndeclare cur_dates cursor local fast_forward for\n\tselect collection_time_utc\n\tfrom $os_task_list_table_name\n\twhere host_name = @perfmon_host_name\n\tand collection_time_utc between @start_time_utc and @end_time_utc\n\tgroup by collection_time_utc\n\torder by collection_time_utc\n\toption(recompile);\n\nopen cur_dates;\nfetch next from cur_dates into @_collection_time_utc;\n\nwhile @@fetch_status = 0\nbegin\n\t-- Set start timestamp\n\tif(@_collection_time_utc_prev is null)\n\tbegin\n\t\tinsert #dates values (@_collection_time_utc);\n\t\tset @_collection_time_utc_prev = @_collection_time_utc;\n\tend\n\t\n\t-- Choose next timestamp based on @delta_minutes\n\tif (@_collection_time_utc_prev is not null)\n\t\tand (@_collection_time_utc >= dateadd(minute,@delta_minutes,@_collection_time_utc_prev))\n\tbegin\n\t\tinsert #dates values (@_collection_time_utc);\n\t\tset @_collection_time_utc_prev = @_collection_time_utc;\n\tend\n\t\n\tfetch next from cur_dates into @_collection_time_utc;\nend\n\nclose cur_dates;\ndeallocate cur_dates;\n\n--select * from #dates;\n\nif object_id('tempdb..#os_task_list') is not null\n\tdrop table #os_task_list;\nwith cte_tasks as (\n\tselect tl.collection_time_utc, tl.task_name, [memory_kb] = sum([memory_kb]), [counts] = count(*)\n\tfrom $os_task_list_table_name tl join #dates d on d.collection_time_utc = tl.collection_time_utc\n\twhere (tl.collection_time_utc between @start_time_utc and @end_time_utc)\n\tand tl.host_name = @perfmon_host_name\n\tand task_name not in ('System Idle Process','') -- add other harmless processes here\n\tgroup by tl.collection_time_utc, tl.task_name\n)\nselect\tcollection_time_utc, task_name, [memory_kb], counts\n\t\t--,[cpu_s__delta] = isnull(cpu_s - (lag(cpu_s) over (partition by task_name order by collection_time_utc)),0)\n\t\t,[RowRank] = ROW_NUMBER() OVER(PARTITION BY [collection_time_utc] ORDER BY [memory_kb] DESC)\ninto #os_task_list\nfrom cte_tasks;\n\n\nselect collection_time_utc as time, task_name as metric, [memory_kb] as value\nfrom #os_task_list\nwhere [RowRank] <= @TopRowFilter\nand collection_time_utc > (select min(m.collection_time_utc) from #os_task_list m)\norder by [time], [RowRank], [memory_kb] desc;\n\"\nset quoted_identifier on;\n\nif '$InstanceScopeFeaturesOnly' = 'true'\n\tselect [time], remarks as metric, [value]\n\tfrom (values ('This feature is not available for this SQLInstance',getutcdate(), 0)) dummy(remarks, [time], value)\n\torder by [time]\nelse\nbegin\n\tif ($is_local = 1)\n\t\texec dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc, @delta_minutes;\n\telse\n\t\texec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc, @delta_minutes;\nend", - "refId": "A", - "sql": { - "columns": [ - { - "parameters": [], - "type": "function" - } - ], - "groupBy": [ - { - "property": { - "type": "string" - }, - "type": "groupBy" - } - ], - "limit": 50 - } + "format": "table", + "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\ndeclare @start_time_utc datetime2;\ndeclare @end_time_utc datetime2;\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @start_time_utc = $__timeFrom();\nset @end_time_utc = $__timeTo();\nset @params = N'@perfmon_host_name varchar(255), @start_time_utc datetime2, @end_time_utc datetime2';\n\nset quoted_identifier off;\nset @sql = \"\nset nocount on;\nselect status, count(*) as counts\nfrom sys.dm_exec_connections as dec with (nolock) \njoin sys.dm_exec_sessions as des with (nolock) on des.session_id = dec.session_id\ngroup by status\norder by counts desc, status\n\"\nset quoted_identifier on;\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nif ($is_local = 1)\n exec dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;\nelse\n exec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;", + "refId": "A" } ], - "title": "[${server}] - OS Processes - Memory Utilization - $cpu_delta_minutes Minute Interval", - "type": "timeseries" + "title": "Connections By Status", + "type": "table" } ], - "repeat": "cpu_delta_minutes", - "title": "OS Tasks (Processes) - Memory Utilization", + "repeat": "datasource", + "title": "SQL Connections - Distribution", "type": "row" }, { @@ -7434,7 +7554,7 @@ "h": 8, "w": 24, "x": 0, - "y": 874 + "y": 1681 }, "id": 86, "options": { @@ -8089,7 +8209,7 @@ "h": 16, "w": 24, "x": 0, - "y": 875 + "y": 1682 }, "id": 185, "options": { @@ -8323,7 +8443,7 @@ "h": 16, "w": 24, "x": 0, - "y": 111 + "y": 918 }, "id": 173, "options": { @@ -8429,7 +8549,7 @@ "h": 15, "w": 24, "x": 0, - "y": 112 + "y": 919 }, "id": 133, "options": { @@ -8508,7 +8628,7 @@ "h": 7, "w": 24, "x": 0, - "y": 923 + "y": 1730 }, "id": 119, "options": { @@ -8733,8 +8853,8 @@ }, { "current": { - "text": "LAB", - "value": "LAB" + "text": "", + "value": "" }, "datasource": { "type": "mssql", @@ -8795,8 +8915,8 @@ }, { "current": { - "text": "15.0.4455.2", - "value": "15.0.4455.2" + "text": "17.0.925.4", + "value": "17.0.925.4" }, "datasource": { "type": "mssql", @@ -8867,8 +8987,8 @@ }, { "current": { - "text": "1763105136058", - "value": "1763105136058" + "text": "1768974398217", + "value": "1768974398217" }, "datasource": { "type": "mssql", @@ -8885,38 +9005,6 @@ "regex": "", "type": "query" }, - { - "current": { - "text": "dbo.vw_os_task_list", - "value": "dbo.vw_os_task_list" - }, - "hide": 2, - "label": "OS Tasks Table Name", - "name": "os_task_list_table_name", - "query": "dbo.vw_os_task_list", - "skipUrlSync": true, - "type": "constant" - }, - { - "current": { - "text": "1763105163871", - "value": "1763105163871" - }, - "datasource": { - "type": "mssql", - "uid": "${sqlmonitor_datasource}" - }, - "definition": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @params = N'@perfmon_host_name varchar(255)';\n\nset quoted_identifier off;\nset @sql = \"select top 1 collection_time_utc\nfrom $os_task_list_table_name with (nolock)\nwhere host_name = @perfmon_host_name\norder by collection_time_utc desc;\n\"\nset quoted_identifier on;\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nif ($is_local = 1)\n exec dbo.sp_executesql @sql , @params, @perfmon_host_name;\nelse\n exec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name;", - "hide": 2, - "includeAll": false, - "label": "Collection Time UTC", - "name": "os_task_list_collection_time_utc", - "options": [], - "query": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @params = N'@perfmon_host_name varchar(255)';\n\nset quoted_identifier off;\nset @sql = \"select top 1 collection_time_utc\nfrom $os_task_list_table_name with (nolock)\nwhere host_name = @perfmon_host_name\norder by collection_time_utc desc;\n\"\nset quoted_identifier on;\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nif ($is_local = 1)\n exec dbo.sp_executesql @sql , @params, @perfmon_host_name;\nelse\n exec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name;", - "refresh": 2, - "regex": "", - "type": "query" - }, { "current": { "text": "dbo.WhoIsActive", @@ -8931,8 +9019,8 @@ }, { "current": { - "text": "1763105162130", - "value": "1763105162130" + "text": "1768974379500", + "value": "1768974379500" }, "datasource": { "type": "mssql", @@ -8990,8 +9078,8 @@ }, { "current": { - "text": "1763101975480", - "value": "1763101975480" + "text": "1768866330053", + "value": "1768866330053" }, "datasource": { "type": "mssql", @@ -9010,8 +9098,8 @@ }, { "current": { - "text": "1763105160003", - "value": "1763105160003" + "text": "1768974440983", + "value": "1768974440983" }, "datasource": { "type": "mssql", @@ -9030,8 +9118,8 @@ }, { "current": { - "text": "8", - "value": "8" + "text": "16", + "value": "16" }, "datasource": { "type": "mssql", @@ -9050,8 +9138,8 @@ }, { "current": { - "text": "1", - "value": "1" + "text": "6", + "value": "6" }, "datasource": { "type": "mssql", @@ -9070,8 +9158,8 @@ }, { "current": { - "text": "92", - "value": "92" + "text": "84", + "value": "84" }, "datasource": { "type": "mssql", @@ -9090,8 +9178,8 @@ }, { "current": { - "text": "94", - "value": "94" + "text": "18", + "value": "18" }, "datasource": { "type": "mssql", @@ -9110,8 +9198,8 @@ }, { "current": { - "text": "5", - "value": "5" + "text": "81", + "value": "81" }, "datasource": { "type": "mssql", @@ -9130,8 +9218,8 @@ }, { "current": { - "text": "475256", - "value": "475256" + "text": "414816", + "value": "414816" }, "datasource": { "type": "mssql", @@ -9222,8 +9310,8 @@ }, { "current": { - "text": "15328176", - "value": "15328176" + "text": "9158576", + "value": "9158576" }, "datasource": { "type": "mssql", @@ -9262,8 +9350,8 @@ }, { "current": { - "text": "3162040", - "value": "3162040" + "text": "5997756", + "value": "5997756" }, "datasource": { "type": "mssql", @@ -9342,8 +9430,8 @@ }, { "current": { - "text": "3216", - "value": "3216" + "text": "108142", + "value": "108142" }, "datasource": { "type": "mssql", @@ -9362,8 +9450,8 @@ }, { "current": { - "text": "15", - "value": "15" + "text": "17", + "value": "17" }, "datasource": { "type": "mssql", @@ -9382,8 +9470,8 @@ }, { "current": { - "text": "4455", - "value": "4455" + "text": "925", + "value": "925" }, "datasource": { "type": "mssql", @@ -9402,8 +9490,8 @@ }, { "current": { - "text": "17", - "value": "17" + "text": "19", + "value": "19" }, "datasource": { "type": "mssql", @@ -9442,8 +9530,8 @@ }, { "current": { - "text": "3", - "value": "3" + "text": "10", + "value": "10" }, "datasource": { "type": "mssql", @@ -9474,8 +9562,8 @@ }, { "current": { - "text": "1763103605525", - "value": "1763103605525" + "text": "1768974004419", + "value": "1768974004419" }, "datasource": { "type": "mssql", @@ -9612,8 +9700,8 @@ }, { "current": { - "text": "1763105101871", - "value": "1763105101871" + "text": "1768974302982", + "value": "1768974302982" }, "datasource": { "type": "mssql", @@ -9695,8 +9783,8 @@ }, { "current": { - "text": "1763105101444", - "value": "1763105101444" + "text": "1768974301136", + "value": "1768974301136" }, "datasource": { "type": "mssql", @@ -9715,8 +9803,8 @@ }, { "current": { - "text": "1763105101323", - "value": "1763105101323" + "text": "1768974301435", + "value": "1768974301435" }, "datasource": { "type": "mssql", @@ -9735,8 +9823,8 @@ }, { "current": { - "text": "8", - "value": "8" + "text": "9", + "value": "9" }, "datasource": { "type": "mssql", @@ -9755,8 +9843,8 @@ }, { "current": { - "text": "15", - "value": "15" + "text": "8", + "value": "8" }, "datasource": { "type": "mssql", @@ -9811,6 +9899,6 @@ "timezone": "browser", "title": "Monitoring - Live - Distributed", "uid": "distributed_live_dashboard", - "version": 24, + "version": 42, "weekStart": "" } \ No newline at end of file diff --git a/Grafana-Dashboards/For-Internal-Use-Only/Monitoring - Perfmon Counters - Quest Softwares - Distributed - INTERNAL.json b/Grafana-Dashboards/For-Internal-Use-Only/Monitoring - Perfmon Counters - Quest Softwares - Distributed - INTERNAL.json index 78782e7..46a833d 100644 --- a/Grafana-Dashboards/For-Internal-Use-Only/Monitoring - Perfmon Counters - Quest Softwares - Distributed - INTERNAL.json +++ b/Grafana-Dashboards/For-Internal-Use-Only/Monitoring - Perfmon Counters - Quest Softwares - Distributed - INTERNAL.json @@ -232,7 +232,7 @@ "h": 5, "w": 24, "x": 0, - "y": 9973 + "y": 18292 }, "id": 64, "options": { @@ -364,7 +364,7 @@ "h": 6, "w": 24, "x": 0, - "y": 2 + "y": 90314 }, "id": 26, "options": { @@ -465,7 +465,7 @@ "h": 11, "w": 24, "x": 0, - "y": 7246 + "y": 102391 }, "id": 58, "options": { @@ -587,7 +587,7 @@ "h": 7, "w": 24, "x": 0, - "y": 7257 + "y": 102402 }, "id": 60, "options": { @@ -709,7 +709,8 @@ "mode": "absolute", "steps": [ { - "color": "green" + "color": "green", + "value": null } ] }, @@ -826,7 +827,8 @@ "mode": "absolute", "steps": [ { - "color": "green" + "color": "green", + "value": null } ] }, @@ -838,7 +840,7 @@ "h": 11, "w": 24, "x": 0, - "y": 5608 + "y": 14 }, "id": 30, "options": { @@ -944,7 +946,8 @@ "mode": "absolute", "steps": [ { - "color": "green" + "color": "green", + "value": null }, { "color": "red", @@ -960,7 +963,7 @@ "h": 8, "w": 24, "x": 0, - "y": 5619 + "y": 25 }, "id": 66, "options": { @@ -1096,7 +1099,7 @@ "h": 6, "w": 24, "x": 0, - "y": 4 + "y": 46903 }, "id": 105, "options": { @@ -1218,7 +1221,7 @@ "h": 15, "w": 24, "x": 0, - "y": 4843 + "y": 55347 }, "id": 106, "options": { @@ -1355,7 +1358,7 @@ "h": 5, "w": 24, "x": 0, - "y": 5 + "y": 18211 }, "id": 110, "options": { @@ -1363,7 +1366,7 @@ "calcs": [ "max", "p99", - "p98" + "last" ], "displayMode": "table", "placement": "right", @@ -1476,14 +1479,14 @@ "h": 6, "w": 24, "x": 0, - "y": 4825 + "y": 18216 }, "id": 112, "options": { "legend": { "calcs": [ "p99", - "p98" + "last" ], "displayMode": "table", "placement": "right", @@ -1531,6 +1534,122 @@ "title": "Logical Disk - Latency", "type": "timeseries" }, + { + "datasource": { + "type": "mssql", + "uid": "${sqlmonitor_datasource}" + }, + "description": "Disk Transfer/Sec => The number of reads and writes per second to disk ", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 10, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 2, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "always", + "spanNulls": true, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "none" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 24, + "x": 0, + "y": 18222 + }, + "id": 157, + "options": { + "legend": { + "calcs": [ + "max", + "p99" + ], + "displayMode": "table", + "placement": "right", + "showLegend": true, + "sortBy": "99th %", + "sortDesc": true + }, + "tooltip": { + "mode": "multi", + "sort": "none" + } + }, + "pluginVersion": "11.3.1", + "targets": [ + { + "alias": "", + "datasource": { + "type": "mssql", + "uid": "${sqlmonitor_datasource}" + }, + "editorMode": "code", + "format": "time_series", + "rawQuery": true, + "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\ndeclare @start_time_utc datetime2;\ndeclare @end_time_utc datetime2;\ndeclare @perfmon_object varchar(125);\ndeclare @disk_drive varchar(255) = '$disk_drive';\ndeclare @database varchar(255) = '$database';\n\nset @database = case when ltrim(rtrim(@database)) = '__All__' then null else @database end;\nset @disk_drive = case when ltrim(rtrim(@disk_drive)) = '__All__' then null else @disk_drive end;\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @start_time_utc = $__timeFrom();\nset @end_time_utc = $__timeTo();\nset @perfmon_object = '$perfmon_object';\nset @params = N'@perfmon_host_name varchar(255), @start_time_utc datetime2, @end_time_utc datetime2, @perfmon_object varchar(125), @disk_drive varchar(255), @database varchar(255)';\n\nset quoted_identifier off;\nset @sql = \"\nset nocount on;\nselect pc.collection_time_utc as time\n\t,instance+' ('+replace(counter,'disk ','')+')' as metric\n\t,pc.value\nfrom $perfmon_table_name pc with (nolock)\nwhere collection_time_utc between @start_time_utc and @end_time_utc\nand pc.host_name = @perfmon_host_name \nand pc.object = 'logicaldisk' and pc.counter in ('disk transfers/sec')\n--and pc.object = 'logicaldisk' and pc.counter in ('disk reads/sec','disk writes/sec')\nand (pc.instance <> '_total' and pc.instance not like 'harddiskvolume%')\n\"+(case when @disk_drive is null then '-- ' else '' end)+\"and (pc.instance+'\\') = @disk_drive\norder by time\n\"\nset quoted_identifier on;\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nif ($is_local = 1)\n exec dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc, @perfmon_object, @disk_drive, @database;\nelse\n exec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc, @perfmon_object, @disk_drive, @database;", + "refId": "A", + "sql": { + "columns": [ + { + "parameters": [], + "type": "function" + } + ], + "groupBy": [ + { + "property": { + "type": "string" + }, + "type": "groupBy" + } + ], + "limit": 50 + } + } + ], + "title": "Logical Disk - IOPS", + "type": "timeseries" + }, { "datasource": { "type": "mssql", @@ -1596,7 +1715,7 @@ "h": 7, "w": 24, "x": 0, - "y": 4831 + "y": 18230 }, "id": 114, "options": { @@ -1731,7 +1850,7 @@ "h": 5, "w": 24, "x": 0, - "y": 6 + "y": 51137 }, "id": 34, "options": { @@ -1853,7 +1972,7 @@ "h": 6, "w": 24, "x": 0, - "y": 4199 + "y": 51142 }, "id": 68, "options": { @@ -1974,7 +2093,7 @@ "h": 7, "w": 24, "x": 0, - "y": 4205 + "y": 51148 }, "id": 69, "options": { @@ -2029,6 +2148,124 @@ ], "title": "Physical Disk - Throughput", "type": "timeseries" + }, + { + "datasource": { + "type": "mssql", + "uid": "${sqlmonitor_datasource}" + }, + "description": "Disk Transfers/Sec => The number of disk reads and writes per second", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 10, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 2, + "scaleDistribution": { + "log": 10, + "type": "log" + }, + "showPoints": "always", + "spanNulls": true, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "none" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 24, + "x": 0, + "y": 51155 + }, + "id": 158, + "options": { + "legend": { + "calcs": [ + "lastNotNull", + "p99", + "max" + ], + "displayMode": "table", + "placement": "right", + "showLegend": true, + "sortBy": "99th %", + "sortDesc": true + }, + "tooltip": { + "mode": "single", + "sort": "desc" + } + }, + "pluginVersion": "11.3.1", + "targets": [ + { + "alias": "", + "datasource": { + "type": "mssql", + "uid": "${sqlmonitor_datasource}" + }, + "editorMode": "code", + "format": "time_series", + "rawQuery": true, + "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\ndeclare @start_time_utc datetime2;\ndeclare @end_time_utc datetime2;\ndeclare @perfmon_object varchar(125);\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @start_time_utc = $__timeFrom();\nset @end_time_utc = $__timeTo();\nset @perfmon_object = '$perfmon_object';\nset @params = N'@perfmon_host_name varchar(255), @start_time_utc datetime2, @end_time_utc datetime2, @perfmon_object varchar(125)';\n\nset quoted_identifier off;\nset @sql = \"\nset nocount on;\nselect pc.collection_time_utc as time\n\t,instance+' ('+replace(counter,'disk ','')+')' as metric\n\t--,object, counter, instance\n\t,pc.value\nfrom $perfmon_table_name pc with (nolock)\nwhere collection_time_utc between @start_time_utc and @end_time_utc\nand pc.host_name = @perfmon_host_name \nand pc.object = 'physicaldisk' and pc.counter in ('disk transfers/sec') and instance like '%:%'\n--and pc.object = 'physicaldisk' and pc.counter in ('disk bytes/sec','disk write bytes/sec','disk read bytes/sec')\nand pc.instance <> '_total'\norder by time\n\"\nset quoted_identifier on;\n\nif '$InstanceScopeFeaturesOnly' = 'true'\n\tselect [time], remarks as metric, [value]\n\tfrom (values ('This feature is not available for this SQLInstance',getutcdate(), 0)) dummy(remarks, [time], value)\n\torder by [time]\nelse\nbegin\n\tif ($is_local = 1)\n\t\t\texec dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc, @perfmon_object;\n\t\telse\n\t\t\texec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc, @perfmon_object;\nend", + "refId": "A", + "sql": { + "columns": [ + { + "parameters": [], + "type": "function" + } + ], + "groupBy": [ + { + "property": { + "type": "string" + }, + "type": "groupBy" + } + ], + "limit": 50 + } + } + ], + "title": "Physical Disk - IOPS", + "type": "timeseries" } ], "repeat": "datasource", @@ -2110,7 +2347,7 @@ "h": 7, "w": 24, "x": 0, - "y": 7 + "y": 95152 }, "id": 71, "options": { @@ -2247,7 +2484,7 @@ "h": 15, "w": 24, "x": 0, - "y": 15 + "y": 95160 }, "id": 38, "options": { @@ -2375,7 +2612,7 @@ "h": 12, "w": 24, "x": 0, - "y": 30 + "y": 95175 }, "id": 115, "options": { @@ -2518,7 +2755,7 @@ "h": 9, "w": 24, "x": 0, - "y": 1897 + "y": 97042 }, "id": 119, "options": { @@ -2644,7 +2881,7 @@ "h": 10, "w": 24, "x": 0, - "y": 1906 + "y": 97051 }, "id": 121, "options": { @@ -2767,7 +3004,7 @@ "h": 15, "w": 24, "x": 0, - "y": 1916 + "y": 97061 }, "id": 123, "options": { @@ -2903,7 +3140,7 @@ "h": 10, "w": 24, "x": 0, - "y": 2666 + "y": 97811 }, "id": 22, "options": { @@ -3037,7 +3274,7 @@ "h": 6, "w": 24, "x": 0, - "y": 2677 + "y": 97822 }, "id": 126, "options": { @@ -3158,7 +3395,7 @@ "h": 7, "w": 24, "x": 0, - "y": 2683 + "y": 97828 }, "id": 14, "options": { @@ -3280,7 +3517,7 @@ "h": 17, "w": 24, "x": 0, - "y": 2690 + "y": 97835 }, "id": 124, "options": { @@ -3414,7 +3651,7 @@ "h": 13, "w": 24, "x": 0, - "y": 2956 + "y": 98101 }, "id": 153, "options": { @@ -3549,7 +3786,7 @@ "h": 9, "w": 24, "x": 0, - "y": 2970 + "y": 98115 }, "id": 77, "options": { @@ -3670,7 +3907,7 @@ "h": 12, "w": 24, "x": 0, - "y": 2979 + "y": 98124 }, "id": 128, "options": { @@ -3807,7 +4044,7 @@ "h": 6, "w": 24, "x": 0, - "y": 3116 + "y": 98261 }, "id": 46, "options": { @@ -3928,7 +4165,7 @@ "h": 8, "w": 24, "x": 0, - "y": 3122 + "y": 98267 }, "id": 129, "options": { @@ -4049,7 +4286,7 @@ "h": 7, "w": 24, "x": 0, - "y": 3130 + "y": 98275 }, "id": 78, "options": { @@ -4171,7 +4408,7 @@ "h": 7, "w": 24, "x": 0, - "y": 3137 + "y": 98282 }, "id": 130, "options": { @@ -4308,7 +4545,7 @@ "h": 5, "w": 24, "x": 0, - "y": 19640 + "y": 114785 }, "id": 134, "options": { @@ -4429,7 +4666,7 @@ "h": 6, "w": 24, "x": 0, - "y": 19718 + "y": 114863 }, "id": 137, "options": { @@ -4550,7 +4787,7 @@ "h": 6, "w": 24, "x": 0, - "y": 19724 + "y": 114869 }, "id": 135, "options": { @@ -4671,7 +4908,7 @@ "h": 6, "w": 24, "x": 0, - "y": 19730 + "y": 114875 }, "id": 136, "options": { @@ -4806,7 +5043,7 @@ "h": 5, "w": 11, "x": 0, - "y": 3242 + "y": 98387 }, "id": 85, "options": { @@ -4920,7 +5157,7 @@ "h": 5, "w": 13, "x": 11, - "y": 3242 + "y": 98387 }, "id": 89, "options": { @@ -5038,7 +5275,7 @@ "h": 5, "w": 11, "x": 0, - "y": 3247 + "y": 98392 }, "id": 88, "options": { @@ -5152,7 +5389,7 @@ "h": 5, "w": 13, "x": 11, - "y": 3247 + "y": 98392 }, "id": 90, "options": { @@ -5287,7 +5524,7 @@ "h": 8, "w": 24, "x": 0, - "y": 3253 + "y": 98398 }, "id": 151, "options": { @@ -5407,7 +5644,7 @@ "h": 7, "w": 24, "x": 0, - "y": 3261 + "y": 98406 }, "id": 16, "options": { @@ -5543,7 +5780,7 @@ "h": 8, "w": 24, "x": 0, - "y": 3370 + "y": 98515 }, "id": 80, "options": { @@ -5665,7 +5902,7 @@ "h": 8, "w": 24, "x": 0, - "y": 3378 + "y": 98523 }, "id": 79, "options": { @@ -5787,7 +6024,7 @@ "h": 8, "w": 24, "x": 0, - "y": 3386 + "y": 98531 }, "id": 82, "options": { @@ -5923,7 +6160,7 @@ "h": 6, "w": 24, "x": 0, - "y": 19644 + "y": 114789 }, "id": 102, "options": { @@ -6044,7 +6281,7 @@ "h": 8, "w": 24, "x": 0, - "y": 19650 + "y": 114795 }, "id": 100, "options": { @@ -6176,7 +6413,7 @@ "h": 8, "w": 24, "x": 0, - "y": 22300 + "y": 117445 }, "id": 148, "options": { @@ -6272,7 +6509,7 @@ "h": 8, "w": 24, "x": 0, - "y": 22308 + "y": 117453 }, "id": 147, "options": { @@ -6383,7 +6620,7 @@ "h": 5, "w": 24, "x": 0, - "y": 22301 + "y": 117446 }, "id": 149, "options": { @@ -6602,8 +6839,8 @@ }, { "current": { - "text": "1738399874944", - "value": "1738399874944" + "text": "1768969085762", + "value": "1768969085762" }, "datasource": { "type": "mssql", @@ -6851,6 +7088,6 @@ "timezone": "", "title": "Monitoring - Perfmon Counters - Quest Softwares - Distributed", "uid": "distributed_perfmon", - "version": 23, + "version": 34, "weekStart": "" } \ No newline at end of file diff --git a/Grafana-Dashboards/Monitoring - Live - All Servers.json b/Grafana-Dashboards/Monitoring - Live - All Servers.json index ef647d0..070b91b 100644 --- a/Grafana-Dashboards/Monitoring - Live - All Servers.json +++ b/Grafana-Dashboards/Monitoring - Live - All Servers.json @@ -1,5 +1,8063 @@ { - "error": { - "message": "Datasource ygPVA4snk was not found" - } + "__inputs": [ + { + "name": "DS_SQLMONITOR", + "label": "SQLMonitor", + "description": "", + "type": "datasource", + "pluginId": "mssql", + "pluginName": "Microsoft SQL Server" + } + ], + "__elements": {}, + "__requires": [ + { + "type": "panel", + "id": "dashlist", + "name": "Dashboard list", + "version": "" + }, + { + "type": "grafana", + "id": "grafana", + "name": "Grafana", + "version": "11.3.1" + }, + { + "type": "datasource", + "id": "mssql", + "name": "Microsoft SQL Server", + "version": "11.3.0" + }, + { + "type": "datasource", + "id": "prometheus", + "name": "Prometheus", + "version": "1.0.0" + }, + { + "type": "panel", + "id": "table", + "name": "Table", + "version": "" + } + ], + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": { + "type": "datasource", + "uid": "grafana" + }, + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "target": { + "limit": 100, + "matchAny": false, + "tags": [], + "type": "dashboard" + }, + "type": "dashboard" + } + ] + }, + "description": "Monitor Server Using Live PerfMon Metrics", + "editable": true, + "fiscalYearStartMonth": 0, + "graphTooltip": 0, + "id": null, + "links": [], + "panels": [ + { + "collapsed": true, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 0 + }, + "id": 243, + "panels": [ + { + "datasource": { + "type": "mssql", + "uid": "${sqlmonitor_datasource}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "custom": { + "align": "auto", + "cellOptions": { + "type": "auto" + }, + "filterable": true, + "inspect": false + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + } + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "sqlserver_start_time_utc" + }, + "properties": [ + { + "id": "custom.hidden", + "value": true + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "os_uptime" + }, + "properties": [ + { + "id": "custom.hidden", + "value": true + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "major_version_number" + }, + "properties": [ + { + "id": "custom.hidden", + "value": true + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "minor_version_number" + }, + "properties": [ + { + "id": "custom.hidden", + "value": true + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "cpu_count" + }, + "properties": [ + { + "id": "custom.hidden", + "value": true + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "scheduler_count" + }, + "properties": [ + { + "id": "custom.hidden", + "value": true + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Is MS Supported" + }, + "properties": [ + { + "id": "custom.cellOptions", + "value": { + "mode": "basic", + "type": "color-background" + } + }, + { + "id": "mappings", + "value": [ + { + "options": { + "false": { + "color": "red", + "index": 1, + "text": "UnSupported" + }, + "true": { + "color": "green", + "index": 0, + "text": "Supported" + } + }, + "type": "value" + } + ] + }, + { + "id": "custom.hidden", + "value": true + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "total_physical_memory_kb" + }, + "properties": [ + { + "id": "displayName", + "value": "RAM" + }, + { + "id": "unit", + "value": "kbytes" + }, + { + "id": "custom.align", + "value": "center" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "srv_name" + }, + "properties": [ + { + "id": "displayName", + "value": "Server" + }, + { + "id": "links", + "value": [ + { + "targetBlank": true, + "title": "Individual Server", + "url": "d/distributed_live_dashboard?var-server=${__data.fields.srv_name}&var-perfmon_host_name=${__data.fields.host_name}" + } + ] + }, + { + "id": "custom.cellOptions", + "value": { + "mode": "basic", + "type": "color-background" + } + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "blue" + } + ] + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "domain" + }, + "properties": [ + { + "id": "displayName", + "value": "Domain" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "host_name" + }, + "properties": [ + { + "id": "displayName", + "value": "Host Name" + }, + { + "id": "links", + "value": [ + { + "targetBlank": true, + "title": "Individual Server", + "url": "d/distributed_live_dashboard?var-server=${__data.fields.srv_name}&var-perfmon_host_name=${__data.fields.host_name}" + } + ] + }, + { + "id": "custom.cellOptions", + "value": { + "mode": "basic", + "type": "color-background" + } + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "super-light-purple" + } + ] + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "CPU (OS / SQL)" + }, + "properties": [ + { + "id": "custom.align", + "value": "center" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "product_version" + }, + "properties": [ + { + "id": "displayName", + "value": "Version" + }, + { + "id": "custom.align", + "value": "center" + }, + { + "id": "links", + "value": [ + { + "targetBlank": true, + "title": "SQLServer Updates", + "url": "https://sqlserverupdates.com/sql-server-2019-updates/" + } + ] + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "os_uptime_days" + }, + "properties": [ + { + "id": "displayName", + "value": "OS Uptime" + }, + { + "id": "custom.align", + "value": "center" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "os_start_time_utc" + }, + "properties": [ + { + "id": "displayName", + "value": "OS Start Time" + }, + { + "id": "unit", + "value": "dateTimeAsIso" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "sqlserver_start_time_utc" + }, + "properties": [ + { + "id": "displayName", + "value": "SqlServer Start Time" + }, + { + "id": "unit", + "value": "dateTimeAsIso" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "MS Support" + }, + "properties": [ + { + "id": "custom.cellOptions", + "value": { + "type": "color-background" + } + }, + { + "id": "mappings", + "value": [ + { + "options": { + "Extended Support": { + "color": "orange", + "index": 1 + }, + "Main Support": { + "color": "green", + "index": 0 + }, + "No Support": { + "color": "red", + "index": 2 + } + }, + "type": "value" + } + ] + } + ] + } + ] + }, + "gridPos": { + "h": 6, + "w": 24, + "x": 0, + "y": 1 + }, + "id": 219, + "options": { + "cellHeight": "sm", + "footer": { + "countRows": false, + "fields": "", + "reducer": [ + "sum" + ], + "show": false + }, + "showHeader": true + }, + "pluginVersion": "11.3.1", + "targets": [ + { + "alias": "", + "datasource": { + "type": "mssql", + "uid": "${DS_SQLMONITOR}" + }, + "editorMode": "code", + "format": "table", + "rawQuery": true, + "rawSql": "declare @sql nvarchar(max);\nset quoted_identifier off;\nset @sql = \"\n/* $__dashboard */\n;with t_cte as (\n\tselect\tsrv_name, domain, host_name, product_version, major_version_number, minor_version_number, cpu_count, \n\t scheduler_count, total_physical_memory_kb, os_start_time_utc, sqlserver_start_time_utc\n\t\t\t,Concat\n\t\t\t(\n\t\t\t\tRIGHT('000'+CAST(ISNULL((datediff(second,os_start_time_utc,GETUTCDATE()) / 3600 / 24), 0) AS VARCHAR(3)),3)\n\t\t\t\t,' '\n\t\t\t\t,RIGHT('00'+CAST(ISNULL(datediff(second,os_start_time_utc,GETUTCDATE()) / 3600 % 24, 0) AS VARCHAR(2)),2)\n\t\t\t\t,':'\n\t\t\t\t,RIGHT('00'+CAST(ISNULL(datediff(second,os_start_time_utc,GETUTCDATE()) / 60 % 60, 0) AS VARCHAR(2)),2)\n\t\t\t\t,':'\n\t\t\t\t,RIGHT('00'+CAST(ISNULL(datediff(second,os_start_time_utc,GETUTCDATE()) % 3600 % 60, 0) AS VARCHAR(2)),2)\n\t\t\t) as [os_uptime]\n\t\t\t,Concat\n\t\t\t(\n\t\t\t\tRIGHT('000'+CAST(ISNULL((datediff(second,sqlserver_start_time_utc,GETUTCDATE()) / 3600 / 24), 0) AS VARCHAR(3)),3)\n\t\t\t\t,' '\n\t\t\t\t,RIGHT('00'+CAST(ISNULL(datediff(second,sqlserver_start_time_utc,GETUTCDATE()) / 3600 % 24, 0) AS VARCHAR(2)),2)\n\t\t\t\t,':'\n\t\t\t\t,RIGHT('00'+CAST(ISNULL(datediff(second,sqlserver_start_time_utc,GETUTCDATE()) / 60 % 60, 0) AS VARCHAR(2)),2)\n\t\t\t\t,':'\n\t\t\t\t,RIGHT('00'+CAST(ISNULL(datediff(second,sqlserver_start_time_utc,GETUTCDATE()) % 3600 % 60, 0) AS VARCHAR(2)),2)\n\t\t\t) as [sqlserver_uptime]\n\t\t\t,datediff(day,os_start_time_utc,GETUTCDATE()) as [os_uptime_days]\n\tfrom dbo.vw_all_server_info\n)\nselect srv_name, domain, host_name, product_version, major_version_number, minor_version_number\n ,[CPU (OS / SQL)] = convert(varchar,cpu_count)+' / '+convert(varchar,scheduler_count)\n ,total_physical_memory_kb ,cpu_count, scheduler_count, [os_uptime_days], os_start_time_utc, sqlserver_start_time_utc, [os_uptime], [sqlserver_uptime]\n\t\t ,[Is MS Supported] = case when c.MainstreamSupportEndDate < getdate() then convert(bit,0) else convert(bit,1) end\n\t\t\t\t,[MS Support] = case when c.MainstreamSupportEndDate > getdate()\n\t\t\t\t\t\tthen 'Mainstream Support'\n\t\t\t\t\t\twhen c.ExtendedSupportEndDate > getdate()\n\t\t\t\t\t\tthen 'Extended Support'\n\t\t\t\t\t\telse 'No Support'\n\t\t\t\t\t\tend\nfrom t_cte cte\nouter apply (\n\tselect\ttop 1 [MajorVersionNumber]\n\t\t\t\t--,[@server_minor_version_number] = @server_minor_version_number\n\t\t\t\t,[MinorVersionNumber]\n\t\t\t\t,[Branch]\n\t\t\t\t,[Url]\n\t\t\t\t,[ReleaseDate]\n\t\t\t\t,[MainstreamSupportEndDate]\n\t\t\t\t,[ExtendedSupportEndDate]\n\t\t\t\t,[MajorVersionName]\n\t\t\t\t,[MinorVersionName]\t \n\t\tfrom [master].[dbo].[SqlServerVersions] as c\n\t\twhere [MajorVersionNumber] = cte.major_version_number\n\t\tand [MinorVersionNumber] <= cte.minor_version_number\n\t\torder by [MinorVersionNumber] desc\n) as c\nouter apply (\n\tselect\ttop 1 [MajorVersionNumber]\n\t\t\t--,[@server_minor_version_number] = @server_minor_version_number\n\t\t\t,[MinorVersionNumber]\n\t\t\t,[Branch]\n\t\t\t,[Url]\n\t\t\t,[ReleaseDate]\n\t\t\t,[MainstreamSupportEndDate]\n\t\t\t,[ExtendedSupportEndDate]\n\t\t\t,[MajorVersionName]\n\t\t\t,[MinorVersionName]\t \n\tfrom [master].[dbo].[SqlServerVersions] as c\n\twhere [MajorVersionNumber] = cte.major_version_number\n\torder by [MinorVersionNumber] desc\n) as l;\n\";\nset quoted_identifier off;\n\nexec dbo.sp_executesql @sql;", + "refId": "A", + "sql": { + "columns": [ + { + "parameters": [], + "type": "function" + } + ], + "groupBy": [ + { + "property": { + "type": "string" + }, + "type": "groupBy" + } + ], + "limit": 50 + } + } + ], + "title": "All Servers - Basic Details @ ${all_server_stable_info__collection_time_utc:date:YYYY-MM-DD HH.mm}", + "type": "table" + } + ], + "title": "All Servers - Basic Info - \"${basic_info_servers_count}\" Total - \"${unsupported_servers_count}\" Non Supported @ ${all_server_stable_info__collection_time_utc:date:YYYY-MM-DD HH.mm}", + "type": "row" + }, + { + "collapsed": true, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 1 + }, + "id": 848, + "panels": [ + { + "datasource": { + "type": "mssql", + "uid": "${sqlmonitor_datasource}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "custom": { + "align": "auto", + "cellOptions": { + "type": "auto" + }, + "inspect": false + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "string" + }, + "overrides": [ + { + "matcher": { + "id": "byType", + "options": "time" + }, + "properties": [ + { + "id": "unit", + "value": "dateTimeAsIso" + } + ] + }, + { + "matcher": { + "id": "byRegexp", + "options": ".*__latency_minutes" + }, + "properties": [ + { + "id": "unit", + "value": "m" + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "#EAB839", + "value": 20 + }, + { + "color": "red", + "value": 40 + } + ] + } + }, + { + "id": "custom.cellOptions", + "value": { + "type": "color-text" + } + } + ] + }, + { + "matcher": { + "id": "byRegexp", + "options": ".*__latency_days" + }, + "properties": [ + { + "id": "unit", + "value": "d" + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "#EAB839", + "value": 8 + }, + { + "color": "red", + "value": 15 + } + ] + } + }, + { + "id": "custom.cellOptions", + "value": { + "type": "color-text" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "srv_name" + }, + "properties": [ + { + "id": "custom.cellOptions", + "value": { + "mode": "gradient", + "type": "color-background" + } + }, + { + "id": "displayName", + "value": "Server" + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "blue" + } + ] + } + }, + { + "id": "links", + "value": [ + { + "targetBlank": true, + "title": "Live Server Details", + "url": "d/distributed_live_dashboard?var-server=${__data.fields.srv_name}" + } + ] + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "performance_counters__latency_minutes" + }, + "properties": [ + { + "id": "displayName", + "value": "performance_counters" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "resource_consumption__latency_minutes" + }, + "properties": [ + { + "id": "displayName", + "value": "resource_consumption" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "WhoIsActive__latency_minutes" + }, + "properties": [ + { + "id": "displayName", + "value": "WhoIsActive" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "disk_space__latency_minutes" + }, + "properties": [ + { + "id": "displayName", + "value": "disk_space" + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "#EAB839", + "value": 60 + }, + { + "color": "red", + "value": 90 + } + ] + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "file_io_stats__latency_minutes" + }, + "properties": [ + { + "id": "displayName", + "value": "file_io_stats" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "wait_stats__latency_minutes" + }, + "properties": [ + { + "id": "displayName", + "value": "wait_stats" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "BlitzIndex__latency_days" + }, + "properties": [ + { + "id": "displayName", + "value": "BlitzIndex" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "BlitzIndex_Mode0__latency_days" + }, + "properties": [ + { + "id": "displayName", + "value": "BlitzIndex_Mode0" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "BlitzIndex_Mode1__latency_days" + }, + "properties": [ + { + "id": "displayName", + "value": "BlitzIndex_Mode1" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "BlitzIndex_Mode4__latency_days" + }, + "properties": [ + { + "id": "displayName", + "value": "BlitzIndex_Mode4" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Issues" + }, + "properties": [ + { + "id": "custom.hidden", + "value": true + } + ] + } + ] + }, + "gridPos": { + "h": 10, + "w": 24, + "x": 0, + "y": 2 + }, + "id": 850, + "options": { + "cellHeight": "sm", + "footer": { + "countRows": false, + "enablePagination": true, + "fields": "", + "reducer": [ + "sum" + ], + "show": false + }, + "showHeader": true, + "sortBy": [] + }, + "pluginVersion": "11.3.1", + "targets": [ + { + "datasource": { + "type": "mssql", + "uid": "${DS_SQLMONITOR}" + }, + "editorMode": "code", + "format": "table", + "hide": false, + "rawQuery": true, + "rawSql": "declare @_latency_minutes_threshold int = 20;\r\ndeclare @_latency_days_threshold int = 3;\r\ndeclare @t_servers_exception table (srv_name varchar(125));\r\n\r\ninsert @t_servers_exception -- list of servers that have permanent issues\r\nvalues ('192.168.1.21'),('192.168.1.22');\r\n\r\nselect\tcli.srv_name, id.jobs_server,\r\n\t\tcli.performance_counters__latency_minutes,\r\n\t\txevent_metrics__latency_minutes = case when (cli.xevent_metrics__latency_minutes > @_latency_minutes_threshold*2 and vi.sql_cpu > 20 and si.major_version_number >= 11) then cli.xevent_metrics__latency_minutes \r\n\t\t\t\t\t\t\t\t\t\t\t\t\twhen cli.xevent_metrics__latency_minutes > @_latency_minutes_threshold then @_latency_minutes_threshold-1\r\n\t\t\t\t\t\t\t\t\t\t\t\t\telse cli.xevent_metrics__latency_minutes end,\r\n\t\tWhoIsActive__latency_minutes = case when cli.WhoIsActive__latency_minutes > @_latency_minutes_threshold*2 and vi.sql_cpu > 20 then cli.WhoIsActive__latency_minutes \r\n\t\t\t\t\t\t\t\t\t\t\t\t\twhen cli.WhoIsActive__latency_minutes > @_latency_minutes_threshold then @_latency_minutes_threshold-1\r\n\t\t\t\t\t\t\t\t\t\t\t\t\telse cli.WhoIsActive__latency_minutes end,\r\n\t\tcli.disk_space__latency_minutes, \r\n\t\tcli.file_io_stats__latency_minutes,\r\n\t\tcli.sql_agent_job_stats__latency_minutes,\r\n\t\tcli.memory_clerks__latency_minutes,\r\n\t\tcli.wait_stats__latency_minutes,\r\n\t\tcli.BlitzIndex__latency_days,\r\n\t\tcli.BlitzIndex_Mode0__latency_days,\r\n\t\t--cli.BlitzIndex_Mode1__latency_days,\r\n\t\t--cli.BlitzIndex_Mode4__latency_days,\r\n\t\t--collection_time = DATEADD(mi, DATEDIFF(mi, getdate(), getutcdate()), cli.collection_time)\r\n\t\t[Issues] = (case when cli.performance_counters__latency_minutes > @_latency_minutes_threshold then 'performance_counters,' else '' end)+\r\n\t\t\t\t\t(case when cli.xevent_metrics__latency_minutes > @_latency_minutes_threshold*2 and vi.sql_cpu > 20 and si.major_version_number >= 11 then 'xevent_metrics' else '' end)+\r\n\t\t\t\t\t(case when cli.WhoIsActive__latency_minutes > @_latency_minutes_threshold*2 and vi.sql_cpu > 20 then 'WhoIsActive,' else '' end)+\r\n\t\t\t\t\t(case when cli.disk_space__latency_minutes > @_latency_minutes_threshold*3 then 'disk_space,' else '' end)+\r\n\t\t\t\t\t(case when cli.file_io_stats__latency_minutes > @_latency_minutes_threshold*3 then 'file_io_stats,' else '' end)+\r\n\t\t\t\t\t(case when cli.wait_stats__latency_minutes > @_latency_minutes_threshold*2 then 'wait_stats,' else '' end)+\r\n\t\t\t\t\t(case when cli.sql_agent_job_stats__latency_minutes > @_latency_minutes_threshold*1.5 then 'sql_agent_job_stats,' else '' end)+\r\n\t\t\t\t\t(case when cli.memory_clerks__latency_minutes > @_latency_minutes_threshold then 'memory_clerks,' else '' end)+\r\n\t\t\t\t\t(case when cli.BlitzIndex__latency_days > @_latency_days_threshold then 'BlitzIndex,' else '' end)+\r\n\t\t\t\t\t(case when cli.BlitzIndex_Mode0__latency_days > @_latency_days_threshold*4 then 'BlitzIndex_Mode0,' else '' end)+\r\n\t\t\t\t\t(case when cli.BlitzIndex_Mode1__latency_days > @_latency_days_threshold*4 then 'BlitzIndex_Mode1,' else '' end)+\r\n\t\t\t\t\t(case when cli.BlitzIndex_Mode4__latency_days > @_latency_days_threshold*4 then 'BlitzIndex_Mode4,' else '' end)\r\n\t\t--,cli.host_name ,si.major_version_number ,si.product_version ,si.edition, vi.os_cpu, vi.sql_cpu\r\nfrom dbo.all_server_collection_latency_info cli\r\njoin dbo.all_server_stable_info si on si.srv_name = cli.srv_name\r\njoin dbo.all_server_volatile_info vi on vi.srv_name = cli.srv_name\r\nouter apply (select STUFF((select ', '+id.collector_powershell_jobs_server from (select distinct id.collector_powershell_jobs_server from dbo.instance_details id where id.sql_instance = cli.srv_name and id.host_name = cli.host_name) id for xml path('')), 1, 1, '') as jobs_server ) id\r\nwhere 1=1\r\nand (\tcli.performance_counters__latency_minutes > @_latency_minutes_threshold\r\n\t\tor (cli.xevent_metrics__latency_minutes > @_latency_minutes_threshold*2 and vi.sql_cpu > 20 and si.major_version_number >= 11)\r\n\t\tor (cli.WhoIsActive__latency_minutes > @_latency_minutes_threshold*2 and vi.sql_cpu > 20)\r\n\t\tor cli.disk_space__latency_minutes > @_latency_minutes_threshold*3\r\n\t\tor cli.file_io_stats__latency_minutes > @_latency_minutes_threshold*3\r\n\t\tor cli.wait_stats__latency_minutes > @_latency_minutes_threshold*2\r\n\t\tor cli.BlitzIndex__latency_days > @_latency_days_threshold\r\n\t\tor cli.BlitzIndex_Mode0__latency_days > @_latency_days_threshold*4\r\n\t\t--or cli.BlitzIndex_Mode1__latency_days > @_latency_days_threshold*4\r\n\t\t--or cli.BlitzIndex_Mode4__latency_days > @_latency_days_threshold*4\r\n\t\tor cli.sql_agent_job_stats__latency_minutes > @_latency_minutes_threshold*1.5\r\n\t\tor cli.memory_clerks__latency_minutes > @_latency_minutes_threshold\r\n\t)\r\nand cli.srv_name not in (select e.srv_name from @t_servers_exception e)\r\n\r\n", + "refId": "A", + "sql": { + "columns": [ + { + "parameters": [], + "type": "function" + } + ], + "groupBy": [ + { + "property": { + "type": "string" + }, + "type": "groupBy" + } + ], + "limit": 50 + } + } + ], + "title": "Servers with Data Collection Issues @ ${collection_latency_info__collection_time_utc:date:YYYY-MM-DD HH.mm}", + "type": "table" + } + ], + "title": "Servers with Data Collection Issues - \"${servers_with_data_issue_count}\" Total @ ${collection_latency_info__collection_time_utc:date:YYYY-MM-DD HH.mm}", + "type": "row" + }, + { + "collapsed": true, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 2 + }, + "id": 846, + "panels": [ + { + "datasource": { + "type": "mssql", + "uid": "${sqlmonitor_datasource}" + }, + "description": "USE DBA\ngo\n\nselect /* Offline or Linked Server not working */ *\nfrom dbo.instance_details id where id.is_enabled = 1 \n\tand (id.is_available = 0 or id.is_linked_server_working = 0);\ngo\n\nexec /* Check why linked server not working */ dbo.usp_GetAllServerInfo \n\t\t@servers = 'ATPR0SVDNTRY160,196.1.115.244', \n\t\t@output = 'srv_name, os_start_time_utc', \n\t\t@verbose = 2\ngo", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "custom": { + "align": "auto", + "cellOptions": { + "mode": "basic", + "type": "color-background" + }, + "filterable": true, + "inspect": true + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "transparent" + } + ] + } + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "sql_instance" + }, + "properties": [ + { + "id": "custom.width", + "value": 127 + }, + { + "id": "displayName", + "value": "Server" + }, + { + "id": "links", + "value": [ + { + "targetBlank": true, + "title": "Live Distributed Dashboard", + "url": "d/distributed_live_dashboard?var-server=${__data.fields.sql_instance}" + } + ] + }, + { + "id": "custom.cellOptions", + "value": { + "type": "color-background" + } + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "blue" + } + ] + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "is_available" + }, + "properties": [ + { + "id": "displayName", + "value": "Is Available" + }, + { + "id": "custom.cellOptions", + "value": { + "mode": "gradient", + "type": "color-background" + } + }, + { + "id": "mappings", + "value": [ + { + "options": { + "0": { + "color": "red", + "index": 1, + "text": "No" + }, + "1": { + "color": "green", + "index": 0, + "text": "Yes" + } + }, + "type": "value" + } + ] + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "is_linked_server_working" + }, + "properties": [ + { + "id": "displayName", + "value": "Linked Server Working" + }, + { + "id": "custom.cellOptions", + "value": { + "mode": "basic", + "type": "color-background" + } + }, + { + "id": "mappings", + "value": [ + { + "options": { + "0": { + "color": "red", + "index": 1, + "text": "No" + }, + "1": { + "color": "green", + "index": 0, + "text": "Yes" + } + }, + "type": "value" + }, + { + "options": { + "match": "null", + "result": { + "color": "transparent", + "index": 2 + } + }, + "type": "special" + } + ] + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "is_alias" + }, + "properties": [ + { + "id": "custom.cellOptions", + "value": { + "type": "color-text" + } + }, + { + "id": "mappings", + "value": [ + { + "options": { + "match": "true", + "result": { + "color": "red", + "index": 0 + } + }, + "type": "special" + }, + { + "options": { + "match": "false", + "result": { + "color": "dark-green", + "index": 1 + } + }, + "type": "special" + } + ] + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "sql_instance_port" + }, + "properties": [ + { + "id": "custom.width", + "value": 165 + } + ] + } + ] + }, + "gridPos": { + "h": 5, + "w": 24, + "x": 0, + "y": 3 + }, + "id": 844, + "options": { + "cellHeight": "sm", + "footer": { + "countRows": false, + "enablePagination": false, + "fields": "", + "reducer": [ + "sum" + ], + "show": false + }, + "showHeader": true, + "sortBy": [] + }, + "pluginVersion": "11.3.1", + "targets": [ + { + "alias": "", + "datasource": { + "type": "mssql", + "uid": "${DS_SQLMONITOR}" + }, + "editorMode": "code", + "format": "table", + "rawQuery": true, + "rawSql": "declare @sql nvarchar(max);\ndeclare @_has_inventory bit = 0;\nset @_has_inventory = convert(bit,'${has_inventory}');\n\nset quoted_identifier off;\nset @sql = \"\n/* $__dashboard */\nselect sql_instance, sql_instance_port, [host_name], is_available,\n\t\t\tis_linked_server_working = case when is_available = 0 then null else is_linked_server_working end, \n\t\t\t--[tsql jobs server] = collector_tsql_jobs_server, \n\t\t--[powershell jobs server] = collector_powershell_jobs_server, \n\t\t[perfmon data server] = data_destination_sql_instance, \n\t\tis_alias,\n\t\t last_unavailability_time_utc\nfrom dbo.instance_details id\nwhere is_enabled = 1 and is_alias = 0\nand (is_available = 0 or is_linked_server_working = 0)\n\"+(case when @_has_inventory = 0 then '--' else '' end)+\"and exists (select * from dbo.sma_servers s where s.is_decommissioned = 0 and s.is_onboarded = 1 and s.server = id.sql_instance)\n\";\nset quoted_identifier off;\n\nexec dbo.sp_executesql @sql;", + "refId": "A", + "sql": { + "columns": [ + { + "parameters": [], + "type": "function" + } + ], + "groupBy": [ + { + "property": { + "type": "string" + }, + "type": "groupBy" + } + ], + "limit": 50 + } + } + ], + "title": "CRITICAL - OFFLINE/Linked Server Issue - \"${offline_servers_count}\" Core Instances", + "type": "table" + }, + { + "datasource": { + "type": "mssql", + "uid": "${sqlmonitor_datasource}" + }, + "description": "USE DBA\ngo\n\nselect /* Offline or Linked Server not working */ *\nfrom dbo.instance_details id where id.is_enabled = 1 \n\tand (id.is_available = 0 or id.is_linked_server_working = 0);\ngo\n\nexec /* Check why linked server not working */ dbo.usp_GetAllServerInfo \n\t\t@servers = 'ATPR0SVDNTRY160,196.1.115.244', \n\t\t@output = 'srv_name, os_start_time_utc', \n\t\t@verbose = 2\ngo", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "custom": { + "align": "auto", + "cellOptions": { + "mode": "basic", + "type": "color-background" + }, + "filterable": true, + "inspect": true + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "transparent" + } + ] + } + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "sql_instance" + }, + "properties": [ + { + "id": "custom.width", + "value": 127 + }, + { + "id": "displayName", + "value": "Alias Server" + }, + { + "id": "links", + "value": [ + { + "targetBlank": true, + "title": "Live Distributed Dashboard", + "url": "d/distributed_live_dashboard?var-server=${__data.fields.sql_instance}" + } + ] + }, + { + "id": "custom.cellOptions", + "value": { + "type": "color-background" + } + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "blue" + } + ] + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "is_available" + }, + "properties": [ + { + "id": "displayName", + "value": "Is Available" + }, + { + "id": "custom.cellOptions", + "value": { + "mode": "gradient", + "type": "color-background" + } + }, + { + "id": "mappings", + "value": [ + { + "options": { + "0": { + "color": "red", + "index": 1, + "text": "No" + }, + "1": { + "color": "green", + "index": 0, + "text": "Yes" + } + }, + "type": "value" + } + ] + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "is_linked_server_working" + }, + "properties": [ + { + "id": "displayName", + "value": "Linked Server Working" + }, + { + "id": "custom.cellOptions", + "value": { + "mode": "basic", + "type": "color-background" + } + }, + { + "id": "mappings", + "value": [ + { + "options": { + "0": { + "color": "red", + "index": 1, + "text": "No" + }, + "1": { + "color": "green", + "index": 0, + "text": "Yes" + } + }, + "type": "value" + }, + { + "options": { + "match": "null", + "result": { + "color": "transparent", + "index": 2 + } + }, + "type": "special" + } + ] + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "source_sql_instance" + }, + "properties": [ + { + "id": "links", + "value": [ + { + "targetBlank": true, + "title": "Live Distributed Dashboard", + "url": "d/distributed_live_dashboard?var-server=${__data.fields.source_sql_instance}" + } + ] + }, + { + "id": "custom.cellOptions", + "value": { + "type": "color-background" + } + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "blue" + } + ] + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "is_alias" + }, + "properties": [ + { + "id": "custom.cellOptions", + "value": { + "type": "color-text" + } + }, + { + "id": "mappings", + "value": [ + { + "options": { + "match": "true", + "result": { + "color": "dark-green", + "index": 1 + } + }, + "type": "special" + }, + { + "options": { + "match": "false", + "result": { + "color": "red", + "index": 2 + } + }, + "type": "special" + } + ] + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "sql_instance_port" + }, + "properties": [ + { + "id": "custom.width", + "value": 166 + } + ] + } + ] + }, + "gridPos": { + "h": 7, + "w": 24, + "x": 0, + "y": 8 + }, + "id": 887, + "options": { + "cellHeight": "sm", + "footer": { + "countRows": false, + "enablePagination": false, + "fields": "", + "reducer": [ + "sum" + ], + "show": false + }, + "showHeader": true, + "sortBy": [] + }, + "pluginVersion": "11.3.1", + "targets": [ + { + "alias": "", + "datasource": { + "type": "mssql", + "uid": "${DS_SQLMONITOR}" + }, + "editorMode": "code", + "format": "table", + "rawQuery": true, + "rawSql": "declare @sql nvarchar(max);\ndeclare @_has_inventory bit = 0;\nset @_has_inventory = convert(bit,'${has_inventory}');\n\nset quoted_identifier off;\nset @sql = \"\n/* $__dashboard */\nselect sql_instance, sql_instance_port, source_sql_instance, is_available,\n\t\t\tis_linked_server_working = case when is_available = 0 then null else is_linked_server_working end, \t\t\t\n\t\t\t--[tsql jobs server] = collector_tsql_jobs_server, [host_name], \n\t\t\t--[powershell jobs server] = collector_powershell_jobs_server, [perfmon data server] = data_destination_sql_instance, \n\t\t\t[host_name], is_alias\n\t\t \t--last_unavailability_time_utc\nfrom dbo.instance_details id\nwhere is_enabled = 1 and is_alias = 1\nand (is_available = 0 or is_linked_server_working = 0)\nand exists (select * from dbo.instance_details srv \n\t\t\twhere srv.is_enabled = 1 and srv.is_alias = 0\n\t\t\tand srv.sql_instance = id.source_sql_instance \n\t\t\tand srv.host_name = id.host_name\n\t\t\tand (srv.is_available = 0 or coalesce(srv.is_linked_server_working,1) = 0)\n\t\t\t\"+(case when @_has_inventory = 0 then '--' else '' end)+\"and exists (select * from dbo.sma_servers s where s.is_decommissioned = 0 and s.is_onboarded = 1 and s.server = id.sql_instance)\n\t\t\t)\n\";\nset quoted_identifier off;\n\nexec dbo.sp_executesql @sql;", + "refId": "A", + "sql": { + "columns": [ + { + "parameters": [], + "type": "function" + } + ], + "groupBy": [ + { + "property": { + "type": "string" + }, + "type": "groupBy" + } + ], + "limit": 50 + } + } + ], + "title": "CRITICAL - OFFLINE/Linked Server Issue - \"${offline_alias_count}\" Alias Instances", + "type": "table" + } + ], + "repeat": "datasource", + "title": "CRITICAL - OFFLINE/Linked Server Issue - \"${offline_servers_count}\" Core Instances - \"${offline_alias_count}\" Alias Instances", + "type": "row" + }, + { + "collapsed": true, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 3 + }, + "id": 872, + "panels": [ + { + "datasource": { + "type": "mssql", + "uid": "${sqlmonitor_datasource}" + }, + "description": "select sas.sql_instance, id.sql_instance_with_port, sas.startup_type_desc, sas.status_desc,\n\t\tsas.servicename, sas.service_account\nfrom dbo.services_all_servers sas\ncross apply (select top 1 sql_instance_with_port = coalesce(id.sql_instance+','+id.sql_instance_port,id.sql_instance) \n\t\t\t\tfrom dbo.instance_details id where id.is_enabled = 1 \n\t\t\t\tand id.is_available = 1 and id.sql_instance = sas.sql_instance) id\nwhere 1=1\nand sas.service_type = 'Agent'\nand sas.status_desc <> 'Running'", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "custom": { + "align": "center", + "cellOptions": { + "type": "auto" + }, + "filterable": true, + "inspect": true + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "blue" + } + ] + } + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "sql_instance" + }, + "properties": [ + { + "id": "displayName", + "value": "SQL Instance" + }, + { + "id": "custom.cellOptions", + "value": { + "mode": "basic", + "type": "color-background" + } + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "blue" + } + ] + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "sql_instance_with_port" + }, + "properties": [ + { + "id": "displayName", + "value": "SQL Instance (port)" + }, + { + "id": "custom.cellOptions", + "value": { + "type": "color-background" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "startup_type_desc" + }, + "properties": [ + { + "id": "displayName", + "value": "Startup Type" + }, + { + "id": "custom.cellOptions", + "value": { + "type": "color-background" + } + }, + { + "id": "mappings", + "value": [ + { + "options": { + "Automatic": { + "color": "green", + "index": 0 + }, + "Disabled": { + "color": "orange", + "index": 1 + } + }, + "type": "value" + } + ] + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "status_desc" + }, + "properties": [ + { + "id": "displayName", + "value": "Status" + }, + { + "id": "custom.cellOptions", + "value": { + "type": "color-background" + } + }, + { + "id": "mappings", + "value": [ + { + "options": { + "Stopped": { + "color": "red", + "index": 0 + } + }, + "type": "value" + } + ] + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "servicename" + }, + "properties": [ + { + "id": "displayName", + "value": "Service Name" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "service_account" + }, + "properties": [ + { + "id": "displayName", + "value": "Service Account" + } + ] + } + ] + }, + "gridPos": { + "h": 6, + "w": 24, + "x": 0, + "y": 408 + }, + "id": 871, + "options": { + "cellHeight": "sm", + "footer": { + "countRows": false, + "enablePagination": true, + "fields": "", + "reducer": [ + "sum" + ], + "show": false + }, + "showHeader": true + }, + "pluginVersion": "11.1.4", + "targets": [ + { + "alias": "", + "datasource": { + "type": "mssql", + "uid": "${DS_SQLMONITOR}" + }, + "editorMode": "code", + "format": "table", + "rawQuery": true, + "rawSql": "declare @sql nvarchar(max);\ndeclare @_has_inventory bit = 0;\nset @_has_inventory = convert(bit,'${has_inventory}');\n\nset quoted_identifier off;\nset @sql = \"\n/* $__dashboard */\nselect sas.sql_instance, id.sql_instance_with_port, sas.startup_type_desc, sas.status_desc,\n\t\tsas.servicename, sas.service_account\nfrom dbo.services_all_servers sas\ncross apply (select top 1 sql_instance_with_port = coalesce(id.sql_instance+','+id.sql_instance_port,id.sql_instance) \n\t\t\t\tfrom dbo.instance_details id where id.is_enabled = 1 \n\t\t\t\tand id.is_available = 1 and id.sql_instance = sas.sql_instance) id\nwhere 1=1\nand sas.service_type = 'Agent'\nand sas.status_desc <> 'Running'\n\"+(case when @_has_inventory = 0 then '--' else '' end)+\"and exists (select * from dbo.sma_servers s where s.is_decommissioned = 0 and s.is_onboarded = 1 and s.server = sas.sql_instance)\n\";\nset quoted_identifier off;\n\nexec dbo.sp_executesql @sql;", + "refId": "A", + "sql": { + "columns": [ + { + "parameters": [], + "type": "function" + } + ], + "groupBy": [ + { + "property": { + "type": "string" + }, + "type": "groupBy" + } + ], + "limit": 50 + } + } + ], + "title": "SQLAgent Service is OFFLINE @ ${services_all_servers__collection_time_utc:date:YYYY-MM-DD HH.mm}", + "type": "table" + } + ], + "title": "CRITICAL - SQLAgent Service - \"${offline_agent_count}\" OFFLINE @ ${services_all_servers__collection_time_utc:date:YYYY-MM-DD HH.mm}", + "type": "row" + }, + { + "collapsed": true, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 4 + }, + "id": 870, + "panels": [ + { + "datasource": { + "type": "mssql", + "uid": "${sqlmonitor_datasource}" + }, + "description": "select * from dbo.backups_all_servers", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "custom": { + "align": "auto", + "cellOptions": { + "type": "auto" + }, + "filterable": true, + "inspect": true + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + } + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "sql_instance" + }, + "properties": [ + { + "id": "displayName", + "value": "Server" + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "purple" + } + ] + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "database_name" + }, + "properties": [ + { + "id": "displayName", + "value": "Database" + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "super-light-purple" + } + ] + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "log_backups_count" + }, + "properties": [ + { + "id": "displayName", + "value": "Total Log Backups" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "database_creation_date_utc" + }, + "properties": [ + { + "id": "displayName", + "value": "Db Created Date" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "recovery_model" + }, + "properties": [ + { + "id": "displayName", + "value": "Recovery Model" + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "dark-blue" + } + ] + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "full_backup_time_utc" + }, + "properties": [ + { + "id": "displayName", + "value": "Full Bkp Time" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "full_backup_size_mb" + }, + "properties": [ + { + "id": "displayName", + "value": "Full Bkp Size" + }, + { + "id": "unit", + "value": "mbytes" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "full_compressed_size_mb" + }, + "properties": [ + { + "id": "displayName", + "value": "Full Compressed" + }, + { + "id": "unit", + "value": "mbytes" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "diff_backup_time_utc" + }, + "properties": [ + { + "id": "displayName", + "value": "Diff Bkp Time" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "diff_backup_size_mb" + }, + "properties": [ + { + "id": "displayName", + "value": "Diff Bkp Size" + }, + { + "id": "unit", + "value": "mbytes" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "diff_compressed_size_mb" + }, + "properties": [ + { + "id": "displayName", + "value": "Diff Compressed" + }, + { + "id": "unit", + "value": "mbytes" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "tlog_backup_time_utc" + }, + "properties": [ + { + "id": "displayName", + "value": "TLog Bkp Time" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "full_backup_file" + }, + "properties": [ + { + "id": "displayName", + "value": "Full File" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "diff_backup_file" + }, + "properties": [ + { + "id": "displayName", + "value": "Diff File" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "tlog_backup_file" + }, + "properties": [ + { + "id": "displayName", + "value": "TLog File" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "full_latency_days" + }, + "properties": [ + { + "id": "displayName", + "value": "Full Delay" + }, + { + "id": "unit", + "value": "d" + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "orange", + "value": 8 + }, + { + "color": "red", + "value": 15 + } + ] + } + }, + { + "id": "custom.cellOptions", + "value": { + "mode": "basic", + "type": "color-background" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "diff_latency_hours" + }, + "properties": [ + { + "id": "displayName", + "value": "Diff Delay" + }, + { + "id": "unit", + "value": "h" + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "yellow", + "value": 24 + }, + { + "color": "orange", + "value": 32 + }, + { + "color": "red", + "value": 48 + } + ] + } + }, + { + "id": "custom.cellOptions", + "value": { + "mode": "basic", + "type": "color-background" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "tlog_latency_minutes" + }, + "properties": [ + { + "id": "displayName", + "value": "TLog Delay" + }, + { + "id": "unit", + "value": "m" + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "#EAB839", + "value": 30 + }, + { + "color": "orange", + "value": 120 + }, + { + "color": "red", + "value": 360 + } + ] + } + }, + { + "id": "custom.cellOptions", + "value": { + "mode": "basic", + "type": "color-background" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "tlog_backup_size_mb" + }, + "properties": [ + { + "id": "displayName", + "value": "TLog Bkp Size" + }, + { + "id": "unit", + "value": "mbytes" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "tlog_compressed_size_mb" + }, + "properties": [ + { + "id": "displayName", + "value": "TLog Compressed" + }, + { + "id": "unit", + "value": "mbytes" + } + ] + } + ] + }, + "gridPos": { + "h": 8, + "w": 24, + "x": 0, + "y": 401 + }, + "id": 874, + "options": { + "cellHeight": "sm", + "footer": { + "countRows": false, + "fields": "", + "reducer": [ + "sum" + ], + "show": false + }, + "showHeader": true + }, + "pluginVersion": "11.2.0", + "targets": [ + { + "alias": "", + "datasource": { + "type": "mssql", + "uid": "${DS_SQLMONITOR}" + }, + "editorMode": "code", + "format": "table", + "hide": false, + "rawQuery": true, + "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\n--declare @sql_instance varchar(255);\n--declare @backup_type varchar(2000);\n--declare @backup_description varchar(2000);\n--declare @perfmon_host_name varchar(255);\ndeclare @start_time_utc datetime2;\ndeclare @end_time_utc datetime2;\n--declare @delta_minutes int;\n--declare @disk_drive varchar(255) = '$disk_drive';\n--declare @database varchar(255) = '$database';\n--declare @filter_for_latency varchar(50) = '$filter_for_latency';\ndeclare @full_threshold_days int = $full_threshold_days;\ndeclare @diff_threshold_hours int = $diff_threshold_hours;\ndeclare @tlog_threshold_minutes int = $tlog_threshold_minutes;\ndeclare @_has_inventory bit = 0;\n\n\n--set @database = case when ltrim(rtrim(@database)) = '__All__' then null else @database end;\n--set @disk_drive = case when ltrim(rtrim(@disk_drive)) = '__All__' then null else @disk_drive end;\n\n--set @perfmon_host_name = '$perfmon_host_name';\nset @start_time_utc = $__timeFrom();\nset @end_time_utc = $__timeTo();\n--set @delta_minutes = $cpu_delta_minutes;\nset @_has_inventory = convert(bit,'${has_inventory}');\n\n--set @backup_type = '${backup_type:csv}';\n--set @backup_description = case when ltrim(rtrim('$backup_description')) = '' then null else ltrim(rtrim('$backup_description')) end;\n\nset @params = N'@start_time_utc datetime2, @end_time_utc datetime2, \n\t\t\t\t\t\t\t\t@full_threshold_days int, @diff_threshold_hours int, @tlog_threshold_minutes int';\n\nset quoted_identifier off;\nset @sql = \"/* SQLMonitor - Dashboard [$__dashboard] */\nset nocount on;\n\n;with t_backups as (\n\t\tselect [collection_time_utc], [sql_instance], [database_name], [backup_type], [log_backups_count], [backup_start_date_utc], [backup_finish_date_utc], [latest_backup_location], [backup_size_mb], [compressed_backup_size_mb], [first_lsn], [last_lsn], [checkpoint_lsn], [database_backup_lsn], [database_creation_date_utc], [backup_software], [recovery_model], [compatibility_level], [device_type], [description]\n\t\tfrom dbo.backups_all_servers bas\n)\n,t_pivot as (\n\t\tselect\t[sql_instance], [database_name]\n\t\t\t\t,[recovery_model] = max([recovery_model])\n\t\t\t\t,[full_backup_time_utc] = max(case when bkp.[backup_type] = 'Full Database Backup' then bkp.[backup_finish_date_utc] else null end)\n\t\t\t\t,[full_backup_size_mb] = max(case when bkp.[backup_type] = 'Full Database Backup' then bkp.[backup_size_mb] else null end)\n\t\t\t\t,[full_compressed_size_mb] = max(case when bkp.[backup_type] = 'Full Database Backup' then bkp.[compressed_backup_size_mb] else null end)\n\t\t\t\t,[diff_backup_time_utc] = max(case when bkp.[backup_type] = 'Differential database Backup' then bkp.[backup_finish_date_utc] else null end)\n\t\t\t\t,[diff_backup_size_mb] = max(case when bkp.[backup_type] = 'Differential database Backup' then bkp.[backup_size_mb] else null end)\n\t\t\t\t,[diff_compressed_size_mb] = max(case when bkp.[backup_type] = 'Differential database Backup' then bkp.[compressed_backup_size_mb] else null end)\n\t\t\t\t,[tlog_backup_time_utc] = max(case when bkp.[backup_type] = 'Transaction Log Backup' then bkp.[backup_finish_date_utc] else null end)\n\t\t\t\t,[tlog_backup_size_mb] = max(case when bkp.[backup_type] = 'Transaction Log Backup' then bkp.[backup_size_mb] else null end)\n\t\t\t\t,[tlog_compressed_size_mb] = max(case when bkp.[backup_type] = 'Transaction Log Backup' then bkp.[compressed_backup_size_mb] else null end)\n\t\t\t\t,[log_backups_count] = max([log_backups_count])\n\t\t\t\t,[database_creation_date_utc] = max([database_creation_date_utc])\n\t\t\t\t,[full_backup_file] = max(case when bkp.[backup_type] = 'Full Database Backup' then bkp.[latest_backup_location] else null end)\n\t\t\t\t,[diff_backup_file] = max(case when bkp.[backup_type] = 'Differential database Backup' then bkp.[latest_backup_location] else null end)\n\t\t\t\t,[tlog_backup_file] = max(case when bkp.[backup_type] = 'Transaction Log Backup' then bkp.[latest_backup_location] else null end)\n\t\tfrom t_backups bkp\n\t\twhere 1=1\n\t\tgroup by [sql_instance], [database_name]\n)\n,t_latency as (\n\t\t\tselect \t[sql_instance], [database_name], [recovery_model], \t\t\t\t\n\t\t\t\t\t\t\t[full_latency_days] = case when [full_backup_time_utc] is null then @full_threshold_days * 10\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\telse datediff(day,[full_backup_time_utc],getutcdate())\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tend,\t\t\t\t\t\t\n\t\t\t\t\t\t\t[diff_latency_hours] = case when [diff_backup_time_utc] is null \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tthen\tcase when (datediff(day,[full_backup_time_utc],getutcdate()) > @full_threshold_days) and (@full_threshold_days >= 7)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tthen @full_threshold_days * 24\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\twhen (datediff(day,[full_backup_time_utc],getutcdate())*24) > @diff_threshold_hours\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tthen ( (datediff(day,[full_backup_time_utc],getutcdate())-1) * 24 )\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\telse null\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\telse datediff(hour,[diff_backup_time_utc],getutcdate())\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tend,\n\t\t\t\t\t\t\t[tlog_latency_minutes] = case when recovery_model = 'SIMPLE' then null\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\twhen recovery_model <> 'SIMPLE'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tthen\tcase when [tlog_backup_time_utc] is null then @full_threshold_days * 1440\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t when [tlog_backup_time_utc] is not null\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t then datediff(minute,[tlog_backup_time_utc],getutcdate())\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t else null\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t end\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\telse null\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tend,\n\t\t\t\t\t\t\t[full_backup_time_utc], [diff_backup_time_utc], [tlog_backup_time_utc], \n\t\t\t\t\t\t\t[full_backup_size_mb], [full_compressed_size_mb], [diff_backup_size_mb], [diff_compressed_size_mb], [tlog_backup_size_mb],\n\t\t\t\t\t\t\t[tlog_compressed_size_mb], [log_backups_count],\n\t\t\t\t\t\t\t[database_creation_date_utc], [full_backup_file], [diff_backup_file], [tlog_backup_file]\n\t\t\tfrom t_pivot as bkp\n\t\t\twhere 1=1\n)\nselect [sql_instance], [database_name], [recovery_model], \t\t\t\t\n\t\t\t\t\t\t\t[full_latency_days], [diff_latency_hours], [tlog_latency_minutes],\n\t\t\t\t\t\t\t[full_backup_time_utc], [diff_backup_time_utc], [tlog_backup_time_utc], \n\t\t\t\t\t\t\t[full_backup_size_mb], [full_compressed_size_mb], [diff_backup_size_mb], [diff_compressed_size_mb], \n\t\t\t\t\t\t\t[tlog_backup_size_mb], [tlog_compressed_size_mb], [log_backups_count], [database_creation_date_utc], \n\t\t\t\t\t\t\t[full_backup_file], [diff_backup_file], [tlog_backup_file]\nfrom t_latency as l\nwhere 1=1\nAND (\t\t(full_latency_days is null or full_latency_days >= @full_threshold_days)\n\t\tOR \t(diff_latency_hours is not null and diff_latency_hours >= @diff_threshold_hours)\n\t\tOR\t(tlog_latency_minutes is not null and tlog_latency_minutes >= @tlog_threshold_minutes)\n\t\t)\n\"+(case when @_has_inventory = 0 then '--' else '' end)+\"and exists (select * from dbo.sma_servers s where s.is_decommissioned = 0 and s.is_onboarded = 1 and s.server = l.sql_instance and (s.hadr_strategy is null or s.hadr_strategy <> 'ag'))\n\"\nset quoted_identifier on;\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nexec dbo.sp_executesql @sql, @params, @start_time_utc, @end_time_utc, @full_threshold_days, @diff_threshold_hours, \n\t\t\t\t\t\t\t\t\t\t\t\t@tlog_threshold_minutes;", + "refId": "Query-Db-File-Stats-Since-Startup", + "sql": { + "columns": [ + { + "parameters": [], + "type": "function" + } + ], + "groupBy": [ + { + "property": { + "type": "string" + }, + "type": "groupBy" + } + ], + "limit": 50 + } + } + ], + "title": "\"${nonag_database_counts_with_backup_issue}\" __Non AG__ Dbs @ ${backups_all_servers__collection_time_utc:date:YYYY-MM-DD HH.mm}", + "type": "table" + }, + { + "datasource": { + "type": "mssql", + "uid": "${sqlmonitor_datasource}" + }, + "description": "select * from dbo.backups_all_servers", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "custom": { + "align": "auto", + "cellOptions": { + "type": "auto" + }, + "filterable": true, + "inspect": true + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + } + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "sql_instance" + }, + "properties": [ + { + "id": "displayName", + "value": "Server" + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "purple" + } + ] + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "database_name" + }, + "properties": [ + { + "id": "displayName", + "value": "Database" + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "super-light-purple" + } + ] + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "log_backups_count" + }, + "properties": [ + { + "id": "displayName", + "value": "Total Log Backups" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "database_creation_date_utc" + }, + "properties": [ + { + "id": "displayName", + "value": "Db Created Date" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "recovery_model" + }, + "properties": [ + { + "id": "displayName", + "value": "Recovery Model" + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "dark-blue" + } + ] + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "full_backup_time_utc" + }, + "properties": [ + { + "id": "displayName", + "value": "Full Bkp Time" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "full_backup_size_mb" + }, + "properties": [ + { + "id": "displayName", + "value": "Full Bkp Size" + }, + { + "id": "unit", + "value": "mbytes" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "full_compressed_size_mb" + }, + "properties": [ + { + "id": "displayName", + "value": "Full Compressed" + }, + { + "id": "unit", + "value": "mbytes" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "diff_backup_time_utc" + }, + "properties": [ + { + "id": "displayName", + "value": "Diff Bkp Time" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "diff_backup_size_mb" + }, + "properties": [ + { + "id": "displayName", + "value": "Diff Bkp Size" + }, + { + "id": "unit", + "value": "mbytes" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "diff_compressed_size_mb" + }, + "properties": [ + { + "id": "displayName", + "value": "Diff Compressed" + }, + { + "id": "unit", + "value": "mbytes" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "tlog_backup_time_utc" + }, + "properties": [ + { + "id": "displayName", + "value": "TLog Bkp Time" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "full_backup_file" + }, + "properties": [ + { + "id": "displayName", + "value": "Full File" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "diff_backup_file" + }, + "properties": [ + { + "id": "displayName", + "value": "Diff File" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "tlog_backup_file" + }, + "properties": [ + { + "id": "displayName", + "value": "TLog File" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "full_latency_days" + }, + "properties": [ + { + "id": "displayName", + "value": "Full Delay" + }, + { + "id": "unit", + "value": "d" + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "orange", + "value": 8 + }, + { + "color": "red", + "value": 15 + } + ] + } + }, + { + "id": "custom.cellOptions", + "value": { + "mode": "basic", + "type": "color-background" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "diff_latency_hours" + }, + "properties": [ + { + "id": "displayName", + "value": "Diff Delay" + }, + { + "id": "unit", + "value": "h" + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "yellow", + "value": 24 + }, + { + "color": "orange", + "value": 32 + }, + { + "color": "red", + "value": 48 + } + ] + } + }, + { + "id": "custom.cellOptions", + "value": { + "mode": "basic", + "type": "color-background" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "tlog_latency_minutes" + }, + "properties": [ + { + "id": "displayName", + "value": "TLog Delay" + }, + { + "id": "unit", + "value": "m" + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "#EAB839", + "value": 30 + }, + { + "color": "orange", + "value": 120 + }, + { + "color": "red", + "value": 360 + } + ] + } + }, + { + "id": "custom.cellOptions", + "value": { + "mode": "basic", + "type": "color-background" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "tlog_backup_size_mb" + }, + "properties": [ + { + "id": "displayName", + "value": "TLog Bkp Size" + }, + { + "id": "unit", + "value": "mbytes" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "tlog_compressed_size_mb" + }, + "properties": [ + { + "id": "displayName", + "value": "TLog Compressed" + }, + { + "id": "unit", + "value": "mbytes" + } + ] + } + ] + }, + "gridPos": { + "h": 10, + "w": 24, + "x": 0, + "y": 409 + }, + "id": 888, + "options": { + "cellHeight": "sm", + "footer": { + "countRows": false, + "fields": "", + "reducer": [ + "sum" + ], + "show": false + }, + "showHeader": true + }, + "pluginVersion": "11.2.0", + "targets": [ + { + "alias": "", + "datasource": { + "type": "mssql", + "uid": "${DS_SQLMONITOR}" + }, + "editorMode": "code", + "format": "table", + "hide": false, + "rawQuery": true, + "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\n--declare @sql_instance varchar(255);\n--declare @backup_type varchar(2000);\n--declare @backup_description varchar(2000);\n--declare @perfmon_host_name varchar(255);\ndeclare @start_time_utc datetime2;\ndeclare @end_time_utc datetime2;\n--declare @delta_minutes int;\n--declare @disk_drive varchar(255) = '$disk_drive';\n--declare @database varchar(255) = '$database';\n--declare @filter_for_latency varchar(50) = '$filter_for_latency';\ndeclare @full_threshold_days int = $full_threshold_days;\ndeclare @diff_threshold_hours int = $diff_threshold_hours;\ndeclare @tlog_threshold_minutes int = $tlog_threshold_minutes;\ndeclare @_has_inventory bit = 0;\n\n\n--set @database = case when ltrim(rtrim(@database)) = '__All__' then null else @database end;\n--set @disk_drive = case when ltrim(rtrim(@disk_drive)) = '__All__' then null else @disk_drive end;\n\n--set @perfmon_host_name = '$perfmon_host_name';\nset @start_time_utc = $__timeFrom();\nset @end_time_utc = $__timeTo();\n--set @delta_minutes = $cpu_delta_minutes;\nset @_has_inventory = convert(bit,'${has_inventory}');\n\n--set @backup_type = '${backup_type:csv}';\n--set @backup_description = case when ltrim(rtrim('$backup_description')) = '' then null else ltrim(rtrim('$backup_description')) end;\n\nset @params = N'@start_time_utc datetime2, @end_time_utc datetime2, \n\t\t\t\t\t\t\t\t@full_threshold_days int, @diff_threshold_hours int, @tlog_threshold_minutes int';\n\nset quoted_identifier off;\nset @sql = \"/* SQLMonitor - Dashboard [Monitoring - Live - All Servers] */\nset nocount on;\n\n;with t_backups as (\n\tselect [collection_time_utc], [sql_instance], s.ag_replicas, [database_name], [backup_type], [log_backups_count], \n\t\t\t[backup_start_date_utc], [backup_finish_date_utc], [latest_backup_location], [backup_size_mb], [compressed_backup_size_mb], [first_lsn], [last_lsn], [checkpoint_lsn], [database_backup_lsn], [database_creation_date_utc], [backup_software], [recovery_model], [compatibility_level], [device_type], [description]\n\t\t\t,db_rowid = ROW_NUMBER()over(partition by s.ag_replicas, [database_name], [backup_type] order by [backup_start_date_utc] desc)\n\tfrom dbo.backups_all_servers bas\n\tjoin dbo.sma_sql_servers s on s.server = bas.sql_instance and s.is_decommissioned = 0 and s.is_onboarded = 1 and s.hadr_strategy = 'ag'\n\twhere 1=1\n\tand charindex(',',s.ag_replicas) > 0\n)\n,t_pivot as (\n\t\tselect\tag_replicas, [sql_instance], [database_name]\n\t\t\t\t,[recovery_model] = max([recovery_model])\n\t\t\t\t,[full_backup_time_utc] = max(case when bkp.[backup_type] = 'Full Database Backup' then bkp.[backup_finish_date_utc] else null end)\n\t\t\t\t,[full_backup_size_mb] = max(case when bkp.[backup_type] = 'Full Database Backup' then bkp.[backup_size_mb] else null end)\n\t\t\t\t,[full_compressed_size_mb] = max(case when bkp.[backup_type] = 'Full Database Backup' then bkp.[compressed_backup_size_mb] else null end)\n\t\t\t\t,[diff_backup_time_utc] = max(case when bkp.[backup_type] = 'Differential database Backup' then bkp.[backup_finish_date_utc] else null end)\n\t\t\t\t,[diff_backup_size_mb] = max(case when bkp.[backup_type] = 'Differential database Backup' then bkp.[backup_size_mb] else null end)\n\t\t\t\t,[diff_compressed_size_mb] = max(case when bkp.[backup_type] = 'Differential database Backup' then bkp.[compressed_backup_size_mb] else null end)\n\t\t\t\t,[tlog_backup_time_utc] = max(case when bkp.[backup_type] = 'Transaction Log Backup' then bkp.[backup_finish_date_utc] else null end)\n\t\t\t\t,[tlog_backup_size_mb] = max(case when bkp.[backup_type] = 'Transaction Log Backup' then bkp.[backup_size_mb] else null end)\n\t\t\t\t,[tlog_compressed_size_mb] = max(case when bkp.[backup_type] = 'Transaction Log Backup' then bkp.[compressed_backup_size_mb] else null end)\n\t\t\t\t,[log_backups_count] = max([log_backups_count])\n\t\t\t\t,[database_creation_date_utc] = max([database_creation_date_utc])\n\t\t\t\t,[full_backup_file] = max(case when bkp.[backup_type] = 'Full Database Backup' then bkp.[latest_backup_location] else null end)\n\t\t\t\t,[diff_backup_file] = max(case when bkp.[backup_type] = 'Differential database Backup' then bkp.[latest_backup_location] else null end)\n\t\t\t\t,[tlog_backup_file] = max(case when bkp.[backup_type] = 'Transaction Log Backup' then bkp.[latest_backup_location] else null end)\n\t\tfrom t_backups bkp\n\t\twhere 1=1\n\t\tand db_rowid = 1\n\t\tgroup by ag_replicas, [sql_instance], [database_name]\n)\n,t_latency as (\n\t\t\tselect \tag_replicas, [sql_instance], [database_name], [recovery_model], \t\t\t\t\n\t\t\t\t\t\t\t[full_latency_days] = case when [full_backup_time_utc] is null then @full_threshold_days * 10\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\telse datediff(day,[full_backup_time_utc],getutcdate())\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tend,\t\t\t\t\t\t\n\t\t\t\t\t\t\t[diff_latency_hours] = case when [diff_backup_time_utc] is null \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tthen\tcase when (datediff(day,[full_backup_time_utc],getutcdate()) > @full_threshold_days) and (@full_threshold_days >= 7)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tthen @full_threshold_days * 24\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\twhen (datediff(day,[full_backup_time_utc],getutcdate())*24) > @diff_threshold_hours\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tthen ( (datediff(day,[full_backup_time_utc],getutcdate())-1) * 24 )\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\telse null\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\telse datediff(hour,[diff_backup_time_utc],getutcdate())\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tend,\n\t\t\t\t\t\t\t[tlog_latency_minutes] = case when recovery_model = 'SIMPLE' then null\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\twhen recovery_model <> 'SIMPLE'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tthen\tcase when [tlog_backup_time_utc] is null then @full_threshold_days * 1440\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t when [tlog_backup_time_utc] is not null\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t then datediff(minute,[tlog_backup_time_utc],getutcdate())\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t else null\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t end\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\telse null\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tend,\n\t\t\t\t\t\t\t[full_backup_time_utc], [diff_backup_time_utc], [tlog_backup_time_utc], \n\t\t\t\t\t\t\t[full_backup_size_mb], [full_compressed_size_mb], [diff_backup_size_mb], [diff_compressed_size_mb], [tlog_backup_size_mb],\n\t\t\t\t\t\t\t[tlog_compressed_size_mb], [log_backups_count],\n\t\t\t\t\t\t\t[database_creation_date_utc], [full_backup_file], [diff_backup_file], [tlog_backup_file]\n\t\t\tfrom t_pivot as bkp\n\t\t\twhere 1=1\n)\nselect ag_replicas, [sql_instance], [database_name], [recovery_model], \t\t\t\t\n\t\t\t\t\t\t\t[full_latency_days], [diff_latency_hours], [tlog_latency_minutes],\n\t\t\t\t\t\t\t[full_backup_time_utc], [diff_backup_time_utc], [tlog_backup_time_utc], \n\t\t\t\t\t\t\t[full_backup_size_mb], [full_compressed_size_mb], [diff_backup_size_mb], [diff_compressed_size_mb], \n\t\t\t\t\t\t\t[tlog_backup_size_mb], [tlog_compressed_size_mb], [log_backups_count], [database_creation_date_utc], \n\t\t\t\t\t\t\t[full_backup_file], [diff_backup_file], [tlog_backup_file]\nfrom t_latency as l\nwhere 1=1\nAND (\t\t(full_latency_days is null or full_latency_days >= @full_threshold_days)\n\t\tOR \t(diff_latency_hours is not null and diff_latency_hours >= @diff_threshold_hours)\n\t\tOR\t(tlog_latency_minutes is not null and tlog_latency_minutes >= @tlog_threshold_minutes)\n\t\t)\norder by ag_replicas, database_name\n\"\nset quoted_identifier on;\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nexec dbo.sp_executesql @sql, @params, @start_time_utc, @end_time_utc, @full_threshold_days, @diff_threshold_hours, \n\t\t\t\t\t\t\t\t\t\t\t\t@tlog_threshold_minutes;", + "refId": "Query-Db-File-Stats-Since-Startup", + "sql": { + "columns": [ + { + "parameters": [], + "type": "function" + } + ], + "groupBy": [ + { + "property": { + "type": "string" + }, + "type": "groupBy" + } + ], + "limit": 50 + } + } + ], + "title": "\"${ag_database_counts_with_backup_issue}\" __AG__ Dbs @ ${backups_all_servers__collection_time_utc:date:YYYY-MM-DD HH.mm}", + "type": "table" + } + ], + "title": "All Backup Issues - Require ATTENTION - \"${nonag_database_counts_with_backup_issue}\" Non AG & \"${ag_database_counts_with_backup_issue}\" AG Dbs @ ${backups_all_servers__collection_time_utc:date:YYYY-MM-DD HH.mm}", + "type": "row" + }, + { + "collapsed": true, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 5 + }, + "id": 866, + "panels": [ + { + "datasource": { + "default": false, + "type": "mssql", + "uid": "${sqlmonitor_datasource}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "custom": { + "align": "auto", + "cellOptions": { + "type": "auto" + }, + "inspect": false + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "CollectionTimeUTC" + }, + "properties": [ + { + "id": "displayName", + "value": "Collection Time" + }, + { + "id": "custom.cellOptions", + "value": { + "mode": "basic", + "type": "color-background" + } + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "super-light-purple" + } + ] + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "sql_instance" + }, + "properties": [ + { + "id": "displayName", + "value": "SQL Instance" + }, + { + "id": "custom.cellOptions", + "value": { + "mode": "basic", + "type": "color-background" + } + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "blue" + } + ] + } + }, + { + "id": "links", + "value": [ + { + "targetBlank": true, + "title": "Live Server Dashboard ", + "url": "d/distributed_live_dashboard?var-server=${__data.fields.sql_instance}" + } + ] + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "JobName" + }, + "properties": [ + { + "id": "displayName", + "value": "Job Name" + }, + { + "id": "custom.cellOptions", + "value": { + "mode": "basic", + "type": "color-background" + } + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + } + }, + { + "id": "custom.minWidth", + "value": 250 + }, + { + "id": "displayName", + "value": "Job Name" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Job-Delay-Minutes" + }, + "properties": [ + { + "id": "displayName", + "value": "Execution Delay" + }, + { + "id": "unit", + "value": "m" + }, + { + "id": "custom.cellOptions", + "value": { + "mode": "basic", + "type": "color-background" + } + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "super-light-yellow" + }, + { + "color": "#EAB839", + "value": 30 + }, + { + "color": "orange", + "value": 60 + }, + { + "color": "red", + "value": 90 + } + ] + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Last_RunTime" + }, + "properties": [ + { + "id": "unit", + "value": "dateTimeAsIso" + }, + { + "id": "displayName", + "value": "Last Run" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Last_Run_Duration_Seconds" + }, + "properties": [ + { + "id": "unit", + "value": "s" + }, + { + "id": "displayName", + "value": "Last Duration" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Last_Run_Outcome" + }, + "properties": [ + { + "id": "displayName", + "value": "Last Outcome" + }, + { + "id": "custom.cellOptions", + "value": { + "mode": "basic", + "type": "color-background" + } + }, + { + "id": "mappings", + "value": [ + { + "options": { + "Failed": { + "color": "red", + "index": 1 + }, + "Succeeded": { + "color": "green", + "index": 2 + } + }, + "type": "value" + }, + { + "options": { + "match": "null", + "result": { + "color": "super-light-yellow", + "index": 0 + } + }, + "type": "special" + } + ] + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Successfull_Execution_ClockTime_Threshold_Minutes" + }, + "properties": [ + { + "id": "displayName", + "value": "Success ClockTime Threshold" + }, + { + "id": "unit", + "value": "m" + }, + { + "id": "custom.cellOptions", + "value": { + "type": "color-text" + } + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "blue" + } + ] + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Expected_Max_Duration_Minutes" + }, + "properties": [ + { + "id": "displayName", + "value": "Expected Max Duration" + }, + { + "id": "unit", + "value": "m" + }, + { + "id": "custom.cellOptions", + "value": { + "type": "color-text" + } + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "blue" + } + ] + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Last_Successful_Execution_Hours" + }, + "properties": [ + { + "id": "displayName", + "value": "Last Successful Execution" + }, + { + "id": "unit", + "value": "h" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "Running_Since_Min" + }, + "properties": [ + { + "id": "displayName", + "value": "Running Since" + }, + { + "id": "unit", + "value": "m" + } + ] + } + ] + }, + "gridPos": { + "h": 8, + "w": 24, + "x": 0, + "y": 402 + }, + "id": 864, + "options": { + "cellHeight": "sm", + "footer": { + "countRows": false, + "fields": "", + "reducer": [ + "sum" + ], + "show": false + }, + "showHeader": true + }, + "pluginVersion": "11.2.0", + "targets": [ + { + "datasource": { + "type": "mssql", + "uid": "${DS_SQLMONITOR}" + }, + "editorMode": "code", + "format": "table", + "rawQuery": true, + "rawSql": "declare @_buffer_time_minutes int = 30;\r\ndeclare @_sql nvarchar(max);\r\ndeclare @_params nvarchar(max);\r\n\r\nset @_params = N'@_buffer_time_minutes int';\r\nset quoted_identifier off;\r\nset @_sql = \"\r\nselect\t/* [Tsql-Stop-Job] = 'exec msdb.dbo.sp_stop_job @job_name = '''+sj.JobName+'''' ,\r\n\t\t[Tsql-Start-Job] = 'exec msdb.dbo.sp_start_job @job_name = '''+sj.JobName+'''' , \r\n\t\t*/\r\n\t\t[CollectionTimeUTC] = [UpdatedDateUTC],\r\n\t\tsj.[sql_instance], [JobName],\r\n\t\t[Job-Delay-Minutes] = case when sj.Last_Successful_ExecutionTime is null then 10080 else datediff(minute, sj.Last_Successful_ExecutionTime, dateadd(minute,-(sj.Successfull_Execution_ClockTime_Threshold_Minutes+@_buffer_time_minutes),getutcdate())) end,\r\n\t\t [Last_RunTime], [Last_Run_Duration_Seconds], [Last_Run_Outcome], \r\n\t\t [Successfull_Execution_ClockTime_Threshold_Minutes], \r\n\t\t [Expected_Max_Duration_Minutes],\r\n\t\t [Last_Successful_ExecutionTime], [Last_Successful_Execution_Hours], \r\n\t\t [Running_Since], [Running_StepName], [Running_Since_Min] \r\nfrom dbo.sql_agent_jobs_all_servers sj\r\ninner join dbo.services_all_servers sas\r\n\ton sas.sql_instance = sj.sql_instance\r\n\tand sas.service_type = 'Agent'\r\n\tand sas.status_desc = 'Running'\r\nwhere 1=1\r\nand exists (select 1/0 from dbo.instance_details id where id.sql_instance = sj.sql_instance and id.is_enabled = 1)\r\nand sj.JobCategory = '(dba) SQLMonitor'\r\nand sj.JobName like '(dba) %'\r\nand sj.IsDisabled = 0\r\nand (\tisnull(sj.Last_Successful_ExecutionTime,sj.Last_RunTime) < dateadd(minute,-(sj.Successfull_Execution_ClockTime_Threshold_Minutes+@_buffer_time_minutes),getutcdate())\r\n\t\tand (sj.Last_Successful_ExecutionTime is not null or sj.Last_RunTime is not null)\r\n\t)\r\n--order by Last_Run_Outcome\r\n\"\r\nset quoted_identifier off;\r\n\r\nexec sp_executesql @_sql, @_params, @_buffer_time_minutes = @_buffer_time_minutes;", + "refId": "A", + "sql": { + "columns": [ + { + "parameters": [], + "type": "function" + } + ], + "groupBy": [ + { + "property": { + "type": "string" + }, + "type": "groupBy" + } + ], + "limit": 50 + } + } + ], + "title": "All Servers - SQLMonitor Jobs - Require ATTENTION @ ${sql_agent_jobs__collection_time_utc:date:YYYY-MM-DD HH.mm}", + "type": "table" + } + ], + "title": "All Servers - SQLMonitor Jobs - \"${dba_jobs_with_issue_counts}\" Require ATTENTION @ ${sql_agent_jobs__collection_time_utc:date:YYYY-MM-DD HH.mm}", + "type": "row" + }, + { + "collapsed": true, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 6 + }, + "id": 854, + "panels": [ + { + "datasource": { + "type": "mssql", + "uid": "${sqlmonitor_datasource}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "custom": { + "align": "auto", + "cellOptions": { + "type": "auto" + }, + "filterable": true, + "inspect": true + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "sql_instance" + }, + "properties": [ + { + "id": "displayName", + "value": "Server" + }, + { + "id": "custom.width", + "value": 127 + }, + { + "id": "custom.cellOptions", + "value": { + "mode": "gradient", + "type": "color-background" + } + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "blue" + } + ] + } + }, + { + "id": "links", + "value": [ + { + "targetBlank": true, + "title": "Disk Space Dashboard", + "url": "d/disk_space?var-server=${__data.fields.sql_instance}&var-perfmon_host_name=${__data.fields.host_name}&viewPanel=23" + } + ] + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "host_name" + }, + "properties": [ + { + "id": "displayName", + "value": "Host" + }, + { + "id": "custom.cellOptions", + "value": { + "mode": "gradient", + "type": "color-background" + } + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "super-light-blue" + } + ] + } + }, + { + "id": "links", + "value": [ + { + "targetBlank": true, + "title": "Disk Space Dashboard", + "url": "d/disk_space?var-server=${__data.fields.sql_instance}&var-perfmon_host_name=${__data.fields.host_name}&viewPanel=23" + } + ] + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "disk_volume" + }, + "properties": [ + { + "id": "displayName", + "value": "Disk" + }, + { + "id": "links", + "value": [ + { + "targetBlank": true, + "title": "Disk Drive Space Trend", + "url": "d/disk_space?var-server=${__data.fields.sql_instance}&var-perfmon_host_name=${__data.fields.host_name}&var-disk_drive=${__data.fields.disk_volume}&viewPanel=26" + } + ] + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "label" + }, + "properties": [ + { + "id": "displayName", + "value": "Disk Label" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "capacity_mb" + }, + "properties": [ + { + "id": "displayName", + "value": "Capacity" + }, + { + "id": "unit", + "value": "mbytes" + }, + { + "id": "links", + "value": [ + { + "targetBlank": true, + "title": "Disk Space - Utilization Trend", + "url": "d/disk_space?var-server=${__data.fields.sql_instance}&var-perfmon_host_name=${__data.fields.host_name}&var-disk_drive=${__data.fields.disk_volume}&viewPanel=26" + } + ] + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "free_mb" + }, + "properties": [ + { + "id": "displayName", + "value": "Free Space" + }, + { + "id": "unit", + "value": "mbytes" + }, + { + "id": "links", + "value": [ + { + "targetBlank": true, + "title": "Disk Space - All Drives Current Sizes", + "url": "d/disk_space?var-server=${__data.fields.sql_instance}&var-perfmon_host_name=${__data.fields.host_name}&viewPanel=23" + } + ] + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "state" + }, + "properties": [ + { + "id": "displayName", + "value": "Status" + }, + { + "id": "mappings", + "value": [ + { + "options": { + "Critical": { + "color": "red", + "index": 0 + }, + "Warning": { + "color": "orange", + "index": 1 + } + }, + "type": "value" + } + ] + }, + { + "id": "custom.cellOptions", + "value": { + "mode": "gradient", + "type": "color-background" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "used_pct" + }, + "properties": [ + { + "id": "displayName", + "value": "Used %" + }, + { + "id": "custom.cellOptions", + "value": { + "mode": "gradient", + "type": "color-background" + } + }, + { + "id": "unit", + "value": "percent" + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "#EAB839", + "value": 80 + }, + { + "color": "orange", + "value": 90 + }, + { + "color": "red", + "value": 95 + } + ] + } + }, + { + "id": "links", + "value": [ + { + "targetBlank": true, + "title": "Disk Space - Utilization % Trend", + "url": "d/disk_space?var-server=${__data.fields.sql_instance}&var-perfmon_host_name=${__data.fields.host_name}&var-disk_drive=${__data.fields.disk_volume}&viewPanel=22" + } + ] + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "updated_date_utc" + }, + "properties": [ + { + "id": "displayName", + "value": "Collection Time" + }, + { + "id": "custom.cellOptions", + "value": { + "mode": "basic", + "type": "color-background" + } + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "super-light-purple" + } + ] + } + } + ] + } + ] + }, + "gridPos": { + "h": 12, + "w": 24, + "x": 0, + "y": 411 + }, + "id": 852, + "options": { + "cellHeight": "sm", + "footer": { + "countRows": false, + "enablePagination": true, + "fields": "", + "reducer": [ + "sum" + ], + "show": false + }, + "showHeader": true + }, + "pluginVersion": "11.1.4", + "targets": [ + { + "datasource": { + "type": "mssql", + "uid": "${DS_SQLMONITOR}" + }, + "editorMode": "code", + "format": "table", + "rawQuery": true, + "rawSql": "declare @_disk_warning_pct decimal(20,2) = ${disk_warning_pct};\r\ndeclare @_disk_critical_pct decimal(20,2) = ${disk_critical_pct};\r\ndeclare @_disk_threshold_gb decimal(20,2) = ${disk_threshold_gb};\r\ndeclare @_large_disk_threshold_pct decimal(20,2) = ${large_disk_threshold_pct};\r\ndeclare @_has_inventory bit = 0;\r\nset @_has_inventory = convert(bit,'${has_inventory}');\r\n\r\ndeclare @_sql nvarchar(max);\r\ndeclare @_params nvarchar(max);\r\n\r\nset @_params = '@disk_warning_pct decimal(20,2), @disk_critical_pct decimal(20,2), @disk_threshold_gb decimal(20,2), @large_disk_threshold_pct decimal(20,2)';\r\n\r\nset quoted_identifier off;\r\nset @_sql = \"\r\nselect\tds.updated_date_utc, ds.sql_instance, ds.host_name, ds.disk_volume, ds.label, ds.capacity_mb, ds.free_mb,\r\n\t\t[state] = case when (ds.free_mb*100.0/ds.capacity_mb) < (100.0-@disk_critical_pct) then 'Critical' else 'Warning' end,\r\n\t\t--[free_pct] = convert(numeric(20,2),ds.free_mb*100.0/ds.capacity_mb),\r\n\t\t[used_pct] = 100.0-convert(numeric(20,2),ds.free_mb*100.0/ds.capacity_mb)\r\n\t\t--ds.block_size, ds.filesystem, \r\n --, ds.collection_time_utc\r\nfrom dbo.disk_space_all_servers ds\r\nwhere ds.updated_date_utc >= dateadd(minute,-60,getutcdate())\r\nand (\t(\t(ds.free_mb*100.0/ds.capacity_mb) < (100-@disk_warning_pct)\r\n\t\t\tand ds.free_mb < (@disk_threshold_gb)*1024\r\n\t \t)\r\n\t\tor ( (ds.free_mb*100.0/ds.capacity_mb) < (100-@large_disk_threshold_pct)) -- free %\r\n\t\t)\r\n\"+(case when @_has_inventory = 0 then '--' else '' end)+\"and exists (select * from dbo.sma_servers s where s.is_decommissioned = 0 and s.is_onboarded = 1 and s.server = ds.sql_instance)\r\n\";\r\nset quoted_identifier off;\r\n\r\nexec sp_executesql @_sql, @_params, @_disk_warning_pct, @_disk_critical_pct, @_disk_threshold_gb , @_large_disk_threshold_pct;", + "refId": "A", + "sql": { + "columns": [ + { + "parameters": [], + "type": "function" + } + ], + "groupBy": [ + { + "property": { + "type": "string" + }, + "type": "groupBy" + } + ], + "limit": 50 + } + } + ], + "title": "Disk Space - All Servers @ ${disk_space__collection_time_utc:date:YYYY-MM-DD HH.mm}", + "type": "table" + } + ], + "title": "All Servers - Disk Utilization - Require ATTENTION - \"${critical_disks_counts}\" CRITICAL - \"${warning_disks_counts}\" WARNING @ ${disk_space__collection_time_utc:date:YYYY-MM-DD HH.mm}", + "type": "row" + }, + { + "collapsed": true, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 7 + }, + "id": 868, + "panels": [ + { + "datasource": { + "type": "mssql", + "uid": "${sqlmonitor_datasource}" + }, + "description": "dbo.ag_health_state_all_servers", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "custom": { + "align": "auto", + "cellOptions": { + "type": "auto" + }, + "filterable": true, + "inspect": true + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + } + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "replica_server_name" + }, + "properties": [ + { + "id": "displayName", + "value": "Replica" + }, + { + "id": "custom.cellOptions", + "value": { + "mode": "basic", + "type": "color-background" + } + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "super-light-purple" + } + ] + } + }, + { + "id": "links", + "value": [ + { + "targetBlank": true, + "title": "Replica Ag Latency Trend", + "url": "d/ag_health_state?var-server=${__data.fields.sql_instance}&var-replica_server_name=${__data.fields.replica_server_name}" + } + ] + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "is_primary_replica" + }, + "properties": [ + { + "id": "displayName", + "value": "Is Primary" + }, + { + "id": "unit", + "value": "bool" + }, + { + "id": "custom.cellOptions", + "value": { + "mode": "basic", + "type": "color-background" + } + }, + { + "id": "mappings", + "value": [ + { + "options": { + "match": "true", + "result": { + "color": "super-light-green", + "index": 0 + } + }, + "type": "special" + }, + { + "options": { + "match": "false", + "result": { + "color": "super-light-blue", + "index": 1 + } + }, + "type": "special" + } + ] + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "database_name" + }, + "properties": [ + { + "id": "displayName", + "value": "Database" + }, + { + "id": "custom.cellOptions", + "value": { + "mode": "basic", + "type": "color-background" + } + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "super-light-purple" + } + ] + } + }, + { + "id": "links", + "value": [ + { + "targetBlank": true, + "title": "Database Ag Latency Trend", + "url": "d/ag_health_state?var-server=${__data.fields.sql_instance}&var-database=${__data.fields.database_name}" + } + ] + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "ag_name" + }, + "properties": [ + { + "id": "displayName", + "value": "AG" + }, + { + "id": "custom.cellOptions", + "value": { + "type": "color-text" + } + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "blue" + } + ] + } + }, + { + "id": "custom.hidden", + "value": true + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "ag_listener" + }, + "properties": [ + { + "id": "displayName", + "value": "Listener" + }, + { + "id": "custom.cellOptions", + "value": { + "mode": "basic", + "type": "color-background" + } + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "super-light-blue" + } + ] + } + }, + { + "id": "custom.minWidth", + "value": 180 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "is_local" + }, + "properties": [ + { + "id": "displayName", + "value": "Is Local" + }, + { + "id": "unit", + "value": "bool" + }, + { + "id": "custom.cellOptions", + "value": { + "mode": "basic", + "type": "color-background" + } + }, + { + "id": "mappings", + "value": [ + { + "options": { + "match": "true", + "result": { + "color": "super-light-green", + "index": 0 + } + }, + "type": "special" + }, + { + "options": { + "match": "false", + "result": { + "color": "super-light-blue", + "index": 1 + } + }, + "type": "special" + } + ] + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "synchronization_state_desc" + }, + "properties": [ + { + "id": "displayName", + "value": "Sync State" + }, + { + "id": "mappings", + "value": [ + { + "options": { + "INITIALIZING": { + "color": "light-yellow", + "index": 4 + }, + "NOT SYNCHRONIZING": { + "color": "red", + "index": 1 + }, + "REVERTING": { + "color": "super-light-yellow", + "index": 3 + }, + "SYNCHRONIZED": { + "color": "green", + "index": 0 + }, + "SYNCHRONIZING": { + "color": "super-light-green", + "index": 2 + } + }, + "type": "value" + } + ] + }, + { + "id": "custom.cellOptions", + "value": { + "mode": "basic", + "type": "color-background" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "synchronization_health_desc" + }, + "properties": [ + { + "id": "displayName", + "value": "Sync Health" + }, + { + "id": "mappings", + "value": [ + { + "options": { + "HEALTHY": { + "color": "green", + "index": 0 + }, + "NOT_HEALTHY": { + "color": "red", + "index": 1 + }, + "PARTIALLY_HEALTHY": { + "color": "yellow", + "index": 2 + } + }, + "type": "value" + } + ] + }, + { + "id": "custom.cellOptions", + "value": { + "mode": "basic", + "type": "color-background" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "latency_seconds" + }, + "properties": [ + { + "id": "displayName", + "value": "Latency" + }, + { + "id": "unit", + "value": "s" + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "super-light-yellow", + "value": 120 + }, + { + "color": "super-light-orange", + "value": 240 + }, + { + "color": "orange", + "value": 300 + }, + { + "color": "super-light-red", + "value": 600 + }, + { + "color": "red", + "value": 1800 + } + ] + } + }, + { + "id": "custom.cellOptions", + "value": { + "mode": "basic", + "type": "color-background" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "redo_queue_size" + }, + "properties": [ + { + "id": "displayName", + "value": "Redo Queue" + }, + { + "id": "unit", + "value": "kbytes" + }, + { + "id": "custom.cellOptions", + "value": { + "mode": "basic", + "type": "color-background" + } + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "super-light-yellow", + "value": 1000000 + }, + { + "color": "light-orange", + "value": 10000000 + }, + { + "color": "red", + "value": 100000000 + } + ] + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "log_send_queue_size" + }, + "properties": [ + { + "id": "displayName", + "value": "Log Send Queue" + }, + { + "id": "unit", + "value": "kbytes" + }, + { + "id": "custom.cellOptions", + "value": { + "mode": "basic", + "type": "color-background" + } + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "super-light-yellow", + "value": 1000000 + }, + { + "color": "light-orange", + "value": 10000000 + }, + { + "color": "red", + "value": 100000000 + } + ] + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "last_redone_time_utc" + }, + "properties": [ + { + "id": "displayName", + "value": "Last Redone" + }, + { + "id": "unit", + "value": "dateTimeAsIso" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "log_send_rate" + }, + "properties": [ + { + "id": "custom.hidden", + "value": true + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "redo_rate" + }, + "properties": [ + { + "id": "custom.hidden", + "value": true + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "estimated_redo_completion_time_min" + }, + "properties": [ + { + "id": "displayName", + "value": "Approx Redo Time" + }, + { + "id": "unit", + "value": "m" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "last_commit_time_utc" + }, + "properties": [ + { + "id": "displayName", + "value": "Last Commit" + }, + { + "id": "unit", + "value": "dateTimeAsIso" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "is_suspended" + }, + "properties": [ + { + "id": "displayName", + "value": "Is Suspended" + }, + { + "id": "unit", + "value": "bool" + }, + { + "id": "custom.cellOptions", + "value": { + "mode": "basic", + "type": "color-background" + } + }, + { + "id": "mappings", + "value": [ + { + "options": { + "match": "true", + "result": { + "color": "light-red", + "index": 0 + } + }, + "type": "special" + }, + { + "options": { + "match": "false", + "result": { + "color": "super-light-green", + "index": 1 + } + }, + "type": "special" + } + ] + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "suspend_reason_desc" + }, + "properties": [ + { + "id": "displayName", + "value": "Suspend Reason" + }, + { + "id": "unit", + "value": "bool" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "collection_time_utc" + }, + "properties": [ + { + "id": "custom.hidden", + "value": true + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "is_distributed" + }, + "properties": [ + { + "id": "custom.cellOptions", + "value": { + "mode": "basic", + "type": "color-background" + } + }, + { + "id": "mappings", + "value": [ + { + "options": { + "match": "true", + "result": { + "color": "super-light-green", + "index": 0 + } + }, + "type": "special" + }, + { + "options": { + "match": "false", + "result": { + "color": "super-light-blue", + "index": 1 + } + }, + "type": "special" + } + ] + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "sql_instance" + }, + "properties": [ + { + "id": "custom.cellOptions", + "value": { + "mode": "gradient", + "type": "color-background" + } + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "dark-blue" + } + ] + } + }, + { + "id": "links", + "value": [ + { + "targetBlank": true, + "title": "Instance Ag Latency Details", + "url": "d/ag_health_state?var-server=${__data.fields.sql_instance}&viewPanel=147" + } + ] + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "replica_server" + }, + "properties": [ + { + "id": "custom.cellOptions", + "value": { + "mode": "basic", + "type": "color-background" + } + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "blue" + } + ] + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "replica_database" + }, + "properties": [ + { + "id": "custom.minWidth", + "value": 250 + }, + { + "id": "custom.cellOptions", + "value": { + "type": "color-background" + } + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "super-light-purple" + } + ] + } + } + ] + } + ] + }, + "gridPos": { + "h": 7, + "w": 24, + "x": 0, + "y": 412 + }, + "id": 867, + "options": { + "cellHeight": "sm", + "footer": { + "countRows": false, + "enablePagination": true, + "fields": "", + "reducer": [ + "sum" + ], + "show": false + }, + "showHeader": true, + "sortBy": [] + }, + "pluginVersion": "11.1.4", + "targets": [ + { + "datasource": { + "type": "mssql", + "uid": "${DS_SQLMONITOR}" + }, + "editorMode": "code", + "format": "table", + "rawQuery": true, + "rawSql": "set nocount on;\n\ndeclare @_sql nvarchar(max);\ndeclare @_params nvarchar(max);\n\ndeclare @_latency_minutes int;\ndeclare @_redo_queue_size_gb int;\ndeclare @_log_send_queue_size_gb int;\ndeclare @_filter_out_offline_sqlagent bit = 1;\ndeclare @_has_inventory bit = 0;\n\nset @_has_inventory = convert(bit,'${has_inventory}');\nset @_latency_minutes = 30;\nset @_redo_queue_size_gb = 10;\nset @_log_send_queue_size_gb = 10;\n\nset @_params = N'@_latency_minutes int, @_redo_queue_size_gb int, @_log_send_queue_size_gb int';\n\nset @_sql = '\nif object_id(''tempdb..#replica_servers'') is not null\n\tdrop table #replica_servers\nselect distinct ahs.replica_server_name\ninto #replica_servers\nfrom dbo.ag_health_state_all_servers ahs\nwhere 1=1;\n\nselect\tsql_instance, [replica_database] = replica_server_name+'' || ''+database_name,\n\t\t--replica_server_name, database_name, \n\t\tag_name, is_primary_replica, \n\t\tag_listener, is_local, synchronization_state_desc, synchronization_health_desc, \n\t\tlatency_seconds, log_send_queue_size, redo_queue_size, last_redone_time, log_send_rate, \n\t\tredo_rate, estimated_redo_completion_time_min, last_commit_time, is_suspended, \n\t\tsuspend_reason_desc, is_distributed, replica_server = rs.srv_name, updated_date_utc, collection_time_utc\nfrom dbo.ag_health_state_all_servers ahs\nleft join (\tselect replica_server = rs.replica_server_name, srv_name = max(asi.srv_name)\n\t\tfrom #replica_servers rs\n\t\tjoin dbo.vw_all_server_info asi\n\t\t\ton rs.replica_server_name in (asi.machine_name, asi.server_name)\n\t\tgroup by rs.replica_server_name\n\t) rs\n\ton rs.replica_server = ahs.replica_server_name\nwhere 1=1\nand (\tahs.synchronization_health_desc <> ''HEALTHY''\n\tor\tahs.synchronization_state_desc not in (''SYNCHRONIZED'',''SYNCHRONIZING'')\n\tor\t(ahs.latency_seconds is not null and ahs.latency_seconds >= @_latency_minutes*60)\n\tor\t(ahs.log_send_queue_size is not null and ahs.log_send_queue_size >= @_log_send_queue_size_gb*1024*1024)\n\tor\t(ahs.redo_queue_size is not null and ahs.redo_queue_size >= @_redo_queue_size_gb*1024*1024)\n\t)\n'+(case when @_has_inventory = 0 then '--' else '' end)+'and exists (select * from dbo.sma_servers s where s.is_decommissioned = 0 and s.is_onboarded = 1 and s.server = ahs.sql_instance)\n'+(case when @_filter_out_offline_sqlagent = 0 then '--' else '' end)+'and exists (select 1/0 from dbo.services_all_servers sas where sas.sql_instance = ahs.sql_instance and sas.service_type = ''Agent''\tand sas.status_desc = ''Running'');\n';\n\nexec sp_executesql @_sql, @_params, @_latency_minutes, @_redo_queue_size_gb, @_log_send_queue_size_gb;\n", + "refId": "A", + "sql": { + "columns": [ + { + "parameters": [], + "type": "function" + } + ], + "groupBy": [ + { + "property": { + "type": "string" + }, + "type": "groupBy" + } + ], + "limit": 50 + } + } + ], + "title": "All Servers - AlwaysOn Latency - dbo.ag_health_state_all_servers @ ${ag_health_state__collection_time_utc:date:YYYY-MM-DD HH.mm}", + "type": "table" + } + ], + "title": "All Servers - AlwaysOn Latency - \"${ag_issue_counts}\" Require ATTENTION @ ${ag_health_state__collection_time_utc:date:YYYY-MM-DD HH.mm}", + "type": "row" + }, + { + "collapsed": true, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 8 + }, + "id": 858, + "panels": [ + { + "datasource": { + "type": "mssql", + "uid": "${sqlmonitor_datasource}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "custom": { + "align": "center", + "cellOptions": { + "type": "auto" + }, + "filterable": true, + "inspect": true + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "sql_instance" + }, + "properties": [ + { + "id": "displayName", + "value": "Server" + }, + { + "id": "custom.width", + "value": 127 + }, + { + "id": "custom.cellOptions", + "value": { + "mode": "gradient", + "type": "color-background" + } + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "blue" + } + ] + } + }, + { + "id": "links", + "value": [ + { + "targetBlank": true, + "title": "Disk Space Utilization", + "url": "d/disk_space?var-server=${__data.fields.sql_instance}&var-database=${__data.fields.database_name}" + } + ] + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "database_name" + }, + "properties": [ + { + "id": "displayName", + "value": "Database" + }, + { + "id": "custom.cellOptions", + "value": { + "mode": "basic", + "type": "color-background" + } + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "super-light-blue" + } + ] + } + }, + { + "id": "links", + "value": [ + { + "targetBlank": true, + "title": "Disk Space Dashboard", + "url": "d/disk_space?var-server=${__data.fields.sql_instance}&var-database=${__data.fields.database_name}" + } + ] + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "recovery_model" + }, + "properties": [ + { + "id": "displayName", + "value": "Recovery Model" + }, + { + "id": "custom.width", + "value": 127 + }, + { + "id": "custom.cellOptions", + "value": { + "type": "color-text" + } + }, + { + "id": "mappings", + "value": [ + { + "options": { + "SIMPLE": { + "color": "text", + "index": 0 + } + }, + "type": "value" + }, + { + "options": { + "pattern": "^((?!SIMPLE).)*$", + "result": { + "color": "yellow", + "index": 1 + } + }, + "type": "regex" + } + ] + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "log_reuse_wait_desc" + }, + "properties": [ + { + "id": "displayName", + "value": "Log Reuse Wait Desc" + }, + { + "id": "custom.width", + "value": 165 + }, + { + "id": "custom.cellOptions", + "value": { + "type": "color-text" + } + }, + { + "id": "mappings", + "value": [ + { + "options": { + "NOTHING": { + "color": "green", + "index": 0 + } + }, + "type": "value" + }, + { + "options": { + "pattern": "^((?!NOTHING).)*$", + "result": { + "color": "yellow", + "index": 1 + } + }, + "type": "regex" + } + ] + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "log_size_mb" + }, + "properties": [ + { + "id": "displayName", + "value": "Log Size" + }, + { + "id": "unit", + "value": "mbytes" + }, + { + "id": "links", + "value": [ + { + "targetBlank": true, + "title": "Perfmon - Log Usage Trend", + "url": "d/distributed_perfmon?var-server=${__data.fields.sql_instance}&var-database=${__data.fields.database_name}&viewPanel=38" + } + ] + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "log_used_mb" + }, + "properties": [ + { + "id": "displayName", + "value": "Log Used" + }, + { + "id": "unit", + "value": "mbytes" + }, + { + "id": "custom.cellOptions", + "value": { + "mode": "gradient", + "type": "color-background" + } + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "#EAB839", + "value": 102400 + } + ] + } + }, + { + "id": "links", + "value": [ + { + "targetBlank": true, + "title": "Perfmon - Log Usage Trend", + "url": "d/distributed_perfmon?var-server=${__data.fields.sql_instance}&var-database=${__data.fields.database_name}&viewPanel=38" + } + ] + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "log_used_pct" + }, + "properties": [ + { + "id": "displayName", + "value": "Log Used %" + }, + { + "id": "custom.cellOptions", + "value": { + "mode": "gradient", + "type": "color-background" + } + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "#EAB839", + "value": 70 + }, + { + "color": "orange", + "value": 80 + }, + { + "color": "red", + "value": 90 + } + ] + } + }, + { + "id": "unit", + "value": "percent" + }, + { + "id": "links", + "value": [ + { + "targetBlank": true, + "title": "Perfmon - Log % Usage Trend", + "url": "d/distributed_perfmon?var-server=${__data.fields.sql_instance}&var-database=${__data.fields.database_name}&viewPanel=123" + } + ] + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "log_used_pct_threshold" + }, + "properties": [ + { + "id": "custom.hidden", + "value": true + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "log_used_gb_threshold" + }, + "properties": [ + { + "id": "custom.hidden", + "value": true + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "updated_date_utc" + }, + "properties": [ + { + "id": "displayName", + "value": "Updated Date" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "collection_time_utc" + }, + "properties": [ + { + "id": "displayName", + "value": "Collection Time" + }, + { + "id": "unit", + "value": "dateTimeAsSystem" + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "super-light-purple" + } + ] + } + }, + { + "id": "custom.cellOptions", + "value": { + "mode": "basic", + "type": "color-background" + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "spid" + }, + "properties": [ + { + "id": "links", + "value": [ + { + "targetBlank": true, + "title": "sp_WhatsRunning - Session Details", + "url": "d/WhoIsActive?var-server=${__data.fields.sql_instance}&var-session_id=${__data.fields.spid}&viewPanel=132" + } + ] + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "login_name" + }, + "properties": [ + { + "id": "links", + "value": [ + { + "targetBlank": true, + "title": "sp_WhatsRunning - Sessions for Login", + "url": "d/WhoIsActive?var-server=${__data.fields.sql_instance}&var-login_name=${__data.fields.login_name}&viewPanel=132" + } + ] + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "program_name" + }, + "properties": [ + { + "id": "links", + "value": [ + { + "targetBlank": true, + "title": "sp_WhatsRunning - Session Details for Program", + "url": "d/WhoIsActive?var-server=${__data.fields.sql_instance}&var-program_name=${__data.fields.program_name}&viewPanel=132" + } + ] + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "host_name" + }, + "properties": [ + { + "id": "links", + "value": [ + { + "targetBlank": true, + "title": "sp_WhatsRunning - Session Details for Host", + "url": "d/WhoIsActive?var-server=${__data.fields.sql_instance}&var-session_host_name=${__data.fields.host_name}&viewPanel=132" + } + ] + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "exists_valid_autogrowing_file" + }, + "properties": [ + { + "id": "displayName", + "value": "Autogrowth" + }, + { + "id": "custom.cellOptions", + "value": { + "type": "color-text" + } + }, + { + "id": "mappings", + "value": [ + { + "options": { + "match": "true", + "result": { + "color": "green", + "index": 0, + "text": "Yes" + } + }, + "type": "special" + }, + { + "options": { + "match": "false", + "result": { + "color": "orange", + "index": 1, + "text": "No" + } + }, + "type": "special" + } + ] + } + ] + } + ] + }, + "gridPos": { + "h": 8, + "w": 24, + "x": 0, + "y": 413 + }, + "id": 856, + "options": { + "cellHeight": "sm", + "footer": { + "countRows": false, + "enablePagination": true, + "fields": "", + "reducer": [ + "sum" + ], + "show": false + }, + "showHeader": true + }, + "pluginVersion": "11.1.4", + "targets": [ + { + "datasource": { + "type": "mssql", + "uid": "${DS_SQLMONITOR}" + }, + "editorMode": "code", + "format": "table", + "rawQuery": true, + "rawSql": "declare @_log_used_pct float;\r\ndeclare @_log_used_gb float;\r\ndeclare @_only_threshold_validated bit;\r\ndeclare @_has_inventory bit = 0;\r\nset @_has_inventory = convert(bit,'${has_inventory}');\r\n\r\n/* When @_only_threshold_validated = 1, then @_log_used_pct & @_log_used_gb are not used */\r\n\r\ndeclare @_sqltext nvarchar(max);\r\ndeclare @_params nvarchar(max);\r\n\r\nset @_log_used_pct = ${log_used_pct_threshold};\r\nset @_log_used_gb = ${log_used_gb_threshold};\r\nset @_only_threshold_validated = case when '${only_validated_log_thresholds}' = 'Yes' then 1 else 0 end;\r\n\r\nset @_params = '@only_threshold_validated bit, @log_used_pct float, @log_used_gb float';\r\n\r\nset @_sqltext = '\r\nselect\t[collection_time_utc] = [updated_date_utc],\r\n\t\t[sql_instance], [database_name], [recovery_model], [log_reuse_wait_desc], [log_size_mb], [exists_valid_autogrowing_file],\r\n\t\t[log_used_mb], [log_used_pct], [log_used_pct_threshold], [log_used_gb_threshold], [spid], \r\n\t\t[transaction_start_time] = DATEADD(mi, DATEDIFF(mi, getdate(), getutcdate()), [transaction_start_time]), \r\n\t\t[login_name], [program_name], [host_name], [host_process_id], [command], [additional_info], \r\n\t\t[action_taken], [sql_text]\t\t\r\nfrom dbo.log_space_consumers_all_servers ls\r\nwhere 1=1\r\n'+(case when @_only_threshold_validated = 1 then '' else '--' end)+'and ls.thresholds_validated = @only_threshold_validated\r\n'+(case when @_only_threshold_validated = 1 then '--' else '' end)+'and ( (ls.log_used_pct > @log_used_pct)\tor (ls.log_used_mb > (@log_used_gb*1024)) )\r\nand (ls.updated_date_utc >= dateadd(minute,-60,getutcdate())\r\n and ls.collection_time_utc >= dateadd(minute,-20,getutcdate())\r\n\t\t)\r\n'+(case when @_has_inventory = 0 then '--' else '' end)+'and exists (select * from dbo.sma_servers s where s.is_decommissioned = 0 and s.is_onboarded = 1 and s.server = ls.sql_instance)\r\n';\r\n\r\nexec sp_executesql @_sqltext, @_params, @only_threshold_validated=@_only_threshold_validated, @log_used_pct=@_log_used_pct, @log_used_gb=@_log_used_gb;", + "refId": "A", + "sql": { + "columns": [ + { + "parameters": [], + "type": "function" + } + ], + "groupBy": [ + { + "property": { + "type": "string" + }, + "type": "groupBy" + } + ], + "limit": 50 + } + } + ], + "title": "Log Space Consumers @ ${log_space_consumers__collection_time_utc:date:YYYY-MM-DD HH.mm}", + "type": "table" + } + ], + "title": "All Servers - Log Space Utilization - \"${log_space_issue_counts}\" Require ATTENTION @ ${log_space_consumers__collection_time_utc:date:YYYY-MM-DD HH.mm}", + "type": "row" + }, + { + "collapsed": true, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 9 + }, + "id": 862, + "panels": [ + { + "datasource": { + "type": "mssql", + "uid": "${sqlmonitor_datasource}" + }, + "description": "select *\nfrom dbo.tempdb_space_consumers tsc\nwhere 1=1\nand tsc.collection_time = (select top 1 i.collection_time from dbo.tempdb_space_consumers i order by i.collection_time desc)", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "custom": { + "align": "auto", + "cellOptions": { + "type": "auto" + }, + "filterable": true, + "inspect": true + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "sql_instance" + }, + "properties": [ + { + "id": "custom.width", + "value": 150 + }, + { + "id": "custom.cellOptions", + "value": { + "mode": "gradient", + "type": "color-background" + } + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "blue" + } + ] + } + }, + { + "id": "displayName", + "value": "Server" + }, + { + "id": "links", + "value": [ + { + "targetBlank": true, + "title": "Disk Space for TempDb", + "url": "d/disk_space?var-server=${__data.fields.sql_instance}&var-database=tempdb" + } + ] + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "data_size_mb" + }, + "properties": [ + { + "id": "unit", + "value": "mbytes" + }, + { + "id": "displayName", + "value": "Data Size" + }, + { + "id": "links", + "value": [ + { + "targetBlank": true, + "title": "Perfmon - Data File Growth Trend", + "url": "d/distributed_perfmon?var-server=${__data.fields.sql_instance}&var-database=tempdb&viewPanel=115" + } + ] + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "data_used_mb" + }, + "properties": [ + { + "id": "displayName", + "value": "Data Used" + }, + { + "id": "unit", + "value": "mbytes" + }, + { + "id": "links", + "value": [ + { + "targetBlank": true, + "title": "Perfmon - Tempdb Free Space Trend", + "url": "d/distributed_perfmon?var-server=${__data.fields.sql_instance}&var-database=tempdb&viewPanel=89" + } + ] + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "data_used_pct" + }, + "properties": [ + { + "id": "displayName", + "value": "Data Used %" + }, + { + "id": "custom.cellOptions", + "value": { + "mode": "gradient", + "type": "color-background" + } + }, + { + "id": "unit", + "value": "percent" + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "yellow", + "value": 70 + }, + { + "color": "orange", + "value": 80 + }, + { + "color": "super-light-red", + "value": 90 + }, + { + "color": "red", + "value": 95 + } + ] + } + }, + { + "id": "links", + "value": [ + { + "targetBlank": true, + "title": "Perfmon - Tempdb % Free Trend", + "url": "d/distributed_perfmon?var-server=${__data.fields.sql_instance}&var-database=tempdb&viewPanel=89" + } + ] + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "log_size_mb" + }, + "properties": [ + { + "id": "displayName", + "value": "Log Size" + }, + { + "id": "unit", + "value": "mbytes" + }, + { + "id": "links", + "value": [ + { + "targetBlank": true, + "title": "Perfmon - Log Usage Trend", + "url": "d/distributed_perfmon?var-server=${__data.fields.sql_instance}&var-database=tempdb&viewPanel=38" + } + ] + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "log_used_mb" + }, + "properties": [ + { + "id": "displayName", + "value": "Log Used" + }, + { + "id": "unit", + "value": "mbytes" + }, + { + "id": "links", + "value": [ + { + "targetBlank": true, + "title": "Perfmon - Log Usage Trend", + "url": "d/distributed_perfmon?var-server=${__data.fields.sql_instance}&var-database=tempdb&viewPanel=38" + } + ] + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "log_used_pct" + }, + "properties": [ + { + "id": "displayName", + "value": "Log Used %" + }, + { + "id": "unit", + "value": "percent" + }, + { + "id": "custom.cellOptions", + "value": { + "mode": "gradient", + "type": "color-background" + } + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "#EAB839", + "value": 70 + }, + { + "color": "orange", + "value": 80 + }, + { + "color": "red", + "value": 90 + } + ] + } + }, + { + "id": "links", + "value": [ + { + "targetBlank": true, + "title": "Perfmon - Log Usage % Trend", + "url": "d/distributed_perfmon?var-server=${__data.fields.sql_instance}&var-database=tempdb&viewPanel=123" + } + ] + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "version_store_mb" + }, + "properties": [ + { + "id": "displayName", + "value": "Version Store" + }, + { + "id": "unit", + "value": "mbytes" + }, + { + "id": "links", + "value": [ + { + "targetBlank": true, + "title": "Tempdb Space Consumers on Individual Server Dashboard", + "url": "d/distributed_live_dashboard?var-server=${__data.fields.sql_instance}&viewPanel=190" + } + ] + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "version_store_pct" + }, + "properties": [ + { + "id": "displayName", + "value": "Version Store %" + }, + { + "id": "unit", + "value": "percent" + }, + { + "id": "custom.cellOptions", + "value": { + "mode": "gradient", + "type": "color-background" + } + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "#EAB839", + "value": 70 + }, + { + "color": "orange", + "value": 80 + }, + { + "color": "red", + "value": 90 + } + ] + } + }, + { + "id": "links", + "value": [ + { + "targetBlank": true, + "title": "Perfmon - VersionStore Usage Trend", + "url": "d/distributed_perfmon?var-server=${__data.fields.sql_instance}&var-database=tempdb&viewPanel=90" + } + ] + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "collection_time_utc" + }, + "properties": [ + { + "id": "custom.hidden", + "value": false + }, + { + "id": "displayName", + "value": "Collection Time" + }, + { + "id": "unit", + "value": "dateTimeAsIso" + }, + { + "id": "custom.cellOptions", + "value": { + "mode": "basic", + "type": "color-background" + } + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "super-light-purple" + } + ] + } + }, + { + "id": "custom.width", + "value": 160 + } + ] + } + ] + }, + "gridPos": { + "h": 8, + "w": 24, + "x": 0, + "y": 316 + }, + "id": 860, + "options": { + "cellHeight": "sm", + "footer": { + "countRows": false, + "enablePagination": true, + "fields": "", + "reducer": [ + "sum" + ], + "show": false + }, + "showHeader": true + }, + "pluginVersion": "11.3.1", + "targets": [ + { + "datasource": { + "type": "mssql", + "uid": "${DS_SQLMONITOR}" + }, + "editorMode": "code", + "format": "table", + "rawQuery": true, + "rawSql": "declare @_data_used_pct float = ${tempdb_used_pct_threshold};\r\ndeclare @_data_used_gb float = ${tempdb_used_gb_threshold};\r\ndeclare @_has_inventory bit = 0;\r\nset @_has_inventory = convert(bit,'${has_inventory}');\r\n\r\ndeclare @_sqltext nvarchar(max);\r\ndeclare @_params nvarchar(max);\r\n\r\nset @_params = '@data_used_pct float, @data_used_gb float';\r\n\r\n\r\nset @_sqltext = '\r\nselect\t[collection_time_utc] = [updated_date_utc],\r\n\t\t[sql_instance], [data_size_mb], [data_used_mb], [data_used_pct], [log_size_mb], [log_used_mb], \r\n\t\t[log_used_pct], [version_store_mb], [version_store_pct]\r\nfrom dbo.tempdb_space_usage_all_servers su\r\nwhere (su.data_used_pct > @data_used_pct\r\n\tor su.data_used_mb > (@data_used_gb*1024) -- 200 gb\r\n\t)\r\nand (su.updated_date_utc >= dateadd(minute,-60,getutcdate())\r\n and su.collection_time_utc >= dateadd(minute,-20,getutcdate())\r\n\t)\r\n'+(case when @_has_inventory = 0 then '--' else '' end)+'and exists (select * from dbo.sma_servers s where s.is_decommissioned = 0 and s.is_onboarded = 1 and s.server = su.sql_instance)\r\n'\r\nexec sp_executesql @_sqltext, @_params, @data_used_pct = @_data_used_pct, @data_used_gb = @_data_used_gb;", + "refId": "A", + "sql": { + "columns": [ + { + "parameters": [], + "type": "function" + } + ], + "groupBy": [ + { + "property": { + "type": "string" + }, + "type": "groupBy" + } + ], + "limit": 50 + } + } + ], + "title": "TempDb Usage @ ${tempdb_space_usage__collection_time_utc:date:YYYY-MM-DD HH.mm}", + "type": "table" + } + ], + "title": "All Servers - Tempdb Utilization - \"${tempdb_space_issue_counts}\" Require ATTENTION @ ${tempdb_space_usage__collection_time_utc:date:YYYY-MM-DD HH.mm}", + "type": "row" + }, + { + "collapsed": true, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 10 + }, + "id": 889, + "panels": [ + { + "datasource": { + "type": "mssql", + "uid": "${sqlmonitor_datasource}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "custom": { + "align": "auto", + "cellOptions": { + "type": "auto", + "wrapText": true + }, + "filterable": true, + "inspect": true + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + } + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "error_number" + }, + "properties": [ + { + "id": "custom.width", + "value": 120 + }, + { + "id": "custom.cellOptions", + "value": { + "type": "color-text" + } + }, + { + "id": "links", + "value": [ + { + "targetBlank": true, + "title": "Error KB", + "url": "https://learn.microsoft.com/en-us/sql/relational-databases/errors-events/mssqlserver-${__data.fields.error_number}-database-engine-error" + } + ] + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "red", + "value": null + } + ] + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "error_severity" + }, + "properties": [ + { + "id": "custom.width", + "value": 128 + }, + { + "id": "custom.cellOptions", + "value": { + "type": "color-text" + } + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "orange", + "value": null + }, + { + "color": "red", + "value": 20 + } + ] + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "error_message" + }, + "properties": [ + { + "id": "custom.align", + "value": "left" + }, + { + "id": "custom.cellOptions", + "value": { + "type": "color-background" + } + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "sql_instance | occurrences | last_occurred" + }, + "properties": [ + { + "id": "custom.align", + "value": "left" + }, + { + "id": "custom.cellOptions", + "value": { + "type": "color-background" + } + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "super-light-blue", + "value": null + } + ] + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "sql_instances" + }, + "properties": [ + { + "id": "custom.hidden", + "value": true + } + ] + } + ] + }, + "gridPos": { + "h": 10, + "w": 24, + "x": 0, + "y": 11 + }, + "id": 890, + "options": { + "cellHeight": "sm", + "footer": { + "countRows": false, + "fields": "", + "reducer": [ + "sum" + ], + "show": false + }, + "showHeader": true, + "sortBy": [] + }, + "pluginVersion": "11.3.1", + "targets": [ + { + "dataset": "AdventureWorks2019", + "datasource": { + "type": "mssql", + "uid": "${DS_SQLMONITOR}" + }, + "editorMode": "code", + "expr": "", + "format": "table", + "legendFormat": "__auto", + "range": true, + "rawQuery": true, + "rawSql": "declare @sql nvarchar(max);\r\ndeclare @params nvarchar(max);\r\ndeclare @sql_instance varchar(max);\r\ndeclare @start_time_utc datetime2;\r\ndeclare @end_time_utc datetime2;\r\ndeclare @_has_inventory bit = 0;\r\nset @_has_inventory = convert(bit,'${has_inventory}');\r\n\r\n--set @sql_instance = case when ltrim(rtrim(@database)) = '__All__' then null else @database end;\r\n\r\nset @start_time_utc = $__timeFrom();\r\nset @end_time_utc = $__timeTo();\r\n\r\nset @params = N'@start_time_utc datetime2, @end_time_utc datetime2';\r\n\r\nset quoted_identifier off;\r\nset @sql = \"/* SQLMonitor - All Server Alert History */\r\nset nocount on;\r\n;with t_aggregated_messages as (\r\nselect a.sql_instance, a.error_number, a.error_severity, occurrences = count(*), last_occurred = max(a.collection_time_utc), error_message = coalesce(max(m.text), max(a.error_message))\r\n --a.collection_time_utc, a.sql_instance, a.server_name, a.database_name, a.error_number, \r\n --a.error_severity, a.error_message, a.host_instance, a.updated_time_utc\r\nfrom dbo.alert_history_all_servers a\r\nleft join sys.messages m \r\n on m.language_id = 1033 and m.message_id = a.error_number\r\nwhere 1 = 1\r\nand a.collection_time_utc between @start_time_utc and @end_time_utc\r\nand (case when a.error_number = 50000 and error_severity = 20 and a.error_message like '%application intent is set to read only%'\r\n then 0\r\n when a.error_number = 1204 then 0\r\n when a.error_number = 50000 and error_severity = 20 and a.error_message like 'Error: 50000 Severity: 20 State: 1 Could not create constraint or index. See previous errors. '\r\n then 0\r\n when a.error_number = 50000 and error_severity = 20 and a.error_message like 'Error: 50000 Severity: 20 State: 1 The instance of the SQL Server Database Engine cannot obtain a LOCK resource at this time%'\r\n then 0\r\n when a.error_number = 17806 and error_severity = 20 and a.error_message like 'SSPI handshake failed with error code 0x8009030c%'\r\n then 0\r\n when a.error_number = 50000 and error_severity = 20 and a.error_message like 'Error: 50000 Severity: 20 State: 1 Lock request time out period exceeded. '\r\n then 0\r\n when a.error_number = 976 and error_severity = 14 and a.error_message like '%Either data movement is suspended or the availability replica is not enabled for read access%'\r\n then 0\r\n when a.error_number = 5084 and error_severity = 10 and a.error_message like 'Setting database option MULTI_USER to ON%'\r\n then 0\r\n when a.error_number = 5084 and error_severity = 10 and a.error_message like 'Setting database option SINGLE_USER to ON%'\r\n then 0\r\n when a.error_number = 14151 and error_severity = 18 and a.error_message like '%Named Pipes Provider: Could not open a connection to SQL Server%'\r\n then 0\r\n when a.error_number = 17828 and error_severity = 20\r\n then 0\r\n when a.error_number in (17832, 17836)\r\n then 0\r\n else 1\r\n end\r\n ) = 1\r\n\"+(case when @_has_inventory = 0 then '--' else '' end)+\"and exists (select * from dbo.sma_servers s where s.is_decommissioned = 0 and s.is_onboarded = 1 and s.server = a.sql_instance)\r\ngroup by a.sql_instance, a.error_number, a.error_severity\r\n--order by error_severity desc, occurrences desc, sql_instance\r\n)\r\n,t_unique_errors as (\r\nselect error_number, error_severity, error_message\r\n --,sql_instance, occurrences, last_occurred\r\nfrom t_aggregated_messages\r\ngroup by error_number, error_severity, error_message\r\n)\r\nselect error_number, error_severity, error_message,\r\n [sql_instance | occurrences | last_occurred] = \r\n stuff(( SELECT ', ' + cc.[sql_instance | occurrences | last_occurred]\r\n FROM t_aggregated_messages am\r\n outer apply (select [last_occurred_localtime] = DATEADD(mi, DATEDIFF(mi, GETUTCDATE(), GETDATE()), last_occurred) ) lt\r\n outer apply (select [sql_instance | occurrences | last_occurred] = '('+sql_instance+' | '+convert(varchar(10),occurrences)+' | '+convert(varchar,lt.last_occurred_localtime,120)+')') cc\r\n where am.error_number = ue.error_number and am.error_severity = ue.error_severity\r\n order by occurrences desc\r\n FOR XML PATH('')\r\n ), 1, 2, ''),\r\n [sql_instances] = \r\n stuff(( SELECT ', ' + cc.sql_instance_quoted\r\n FROM t_aggregated_messages am\r\n outer apply (select sql_instance_quoted = quotename(sql_instance,'''')) cc\r\n where am.error_number = ue.error_number and am.error_severity = ue.error_severity\r\n FOR XML PATH('')\r\n ), 1, 2, '')\r\nfrom t_unique_errors ue\r\n\"\r\nset quoted_identifier on;\r\n\r\nexec dbo.sp_executesql @sql, @params, @start_time_utc, @end_time_utc;", + "refId": "A", + "sql": { + "columns": [ + { + "parameters": [], + "type": "function" + } + ], + "groupBy": [ + { + "property": { + "type": "string" + }, + "type": "groupBy" + } + ], + "limit": 50 + } + } + ], + "title": "Alerts Aggregated by Type - \"${alert_history_aggregated_row_count}\" Total - Between ____${__from:date:YYYY-MM-DD HH.mm}___to___${__to:date:YYYY-MM-DD HH.mm}____", + "type": "table" + }, + { + "datasource": { + "type": "mssql", + "uid": "${sqlmonitor_datasource}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "custom": { + "align": "auto", + "cellOptions": { + "type": "auto", + "wrapText": false + }, + "filterable": true, + "inspect": true + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + } + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "collection_time_utc" + }, + "properties": [ + { + "id": "displayName", + "value": "collection_time" + }, + { + "id": "custom.cellOptions", + "value": { + "type": "color-background", + "wrapText": true + } + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "dark-blue", + "value": null + } + ] + } + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "sql_instance" + }, + "properties": [ + { + "id": "custom.cellOptions", + "value": { + "type": "color-background", + "wrapText": true + } + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "blue", + "value": null + } + ] + } + }, + { + "id": "custom.width", + "value": 218 + }, + { + "id": "links", + "value": [ + { + "targetBlank": true, + "title": "Live Server Health Dashboard", + "url": "d/distributed_live_dashboard?var-server=${__data.fields.sql_instance}" + } + ] + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "server_name" + }, + "properties": [ + { + "id": "custom.hidden", + "value": true + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "database_name" + }, + "properties": [ + { + "id": "custom.cellOptions", + "value": { + "type": "color-background", + "wrapText": true + } + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "super-light-blue", + "value": null + } + ] + } + }, + { + "id": "custom.width", + "value": 189 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "error_number" + }, + "properties": [ + { + "id": "custom.cellOptions", + "value": { + "type": "color-text" + } + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "red", + "value": null + } + ] + } + }, + { + "id": "custom.width", + "value": 124 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "error_severity" + }, + "properties": [ + { + "id": "custom.cellOptions", + "value": { + "type": "color-text" + } + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "yellow", + "value": null + }, + { + "color": "red", + "value": 20 + } + ] + } + }, + { + "id": "custom.width", + "value": 126 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "error_message" + }, + "properties": [ + { + "id": "custom.cellOptions", + "value": { + "type": "color-background", + "wrapText": false + } + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "super-light-yellow", + "value": null + } + ] + } + }, + { + "id": "custom.minWidth", + "value": 400 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "host_instance" + }, + "properties": [ + { + "id": "custom.hidden", + "value": true + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "updated_time_utc" + }, + "properties": [ + { + "id": "custom.hidden", + "value": true + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "collection_time" + }, + "properties": [ + { + "id": "custom.width", + "value": 152 + } + ] + } + ] + }, + "gridPos": { + "h": 12, + "w": 24, + "x": 0, + "y": 21 + }, + "id": 873, + "options": { + "cellHeight": "sm", + "footer": { + "countRows": false, + "fields": "", + "reducer": [ + "sum" + ], + "show": false + }, + "showHeader": true, + "sortBy": [] + }, + "pluginVersion": "11.3.1", + "targets": [ + { + "dataset": "AdventureWorks2019", + "datasource": { + "type": "mssql", + "uid": "${DS_SQLMONITOR}" + }, + "editorMode": "code", + "format": "table", + "rawQuery": true, + "rawSql": "declare @sql nvarchar(max);\r\ndeclare @params nvarchar(max);\r\ndeclare @sql_instance varchar(max);\r\ndeclare @start_time_utc datetime2;\r\ndeclare @end_time_utc datetime2;\r\ndeclare @_has_inventory bit = 0;\r\nset @_has_inventory = convert(bit,'${has_inventory}');\r\n\r\n--set @sql_instance = case when ltrim(rtrim(@database)) = '__All__' then null else @database end;\r\n\r\nset @start_time_utc = $__timeFrom();\r\nset @end_time_utc = $__timeTo();\r\n\r\nset @params = N'@start_time_utc datetime2, @end_time_utc datetime2';\r\n\r\nset quoted_identifier off;\r\nset @sql = \"/* SQLMonitor - All Server Alert History */\r\nset nocount on;\r\nselect a.collection_time_utc, a.sql_instance, a.database_name, a.error_number, \r\n a.error_severity, a.error_message \r\n --, a.host_instance, a.updated_time_utc, a.server_name\r\nfrom dbo.alert_history_all_servers a\r\nwhere 1 = 1\r\nand a.collection_time_utc between @start_time_utc and @end_time_utc\r\nand (case when a.error_number = 50000 and error_severity = 20 and a.error_message like '%application intent is set to read only%'\r\n then 0\r\n when a.error_number = 1204 then 0\r\n when a.error_number = 50000 and error_severity = 20 and a.error_message like 'Error: 50000 Severity: 20 State: 1 Could not create constraint or index. See previous errors. '\r\n then 0\r\n when a.error_number = 50000 and error_severity = 20 and a.error_message like 'Error: 50000 Severity: 20 State: 1 The instance of the SQL Server Database Engine cannot obtain a LOCK resource at this time%'\r\n then 0\r\n when a.error_number = 17806 and error_severity = 20 and a.error_message like 'SSPI handshake failed with error code 0x8009030c%'\r\n then 0\r\n when a.error_number = 50000 and error_severity = 20 and a.error_message like 'Error: 50000 Severity: 20 State: 1 Lock request time out period exceeded. '\r\n then 0\r\n when a.error_number = 976 and error_severity = 14 and a.error_message like '%Either data movement is suspended or the availability replica is not enabled for read access%'\r\n then 0\r\n else 1\r\n end\r\n ) = 1\r\n\"+(case when @_has_inventory = 0 then '--' else '' end)+\"and exists (select * from dbo.sma_servers s where s.is_decommissioned = 0 and s.is_onboarded = 1 and s.server = a.sql_instance)\r\norder by 1 desc, 2\r\n\"\r\nset quoted_identifier on;\r\n\r\nexec dbo.sp_executesql @sql, @params, @start_time_utc, @end_time_utc;", + "refId": "A", + "sql": { + "columns": [ + { + "parameters": [], + "type": "function" + } + ], + "groupBy": [ + { + "property": { + "type": "string" + }, + "type": "groupBy" + } + ], + "limit": 50 + } + } + ], + "title": "All Servers - Alert History - \"${alert_history_row_count}\" Total - Between ____${__from:date:YYYY-MM-DD HH.mm}___to___${__to:date:YYYY-MM-DD HH.mm}____", + "type": "table" + } + ], + "title": "All Servers - Alert History - \"${alert_history_aggregated_row_count}/${alert_history_row_count}\" Total - Between ____${__from:date:YYYY-MM-DD HH.mm}___to___${__to:date:YYYY-MM-DD HH.mm}____", + "type": "row" + }, + { + "collapsed": false, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 11 + }, + "id": 245, + "panels": [], + "title": "All Servers - Health Metrics - \"${core_metrics_issue_counts}\" Require ATTENTION @ ${all_server_volatile_info__collection_time_utc:date:YYYY-MM-DD HH.mm}", + "type": "row" + }, + { + "datasource": { + "default": false, + "type": "mssql", + "uid": "${sqlmonitor_datasource}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "custom": { + "align": "center", + "cellOptions": { + "type": "auto", + "wrapText": true + }, + "filterable": true, + "inspect": false + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + }, + "unit": "none" + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "os_cpu" + }, + "properties": [ + { + "id": "custom.cellOptions", + "value": { + "mode": "gradient", + "type": "color-background" + } + }, + { + "id": "color" + }, + { + "id": "unit", + "value": "percent" + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "yellow", + "value": 70 + }, + { + "color": "orange", + "value": 80 + }, + { + "color": "red", + "value": 90 + } + ] + } + }, + { + "id": "displayName", + "value": "OS CPU" + }, + { + "id": "links", + "value": [ + { + "targetBlank": true, + "title": "Perfmon - CPU Trend", + "url": "d/distributed_perfmon?var-server=${__data.fields.srv_name}&viewPanel=62" + } + ] + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "sql_cpu" + }, + "properties": [ + { + "id": "custom.cellOptions", + "value": { + "mode": "gradient", + "type": "color-background" + } + }, + { + "id": "unit", + "value": "percent" + }, + { + "id": "color" + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "#EAB839", + "value": 65 + }, + { + "color": "orange", + "value": 70 + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + { + "id": "displayName", + "value": "SQL CPU" + }, + { + "id": "links", + "value": [ + { + "targetBlank": true, + "title": "Perfmon - CPU Trend", + "url": "d/distributed_perfmon?var-server=${__data.fields.srv_name}&viewPanel=62" + } + ] + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "waits_per_core_per_minute" + }, + "properties": [ + { + "id": "custom.cellOptions", + "value": { + "mode": "gradient", + "type": "color-background" + } + }, + { + "id": "unit", + "value": "s" + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "yellow", + "value": 180 + }, + { + "color": "orange", + "value": 240 + }, + { + "color": "red", + "value": 300 + } + ] + } + }, + { + "id": "displayName", + "value": "Waits Per Core Per Minute" + }, + { + "id": "links", + "value": [ + { + "targetBlank": true, + "title": "Wait Stats Dashboard", + "url": "d/wait_stats?var-server=${__data.fields.srv_name}&from=now-30m&to=now" + } + ] + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "blocked_counts" + }, + "properties": [ + { + "id": "custom.cellOptions", + "value": { + "mode": "gradient", + "type": "color-background" + } + }, + { + "id": "unit", + "value": "short" + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "yellow", + "value": 1 + }, + { + "color": "orange", + "value": 5 + }, + { + "color": "red", + "value": 10 + } + ] + } + }, + { + "id": "displayName", + "value": "Blocked Over '60' Seconds" + }, + { + "id": "links", + "value": [ + { + "targetBlank": true, + "title": "Blocked Processes Trend", + "url": "d/distributed_perfmon?var-server=${__data.fields.srv_name}&viewPanel=16" + } + ] + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "blocked_duration_max_seconds" + }, + "properties": [ + { + "id": "custom.cellOptions", + "value": { + "mode": "gradient", + "type": "color-background" + } + }, + { + "id": "unit", + "value": "s" + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "super-light-yellow", + "value": 60 + }, + { + "color": "yellow", + "value": 120 + }, + { + "color": "super-light-orange", + "value": 300 + }, + { + "color": "orange", + "value": 600 + }, + { + "color": "red", + "value": 1800 + } + ] + } + }, + { + "id": "displayName", + "value": "Longest Blocking" + }, + { + "id": "links", + "value": [ + { + "targetBlank": true, + "title": "Blocking Tree With Queries", + "url": "d/distributed_live_dashboard?var-server=${__data.fields.srv_name}&viewPanel=111" + } + ] + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "available_physical_memory_kb" + }, + "properties": [ + { + "id": "displayName", + "value": "Available Memory" + }, + { + "id": "custom.cellOptions", + "value": { + "mode": "gradient", + "type": "color-background" + } + }, + { + "id": "unit", + "value": "kbytes" + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "red", + "value": null + }, + { + "color": "orange", + "value": 512000 + }, + { + "color": "yellow", + "value": 2097152 + }, + { + "color": "green", + "value": 4194304 + } + ] + } + }, + { + "id": "links", + "value": [ + { + "targetBlank": true, + "title": "SQL M/r Consumption", + "url": "d/distributed_perfmon?var-server=${__data.fields.srv_name}&viewPanel=26" + } + ] + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "system_high_memory_signal_state" + }, + "properties": [ + { + "id": "custom.hidden" + }, + { + "id": "unit", + "value": "string" + }, + { + "id": "custom.cellOptions", + "value": { + "mode": "gradient", + "type": "color-background" + } + }, + { + "id": "displayName", + "value": "OS Memory State" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "physical_memory_in_use_kb" + }, + "properties": [ + { + "id": "displayName", + "value": "Used SQL Memory" + }, + { + "id": "custom.cellOptions", + "value": { + "mode": "gradient", + "type": "color-background" + } + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "purple", + "value": null + } + ] + } + }, + { + "id": "unit", + "value": "kbytes" + }, + { + "id": "links", + "value": [ + { + "targetBlank": true, + "title": "SQL M/r Usage", + "url": "d/distributed_perfmon?var-server=${__data.fields.srv_name}&viewPanel=30" + } + ] + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "memory_grants_pending" + }, + "properties": [ + { + "id": "custom.cellOptions", + "value": { + "mode": "gradient", + "type": "color-background" + } + }, + { + "id": "unit", + "value": "none" + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 1 + } + ] + } + }, + { + "id": "displayName", + "value": "Memory Grant Pending" + }, + { + "id": "unit", + "value": "short" + }, + { + "id": "links", + "value": [ + { + "targetBlank": true, + "title": "Memory Consumers", + "url": "d/WhoIsActive?var-server=${__data.fields.srv_name}&viewPanel=122" + } + ] + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "srv_name" + }, + "properties": [ + { + "id": "custom.width", + "value": 127 + }, + { + "id": "displayName", + "value": "Server" + }, + { + "id": "custom.cellOptions", + "value": { + "mode": "gradient", + "type": "color-background" + } + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "blue", + "value": null + } + ] + } + }, + { + "id": "links", + "value": [ + { + "targetBlank": true, + "title": "Live Health", + "url": "d/distributed_live_dashboard?var-server=${__data.fields.srv_name}" + } + ] + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "connection_count" + }, + "properties": [ + { + "id": "displayName", + "value": "SQL Connections" + }, + { + "id": "custom.cellOptions", + "value": { + "mode": "gradient", + "type": "color-background" + } + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "#EAB839", + "value": 800 + }, + { + "color": "#EF843C", + "value": 1000 + }, + { + "color": "red", + "value": 1200 + } + ] + } + }, + { + "id": "links", + "value": [ + { + "targetBlank": true, + "title": "Connection Distribution", + "url": "d/distributed_live_dashboard?var-server=${__data.fields.srv_name}&viewPanel=124" + } + ] + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "avg_disk_latency_ms" + }, + "properties": [ + { + "id": "displayName", + "value": "Disk Latency" + }, + { + "id": "custom.cellOptions", + "value": { + "type": "color-background" + } + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "#EAB839", + "value": 10 + }, + { + "color": "orange", + "value": 15 + }, + { + "color": "red", + "value": 20 + } + ] + } + }, + { + "id": "links", + "value": [ + { + "targetBlank": true, + "title": "Wait Stats Dashboard", + "url": "d/wait_stats?var-server=${__data.fields.srv_name}&from=now-30m&to=now" + }, + { + "targetBlank": true, + "title": "Perfmon - Disk Latency", + "url": "d/distributed_perfmon?var-server=${__data.fields.srv_name}&viewPanel=112" + }, + { + "targetBlank": true, + "title": "File IO Stats", + "url": "d/database_file_io_stats?var-server=${__data.fields.srv_name}&viewPanel=18&from=now-30m&to=now" + } + ] + }, + { + "id": "unit", + "value": "ms" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "issue_rank" + }, + "properties": [ + { + "id": "custom.hidden", + "value": true + } + ] + } + ] + }, + "gridPos": { + "h": 12, + "w": 24, + "x": 0, + "y": 12 + }, + "id": 842, + "options": { + "cellHeight": "sm", + "footer": { + "countRows": false, + "fields": "", + "reducer": [ + "sum" + ], + "show": false + }, + "showHeader": true, + "sortBy": [] + }, + "pluginVersion": "11.3.1", + "targets": [ + { + "alias": "", + "datasource": { + "type": "mssql", + "uid": "${DS_SQLMONITOR}" + }, + "editorMode": "code", + "format": "table", + "rawQuery": true, + "rawSql": "declare @os_cpu_threshold decimal(20,2) = 70;\ndeclare @sql_cpu_threshold decimal(20,2) = 65;\ndeclare @blocked_counts_threshold int = 1;\ndeclare @blocked_duration_max_seconds_threshold bigint = 60;\ndeclare @available_physical_memory_kb_threshold bigint = (4*1024*1024);\ndeclare @system_high_memory_signal_state_threshold varchar(20) = 'Low';\n--declare @physical_memory_in_use_kb_threshold decimal(20,2);\ndeclare @memory_grants_pending_threshold int = 1;\ndeclare @connection_count_threshold int = 1000;\ndeclare @waits_per_core_per_minute_threshold decimal(20,2) = 180;\ndeclare @avg_disk_latency_ms int = 10;\ndeclare @_has_inventory bit = 0;\n\nset @_has_inventory = convert(bit,'${has_inventory}');\n\ndeclare @sql nvarchar(max);\ndeclare @params nvarchar(max);\n\nset @params = N'@os_cpu_threshold decimal(20,2), @sql_cpu_threshold decimal(20,2), @blocked_counts_threshold int, \n\t\t\t\t@blocked_duration_max_seconds_threshold bigint, @available_physical_memory_kb_threshold bigint, \n\t\t\t\t@system_high_memory_signal_state_threshold varchar(20), @memory_grants_pending_threshold int, \n\t\t\t\t@connection_count_threshold int, @waits_per_core_per_minute_threshold decimal(20,2), @avg_disk_latency_ms int';\n\nset quoted_identifier off;\nset @sql = \"\n;with t_cte as (\n\tselect\tsrv_name, os_cpu, sql_cpu, blocked_counts, blocked_duration_max_seconds, avg_disk_latency_ms, available_physical_memory_kb,\n physical_memory_in_use_kb, memory_grants_pending, connection_count, waits_per_core_per_minute, system_high_memory_signal_state\n ,issue_rank = (case when os_cpu >= 90 then 3 when os_cpu >= @os_cpu_threshold then 1 else 0 end) +\n (case when os_cpu >= 80 then 3 when sql_cpu >= @sql_cpu_threshold then 1 else 0 end) +\n (case when blocked_counts >= 20 then 5\n when blocked_counts >= 10 then 4\n when blocked_counts >= 5 then 2\n when blocked_counts >= @blocked_counts_threshold then 1\n else 0\n end) +\n (case when blocked_duration_max_seconds >= @blocked_duration_max_seconds_threshold then 1 else 0 end) +\n (case when ( available_physical_memory_kb < @available_physical_memory_kb_threshold and system_high_memory_signal_state = @system_high_memory_signal_state_threshold ) then 1 else 0 end) +\n (case when memory_grants_pending > 10 then 5\n when memory_grants_pending > 5 then 4\n when memory_grants_pending > @memory_grants_pending_threshold then 2\n else 0\n end) +\n (case when connection_count >= @connection_count_threshold then 1 else 0 end) +\n (case when avg_disk_latency_ms >= 100 then 5\n when avg_disk_latency_ms >= 80 then 4\n when avg_disk_latency_ms >= 50 then 3\n when avg_disk_latency_ms >= 35 then 2\n when avg_disk_latency_ms >= @avg_disk_latency_ms then 1\n else 0\n end) +\n (case when waits_per_core_per_minute > @waits_per_core_per_minute_threshold then 1 else 0 end)\n\tfrom dbo.vw_all_server_info\n)\nselect *\nfrom t_cte cte\nwhere 1=1\nand ( os_cpu >= @os_cpu_threshold\n or sql_cpu >= @sql_cpu_threshold \n or blocked_counts >= @blocked_counts_threshold\n or blocked_duration_max_seconds >= @blocked_duration_max_seconds_threshold\n or ( available_physical_memory_kb < @available_physical_memory_kb_threshold and system_high_memory_signal_state = @system_high_memory_signal_state_threshold )\n or memory_grants_pending > @memory_grants_pending_threshold\n or connection_count >= @connection_count_threshold\n or waits_per_core_per_minute > @waits_per_core_per_minute_threshold\n or avg_disk_latency_ms >= @avg_disk_latency_ms\n)\n\"+(case when @_has_inventory = 0 then '--' else '' end)+\"and exists (select * from dbo.sma_servers s where s.is_decommissioned = 0 and s.is_onboarded = 1 and s.server = cte.srv_name)\norder by issue_rank desc, avg_disk_latency_ms desc, srv_name\n\";\nset quoted_identifier off;\n\n--print @sql\nexec dbo.sp_executesql @sql, @params, @os_cpu_threshold, @sql_cpu_threshold, @blocked_counts_threshold, @blocked_duration_max_seconds_threshold, \n@available_physical_memory_kb_threshold, @system_high_memory_signal_state_threshold, @memory_grants_pending_threshold, \n@connection_count_threshold, @waits_per_core_per_minute_threshold, @avg_disk_latency_ms;", + "refId": "A", + "sql": { + "columns": [ + { + "parameters": [], + "type": "function" + } + ], + "groupBy": [ + { + "property": { + "type": "string" + }, + "type": "groupBy" + } + ], + "limit": 50 + } + } + ], + "title": "Servers Need Help - Health Metrics @ ${collection_time_utc:date:YYYY-MM-DD HH.mm}", + "type": "table" + }, + { + "collapsed": true, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 24 + }, + "id": 121, + "panels": [ + { + "description": "", + "fieldConfig": { + "defaults": {}, + "overrides": [] + }, + "gridPos": { + "h": 7, + "w": 24, + "x": 0, + "y": 462 + }, + "id": 119, + "options": { + "folderId": 4, + "maxItems": 10, + "query": "", + "showHeadings": false, + "showRecentlyViewed": false, + "showSearch": true, + "showStarred": false, + "tags": [] + }, + "pluginVersion": "9.4.7", + "title": "Other Dashboards", + "type": "dashlist" + } + ], + "title": "Other Dashboards", + "type": "row" + } + ], + "refresh": "5s", + "schemaVersion": 40, + "tags": [ + "mssql", + "sqlmonitor", + "All Servers", + "Alerts" + ], + "templating": { + "list": [ + { + "current": {}, + "description": "SQLMonitor Inventory Server Name", + "hide": 2, + "includeAll": false, + "label": "SQLMonitor Data Source", + "name": "sqlmonitor_datasource", + "options": [], + "query": "mssql", + "refresh": 1, + "regex": "", + "type": "datasource" + }, + { + "current": {}, + "datasource": { + "type": "mssql", + "uid": "${sqlmonitor_datasource}" + }, + "definition": "declare @sql nvarchar(max);\nset quoted_identifier off;\nset @sql = \"\nselect distinct srvname = sql_instance from dbo.instance_details\nwhere is_available = 1 and is_enabled =1\n\";\nset quoted_identifier off;\n\nexec dbo.sp_executesql @sql;", + "hide": 2, + "includeAll": true, + "label": "Sql Instance", + "multi": true, + "name": "server", + "options": [], + "query": "declare @sql nvarchar(max);\nset quoted_identifier off;\nset @sql = \"\nselect distinct srvname = sql_instance from dbo.instance_details\nwhere is_available = 1 and is_enabled =1\n\";\nset quoted_identifier off;\n\nexec dbo.sp_executesql @sql;", + "refresh": 2, + "regex": "", + "sort": 1, + "type": "query" + }, + { + "current": {}, + "datasource": { + "type": "mssql", + "uid": "${DS_SQLMONITOR}" + }, + "definition": "SELECT DB_NAME() as [db_name]", + "hide": 2, + "includeAll": false, + "label": "Inventory Database", + "name": "inventory_db", + "options": [], + "query": "SELECT DB_NAME() as [db_name]", + "refresh": 1, + "regex": "", + "type": "query" + }, + { + "current": {}, + "datasource": { + "type": "mssql", + "uid": "${sqlmonitor_datasource}" + }, + "definition": "select collection_time_utc = DATEADD(mi, DATEDIFF(mi, getdate(), getutcdate()), max(collection_time)) from dbo.all_server_volatile_info", + "hide": 2, + "includeAll": false, + "label": "Collection Time UTC", + "name": "collection_time_utc", + "options": [], + "query": "select collection_time_utc = DATEADD(mi, DATEDIFF(mi, getdate(), getutcdate()), max(collection_time)) from dbo.all_server_volatile_info", + "refresh": 2, + "regex": "", + "type": "query" + }, + { + "current": { + "text": "70", + "value": "70" + }, + "includeAll": false, + "label": "Tempdb Used %", + "name": "tempdb_used_pct_threshold", + "options": [ + { + "selected": false, + "text": "30", + "value": "30" + }, + { + "selected": false, + "text": "50", + "value": "50" + }, + { + "selected": true, + "text": "70", + "value": "70" + }, + { + "selected": false, + "text": "80", + "value": "80" + }, + { + "selected": false, + "text": "90", + "value": "90" + }, + { + "selected": false, + "text": "95", + "value": "95" + } + ], + "query": "30,50,70,80,90,95", + "type": "custom" + }, + { + "current": { + "text": "20", + "value": "20" + }, + "includeAll": false, + "label": "Tempdb Used Gb", + "name": "tempdb_used_gb_threshold", + "options": [ + { + "selected": false, + "text": "2", + "value": "2" + }, + { + "selected": true, + "text": "20", + "value": "20" + }, + { + "selected": false, + "text": "50", + "value": "50" + }, + { + "selected": false, + "text": "100", + "value": "100" + }, + { + "selected": false, + "text": "200", + "value": "200" + }, + { + "selected": false, + "text": "350", + "value": "350" + }, + { + "selected": false, + "text": "500", + "value": "500" + }, + { + "selected": false, + "text": "800", + "value": "800" + }, + { + "selected": false, + "text": "1000", + "value": "1000" + }, + { + "selected": false, + "text": "1500", + "value": "1500" + } + ], + "query": "2,20,50,100,200,350,500,800,1000,1500", + "type": "custom" + }, + { + "current": { + "text": "No", + "value": "No" + }, + "description": "When yes, log space threshold won't be considered. Rather threshold are used based on server level LogSaver jobs", + "includeAll": false, + "label": "Pre Validated Logs", + "name": "only_validated_log_thresholds", + "options": [ + { + "selected": false, + "text": "Yes", + "value": "Yes" + }, + { + "selected": true, + "text": "No", + "value": "No" + } + ], + "query": "Yes,No", + "type": "custom" + }, + { + "current": { + "text": "70", + "value": "70" + }, + "description": "Effective only when {Pre Validated Logs} is NO", + "includeAll": false, + "label": "Log Used %", + "name": "log_used_pct_threshold", + "options": [ + { + "selected": false, + "text": "30", + "value": "30" + }, + { + "selected": false, + "text": "50", + "value": "50" + }, + { + "selected": true, + "text": "70", + "value": "70" + }, + { + "selected": false, + "text": "80", + "value": "80" + }, + { + "selected": false, + "text": "90", + "value": "90" + }, + { + "selected": false, + "text": "95", + "value": "95" + } + ], + "query": "30,50,70,80,90,95", + "type": "custom" + }, + { + "current": { + "text": "20", + "value": "20" + }, + "description": "Effective only when {Pre Validated Logs} is NO", + "includeAll": false, + "label": "Log Used Gb", + "name": "log_used_gb_threshold", + "options": [ + { + "selected": false, + "text": "2", + "value": "2" + }, + { + "selected": true, + "text": "20", + "value": "20" + }, + { + "selected": false, + "text": "50", + "value": "50" + }, + { + "selected": false, + "text": "100", + "value": "100" + }, + { + "selected": false, + "text": "200", + "value": "200" + }, + { + "selected": false, + "text": "350", + "value": "350" + }, + { + "selected": false, + "text": "500", + "value": "500" + }, + { + "selected": false, + "text": "800", + "value": "800" + }, + { + "selected": false, + "text": "1000", + "value": "1000" + }, + { + "selected": false, + "text": "1500", + "value": "1500" + } + ], + "query": "2,20,50,100,200,350,500,800,1000,1500", + "type": "custom" + }, + { + "current": { + "text": "80", + "value": "80" + }, + "includeAll": false, + "label": "Disk Warning %", + "name": "disk_warning_pct", + "options": [ + { + "selected": false, + "text": "30", + "value": "30" + }, + { + "selected": false, + "text": "50", + "value": "50" + }, + { + "selected": false, + "text": "70", + "value": "70" + }, + { + "selected": true, + "text": "80", + "value": "80" + }, + { + "selected": false, + "text": "85", + "value": "85" + }, + { + "selected": false, + "text": "90", + "value": "90" + } + ], + "query": "30,50,70,80,85,90", + "type": "custom" + }, + { + "current": { + "text": "90", + "value": "90" + }, + "includeAll": false, + "label": "Disk Critical %", + "name": "disk_critical_pct", + "options": [ + { + "selected": true, + "text": "90", + "value": "90" + }, + { + "selected": false, + "text": "92", + "value": "92" + }, + { + "selected": false, + "text": "95", + "value": "95" + }, + { + "selected": false, + "text": "98", + "value": "98" + } + ], + "query": "90,92,95,98", + "type": "custom" + }, + { + "current": { + "text": "250", + "value": "250" + }, + "description": "Free Space in Gb to segregate Large Disk from Small Disk", + "includeAll": false, + "label": "Free Disk Boundary (Gb)", + "name": "disk_threshold_gb", + "options": [ + { + "selected": false, + "text": "1", + "value": "1" + }, + { + "selected": false, + "text": "5", + "value": "5" + }, + { + "selected": false, + "text": "10", + "value": "10" + }, + { + "selected": false, + "text": "20", + "value": "20" + }, + { + "selected": false, + "text": "50", + "value": "50" + }, + { + "selected": false, + "text": "100", + "value": "100" + }, + { + "selected": false, + "text": "200", + "value": "200" + }, + { + "selected": true, + "text": "250", + "value": "250" + }, + { + "selected": false, + "text": "350", + "value": "350" + }, + { + "selected": false, + "text": "500", + "value": "500" + }, + { + "selected": false, + "text": "800", + "value": "800" + }, + { + "selected": false, + "text": "1024", + "value": "1024" + } + ], + "query": "1,5,10,20,50,100,200,250,350,500,800,1024", + "type": "custom" + }, + { + "current": { + "text": "95", + "value": "95" + }, + "description": "Disk full threshold to consider when disk has more than {Free Disk Boundary} gb free space", + "includeAll": false, + "label": "Large Disk %", + "name": "large_disk_threshold_pct", + "options": [ + { + "selected": false, + "text": "85", + "value": "85" + }, + { + "selected": false, + "text": "90", + "value": "90" + }, + { + "selected": false, + "text": "92", + "value": "92" + }, + { + "selected": true, + "text": "95", + "value": "95" + }, + { + "selected": false, + "text": "97", + "value": "97" + }, + { + "selected": false, + "text": "98", + "value": "98" + } + ], + "query": "85,90,92,95,97,98", + "type": "custom" + }, + { + "current": { + "text": "8", + "value": "8" + }, + "includeAll": false, + "label": "Full Threshold (Days)", + "name": "full_threshold_days", + "options": [ + { + "selected": false, + "text": "1", + "value": "1" + }, + { + "selected": false, + "text": "3", + "value": "3" + }, + { + "selected": false, + "text": "7", + "value": "7" + }, + { + "selected": true, + "text": "8", + "value": "8" + }, + { + "selected": false, + "text": "9", + "value": "9" + }, + { + "selected": false, + "text": "10", + "value": "10" + }, + { + "selected": false, + "text": "15", + "value": "15" + }, + { + "selected": false, + "text": "30", + "value": "30" + }, + { + "selected": false, + "text": "90", + "value": "90" + }, + { + "selected": false, + "text": "366", + "value": "366" + } + ], + "query": "1,3,7,8,9,10,15,30,90,366", + "type": "custom" + }, + { + "current": { + "text": "26", + "value": "26" + }, + "includeAll": false, + "label": "Diff Threshold (Hrs)", + "name": "diff_threshold_hours", + "options": [ + { + "selected": false, + "text": "4", + "value": "4" + }, + { + "selected": false, + "text": "8", + "value": "8" + }, + { + "selected": false, + "text": "12", + "value": "12" + }, + { + "selected": false, + "text": "24", + "value": "24" + }, + { + "selected": true, + "text": "26", + "value": "26" + }, + { + "selected": false, + "text": "28", + "value": "28" + }, + { + "selected": false, + "text": "32", + "value": "32" + }, + { + "selected": false, + "text": "36", + "value": "36" + }, + { + "selected": false, + "text": "48", + "value": "48" + } + ], + "query": "4,8,12,24,26,28,32,36,48", + "type": "custom" + }, + { + "current": { + "text": "60", + "value": "60" + }, + "includeAll": false, + "label": "TLog Threshold (Min)", + "name": "tlog_threshold_minutes", + "options": [ + { + "selected": false, + "text": "5", + "value": "5" + }, + { + "selected": false, + "text": "10", + "value": "10" + }, + { + "selected": false, + "text": "15", + "value": "15" + }, + { + "selected": false, + "text": "20", + "value": "20" + }, + { + "selected": false, + "text": "30", + "value": "30" + }, + { + "selected": false, + "text": "45", + "value": "45" + }, + { + "selected": true, + "text": "60", + "value": "60" + }, + { + "selected": false, + "text": "90", + "value": "90" + }, + { + "selected": false, + "text": "120", + "value": "120" + }, + { + "selected": false, + "text": "240", + "value": "240" + }, + { + "selected": false, + "text": "360", + "value": "360" + } + ], + "query": "5,10,15,20,30,45,60,90,120,240,360", + "type": "custom" + }, + { + "current": {}, + "datasource": { + "type": "mssql", + "uid": "${DS_SQLMONITOR}" + }, + "definition": "declare @sql nvarchar(max);\ndeclare @_has_inventory bit = 0;\nset @_has_inventory = convert(bit,'${has_inventory}');\n\nset quoted_identifier off;\nset @sql = \"\n/* $__dashboard */\nselect count(sql_instance)\nfrom dbo.instance_details id\nwhere is_enabled = 1 and is_alias = 0\nand (is_available = 0 or is_linked_server_working = 0)\n\"+(case when @_has_inventory = 0 then '--' else '' end)+\"and exists (select * from dbo.sma_servers s where s.is_decommissioned = 0 and s.is_onboarded = 1 and s.server = id.sql_instance)\n\";\nset quoted_identifier off;\n\nexec dbo.sp_executesql @sql;", + "hide": 2, + "includeAll": false, + "label": "Offline Servers Count", + "name": "offline_servers_count", + "options": [], + "query": "declare @sql nvarchar(max);\ndeclare @_has_inventory bit = 0;\nset @_has_inventory = convert(bit,'${has_inventory}');\n\nset quoted_identifier off;\nset @sql = \"\n/* $__dashboard */\nselect count(sql_instance)\nfrom dbo.instance_details id\nwhere is_enabled = 1 and is_alias = 0\nand (is_available = 0 or is_linked_server_working = 0)\n\"+(case when @_has_inventory = 0 then '--' else '' end)+\"and exists (select * from dbo.sma_servers s where s.is_decommissioned = 0 and s.is_onboarded = 1 and s.server = id.sql_instance)\n\";\nset quoted_identifier off;\n\nexec dbo.sp_executesql @sql;", + "refresh": 2, + "regex": "", + "type": "query" + }, + { + "current": {}, + "datasource": { + "type": "mssql", + "uid": "${sqlmonitor_datasource}" + }, + "definition": "declare @sql nvarchar(max);\ndeclare @_has_inventory bit = 0;\nset @_has_inventory = convert(bit,'${has_inventory}');\n\nset quoted_identifier off;\nset @sql = \"\n/* $__dashboard */\nselect count(distinct sql_instance)\nfrom dbo.instance_details id\nwhere is_enabled = 1 and is_alias = 1\nand (is_available = 0 or is_linked_server_working = 0)\n\"+(case when @_has_inventory = 0 then '--' else '' end)+\"and exists (select * from dbo.sma_servers s where s.is_decommissioned = 0 and s.is_onboarded = 1 and s.server = id.source_sql_instance)\n\";\nset quoted_identifier off;\n\nexec dbo.sp_executesql @sql;", + "hide": 2, + "includeAll": false, + "label": "Offline Alias Count", + "name": "offline_alias_count", + "options": [], + "query": "declare @sql nvarchar(max);\ndeclare @_has_inventory bit = 0;\nset @_has_inventory = convert(bit,'${has_inventory}');\n\nset quoted_identifier off;\nset @sql = \"\n/* $__dashboard */\nselect count(distinct sql_instance)\nfrom dbo.instance_details id\nwhere is_enabled = 1 and is_alias = 1\nand (is_available = 0 or is_linked_server_working = 0)\n\"+(case when @_has_inventory = 0 then '--' else '' end)+\"and exists (select * from dbo.sma_servers s where s.is_decommissioned = 0 and s.is_onboarded = 1 and s.server = id.source_sql_instance)\n\";\nset quoted_identifier off;\n\nexec dbo.sp_executesql @sql;", + "refresh": 2, + "regex": "", + "type": "query" + }, + { + "current": {}, + "datasource": { + "type": "mssql", + "uid": "${DS_SQLMONITOR}" + }, + "definition": "declare @sql nvarchar(max);\ndeclare @_has_inventory bit = 0;\nset @_has_inventory = convert(bit,'${has_inventory}');\n\nset quoted_identifier off;\nset @sql = \"\n/* $__dashboard */\nselect count(*) as counts\nfrom dbo.services_all_servers sas\ncross apply (select top 1 sql_instance_with_port = coalesce(id.sql_instance+','+id.sql_instance_port,id.sql_instance) \n\t\t\t\tfrom dbo.instance_details id where id.is_enabled = 1 \n\t\t\t\tand id.is_available = 1 and id.sql_instance = sas.sql_instance) id\nwhere 1=1\nand sas.service_type = 'Agent'\nand sas.status_desc <> 'Running'\n\"+(case when @_has_inventory = 0 then '--' else '' end)+\"and exists (select * from dbo.sma_servers s where s.is_decommissioned = 0 and s.is_onboarded = 1 and s.server = sas.sql_instance)\n\";\nset quoted_identifier off;\n\nexec dbo.sp_executesql @sql;", + "hide": 2, + "includeAll": false, + "label": "Offline SQLAgent Services Count", + "name": "offline_agent_count", + "options": [], + "query": "declare @sql nvarchar(max);\ndeclare @_has_inventory bit = 0;\nset @_has_inventory = convert(bit,'${has_inventory}');\n\nset quoted_identifier off;\nset @sql = \"\n/* $__dashboard */\nselect count(*) as counts\nfrom dbo.services_all_servers sas\ncross apply (select top 1 sql_instance_with_port = coalesce(id.sql_instance+','+id.sql_instance_port,id.sql_instance) \n\t\t\t\tfrom dbo.instance_details id where id.is_enabled = 1 \n\t\t\t\tand id.is_available = 1 and id.sql_instance = sas.sql_instance) id\nwhere 1=1\nand sas.service_type = 'Agent'\nand sas.status_desc <> 'Running'\n\"+(case when @_has_inventory = 0 then '--' else '' end)+\"and exists (select * from dbo.sma_servers s where s.is_decommissioned = 0 and s.is_onboarded = 1 and s.server = sas.sql_instance)\n\";\nset quoted_identifier off;\n\nexec dbo.sp_executesql @sql;", + "refresh": 2, + "regex": "", + "type": "query" + }, + { + "current": {}, + "datasource": { + "type": "mssql", + "uid": "${sqlmonitor_datasource}" + }, + "definition": "declare @sql nvarchar(max);\nset quoted_identifier off;\nset @sql = \"\n/* $__dashboard */\n;with t_cte as (\n\tselect\tsrv_name, domain, host_name, product_version, major_version_number, minor_version_number, cpu_count, \n\t scheduler_count, total_physical_memory_kb, os_start_time_utc, sqlserver_start_time_utc\n\t\t\t,Concat\n\t\t\t(\n\t\t\t\tRIGHT('000'+CAST(ISNULL((datediff(second,os_start_time_utc,GETUTCDATE()) / 3600 / 24), 0) AS VARCHAR(3)),3)\n\t\t\t\t,' '\n\t\t\t\t,RIGHT('00'+CAST(ISNULL(datediff(second,os_start_time_utc,GETUTCDATE()) / 3600 % 24, 0) AS VARCHAR(2)),2)\n\t\t\t\t,':'\n\t\t\t\t,RIGHT('00'+CAST(ISNULL(datediff(second,os_start_time_utc,GETUTCDATE()) / 60 % 60, 0) AS VARCHAR(2)),2)\n\t\t\t\t,':'\n\t\t\t\t,RIGHT('00'+CAST(ISNULL(datediff(second,os_start_time_utc,GETUTCDATE()) % 3600 % 60, 0) AS VARCHAR(2)),2)\n\t\t\t) as [os_uptime]\n\t\t\t,Concat\n\t\t\t(\n\t\t\t\tRIGHT('000'+CAST(ISNULL((datediff(second,sqlserver_start_time_utc,GETUTCDATE()) / 3600 / 24), 0) AS VARCHAR(3)),3)\n\t\t\t\t,' '\n\t\t\t\t,RIGHT('00'+CAST(ISNULL(datediff(second,sqlserver_start_time_utc,GETUTCDATE()) / 3600 % 24, 0) AS VARCHAR(2)),2)\n\t\t\t\t,':'\n\t\t\t\t,RIGHT('00'+CAST(ISNULL(datediff(second,sqlserver_start_time_utc,GETUTCDATE()) / 60 % 60, 0) AS VARCHAR(2)),2)\n\t\t\t\t,':'\n\t\t\t\t,RIGHT('00'+CAST(ISNULL(datediff(second,sqlserver_start_time_utc,GETUTCDATE()) % 3600 % 60, 0) AS VARCHAR(2)),2)\n\t\t\t) as [sqlserver_uptime]\n\t\t\t,datediff(day,os_start_time_utc,GETUTCDATE()) as [os_uptime_days]\n\tfrom dbo.vw_all_server_info\n)\nselect count(*)\n/*\nselect srv_name, domain, host_name, product_version, major_version_number, minor_version_number\n ,[CPU (OS / SQL)] = convert(varchar,cpu_count)+' / '+convert(varchar,scheduler_count)\n ,total_physical_memory_kb ,cpu_count, scheduler_count, [os_uptime_days], os_start_time_utc, sqlserver_start_time_utc, [os_uptime], [sqlserver_uptime]\n\t\t ,[Is MS Supported] = case when c.MainstreamSupportEndDate < getdate() then convert(bit,0) else convert(bit,1) end\n*/\nfrom t_cte cte\nouter apply (\n\tselect\ttop 1 [MajorVersionNumber]\n\t\t\t\t--,[@server_minor_version_number] = @server_minor_version_number\n\t\t\t\t,[MinorVersionNumber]\n\t\t\t\t,[Branch]\n\t\t\t\t,[Url]\n\t\t\t\t,[ReleaseDate]\n\t\t\t\t,[MainstreamSupportEndDate]\n\t\t\t\t,[ExtendedSupportEndDate]\n\t\t\t\t,[MajorVersionName]\n\t\t\t\t,[MinorVersionName]\t \n\t\tfrom [master].[dbo].[SqlServerVersions] as c\n\t\twhere [MajorVersionNumber] = cte.major_version_number\n\t\tand [MinorVersionNumber] <= cte.minor_version_number\n\t\torder by [MinorVersionNumber] desc\n) as c\nouter apply (\n\tselect\ttop 1 [MajorVersionNumber]\n\t\t\t--,[@server_minor_version_number] = @server_minor_version_number\n\t\t\t,[MinorVersionNumber]\n\t\t\t,[Branch]\n\t\t\t,[Url]\n\t\t\t,[ReleaseDate]\n\t\t\t,[MainstreamSupportEndDate]\n\t\t\t,[ExtendedSupportEndDate]\n\t\t\t,[MajorVersionName]\n\t\t\t,[MinorVersionName]\t \n\tfrom [master].[dbo].[SqlServerVersions] as c\n\twhere [MajorVersionNumber] = cte.major_version_number\n\torder by [MinorVersionNumber] desc\n) as l;\n\";\nset quoted_identifier off;\n\nexec dbo.sp_executesql @sql;", + "hide": 2, + "includeAll": false, + "label": "Basic Info Servers Count", + "name": "basic_info_servers_count", + "options": [], + "query": "declare @sql nvarchar(max);\nset quoted_identifier off;\nset @sql = \"\n/* $__dashboard */\n;with t_cte as (\n\tselect\tsrv_name, domain, host_name, product_version, major_version_number, minor_version_number, cpu_count, \n\t scheduler_count, total_physical_memory_kb, os_start_time_utc, sqlserver_start_time_utc\n\t\t\t,Concat\n\t\t\t(\n\t\t\t\tRIGHT('000'+CAST(ISNULL((datediff(second,os_start_time_utc,GETUTCDATE()) / 3600 / 24), 0) AS VARCHAR(3)),3)\n\t\t\t\t,' '\n\t\t\t\t,RIGHT('00'+CAST(ISNULL(datediff(second,os_start_time_utc,GETUTCDATE()) / 3600 % 24, 0) AS VARCHAR(2)),2)\n\t\t\t\t,':'\n\t\t\t\t,RIGHT('00'+CAST(ISNULL(datediff(second,os_start_time_utc,GETUTCDATE()) / 60 % 60, 0) AS VARCHAR(2)),2)\n\t\t\t\t,':'\n\t\t\t\t,RIGHT('00'+CAST(ISNULL(datediff(second,os_start_time_utc,GETUTCDATE()) % 3600 % 60, 0) AS VARCHAR(2)),2)\n\t\t\t) as [os_uptime]\n\t\t\t,Concat\n\t\t\t(\n\t\t\t\tRIGHT('000'+CAST(ISNULL((datediff(second,sqlserver_start_time_utc,GETUTCDATE()) / 3600 / 24), 0) AS VARCHAR(3)),3)\n\t\t\t\t,' '\n\t\t\t\t,RIGHT('00'+CAST(ISNULL(datediff(second,sqlserver_start_time_utc,GETUTCDATE()) / 3600 % 24, 0) AS VARCHAR(2)),2)\n\t\t\t\t,':'\n\t\t\t\t,RIGHT('00'+CAST(ISNULL(datediff(second,sqlserver_start_time_utc,GETUTCDATE()) / 60 % 60, 0) AS VARCHAR(2)),2)\n\t\t\t\t,':'\n\t\t\t\t,RIGHT('00'+CAST(ISNULL(datediff(second,sqlserver_start_time_utc,GETUTCDATE()) % 3600 % 60, 0) AS VARCHAR(2)),2)\n\t\t\t) as [sqlserver_uptime]\n\t\t\t,datediff(day,os_start_time_utc,GETUTCDATE()) as [os_uptime_days]\n\tfrom dbo.vw_all_server_info\n)\nselect count(*)\n/*\nselect srv_name, domain, host_name, product_version, major_version_number, minor_version_number\n ,[CPU (OS / SQL)] = convert(varchar,cpu_count)+' / '+convert(varchar,scheduler_count)\n ,total_physical_memory_kb ,cpu_count, scheduler_count, [os_uptime_days], os_start_time_utc, sqlserver_start_time_utc, [os_uptime], [sqlserver_uptime]\n\t\t ,[Is MS Supported] = case when c.MainstreamSupportEndDate < getdate() then convert(bit,0) else convert(bit,1) end\n*/\nfrom t_cte cte\nouter apply (\n\tselect\ttop 1 [MajorVersionNumber]\n\t\t\t\t--,[@server_minor_version_number] = @server_minor_version_number\n\t\t\t\t,[MinorVersionNumber]\n\t\t\t\t,[Branch]\n\t\t\t\t,[Url]\n\t\t\t\t,[ReleaseDate]\n\t\t\t\t,[MainstreamSupportEndDate]\n\t\t\t\t,[ExtendedSupportEndDate]\n\t\t\t\t,[MajorVersionName]\n\t\t\t\t,[MinorVersionName]\t \n\t\tfrom [master].[dbo].[SqlServerVersions] as c\n\t\twhere [MajorVersionNumber] = cte.major_version_number\n\t\tand [MinorVersionNumber] <= cte.minor_version_number\n\t\torder by [MinorVersionNumber] desc\n) as c\nouter apply (\n\tselect\ttop 1 [MajorVersionNumber]\n\t\t\t--,[@server_minor_version_number] = @server_minor_version_number\n\t\t\t,[MinorVersionNumber]\n\t\t\t,[Branch]\n\t\t\t,[Url]\n\t\t\t,[ReleaseDate]\n\t\t\t,[MainstreamSupportEndDate]\n\t\t\t,[ExtendedSupportEndDate]\n\t\t\t,[MajorVersionName]\n\t\t\t,[MinorVersionName]\t \n\tfrom [master].[dbo].[SqlServerVersions] as c\n\twhere [MajorVersionNumber] = cte.major_version_number\n\torder by [MinorVersionNumber] desc\n) as l;\n\";\nset quoted_identifier off;\n\nexec dbo.sp_executesql @sql;", + "refresh": 1, + "regex": "", + "type": "query" + }, + { + "current": {}, + "datasource": { + "type": "mssql", + "uid": "${DS_SQLMONITOR}" + }, + "definition": "declare @sql nvarchar(max);\nset quoted_identifier off;\nset @sql = \"\n/* $__dashboard */\n;with t_cte as (\n\tselect\tsrv_name, domain, host_name, product_version, major_version_number, minor_version_number, cpu_count, \n\t scheduler_count, total_physical_memory_kb, os_start_time_utc, sqlserver_start_time_utc\n\t\t\t,Concat\n\t\t\t(\n\t\t\t\tRIGHT('000'+CAST(ISNULL((datediff(second,os_start_time_utc,GETUTCDATE()) / 3600 / 24), 0) AS VARCHAR(3)),3)\n\t\t\t\t,' '\n\t\t\t\t,RIGHT('00'+CAST(ISNULL(datediff(second,os_start_time_utc,GETUTCDATE()) / 3600 % 24, 0) AS VARCHAR(2)),2)\n\t\t\t\t,':'\n\t\t\t\t,RIGHT('00'+CAST(ISNULL(datediff(second,os_start_time_utc,GETUTCDATE()) / 60 % 60, 0) AS VARCHAR(2)),2)\n\t\t\t\t,':'\n\t\t\t\t,RIGHT('00'+CAST(ISNULL(datediff(second,os_start_time_utc,GETUTCDATE()) % 3600 % 60, 0) AS VARCHAR(2)),2)\n\t\t\t) as [os_uptime]\n\t\t\t,Concat\n\t\t\t(\n\t\t\t\tRIGHT('000'+CAST(ISNULL((datediff(second,sqlserver_start_time_utc,GETUTCDATE()) / 3600 / 24), 0) AS VARCHAR(3)),3)\n\t\t\t\t,' '\n\t\t\t\t,RIGHT('00'+CAST(ISNULL(datediff(second,sqlserver_start_time_utc,GETUTCDATE()) / 3600 % 24, 0) AS VARCHAR(2)),2)\n\t\t\t\t,':'\n\t\t\t\t,RIGHT('00'+CAST(ISNULL(datediff(second,sqlserver_start_time_utc,GETUTCDATE()) / 60 % 60, 0) AS VARCHAR(2)),2)\n\t\t\t\t,':'\n\t\t\t\t,RIGHT('00'+CAST(ISNULL(datediff(second,sqlserver_start_time_utc,GETUTCDATE()) % 3600 % 60, 0) AS VARCHAR(2)),2)\n\t\t\t) as [sqlserver_uptime]\n\t\t\t,datediff(day,os_start_time_utc,GETUTCDATE()) as [os_uptime_days]\n\tfrom dbo.vw_all_server_info\n)\nselect count(*)\nfrom t_cte cte\nouter apply (\n\tselect\ttop 1 [MajorVersionNumber]\n\t\t\t\t--,[@server_minor_version_number] = @server_minor_version_number\n\t\t\t\t,[MinorVersionNumber]\n\t\t\t\t,[Branch]\n\t\t\t\t,[Url]\n\t\t\t\t,[ReleaseDate]\n\t\t\t\t,[MainstreamSupportEndDate]\n\t\t\t\t,[ExtendedSupportEndDate]\n\t\t\t\t,[MajorVersionName]\n\t\t\t\t,[MinorVersionName]\t \n\t\tfrom [master].[dbo].[SqlServerVersions] as c\n\t\twhere [MajorVersionNumber] = cte.major_version_number\n\t\tand [MinorVersionNumber] <= cte.minor_version_number\n\t\torder by [MinorVersionNumber] desc\n) as c\nouter apply (\n\tselect\ttop 1 [MajorVersionNumber]\n\t\t\t--,[@server_minor_version_number] = @server_minor_version_number\n\t\t\t,[MinorVersionNumber]\n\t\t\t,[Branch]\n\t\t\t,[Url]\n\t\t\t,[ReleaseDate]\n\t\t\t,[MainstreamSupportEndDate]\n\t\t\t,[ExtendedSupportEndDate]\n\t\t\t,[MajorVersionName]\n\t\t\t,[MinorVersionName]\t \n\tfrom [master].[dbo].[SqlServerVersions] as c\n\twhere [MajorVersionNumber] = cte.major_version_number\n\torder by [MinorVersionNumber] desc\n) as l\nwhere 1=1\nand c.ExtendedSupportEndDate < getdate();\n\";\nset quoted_identifier off;\n\nexec dbo.sp_executesql @sql;", + "hide": 2, + "includeAll": false, + "label": "Out of Supported Servers Count", + "name": "unsupported_servers_count", + "options": [], + "query": "declare @sql nvarchar(max);\nset quoted_identifier off;\nset @sql = \"\n/* $__dashboard */\n;with t_cte as (\n\tselect\tsrv_name, domain, host_name, product_version, major_version_number, minor_version_number, cpu_count, \n\t scheduler_count, total_physical_memory_kb, os_start_time_utc, sqlserver_start_time_utc\n\t\t\t,Concat\n\t\t\t(\n\t\t\t\tRIGHT('000'+CAST(ISNULL((datediff(second,os_start_time_utc,GETUTCDATE()) / 3600 / 24), 0) AS VARCHAR(3)),3)\n\t\t\t\t,' '\n\t\t\t\t,RIGHT('00'+CAST(ISNULL(datediff(second,os_start_time_utc,GETUTCDATE()) / 3600 % 24, 0) AS VARCHAR(2)),2)\n\t\t\t\t,':'\n\t\t\t\t,RIGHT('00'+CAST(ISNULL(datediff(second,os_start_time_utc,GETUTCDATE()) / 60 % 60, 0) AS VARCHAR(2)),2)\n\t\t\t\t,':'\n\t\t\t\t,RIGHT('00'+CAST(ISNULL(datediff(second,os_start_time_utc,GETUTCDATE()) % 3600 % 60, 0) AS VARCHAR(2)),2)\n\t\t\t) as [os_uptime]\n\t\t\t,Concat\n\t\t\t(\n\t\t\t\tRIGHT('000'+CAST(ISNULL((datediff(second,sqlserver_start_time_utc,GETUTCDATE()) / 3600 / 24), 0) AS VARCHAR(3)),3)\n\t\t\t\t,' '\n\t\t\t\t,RIGHT('00'+CAST(ISNULL(datediff(second,sqlserver_start_time_utc,GETUTCDATE()) / 3600 % 24, 0) AS VARCHAR(2)),2)\n\t\t\t\t,':'\n\t\t\t\t,RIGHT('00'+CAST(ISNULL(datediff(second,sqlserver_start_time_utc,GETUTCDATE()) / 60 % 60, 0) AS VARCHAR(2)),2)\n\t\t\t\t,':'\n\t\t\t\t,RIGHT('00'+CAST(ISNULL(datediff(second,sqlserver_start_time_utc,GETUTCDATE()) % 3600 % 60, 0) AS VARCHAR(2)),2)\n\t\t\t) as [sqlserver_uptime]\n\t\t\t,datediff(day,os_start_time_utc,GETUTCDATE()) as [os_uptime_days]\n\tfrom dbo.vw_all_server_info\n)\nselect count(*)\nfrom t_cte cte\nouter apply (\n\tselect\ttop 1 [MajorVersionNumber]\n\t\t\t\t--,[@server_minor_version_number] = @server_minor_version_number\n\t\t\t\t,[MinorVersionNumber]\n\t\t\t\t,[Branch]\n\t\t\t\t,[Url]\n\t\t\t\t,[ReleaseDate]\n\t\t\t\t,[MainstreamSupportEndDate]\n\t\t\t\t,[ExtendedSupportEndDate]\n\t\t\t\t,[MajorVersionName]\n\t\t\t\t,[MinorVersionName]\t \n\t\tfrom [master].[dbo].[SqlServerVersions] as c\n\t\twhere [MajorVersionNumber] = cte.major_version_number\n\t\tand [MinorVersionNumber] <= cte.minor_version_number\n\t\torder by [MinorVersionNumber] desc\n) as c\nouter apply (\n\tselect\ttop 1 [MajorVersionNumber]\n\t\t\t--,[@server_minor_version_number] = @server_minor_version_number\n\t\t\t,[MinorVersionNumber]\n\t\t\t,[Branch]\n\t\t\t,[Url]\n\t\t\t,[ReleaseDate]\n\t\t\t,[MainstreamSupportEndDate]\n\t\t\t,[ExtendedSupportEndDate]\n\t\t\t,[MajorVersionName]\n\t\t\t,[MinorVersionName]\t \n\tfrom [master].[dbo].[SqlServerVersions] as c\n\twhere [MajorVersionNumber] = cte.major_version_number\n\torder by [MinorVersionNumber] desc\n) as l\nwhere 1=1\nand c.ExtendedSupportEndDate < getdate();\n\";\nset quoted_identifier off;\n\nexec dbo.sp_executesql @sql;", + "refresh": 1, + "regex": "", + "type": "query" + }, + { + "current": {}, + "datasource": { + "type": "mssql", + "uid": "${sqlmonitor_datasource}" + }, + "definition": "declare @_latency_minutes_threshold int = 20;\ndeclare @_latency_days_threshold int = 3;\ndeclare @t_servers_exception table (srv_name varchar(125));\n\ninsert @t_servers_exception -- list of servers that have permanent issues\nvalues ('196.1.115.169'),('196.1.115.212');\n\nselect\tcount(*) /*\n cli.srv_name, id.jobs_server,\n\t\tcli.performance_counters__latency_minutes,\n\t\txevent_metrics__latency_minutes = case when (cli.xevent_metrics__latency_minutes > @_latency_minutes_threshold*2 and vi.sql_cpu > 20 and si.major_version_number >= 11) then cli.xevent_metrics__latency_minutes \n\t\t\t\t\t\t\t\t\t\t\t\t\twhen cli.xevent_metrics__latency_minutes > @_latency_minutes_threshold then @_latency_minutes_threshold-1\n\t\t\t\t\t\t\t\t\t\t\t\t\telse cli.xevent_metrics__latency_minutes end,\n\t\tWhoIsActive__latency_minutes = case when cli.WhoIsActive__latency_minutes > @_latency_minutes_threshold*2 and vi.sql_cpu > 20 then cli.WhoIsActive__latency_minutes \n\t\t\t\t\t\t\t\t\t\t\t\t\twhen cli.WhoIsActive__latency_minutes > @_latency_minutes_threshold then @_latency_minutes_threshold-1\n\t\t\t\t\t\t\t\t\t\t\t\t\telse cli.WhoIsActive__latency_minutes end,\n\t\tcli.os_task_list__latency_minutes,\n\t\tcli.disk_space__latency_minutes, \n\t\tcli.file_io_stats__latency_minutes,\n\t\tcli.sql_agent_job_stats__latency_minutes,\n\t\tcli.memory_clerks__latency_minutes,\n\t\tcli.wait_stats__latency_minutes,\n\t\tcli.BlitzIndex__latency_days,\n\t\tcli.BlitzIndex_Mode0__latency_days,\n\t\t--cli.BlitzIndex_Mode1__latency_days,\n\t\t--cli.BlitzIndex_Mode4__latency_days,\n\t\t--collection_time = DATEADD(mi, DATEDIFF(mi, getdate(), getutcdate()), cli.collection_time)\n\t\t[Issues] = (case when cli.performance_counters__latency_minutes > @_latency_minutes_threshold then 'performance_counters,' else '' end)+\n\t\t\t\t\t(case when cli.xevent_metrics__latency_minutes > @_latency_minutes_threshold*2 and vi.sql_cpu > 20 and si.major_version_number >= 11 then 'xevent_metrics' else '' end)+\n\t\t\t\t\t(case when cli.WhoIsActive__latency_minutes > @_latency_minutes_threshold*2 and vi.sql_cpu > 20 then 'WhoIsActive,' else '' end)+\n\t\t\t\t\t(case when cli.os_task_list__latency_minutes > @_latency_minutes_threshold then 'os_task_list,' else '' end)+\n\t\t\t\t\t(case when cli.disk_space__latency_minutes > @_latency_minutes_threshold*3 then 'disk_space,' else '' end)+\n\t\t\t\t\t(case when cli.file_io_stats__latency_minutes > @_latency_minutes_threshold*3 then 'file_io_stats,' else '' end)+\n\t\t\t\t\t(case when cli.wait_stats__latency_minutes > @_latency_minutes_threshold*2 then 'wait_stats,' else '' end)+\n\t\t\t\t\t(case when cli.sql_agent_job_stats__latency_minutes > @_latency_minutes_threshold*1.5 then 'sql_agent_job_stats,' else '' end)+\n\t\t\t\t\t(case when cli.memory_clerks__latency_minutes > @_latency_minutes_threshold then 'memory_clerks,' else '' end)+\n\t\t\t\t\t(case when cli.BlitzIndex__latency_days > @_latency_days_threshold then 'BlitzIndex,' else '' end)+\n\t\t\t\t\t(case when cli.BlitzIndex_Mode0__latency_days > @_latency_days_threshold*4 then 'BlitzIndex_Mode0,' else '' end)+\n\t\t\t\t\t(case when cli.BlitzIndex_Mode1__latency_days > @_latency_days_threshold*4 then 'BlitzIndex_Mode1,' else '' end)+\n\t\t\t\t\t(case when cli.BlitzIndex_Mode4__latency_days > @_latency_days_threshold*4 then 'BlitzIndex_Mode4,' else '' end)\n\t\t--,cli.host_name ,si.major_version_number ,si.product_version ,si.edition, vi.os_cpu, vi.sql_cpu\n*/\nfrom dbo.all_server_collection_latency_info cli\njoin dbo.all_server_stable_info si on si.srv_name = cli.srv_name\njoin dbo.all_server_volatile_info vi on vi.srv_name = cli.srv_name\nouter apply (select STUFF((select ', '+id.collector_powershell_jobs_server from (select distinct id.collector_powershell_jobs_server from dbo.instance_details id where id.sql_instance = cli.srv_name and id.host_name = cli.host_name) id for xml path('')), 1, 1, '') as jobs_server ) id\nwhere 1=1\nand (\tcli.performance_counters__latency_minutes > @_latency_minutes_threshold\n\t\tor (cli.xevent_metrics__latency_minutes > @_latency_minutes_threshold*2 and vi.sql_cpu > 20 and si.major_version_number >= 11)\n\t\tor (cli.WhoIsActive__latency_minutes > @_latency_minutes_threshold*2 and vi.sql_cpu > 20)\n\t\tor cli.os_task_list__latency_minutes > @_latency_minutes_threshold\n\t\tor cli.disk_space__latency_minutes > @_latency_minutes_threshold*3\n\t\tor cli.file_io_stats__latency_minutes > @_latency_minutes_threshold*3\n\t\tor cli.wait_stats__latency_minutes > @_latency_minutes_threshold*2\n\t\tor cli.BlitzIndex__latency_days > @_latency_days_threshold\n\t\tor cli.BlitzIndex_Mode0__latency_days > @_latency_days_threshold*4\n\t\t--or cli.BlitzIndex_Mode1__latency_days > @_latency_days_threshold*4\n\t\t--or cli.BlitzIndex_Mode4__latency_days > @_latency_days_threshold*4\n\t\tor cli.sql_agent_job_stats__latency_minutes > @_latency_minutes_threshold*1.5\n\t\tor cli.memory_clerks__latency_minutes > @_latency_minutes_threshold\n\t)\nand cli.srv_name not in (select e.srv_name from @t_servers_exception e)\n\n", + "hide": 2, + "includeAll": false, + "label": "Servers Count With Data Issue", + "name": "servers_with_data_issue_count", + "options": [], + "query": "declare @_latency_minutes_threshold int = 20;\ndeclare @_latency_days_threshold int = 3;\ndeclare @t_servers_exception table (srv_name varchar(125));\n\ninsert @t_servers_exception -- list of servers that have permanent issues\nvalues ('196.1.115.169'),('196.1.115.212');\n\nselect\tcount(*) /*\n cli.srv_name, id.jobs_server,\n\t\tcli.performance_counters__latency_minutes,\n\t\txevent_metrics__latency_minutes = case when (cli.xevent_metrics__latency_minutes > @_latency_minutes_threshold*2 and vi.sql_cpu > 20 and si.major_version_number >= 11) then cli.xevent_metrics__latency_minutes \n\t\t\t\t\t\t\t\t\t\t\t\t\twhen cli.xevent_metrics__latency_minutes > @_latency_minutes_threshold then @_latency_minutes_threshold-1\n\t\t\t\t\t\t\t\t\t\t\t\t\telse cli.xevent_metrics__latency_minutes end,\n\t\tWhoIsActive__latency_minutes = case when cli.WhoIsActive__latency_minutes > @_latency_minutes_threshold*2 and vi.sql_cpu > 20 then cli.WhoIsActive__latency_minutes \n\t\t\t\t\t\t\t\t\t\t\t\t\twhen cli.WhoIsActive__latency_minutes > @_latency_minutes_threshold then @_latency_minutes_threshold-1\n\t\t\t\t\t\t\t\t\t\t\t\t\telse cli.WhoIsActive__latency_minutes end,\n\t\tcli.os_task_list__latency_minutes,\n\t\tcli.disk_space__latency_minutes, \n\t\tcli.file_io_stats__latency_minutes,\n\t\tcli.sql_agent_job_stats__latency_minutes,\n\t\tcli.memory_clerks__latency_minutes,\n\t\tcli.wait_stats__latency_minutes,\n\t\tcli.BlitzIndex__latency_days,\n\t\tcli.BlitzIndex_Mode0__latency_days,\n\t\t--cli.BlitzIndex_Mode1__latency_days,\n\t\t--cli.BlitzIndex_Mode4__latency_days,\n\t\t--collection_time = DATEADD(mi, DATEDIFF(mi, getdate(), getutcdate()), cli.collection_time)\n\t\t[Issues] = (case when cli.performance_counters__latency_minutes > @_latency_minutes_threshold then 'performance_counters,' else '' end)+\n\t\t\t\t\t(case when cli.xevent_metrics__latency_minutes > @_latency_minutes_threshold*2 and vi.sql_cpu > 20 and si.major_version_number >= 11 then 'xevent_metrics' else '' end)+\n\t\t\t\t\t(case when cli.WhoIsActive__latency_minutes > @_latency_minutes_threshold*2 and vi.sql_cpu > 20 then 'WhoIsActive,' else '' end)+\n\t\t\t\t\t(case when cli.os_task_list__latency_minutes > @_latency_minutes_threshold then 'os_task_list,' else '' end)+\n\t\t\t\t\t(case when cli.disk_space__latency_minutes > @_latency_minutes_threshold*3 then 'disk_space,' else '' end)+\n\t\t\t\t\t(case when cli.file_io_stats__latency_minutes > @_latency_minutes_threshold*3 then 'file_io_stats,' else '' end)+\n\t\t\t\t\t(case when cli.wait_stats__latency_minutes > @_latency_minutes_threshold*2 then 'wait_stats,' else '' end)+\n\t\t\t\t\t(case when cli.sql_agent_job_stats__latency_minutes > @_latency_minutes_threshold*1.5 then 'sql_agent_job_stats,' else '' end)+\n\t\t\t\t\t(case when cli.memory_clerks__latency_minutes > @_latency_minutes_threshold then 'memory_clerks,' else '' end)+\n\t\t\t\t\t(case when cli.BlitzIndex__latency_days > @_latency_days_threshold then 'BlitzIndex,' else '' end)+\n\t\t\t\t\t(case when cli.BlitzIndex_Mode0__latency_days > @_latency_days_threshold*4 then 'BlitzIndex_Mode0,' else '' end)+\n\t\t\t\t\t(case when cli.BlitzIndex_Mode1__latency_days > @_latency_days_threshold*4 then 'BlitzIndex_Mode1,' else '' end)+\n\t\t\t\t\t(case when cli.BlitzIndex_Mode4__latency_days > @_latency_days_threshold*4 then 'BlitzIndex_Mode4,' else '' end)\n\t\t--,cli.host_name ,si.major_version_number ,si.product_version ,si.edition, vi.os_cpu, vi.sql_cpu\n*/\nfrom dbo.all_server_collection_latency_info cli\njoin dbo.all_server_stable_info si on si.srv_name = cli.srv_name\njoin dbo.all_server_volatile_info vi on vi.srv_name = cli.srv_name\nouter apply (select STUFF((select ', '+id.collector_powershell_jobs_server from (select distinct id.collector_powershell_jobs_server from dbo.instance_details id where id.sql_instance = cli.srv_name and id.host_name = cli.host_name) id for xml path('')), 1, 1, '') as jobs_server ) id\nwhere 1=1\nand (\tcli.performance_counters__latency_minutes > @_latency_minutes_threshold\n\t\tor (cli.xevent_metrics__latency_minutes > @_latency_minutes_threshold*2 and vi.sql_cpu > 20 and si.major_version_number >= 11)\n\t\tor (cli.WhoIsActive__latency_minutes > @_latency_minutes_threshold*2 and vi.sql_cpu > 20)\n\t\tor cli.os_task_list__latency_minutes > @_latency_minutes_threshold\n\t\tor cli.disk_space__latency_minutes > @_latency_minutes_threshold*3\n\t\tor cli.file_io_stats__latency_minutes > @_latency_minutes_threshold*3\n\t\tor cli.wait_stats__latency_minutes > @_latency_minutes_threshold*2\n\t\tor cli.BlitzIndex__latency_days > @_latency_days_threshold\n\t\tor cli.BlitzIndex_Mode0__latency_days > @_latency_days_threshold*4\n\t\t--or cli.BlitzIndex_Mode1__latency_days > @_latency_days_threshold*4\n\t\t--or cli.BlitzIndex_Mode4__latency_days > @_latency_days_threshold*4\n\t\tor cli.sql_agent_job_stats__latency_minutes > @_latency_minutes_threshold*1.5\n\t\tor cli.memory_clerks__latency_minutes > @_latency_minutes_threshold\n\t)\nand cli.srv_name not in (select e.srv_name from @t_servers_exception e)\n\n", + "refresh": 1, + "regex": "", + "type": "query" + }, + { + "current": {}, + "datasource": { + "type": "mssql", + "uid": "${DS_SQLMONITOR}" + }, + "definition": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\n--declare @sql_instance varchar(255);\n--declare @backup_type varchar(2000);\n--declare @backup_description varchar(2000);\n--declare @perfmon_host_name varchar(255);\ndeclare @start_time_utc datetime2;\ndeclare @end_time_utc datetime2;\n--declare @delta_minutes int;\n--declare @disk_drive varchar(255) = '$disk_drive';\n--declare @database varchar(255) = '$database';\n--declare @filter_for_latency varchar(50) = '$filter_for_latency';\ndeclare @full_threshold_days int = $full_threshold_days;\ndeclare @diff_threshold_hours int = $diff_threshold_hours;\ndeclare @tlog_threshold_minutes int = $tlog_threshold_minutes;\ndeclare @_has_inventory bit = 0;\nset @_has_inventory = convert(bit,'${has_inventory}');\n\n--set @database = case when ltrim(rtrim(@database)) = '__All__' then null else @database end;\n--set @disk_drive = case when ltrim(rtrim(@disk_drive)) = '__All__' then null else @disk_drive end;\n\n--set @perfmon_host_name = '$perfmon_host_name';\nset @start_time_utc = $__timeFrom();\nset @end_time_utc = $__timeTo();\n--set @delta_minutes = $cpu_delta_minutes;\n\n--set @backup_type = '${backup_type:csv}';\n--set @backup_description = case when ltrim(rtrim('$backup_description')) = '' then null else ltrim(rtrim('$backup_description')) end;\n\nset @params = N'@start_time_utc datetime2, @end_time_utc datetime2, \n\t\t\t\t\t\t\t\t@full_threshold_days int, @diff_threshold_hours int, @tlog_threshold_minutes int';\n\nset quoted_identifier off;\nset @sql = \"/* SQLMonitor - Dashboard [$__dashboard] */\nset nocount on;\n\n;with t_backups as (\n\t\tselect [collection_time_utc], [sql_instance], [database_name], [backup_type], [log_backups_count], [backup_start_date_utc], [backup_finish_date_utc], [latest_backup_location], [backup_size_mb], [compressed_backup_size_mb], [first_lsn], [last_lsn], [checkpoint_lsn], [database_backup_lsn], [database_creation_date_utc], [backup_software], [recovery_model], [compatibility_level], [device_type], [description]\n\t\tfrom dbo.backups_all_servers bas\n)\n,t_pivot as (\n\t\tselect\t[sql_instance], [database_name]\n\t\t\t\t,[recovery_model] = max([recovery_model])\n\t\t\t\t,[full_backup_time_utc] = max(case when bkp.[backup_type] = 'Full Database Backup' then bkp.[backup_finish_date_utc] else null end)\n\t\t\t\t,[full_backup_size_mb] = max(case when bkp.[backup_type] = 'Full Database Backup' then bkp.[backup_size_mb] else null end)\n\t\t\t\t,[full_compressed_size_mb] = max(case when bkp.[backup_type] = 'Full Database Backup' then bkp.[compressed_backup_size_mb] else null end)\n\t\t\t\t,[diff_backup_time_utc] = max(case when bkp.[backup_type] = 'Differential database Backup' then bkp.[backup_finish_date_utc] else null end)\n\t\t\t\t,[diff_backup_size_mb] = max(case when bkp.[backup_type] = 'Differential database Backup' then bkp.[backup_size_mb] else null end)\n\t\t\t\t,[diff_compressed_size_mb] = max(case when bkp.[backup_type] = 'Differential database Backup' then bkp.[compressed_backup_size_mb] else null end)\n\t\t\t\t,[tlog_backup_time_utc] = max(case when bkp.[backup_type] = 'Transaction Log Backup' then bkp.[backup_finish_date_utc] else null end)\n\t\t\t\t,[tlog_backup_size_mb] = max(case when bkp.[backup_type] = 'Transaction Log Backup' then bkp.[backup_size_mb] else null end)\n\t\t\t\t,[tlog_compressed_size_mb] = max(case when bkp.[backup_type] = 'Transaction Log Backup' then bkp.[compressed_backup_size_mb] else null end)\n\t\t\t\t,[log_backups_count] = max([log_backups_count])\n\t\t\t\t,[database_creation_date_utc] = max([database_creation_date_utc])\n\t\t\t\t,[full_backup_file] = max(case when bkp.[backup_type] = 'Full Database Backup' then bkp.[latest_backup_location] else null end)\n\t\t\t\t,[diff_backup_file] = max(case when bkp.[backup_type] = 'Differential database Backup' then bkp.[latest_backup_location] else null end)\n\t\t\t\t,[tlog_backup_file] = max(case when bkp.[backup_type] = 'Transaction Log Backup' then bkp.[latest_backup_location] else null end)\n\t\tfrom t_backups bkp\n\t\twhere 1=1\n\t\tgroup by [sql_instance], [database_name]\n)\n,t_latency as (\n\t\t\tselect \t[sql_instance], [database_name], [recovery_model], \t\t\t\t\n\t\t\t\t\t\t\t[full_latency_days] = case when [full_backup_time_utc] is null then @full_threshold_days * 10\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\telse datediff(day,[full_backup_time_utc],getutcdate())\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tend,\t\t\t\t\t\t\n\t\t\t\t\t\t\t[diff_latency_hours] = case when [diff_backup_time_utc] is null \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tthen\tcase when (datediff(day,[full_backup_time_utc],getutcdate()) > @full_threshold_days) and (@full_threshold_days >= 7)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tthen @full_threshold_days * 24\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\twhen (datediff(day,[full_backup_time_utc],getutcdate())*24) > @diff_threshold_hours\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tthen ( (datediff(day,[full_backup_time_utc],getutcdate())-1) * 24 )\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\telse null\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\telse datediff(hour,[diff_backup_time_utc],getutcdate())\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tend,\n\t\t\t\t\t\t\t[tlog_latency_minutes] = case when recovery_model = 'SIMPLE' then null\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\twhen recovery_model <> 'SIMPLE'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tthen\tcase when [tlog_backup_time_utc] is null then @full_threshold_days * 1440\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t when [tlog_backup_time_utc] is not null\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t then datediff(minute,[tlog_backup_time_utc],getutcdate())\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t else null\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t end\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\telse null\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tend,\n\t\t\t\t\t\t\t[full_backup_time_utc], [diff_backup_time_utc], [tlog_backup_time_utc], \n\t\t\t\t\t\t\t[full_backup_size_mb], [full_compressed_size_mb], [diff_backup_size_mb], [diff_compressed_size_mb], [tlog_backup_size_mb],\n\t\t\t\t\t\t\t[tlog_compressed_size_mb], [log_backups_count],\n\t\t\t\t\t\t\t[database_creation_date_utc], [full_backup_file], [diff_backup_file], [tlog_backup_file]\n\t\t\tfrom t_pivot as bkp\n\t\t\twhere 1=1\n)\nselect count(*)\n/*\nselect [sql_instance], [database_name], [recovery_model], \t\t\t\t\n\t\t\t\t\t\t\t[full_latency_days], [diff_latency_hours], [tlog_latency_minutes],\n\t\t\t\t\t\t\t[full_backup_time_utc], [diff_backup_time_utc], [tlog_backup_time_utc], \n\t\t\t\t\t\t\t[full_backup_size_mb], [full_compressed_size_mb], [diff_backup_size_mb], [diff_compressed_size_mb], \n\t\t\t\t\t\t\t[tlog_backup_size_mb], [tlog_compressed_size_mb], [log_backups_count], [database_creation_date_utc], \n\t\t\t\t\t\t\t[full_backup_file], [diff_backup_file], [tlog_backup_file]\n*/\nfrom t_latency as l\nwhere 1=1\nAND (\t\t(full_latency_days is null or full_latency_days >= @full_threshold_days)\n\t\tOR \t(diff_latency_hours is not null and diff_latency_hours >= @diff_threshold_hours)\n\t\tOR\t(tlog_latency_minutes is not null and tlog_latency_minutes >= @tlog_threshold_minutes)\n\t\t)\n\"+(case when @_has_inventory = 0 then '--' else '' end)+\"and exists (select * from dbo.sma_servers s where s.is_decommissioned = 0 and s.is_onboarded = 1 and s.server = l.sql_instance and (s.hadr_strategy is null or s.hadr_strategy <> 'ag'))\n\"\nset quoted_identifier on;\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nexec dbo.sp_executesql @sql, @params, @start_time_utc, @end_time_utc, @full_threshold_days, @diff_threshold_hours, \n\t\t\t\t\t\t\t\t\t\t\t\t@tlog_threshold_minutes;", + "hide": 2, + "includeAll": false, + "label": "Database Count With Backup Issue", + "name": "nonag_database_counts_with_backup_issue", + "options": [], + "query": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\n--declare @sql_instance varchar(255);\n--declare @backup_type varchar(2000);\n--declare @backup_description varchar(2000);\n--declare @perfmon_host_name varchar(255);\ndeclare @start_time_utc datetime2;\ndeclare @end_time_utc datetime2;\n--declare @delta_minutes int;\n--declare @disk_drive varchar(255) = '$disk_drive';\n--declare @database varchar(255) = '$database';\n--declare @filter_for_latency varchar(50) = '$filter_for_latency';\ndeclare @full_threshold_days int = $full_threshold_days;\ndeclare @diff_threshold_hours int = $diff_threshold_hours;\ndeclare @tlog_threshold_minutes int = $tlog_threshold_minutes;\ndeclare @_has_inventory bit = 0;\nset @_has_inventory = convert(bit,'${has_inventory}');\n\n--set @database = case when ltrim(rtrim(@database)) = '__All__' then null else @database end;\n--set @disk_drive = case when ltrim(rtrim(@disk_drive)) = '__All__' then null else @disk_drive end;\n\n--set @perfmon_host_name = '$perfmon_host_name';\nset @start_time_utc = $__timeFrom();\nset @end_time_utc = $__timeTo();\n--set @delta_minutes = $cpu_delta_minutes;\n\n--set @backup_type = '${backup_type:csv}';\n--set @backup_description = case when ltrim(rtrim('$backup_description')) = '' then null else ltrim(rtrim('$backup_description')) end;\n\nset @params = N'@start_time_utc datetime2, @end_time_utc datetime2, \n\t\t\t\t\t\t\t\t@full_threshold_days int, @diff_threshold_hours int, @tlog_threshold_minutes int';\n\nset quoted_identifier off;\nset @sql = \"/* SQLMonitor - Dashboard [$__dashboard] */\nset nocount on;\n\n;with t_backups as (\n\t\tselect [collection_time_utc], [sql_instance], [database_name], [backup_type], [log_backups_count], [backup_start_date_utc], [backup_finish_date_utc], [latest_backup_location], [backup_size_mb], [compressed_backup_size_mb], [first_lsn], [last_lsn], [checkpoint_lsn], [database_backup_lsn], [database_creation_date_utc], [backup_software], [recovery_model], [compatibility_level], [device_type], [description]\n\t\tfrom dbo.backups_all_servers bas\n)\n,t_pivot as (\n\t\tselect\t[sql_instance], [database_name]\n\t\t\t\t,[recovery_model] = max([recovery_model])\n\t\t\t\t,[full_backup_time_utc] = max(case when bkp.[backup_type] = 'Full Database Backup' then bkp.[backup_finish_date_utc] else null end)\n\t\t\t\t,[full_backup_size_mb] = max(case when bkp.[backup_type] = 'Full Database Backup' then bkp.[backup_size_mb] else null end)\n\t\t\t\t,[full_compressed_size_mb] = max(case when bkp.[backup_type] = 'Full Database Backup' then bkp.[compressed_backup_size_mb] else null end)\n\t\t\t\t,[diff_backup_time_utc] = max(case when bkp.[backup_type] = 'Differential database Backup' then bkp.[backup_finish_date_utc] else null end)\n\t\t\t\t,[diff_backup_size_mb] = max(case when bkp.[backup_type] = 'Differential database Backup' then bkp.[backup_size_mb] else null end)\n\t\t\t\t,[diff_compressed_size_mb] = max(case when bkp.[backup_type] = 'Differential database Backup' then bkp.[compressed_backup_size_mb] else null end)\n\t\t\t\t,[tlog_backup_time_utc] = max(case when bkp.[backup_type] = 'Transaction Log Backup' then bkp.[backup_finish_date_utc] else null end)\n\t\t\t\t,[tlog_backup_size_mb] = max(case when bkp.[backup_type] = 'Transaction Log Backup' then bkp.[backup_size_mb] else null end)\n\t\t\t\t,[tlog_compressed_size_mb] = max(case when bkp.[backup_type] = 'Transaction Log Backup' then bkp.[compressed_backup_size_mb] else null end)\n\t\t\t\t,[log_backups_count] = max([log_backups_count])\n\t\t\t\t,[database_creation_date_utc] = max([database_creation_date_utc])\n\t\t\t\t,[full_backup_file] = max(case when bkp.[backup_type] = 'Full Database Backup' then bkp.[latest_backup_location] else null end)\n\t\t\t\t,[diff_backup_file] = max(case when bkp.[backup_type] = 'Differential database Backup' then bkp.[latest_backup_location] else null end)\n\t\t\t\t,[tlog_backup_file] = max(case when bkp.[backup_type] = 'Transaction Log Backup' then bkp.[latest_backup_location] else null end)\n\t\tfrom t_backups bkp\n\t\twhere 1=1\n\t\tgroup by [sql_instance], [database_name]\n)\n,t_latency as (\n\t\t\tselect \t[sql_instance], [database_name], [recovery_model], \t\t\t\t\n\t\t\t\t\t\t\t[full_latency_days] = case when [full_backup_time_utc] is null then @full_threshold_days * 10\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\telse datediff(day,[full_backup_time_utc],getutcdate())\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tend,\t\t\t\t\t\t\n\t\t\t\t\t\t\t[diff_latency_hours] = case when [diff_backup_time_utc] is null \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tthen\tcase when (datediff(day,[full_backup_time_utc],getutcdate()) > @full_threshold_days) and (@full_threshold_days >= 7)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tthen @full_threshold_days * 24\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\twhen (datediff(day,[full_backup_time_utc],getutcdate())*24) > @diff_threshold_hours\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tthen ( (datediff(day,[full_backup_time_utc],getutcdate())-1) * 24 )\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\telse null\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\telse datediff(hour,[diff_backup_time_utc],getutcdate())\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tend,\n\t\t\t\t\t\t\t[tlog_latency_minutes] = case when recovery_model = 'SIMPLE' then null\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\twhen recovery_model <> 'SIMPLE'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tthen\tcase when [tlog_backup_time_utc] is null then @full_threshold_days * 1440\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t when [tlog_backup_time_utc] is not null\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t then datediff(minute,[tlog_backup_time_utc],getutcdate())\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t else null\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t end\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\telse null\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tend,\n\t\t\t\t\t\t\t[full_backup_time_utc], [diff_backup_time_utc], [tlog_backup_time_utc], \n\t\t\t\t\t\t\t[full_backup_size_mb], [full_compressed_size_mb], [diff_backup_size_mb], [diff_compressed_size_mb], [tlog_backup_size_mb],\n\t\t\t\t\t\t\t[tlog_compressed_size_mb], [log_backups_count],\n\t\t\t\t\t\t\t[database_creation_date_utc], [full_backup_file], [diff_backup_file], [tlog_backup_file]\n\t\t\tfrom t_pivot as bkp\n\t\t\twhere 1=1\n)\nselect count(*)\n/*\nselect [sql_instance], [database_name], [recovery_model], \t\t\t\t\n\t\t\t\t\t\t\t[full_latency_days], [diff_latency_hours], [tlog_latency_minutes],\n\t\t\t\t\t\t\t[full_backup_time_utc], [diff_backup_time_utc], [tlog_backup_time_utc], \n\t\t\t\t\t\t\t[full_backup_size_mb], [full_compressed_size_mb], [diff_backup_size_mb], [diff_compressed_size_mb], \n\t\t\t\t\t\t\t[tlog_backup_size_mb], [tlog_compressed_size_mb], [log_backups_count], [database_creation_date_utc], \n\t\t\t\t\t\t\t[full_backup_file], [diff_backup_file], [tlog_backup_file]\n*/\nfrom t_latency as l\nwhere 1=1\nAND (\t\t(full_latency_days is null or full_latency_days >= @full_threshold_days)\n\t\tOR \t(diff_latency_hours is not null and diff_latency_hours >= @diff_threshold_hours)\n\t\tOR\t(tlog_latency_minutes is not null and tlog_latency_minutes >= @tlog_threshold_minutes)\n\t\t)\n\"+(case when @_has_inventory = 0 then '--' else '' end)+\"and exists (select * from dbo.sma_servers s where s.is_decommissioned = 0 and s.is_onboarded = 1 and s.server = l.sql_instance and (s.hadr_strategy is null or s.hadr_strategy <> 'ag'))\n\"\nset quoted_identifier on;\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nexec dbo.sp_executesql @sql, @params, @start_time_utc, @end_time_utc, @full_threshold_days, @diff_threshold_hours, \n\t\t\t\t\t\t\t\t\t\t\t\t@tlog_threshold_minutes;", + "refresh": 2, + "regex": "", + "type": "query" + }, + { + "current": {}, + "datasource": { + "type": "mssql", + "uid": "${sqlmonitor_datasource}" + }, + "definition": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\n--declare @sql_instance varchar(255);\n--declare @backup_type varchar(2000);\n--declare @backup_description varchar(2000);\n--declare @perfmon_host_name varchar(255);\ndeclare @start_time_utc datetime2;\ndeclare @end_time_utc datetime2;\n--declare @delta_minutes int;\n--declare @disk_drive varchar(255) = '$disk_drive';\n--declare @database varchar(255) = '$database';\n--declare @filter_for_latency varchar(50) = '$filter_for_latency';\ndeclare @full_threshold_days int = $full_threshold_days;\ndeclare @diff_threshold_hours int = $diff_threshold_hours;\ndeclare @tlog_threshold_minutes int = $tlog_threshold_minutes;\ndeclare @_has_inventory bit = 0;\n\n\n--set @database = case when ltrim(rtrim(@database)) = '__All__' then null else @database end;\n--set @disk_drive = case when ltrim(rtrim(@disk_drive)) = '__All__' then null else @disk_drive end;\n\n--set @perfmon_host_name = '$perfmon_host_name';\nset @start_time_utc = $__timeFrom();\nset @end_time_utc = $__timeTo();\n--set @delta_minutes = $cpu_delta_minutes;\nset @_has_inventory = convert(bit,'${has_inventory}');\n\n--set @backup_type = '${backup_type:csv}';\n--set @backup_description = case when ltrim(rtrim('$backup_description')) = '' then null else ltrim(rtrim('$backup_description')) end;\n\nset @params = N'@start_time_utc datetime2, @end_time_utc datetime2, \n\t\t\t\t\t\t\t\t@full_threshold_days int, @diff_threshold_hours int, @tlog_threshold_minutes int';\n\nset quoted_identifier off;\nset @sql = \"/* SQLMonitor - Dashboard [Monitoring - Live - All Servers] */\nset nocount on;\n\n;with t_backups as (\n\tselect [collection_time_utc], [sql_instance], s.ag_replicas, [database_name], [backup_type], [log_backups_count], \n\t\t\t[backup_start_date_utc], [backup_finish_date_utc], [latest_backup_location], [backup_size_mb], [compressed_backup_size_mb], [first_lsn], [last_lsn], [checkpoint_lsn], [database_backup_lsn], [database_creation_date_utc], [backup_software], [recovery_model], [compatibility_level], [device_type], [description]\n\t\t\t,db_rowid = ROW_NUMBER()over(partition by s.ag_replicas, [database_name], [backup_type] order by [backup_start_date_utc] desc)\n\tfrom dbo.backups_all_servers bas\n\tjoin dbo.sma_sql_servers s on s.server = bas.sql_instance and s.is_decommissioned = 0 and s.is_onboarded = 1 and s.hadr_strategy = 'ag'\n\twhere 1=1\n\tand charindex(',',s.ag_replicas) > 0\n)\n,t_pivot as (\n\t\tselect\tag_replicas, [sql_instance], [database_name]\n\t\t\t\t,[recovery_model] = max([recovery_model])\n\t\t\t\t,[full_backup_time_utc] = max(case when bkp.[backup_type] = 'Full Database Backup' then bkp.[backup_finish_date_utc] else null end)\n\t\t\t\t,[full_backup_size_mb] = max(case when bkp.[backup_type] = 'Full Database Backup' then bkp.[backup_size_mb] else null end)\n\t\t\t\t,[full_compressed_size_mb] = max(case when bkp.[backup_type] = 'Full Database Backup' then bkp.[compressed_backup_size_mb] else null end)\n\t\t\t\t,[diff_backup_time_utc] = max(case when bkp.[backup_type] = 'Differential database Backup' then bkp.[backup_finish_date_utc] else null end)\n\t\t\t\t,[diff_backup_size_mb] = max(case when bkp.[backup_type] = 'Differential database Backup' then bkp.[backup_size_mb] else null end)\n\t\t\t\t,[diff_compressed_size_mb] = max(case when bkp.[backup_type] = 'Differential database Backup' then bkp.[compressed_backup_size_mb] else null end)\n\t\t\t\t,[tlog_backup_time_utc] = max(case when bkp.[backup_type] = 'Transaction Log Backup' then bkp.[backup_finish_date_utc] else null end)\n\t\t\t\t,[tlog_backup_size_mb] = max(case when bkp.[backup_type] = 'Transaction Log Backup' then bkp.[backup_size_mb] else null end)\n\t\t\t\t,[tlog_compressed_size_mb] = max(case when bkp.[backup_type] = 'Transaction Log Backup' then bkp.[compressed_backup_size_mb] else null end)\n\t\t\t\t,[log_backups_count] = max([log_backups_count])\n\t\t\t\t,[database_creation_date_utc] = max([database_creation_date_utc])\n\t\t\t\t,[full_backup_file] = max(case when bkp.[backup_type] = 'Full Database Backup' then bkp.[latest_backup_location] else null end)\n\t\t\t\t,[diff_backup_file] = max(case when bkp.[backup_type] = 'Differential database Backup' then bkp.[latest_backup_location] else null end)\n\t\t\t\t,[tlog_backup_file] = max(case when bkp.[backup_type] = 'Transaction Log Backup' then bkp.[latest_backup_location] else null end)\n\t\tfrom t_backups bkp\n\t\twhere 1=1\n\t\tand db_rowid = 1\n\t\tgroup by ag_replicas, [sql_instance], [database_name]\n)\n,t_latency as (\n\t\t\tselect \tag_replicas, [sql_instance], [database_name], [recovery_model], \t\t\t\t\n\t\t\t\t\t\t\t[full_latency_days] = case when [full_backup_time_utc] is null then @full_threshold_days * 10\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\telse datediff(day,[full_backup_time_utc],getutcdate())\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tend,\t\t\t\t\t\t\n\t\t\t\t\t\t\t[diff_latency_hours] = case when [diff_backup_time_utc] is null \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tthen\tcase when (datediff(day,[full_backup_time_utc],getutcdate()) > @full_threshold_days) and (@full_threshold_days >= 7)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tthen @full_threshold_days * 24\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\twhen (datediff(day,[full_backup_time_utc],getutcdate())*24) > @diff_threshold_hours\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tthen ( (datediff(day,[full_backup_time_utc],getutcdate())-1) * 24 )\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\telse null\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\telse datediff(hour,[diff_backup_time_utc],getutcdate())\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tend,\n\t\t\t\t\t\t\t[tlog_latency_minutes] = case when recovery_model = 'SIMPLE' then null\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\twhen recovery_model <> 'SIMPLE'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tthen\tcase when [tlog_backup_time_utc] is null then @full_threshold_days * 1440\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t when [tlog_backup_time_utc] is not null\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t then datediff(minute,[tlog_backup_time_utc],getutcdate())\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t else null\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t end\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\telse null\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tend,\n\t\t\t\t\t\t\t[full_backup_time_utc], [diff_backup_time_utc], [tlog_backup_time_utc], \n\t\t\t\t\t\t\t[full_backup_size_mb], [full_compressed_size_mb], [diff_backup_size_mb], [diff_compressed_size_mb], [tlog_backup_size_mb],\n\t\t\t\t\t\t\t[tlog_compressed_size_mb], [log_backups_count],\n\t\t\t\t\t\t\t[database_creation_date_utc], [full_backup_file], [diff_backup_file], [tlog_backup_file]\n\t\t\tfrom t_pivot as bkp\n\t\t\twhere 1=1\n)\nselect count(*)\nfrom t_latency as l\nwhere 1=1\nAND (\t\t(full_latency_days is null or full_latency_days >= @full_threshold_days)\n\t\tOR \t(diff_latency_hours is not null and diff_latency_hours >= @diff_threshold_hours)\n\t\tOR\t(tlog_latency_minutes is not null and tlog_latency_minutes >= @tlog_threshold_minutes)\n\t\t)\n--order by ag_replicas, database_name\n\"\nset quoted_identifier on;\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nexec dbo.sp_executesql @sql, @params, @start_time_utc, @end_time_utc, @full_threshold_days, @diff_threshold_hours, \n\t\t\t\t\t\t\t\t\t\t\t\t@tlog_threshold_minutes;", + "hide": 2, + "includeAll": false, + "label": "Database Count With Backup Issue", + "name": "ag_database_counts_with_backup_issue", + "options": [], + "query": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\n--declare @sql_instance varchar(255);\n--declare @backup_type varchar(2000);\n--declare @backup_description varchar(2000);\n--declare @perfmon_host_name varchar(255);\ndeclare @start_time_utc datetime2;\ndeclare @end_time_utc datetime2;\n--declare @delta_minutes int;\n--declare @disk_drive varchar(255) = '$disk_drive';\n--declare @database varchar(255) = '$database';\n--declare @filter_for_latency varchar(50) = '$filter_for_latency';\ndeclare @full_threshold_days int = $full_threshold_days;\ndeclare @diff_threshold_hours int = $diff_threshold_hours;\ndeclare @tlog_threshold_minutes int = $tlog_threshold_minutes;\ndeclare @_has_inventory bit = 0;\n\n\n--set @database = case when ltrim(rtrim(@database)) = '__All__' then null else @database end;\n--set @disk_drive = case when ltrim(rtrim(@disk_drive)) = '__All__' then null else @disk_drive end;\n\n--set @perfmon_host_name = '$perfmon_host_name';\nset @start_time_utc = $__timeFrom();\nset @end_time_utc = $__timeTo();\n--set @delta_minutes = $cpu_delta_minutes;\nset @_has_inventory = convert(bit,'${has_inventory}');\n\n--set @backup_type = '${backup_type:csv}';\n--set @backup_description = case when ltrim(rtrim('$backup_description')) = '' then null else ltrim(rtrim('$backup_description')) end;\n\nset @params = N'@start_time_utc datetime2, @end_time_utc datetime2, \n\t\t\t\t\t\t\t\t@full_threshold_days int, @diff_threshold_hours int, @tlog_threshold_minutes int';\n\nset quoted_identifier off;\nset @sql = \"/* SQLMonitor - Dashboard [Monitoring - Live - All Servers] */\nset nocount on;\n\n;with t_backups as (\n\tselect [collection_time_utc], [sql_instance], s.ag_replicas, [database_name], [backup_type], [log_backups_count], \n\t\t\t[backup_start_date_utc], [backup_finish_date_utc], [latest_backup_location], [backup_size_mb], [compressed_backup_size_mb], [first_lsn], [last_lsn], [checkpoint_lsn], [database_backup_lsn], [database_creation_date_utc], [backup_software], [recovery_model], [compatibility_level], [device_type], [description]\n\t\t\t,db_rowid = ROW_NUMBER()over(partition by s.ag_replicas, [database_name], [backup_type] order by [backup_start_date_utc] desc)\n\tfrom dbo.backups_all_servers bas\n\tjoin dbo.sma_sql_servers s on s.server = bas.sql_instance and s.is_decommissioned = 0 and s.is_onboarded = 1 and s.hadr_strategy = 'ag'\n\twhere 1=1\n\tand charindex(',',s.ag_replicas) > 0\n)\n,t_pivot as (\n\t\tselect\tag_replicas, [sql_instance], [database_name]\n\t\t\t\t,[recovery_model] = max([recovery_model])\n\t\t\t\t,[full_backup_time_utc] = max(case when bkp.[backup_type] = 'Full Database Backup' then bkp.[backup_finish_date_utc] else null end)\n\t\t\t\t,[full_backup_size_mb] = max(case when bkp.[backup_type] = 'Full Database Backup' then bkp.[backup_size_mb] else null end)\n\t\t\t\t,[full_compressed_size_mb] = max(case when bkp.[backup_type] = 'Full Database Backup' then bkp.[compressed_backup_size_mb] else null end)\n\t\t\t\t,[diff_backup_time_utc] = max(case when bkp.[backup_type] = 'Differential database Backup' then bkp.[backup_finish_date_utc] else null end)\n\t\t\t\t,[diff_backup_size_mb] = max(case when bkp.[backup_type] = 'Differential database Backup' then bkp.[backup_size_mb] else null end)\n\t\t\t\t,[diff_compressed_size_mb] = max(case when bkp.[backup_type] = 'Differential database Backup' then bkp.[compressed_backup_size_mb] else null end)\n\t\t\t\t,[tlog_backup_time_utc] = max(case when bkp.[backup_type] = 'Transaction Log Backup' then bkp.[backup_finish_date_utc] else null end)\n\t\t\t\t,[tlog_backup_size_mb] = max(case when bkp.[backup_type] = 'Transaction Log Backup' then bkp.[backup_size_mb] else null end)\n\t\t\t\t,[tlog_compressed_size_mb] = max(case when bkp.[backup_type] = 'Transaction Log Backup' then bkp.[compressed_backup_size_mb] else null end)\n\t\t\t\t,[log_backups_count] = max([log_backups_count])\n\t\t\t\t,[database_creation_date_utc] = max([database_creation_date_utc])\n\t\t\t\t,[full_backup_file] = max(case when bkp.[backup_type] = 'Full Database Backup' then bkp.[latest_backup_location] else null end)\n\t\t\t\t,[diff_backup_file] = max(case when bkp.[backup_type] = 'Differential database Backup' then bkp.[latest_backup_location] else null end)\n\t\t\t\t,[tlog_backup_file] = max(case when bkp.[backup_type] = 'Transaction Log Backup' then bkp.[latest_backup_location] else null end)\n\t\tfrom t_backups bkp\n\t\twhere 1=1\n\t\tand db_rowid = 1\n\t\tgroup by ag_replicas, [sql_instance], [database_name]\n)\n,t_latency as (\n\t\t\tselect \tag_replicas, [sql_instance], [database_name], [recovery_model], \t\t\t\t\n\t\t\t\t\t\t\t[full_latency_days] = case when [full_backup_time_utc] is null then @full_threshold_days * 10\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\telse datediff(day,[full_backup_time_utc],getutcdate())\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tend,\t\t\t\t\t\t\n\t\t\t\t\t\t\t[diff_latency_hours] = case when [diff_backup_time_utc] is null \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tthen\tcase when (datediff(day,[full_backup_time_utc],getutcdate()) > @full_threshold_days) and (@full_threshold_days >= 7)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tthen @full_threshold_days * 24\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\twhen (datediff(day,[full_backup_time_utc],getutcdate())*24) > @diff_threshold_hours\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tthen ( (datediff(day,[full_backup_time_utc],getutcdate())-1) * 24 )\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\telse null\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\telse datediff(hour,[diff_backup_time_utc],getutcdate())\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tend,\n\t\t\t\t\t\t\t[tlog_latency_minutes] = case when recovery_model = 'SIMPLE' then null\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\twhen recovery_model <> 'SIMPLE'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tthen\tcase when [tlog_backup_time_utc] is null then @full_threshold_days * 1440\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t when [tlog_backup_time_utc] is not null\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t then datediff(minute,[tlog_backup_time_utc],getutcdate())\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t else null\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t end\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\telse null\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tend,\n\t\t\t\t\t\t\t[full_backup_time_utc], [diff_backup_time_utc], [tlog_backup_time_utc], \n\t\t\t\t\t\t\t[full_backup_size_mb], [full_compressed_size_mb], [diff_backup_size_mb], [diff_compressed_size_mb], [tlog_backup_size_mb],\n\t\t\t\t\t\t\t[tlog_compressed_size_mb], [log_backups_count],\n\t\t\t\t\t\t\t[database_creation_date_utc], [full_backup_file], [diff_backup_file], [tlog_backup_file]\n\t\t\tfrom t_pivot as bkp\n\t\t\twhere 1=1\n)\nselect count(*)\nfrom t_latency as l\nwhere 1=1\nAND (\t\t(full_latency_days is null or full_latency_days >= @full_threshold_days)\n\t\tOR \t(diff_latency_hours is not null and diff_latency_hours >= @diff_threshold_hours)\n\t\tOR\t(tlog_latency_minutes is not null and tlog_latency_minutes >= @tlog_threshold_minutes)\n\t\t)\n--order by ag_replicas, database_name\n\"\nset quoted_identifier on;\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nexec dbo.sp_executesql @sql, @params, @start_time_utc, @end_time_utc, @full_threshold_days, @diff_threshold_hours, \n\t\t\t\t\t\t\t\t\t\t\t\t@tlog_threshold_minutes;", + "refresh": 2, + "regex": "", + "type": "query" + }, + { + "current": {}, + "datasource": { + "type": "mssql", + "uid": "${DS_SQLMONITOR}" + }, + "definition": "declare @_buffer_time_minutes int = 30;\ndeclare @_sql nvarchar(max);\ndeclare @_params nvarchar(max);\n\nset @_params = N'@_buffer_time_minutes int';\nset quoted_identifier off;\nset @_sql = \"\nselect\tcount(*) /* [Tsql-Stop-Job] = 'exec msdb.dbo.sp_stop_job @job_name = '''+sj.JobName+'''' ,\n\t\t[Tsql-Start-Job] = 'exec msdb.dbo.sp_start_job @job_name = '''+sj.JobName+'''' , \n\t\t\n\t\t[CollectionTimeUTC] = [UpdatedDateUTC],\n\t\t[sql_instance] = sql_instance_with_port, [JobName],\n\t\t[Job-Delay-Minutes] = case when sj.Last_Successful_ExecutionTime is null then 10080 else datediff(minute, sj.Last_Successful_ExecutionTime, dateadd(minute,-(sj.Successfull_Execution_ClockTime_Threshold_Minutes+@_buffer_time_minutes),getutcdate())) end,\n\t\t [Last_RunTime], [Last_Run_Duration_Seconds], [Last_Run_Outcome], \n\t\t [Successfull_Execution_ClockTime_Threshold_Minutes], \n\t\t [Expected_Max_Duration_Minutes],\n\t\t [Last_Successful_ExecutionTime], [Last_Successful_Execution_Hours], \n\t\t [Running_Since], [Running_StepName], [Running_Since_Min] \n*/\nfrom dbo.sql_agent_jobs_all_servers sj\ninner join dbo.services_all_servers sas\n\ton sas.sql_instance = sj.sql_instance\n\tand sas.service_type = 'Agent'\n\tand sas.status_desc = 'Running'\ncross apply (select top 1 sql_instance_with_port = coalesce(id.sql_instance+','+sql_instance_port,id.sql_instance) from dbo.instance_details id where id.sql_instance = sj.sql_instance and id.is_enabled = 1) id\nwhere 1=1\n--and exists (select 1/0 from dbo.instance_details id where id.sql_instance = sj.sql_instance and id.is_enabled = 1)\nand sj.JobCategory = '(dba) SQLMonitor'\nand sj.JobName like '(dba) %'\nand sj.IsDisabled = 0\nand (\tdateadd(minute,-(sj.Successfull_Execution_ClockTime_Threshold_Minutes+@_buffer_time_minutes),getutcdate()) > sj.Last_Successful_ExecutionTime\n\t\t\tor sj.Last_Successful_ExecutionTime is null\n\t\t)\n--order by Last_Run_Outcome\n\"\nset quoted_identifier off;\n\nexec sp_executesql @_sql, @_params, @_buffer_time_minutes = @_buffer_time_minutes;", + "hide": 2, + "includeAll": false, + "label": "DBA Jobs With Issue", + "name": "dba_jobs_with_issue_counts", + "options": [], + "query": "declare @_buffer_time_minutes int = 30;\ndeclare @_sql nvarchar(max);\ndeclare @_params nvarchar(max);\n\nset @_params = N'@_buffer_time_minutes int';\nset quoted_identifier off;\nset @_sql = \"\nselect\tcount(*) /* [Tsql-Stop-Job] = 'exec msdb.dbo.sp_stop_job @job_name = '''+sj.JobName+'''' ,\n\t\t[Tsql-Start-Job] = 'exec msdb.dbo.sp_start_job @job_name = '''+sj.JobName+'''' , \n\t\t\n\t\t[CollectionTimeUTC] = [UpdatedDateUTC],\n\t\t[sql_instance] = sql_instance_with_port, [JobName],\n\t\t[Job-Delay-Minutes] = case when sj.Last_Successful_ExecutionTime is null then 10080 else datediff(minute, sj.Last_Successful_ExecutionTime, dateadd(minute,-(sj.Successfull_Execution_ClockTime_Threshold_Minutes+@_buffer_time_minutes),getutcdate())) end,\n\t\t [Last_RunTime], [Last_Run_Duration_Seconds], [Last_Run_Outcome], \n\t\t [Successfull_Execution_ClockTime_Threshold_Minutes], \n\t\t [Expected_Max_Duration_Minutes],\n\t\t [Last_Successful_ExecutionTime], [Last_Successful_Execution_Hours], \n\t\t [Running_Since], [Running_StepName], [Running_Since_Min] \n*/\nfrom dbo.sql_agent_jobs_all_servers sj\ninner join dbo.services_all_servers sas\n\ton sas.sql_instance = sj.sql_instance\n\tand sas.service_type = 'Agent'\n\tand sas.status_desc = 'Running'\ncross apply (select top 1 sql_instance_with_port = coalesce(id.sql_instance+','+sql_instance_port,id.sql_instance) from dbo.instance_details id where id.sql_instance = sj.sql_instance and id.is_enabled = 1) id\nwhere 1=1\n--and exists (select 1/0 from dbo.instance_details id where id.sql_instance = sj.sql_instance and id.is_enabled = 1)\nand sj.JobCategory = '(dba) SQLMonitor'\nand sj.JobName like '(dba) %'\nand sj.IsDisabled = 0\nand (\tdateadd(minute,-(sj.Successfull_Execution_ClockTime_Threshold_Minutes+@_buffer_time_minutes),getutcdate()) > sj.Last_Successful_ExecutionTime\n\t\t\tor sj.Last_Successful_ExecutionTime is null\n\t\t)\n--order by Last_Run_Outcome\n\"\nset quoted_identifier off;\n\nexec sp_executesql @_sql, @_params, @_buffer_time_minutes = @_buffer_time_minutes;", + "refresh": 2, + "regex": "", + "type": "query" + }, + { + "current": {}, + "datasource": { + "type": "mssql", + "uid": "${sqlmonitor_datasource}" + }, + "definition": "declare @_disk_warning_pct decimal(20,2) = 80;\ndeclare @_disk_critical_pct decimal(20,2) = 90;\ndeclare @_disk_threshold_gb decimal(20,2) = 200;\ndeclare @_large_disk_threshold_pct decimal(20,2) = 95;\ndeclare @_has_inventory bit = 0;\nset @_has_inventory = convert(bit,'${has_inventory}');\n\ndeclare @_sql nvarchar(max);\ndeclare @_params nvarchar(max);\n\nset @_params = '@disk_warning_pct decimal(20,2), @disk_critical_pct decimal(20,2), @disk_threshold_gb decimal(20,2), @large_disk_threshold_pct decimal(20,2)';\n\nset quoted_identifier off;\nset @_sql = \"\nselect\tcount(*) \nfrom dbo.disk_space_all_servers ds\nwhere ds.updated_date_utc >= dateadd(minute,-60,getutcdate())\nand (\t(\t(ds.free_mb*100.0/ds.capacity_mb) < (100-@disk_warning_pct)\n\t\t\tand ds.free_mb < (@disk_threshold_gb)*1024\n\t \t)\n\t\tor ( (ds.free_mb*100.0/ds.capacity_mb) < (100-@large_disk_threshold_pct)) -- free %\n\t)\nand (ds.free_mb*100.0/ds.capacity_mb) < (100-@disk_critical_pct)\n\"+(case when @_has_inventory = 0 then '--' else '' end)+\"and exists (select * from dbo.sma_servers s where s.is_decommissioned = 0 and s.is_onboarded = 1 and s.server = ds.sql_instance)\n\";\nset quoted_identifier off;\n\nexec sp_executesql @_sql, @_params, @_disk_warning_pct, @_disk_critical_pct, @_disk_threshold_gb , @_large_disk_threshold_pct;", + "hide": 2, + "includeAll": false, + "label": "Disks in Critical State", + "name": "critical_disks_counts", + "options": [], + "query": "declare @_disk_warning_pct decimal(20,2) = 80;\ndeclare @_disk_critical_pct decimal(20,2) = 90;\ndeclare @_disk_threshold_gb decimal(20,2) = 200;\ndeclare @_large_disk_threshold_pct decimal(20,2) = 95;\ndeclare @_has_inventory bit = 0;\nset @_has_inventory = convert(bit,'${has_inventory}');\n\ndeclare @_sql nvarchar(max);\ndeclare @_params nvarchar(max);\n\nset @_params = '@disk_warning_pct decimal(20,2), @disk_critical_pct decimal(20,2), @disk_threshold_gb decimal(20,2), @large_disk_threshold_pct decimal(20,2)';\n\nset quoted_identifier off;\nset @_sql = \"\nselect\tcount(*) \nfrom dbo.disk_space_all_servers ds\nwhere ds.updated_date_utc >= dateadd(minute,-60,getutcdate())\nand (\t(\t(ds.free_mb*100.0/ds.capacity_mb) < (100-@disk_warning_pct)\n\t\t\tand ds.free_mb < (@disk_threshold_gb)*1024\n\t \t)\n\t\tor ( (ds.free_mb*100.0/ds.capacity_mb) < (100-@large_disk_threshold_pct)) -- free %\n\t)\nand (ds.free_mb*100.0/ds.capacity_mb) < (100-@disk_critical_pct)\n\"+(case when @_has_inventory = 0 then '--' else '' end)+\"and exists (select * from dbo.sma_servers s where s.is_decommissioned = 0 and s.is_onboarded = 1 and s.server = ds.sql_instance)\n\";\nset quoted_identifier off;\n\nexec sp_executesql @_sql, @_params, @_disk_warning_pct, @_disk_critical_pct, @_disk_threshold_gb , @_large_disk_threshold_pct;", + "refresh": 2, + "regex": "", + "type": "query" + }, + { + "current": {}, + "datasource": { + "type": "mssql", + "uid": "${DS_SQLMONITOR}" + }, + "definition": "declare @_disk_warning_pct decimal(20,2) = 80;\ndeclare @_disk_critical_pct decimal(20,2) = 90;\ndeclare @_disk_threshold_gb decimal(20,2) = 200;\ndeclare @_large_disk_threshold_pct decimal(20,2) = 95;\ndeclare @_critical_disks_counts int = 0;\ndeclare @_has_inventory bit = 0;\n\nset @_has_inventory = convert(bit,'${has_inventory}');\nset @_critical_disks_counts = '${critical_disks_counts}';\n\ndeclare @_sql nvarchar(max);\ndeclare @_params nvarchar(max);\n\nset @_params = '@disk_warning_pct decimal(20,2), @disk_critical_pct decimal(20,2), @disk_threshold_gb decimal(20,2), @large_disk_threshold_pct decimal(20,2), @critical_disks_counts int';\n\nset quoted_identifier off;\nset @_sql = \"\nselect counts = count(*)-@critical_disks_counts\nfrom dbo.disk_space_all_servers ds\nwhere ds.updated_date_utc >= dateadd(minute,-60,getutcdate())\nand (\t(\t(ds.free_mb*100.0/ds.capacity_mb) < (100-@disk_warning_pct)\n\t\t\tand ds.free_mb < (@disk_threshold_gb)*1024\n\t \t)\n\t\tor ( (ds.free_mb*100.0/ds.capacity_mb) < (100-@large_disk_threshold_pct)) -- free %\n\t)\n\"+(case when @_has_inventory = 0 then '--' else '' end)+\"and exists (select * from dbo.sma_servers s where s.is_decommissioned = 0 and s.is_onboarded = 1 and s.server = ds.sql_instance)\n\";\nset quoted_identifier off;\n\nexec sp_executesql @_sql, @_params, @_disk_warning_pct, @_disk_critical_pct, @_disk_threshold_gb , @_large_disk_threshold_pct, @_critical_disks_counts;", + "hide": 2, + "includeAll": false, + "label": "Disks in Warning State", + "name": "warning_disks_counts", + "options": [], + "query": "declare @_disk_warning_pct decimal(20,2) = 80;\ndeclare @_disk_critical_pct decimal(20,2) = 90;\ndeclare @_disk_threshold_gb decimal(20,2) = 200;\ndeclare @_large_disk_threshold_pct decimal(20,2) = 95;\ndeclare @_critical_disks_counts int = 0;\ndeclare @_has_inventory bit = 0;\n\nset @_has_inventory = convert(bit,'${has_inventory}');\nset @_critical_disks_counts = '${critical_disks_counts}';\n\ndeclare @_sql nvarchar(max);\ndeclare @_params nvarchar(max);\n\nset @_params = '@disk_warning_pct decimal(20,2), @disk_critical_pct decimal(20,2), @disk_threshold_gb decimal(20,2), @large_disk_threshold_pct decimal(20,2), @critical_disks_counts int';\n\nset quoted_identifier off;\nset @_sql = \"\nselect counts = count(*)-@critical_disks_counts\nfrom dbo.disk_space_all_servers ds\nwhere ds.updated_date_utc >= dateadd(minute,-60,getutcdate())\nand (\t(\t(ds.free_mb*100.0/ds.capacity_mb) < (100-@disk_warning_pct)\n\t\t\tand ds.free_mb < (@disk_threshold_gb)*1024\n\t \t)\n\t\tor ( (ds.free_mb*100.0/ds.capacity_mb) < (100-@large_disk_threshold_pct)) -- free %\n\t)\n\"+(case when @_has_inventory = 0 then '--' else '' end)+\"and exists (select * from dbo.sma_servers s where s.is_decommissioned = 0 and s.is_onboarded = 1 and s.server = ds.sql_instance)\n\";\nset quoted_identifier off;\n\nexec sp_executesql @_sql, @_params, @_disk_warning_pct, @_disk_critical_pct, @_disk_threshold_gb , @_large_disk_threshold_pct, @_critical_disks_counts;", + "refresh": 2, + "regex": "", + "type": "query" + }, + { + "current": {}, + "datasource": { + "type": "mssql", + "uid": "${sqlmonitor_datasource}" + }, + "definition": "declare @_sqltext nvarchar(max);\ndeclare @_params nvarchar(max);\ndeclare @_has_inventory bit = 0;\nset @_has_inventory = convert(bit,'${has_inventory}');\n\nset @_sqltext = '\nselect\tcount(*)\nfrom dbo.log_space_consumers_all_servers ls\nwhere 1=1\nand ls.thresholds_validated = 1\nand (ls.updated_date_utc >= dateadd(minute,-60,getutcdate())\n and ls.collection_time_utc >= dateadd(minute,-20,getutcdate())\n\t\t)\n'+(case when @_has_inventory = 0 then '--' else '' end)+'and exists (select * from dbo.sma_servers s where s.is_decommissioned = 0 and s.is_onboarded = 1 and s.server = ls.sql_instance)\n';\n\nexec sp_executesql @_sqltext, @_params;", + "hide": 2, + "includeAll": false, + "label": "Log Space Issue Counts", + "name": "log_space_issue_counts", + "options": [], + "query": "declare @_sqltext nvarchar(max);\ndeclare @_params nvarchar(max);\ndeclare @_has_inventory bit = 0;\nset @_has_inventory = convert(bit,'${has_inventory}');\n\nset @_sqltext = '\nselect\tcount(*)\nfrom dbo.log_space_consumers_all_servers ls\nwhere 1=1\nand ls.thresholds_validated = 1\nand (ls.updated_date_utc >= dateadd(minute,-60,getutcdate())\n and ls.collection_time_utc >= dateadd(minute,-20,getutcdate())\n\t\t)\n'+(case when @_has_inventory = 0 then '--' else '' end)+'and exists (select * from dbo.sma_servers s where s.is_decommissioned = 0 and s.is_onboarded = 1 and s.server = ls.sql_instance)\n';\n\nexec sp_executesql @_sqltext, @_params;", + "refresh": 2, + "regex": "", + "type": "query" + }, + { + "current": {}, + "datasource": { + "type": "mssql", + "uid": "${DS_SQLMONITOR}" + }, + "definition": "declare @_sqltext nvarchar(max);\ndeclare @_params nvarchar(max);\ndeclare @_has_inventory bit = 0;\nset @_has_inventory = convert(bit,'${has_inventory}');\n\nset @_sqltext = '\nselect\tcount(*)\nfrom dbo.tempdb_space_usage_all_servers su\nwhere (su.data_used_pct > 80.0\n\tor su.data_used_mb > (200.0*1024) -- 200 gb\n\t)\nand (su.updated_date_utc >= dateadd(minute,-60,getutcdate())\n and su.collection_time_utc >= dateadd(minute,-20,getutcdate())\n\t)\n'+(case when @_has_inventory = 0 then '--' else '' end)+'and exists (select * from dbo.sma_servers s where s.is_decommissioned = 0 and s.is_onboarded = 1 and s.server = su.sql_instance)\n'\nexec sp_executesql @_sqltext, @_params;", + "hide": 2, + "includeAll": false, + "label": "Tempdb Space Issue Counts", + "name": "tempdb_space_issue_counts", + "options": [], + "query": "declare @_sqltext nvarchar(max);\ndeclare @_params nvarchar(max);\ndeclare @_has_inventory bit = 0;\nset @_has_inventory = convert(bit,'${has_inventory}');\n\nset @_sqltext = '\nselect\tcount(*)\nfrom dbo.tempdb_space_usage_all_servers su\nwhere (su.data_used_pct > 80.0\n\tor su.data_used_mb > (200.0*1024) -- 200 gb\n\t)\nand (su.updated_date_utc >= dateadd(minute,-60,getutcdate())\n and su.collection_time_utc >= dateadd(minute,-20,getutcdate())\n\t)\n'+(case when @_has_inventory = 0 then '--' else '' end)+'and exists (select * from dbo.sma_servers s where s.is_decommissioned = 0 and s.is_onboarded = 1 and s.server = su.sql_instance)\n'\nexec sp_executesql @_sqltext, @_params;", + "refresh": 2, + "regex": "", + "type": "query" + }, + { + "current": {}, + "datasource": { + "type": "mssql", + "uid": "${sqlmonitor_datasource}" + }, + "definition": "declare @os_cpu_threshold decimal(20,2) = 70;\ndeclare @sql_cpu_threshold decimal(20,2) = 65;\ndeclare @blocked_counts_threshold int = 1;\ndeclare @blocked_duration_max_seconds_threshold bigint = 60;\ndeclare @available_physical_memory_kb_threshold bigint = (4*1024*1024);\ndeclare @system_high_memory_signal_state_threshold varchar(20) = 'Low';\n--declare @physical_memory_in_use_kb_threshold decimal(20,2);\ndeclare @memory_grants_pending_threshold int = 1;\ndeclare @connection_count_threshold int = 1500;\ndeclare @waits_per_core_per_minute_threshold decimal(20,2) = 180;\ndeclare @_has_inventory bit = 0;\nset @_has_inventory = convert(bit,'${has_inventory}');\n\ndeclare @sql nvarchar(max);\ndeclare @params nvarchar(max);\n\nset @params = N'@os_cpu_threshold decimal(20,2), @sql_cpu_threshold decimal(20,2), @blocked_counts_threshold int, \n\t\t\t\t@blocked_duration_max_seconds_threshold bigint, @available_physical_memory_kb_threshold bigint, \n\t\t\t\t@system_high_memory_signal_state_threshold varchar(20), @memory_grants_pending_threshold int, \n\t\t\t\t@connection_count_threshold int, @waits_per_core_per_minute_threshold decimal(20,2)';\n\nset quoted_identifier off;\nset @sql = \"\n;with t_cte as (\n\tselect\tsrv_name, os_cpu, sql_cpu, blocked_counts, blocked_duration_max_seconds, available_physical_memory_kb, system_high_memory_signal_state, physical_memory_in_use_kb, memory_grants_pending, connection_count, waits_per_core_per_minute\n\tfrom dbo.vw_all_server_info asi\n where 1=1\n \"+(case when @_has_inventory = 0 then '--' else '' end)+\"and exists (select * from dbo.sma_servers s where s.is_decommissioned = 0 and s.is_onboarded = 1 and s.server = asi.srv_name)\n)\nselect count(*)\nfrom t_cte cte\nwhere 1=1\nand ( os_cpu >= @os_cpu_threshold\n or sql_cpu >= @sql_cpu_threshold \n or blocked_counts >= @blocked_counts_threshold\n or blocked_duration_max_seconds >= @blocked_duration_max_seconds_threshold\n or ( available_physical_memory_kb < @available_physical_memory_kb_threshold and system_high_memory_signal_state = @system_high_memory_signal_state_threshold )\n or memory_grants_pending > @memory_grants_pending_threshold\n or connection_count >= @connection_count_threshold\n or waits_per_core_per_minute > @waits_per_core_per_minute_threshold\n)\n\";\nset quoted_identifier off;\n\n--print @sql\nexec dbo.sp_executesql @sql, @params, @os_cpu_threshold, @sql_cpu_threshold, @blocked_counts_threshold, @blocked_duration_max_seconds_threshold, @available_physical_memory_kb_threshold, @system_high_memory_signal_state_threshold, @memory_grants_pending_threshold, @connection_count_threshold, @waits_per_core_per_minute_threshold;", + "hide": 2, + "includeAll": false, + "label": "Core Metrics Issue Count", + "name": "core_metrics_issue_counts", + "options": [], + "query": "declare @os_cpu_threshold decimal(20,2) = 70;\ndeclare @sql_cpu_threshold decimal(20,2) = 65;\ndeclare @blocked_counts_threshold int = 1;\ndeclare @blocked_duration_max_seconds_threshold bigint = 60;\ndeclare @available_physical_memory_kb_threshold bigint = (4*1024*1024);\ndeclare @system_high_memory_signal_state_threshold varchar(20) = 'Low';\n--declare @physical_memory_in_use_kb_threshold decimal(20,2);\ndeclare @memory_grants_pending_threshold int = 1;\ndeclare @connection_count_threshold int = 1500;\ndeclare @waits_per_core_per_minute_threshold decimal(20,2) = 180;\ndeclare @_has_inventory bit = 0;\nset @_has_inventory = convert(bit,'${has_inventory}');\n\ndeclare @sql nvarchar(max);\ndeclare @params nvarchar(max);\n\nset @params = N'@os_cpu_threshold decimal(20,2), @sql_cpu_threshold decimal(20,2), @blocked_counts_threshold int, \n\t\t\t\t@blocked_duration_max_seconds_threshold bigint, @available_physical_memory_kb_threshold bigint, \n\t\t\t\t@system_high_memory_signal_state_threshold varchar(20), @memory_grants_pending_threshold int, \n\t\t\t\t@connection_count_threshold int, @waits_per_core_per_minute_threshold decimal(20,2)';\n\nset quoted_identifier off;\nset @sql = \"\n;with t_cte as (\n\tselect\tsrv_name, os_cpu, sql_cpu, blocked_counts, blocked_duration_max_seconds, available_physical_memory_kb, system_high_memory_signal_state, physical_memory_in_use_kb, memory_grants_pending, connection_count, waits_per_core_per_minute\n\tfrom dbo.vw_all_server_info asi\n where 1=1\n \"+(case when @_has_inventory = 0 then '--' else '' end)+\"and exists (select * from dbo.sma_servers s where s.is_decommissioned = 0 and s.is_onboarded = 1 and s.server = asi.srv_name)\n)\nselect count(*)\nfrom t_cte cte\nwhere 1=1\nand ( os_cpu >= @os_cpu_threshold\n or sql_cpu >= @sql_cpu_threshold \n or blocked_counts >= @blocked_counts_threshold\n or blocked_duration_max_seconds >= @blocked_duration_max_seconds_threshold\n or ( available_physical_memory_kb < @available_physical_memory_kb_threshold and system_high_memory_signal_state = @system_high_memory_signal_state_threshold )\n or memory_grants_pending > @memory_grants_pending_threshold\n or connection_count >= @connection_count_threshold\n or waits_per_core_per_minute > @waits_per_core_per_minute_threshold\n)\n\";\nset quoted_identifier off;\n\n--print @sql\nexec dbo.sp_executesql @sql, @params, @os_cpu_threshold, @sql_cpu_threshold, @blocked_counts_threshold, @blocked_duration_max_seconds_threshold, @available_physical_memory_kb_threshold, @system_high_memory_signal_state_threshold, @memory_grants_pending_threshold, @connection_count_threshold, @waits_per_core_per_minute_threshold;", + "refresh": 2, + "regex": "", + "type": "query" + }, + { + "current": {}, + "datasource": { + "type": "mssql", + "uid": "${DS_SQLMONITOR}" + }, + "definition": "set nocount on;\n\ndeclare @_sql nvarchar(max);\ndeclare @_params nvarchar(max);\n\ndeclare @_latency_minutes int;\ndeclare @_redo_queue_size_gb int;\ndeclare @_log_send_queue_size_gb int;\ndeclare @_filter_out_offline_sqlagent bit = 1;\ndeclare @_has_inventory bit = 0;\nset @_has_inventory = convert(bit,'${has_inventory}');\n\nset @_latency_minutes = 30;\nset @_redo_queue_size_gb = 10;\nset @_log_send_queue_size_gb = 10;\n\nset @_params = N'@_latency_minutes int, @_redo_queue_size_gb int, @_log_send_queue_size_gb int';\n\nset @_sql = '\nif object_id(''tempdb..#replica_servers'') is not null\n\tdrop table #replica_servers\nselect distinct ahs.replica_server_name\ninto #replica_servers\nfrom dbo.ag_health_state_all_servers ahs\nwhere 1=1;\n\nselect\tcount(*) /* sql_instance, [replica_database] = replica_server_name+'' || ''+database_name,\n\t\t--replica_server_name, database_name, \n\t\tag_name, is_primary_replica, \n\t\tag_listener, is_local, synchronization_state_desc, synchronization_health_desc, \n\t\tlatency_seconds, log_send_queue_size, redo_queue_size, last_redone_time, log_send_rate, \n\t\tredo_rate, estimated_redo_completion_time_min, last_commit_time, is_suspended, \n\t\tsuspend_reason_desc, is_distributed, replica_server = rs.srv_name, updated_date_utc, collection_time_utc */\nfrom dbo.ag_health_state_all_servers ahs\nleft join (\tselect replica_server = rs.replica_server_name, srv_name = max(asi.srv_name)\n\t\tfrom #replica_servers rs\n\t\tjoin dbo.vw_all_server_info asi\n\t\t\ton rs.replica_server_name in (asi.machine_name, asi.server_name)\n\t\tgroup by rs.replica_server_name\n\t) rs\n\ton rs.replica_server = ahs.replica_server_name\nwhere 1=1\nand (\tahs.synchronization_health_desc <> ''HEALTHY''\n\tor\tahs.synchronization_state_desc not in (''SYNCHRONIZED'',''SYNCHRONIZING'')\n\tor\t(ahs.latency_seconds is not null and ahs.latency_seconds >= @_latency_minutes*60)\n\tor\t(ahs.log_send_queue_size is not null and ahs.log_send_queue_size >= @_log_send_queue_size_gb*1024*1024)\n\tor\t(ahs.redo_queue_size is not null and ahs.redo_queue_size >= @_redo_queue_size_gb*1024*1024)\n\t)\n'+(case when @_filter_out_offline_sqlagent = 0 then '--' else '' end)+'and exists (select 1/0 from dbo.services_all_servers sas where sas.sql_instance = ahs.sql_instance and sas.service_type = ''Agent''\tand sas.status_desc = ''Running'')\n\n'+(case when @_has_inventory = 0 then '--' else '' end)+'and exists (select * from dbo.sma_servers s where s.is_decommissioned = 0 and s.is_onboarded = 1 and s.server = ahs.sql_instance)\n';\n\nexec sp_executesql @_sql, @_params, @_latency_minutes, @_redo_queue_size_gb, @_log_send_queue_size_gb;\n", + "hide": 2, + "includeAll": false, + "label": "Ag Issue Counts", + "name": "ag_issue_counts", + "options": [], + "query": "set nocount on;\n\ndeclare @_sql nvarchar(max);\ndeclare @_params nvarchar(max);\n\ndeclare @_latency_minutes int;\ndeclare @_redo_queue_size_gb int;\ndeclare @_log_send_queue_size_gb int;\ndeclare @_filter_out_offline_sqlagent bit = 1;\ndeclare @_has_inventory bit = 0;\nset @_has_inventory = convert(bit,'${has_inventory}');\n\nset @_latency_minutes = 30;\nset @_redo_queue_size_gb = 10;\nset @_log_send_queue_size_gb = 10;\n\nset @_params = N'@_latency_minutes int, @_redo_queue_size_gb int, @_log_send_queue_size_gb int';\n\nset @_sql = '\nif object_id(''tempdb..#replica_servers'') is not null\n\tdrop table #replica_servers\nselect distinct ahs.replica_server_name\ninto #replica_servers\nfrom dbo.ag_health_state_all_servers ahs\nwhere 1=1;\n\nselect\tcount(*) /* sql_instance, [replica_database] = replica_server_name+'' || ''+database_name,\n\t\t--replica_server_name, database_name, \n\t\tag_name, is_primary_replica, \n\t\tag_listener, is_local, synchronization_state_desc, synchronization_health_desc, \n\t\tlatency_seconds, log_send_queue_size, redo_queue_size, last_redone_time, log_send_rate, \n\t\tredo_rate, estimated_redo_completion_time_min, last_commit_time, is_suspended, \n\t\tsuspend_reason_desc, is_distributed, replica_server = rs.srv_name, updated_date_utc, collection_time_utc */\nfrom dbo.ag_health_state_all_servers ahs\nleft join (\tselect replica_server = rs.replica_server_name, srv_name = max(asi.srv_name)\n\t\tfrom #replica_servers rs\n\t\tjoin dbo.vw_all_server_info asi\n\t\t\ton rs.replica_server_name in (asi.machine_name, asi.server_name)\n\t\tgroup by rs.replica_server_name\n\t) rs\n\ton rs.replica_server = ahs.replica_server_name\nwhere 1=1\nand (\tahs.synchronization_health_desc <> ''HEALTHY''\n\tor\tahs.synchronization_state_desc not in (''SYNCHRONIZED'',''SYNCHRONIZING'')\n\tor\t(ahs.latency_seconds is not null and ahs.latency_seconds >= @_latency_minutes*60)\n\tor\t(ahs.log_send_queue_size is not null and ahs.log_send_queue_size >= @_log_send_queue_size_gb*1024*1024)\n\tor\t(ahs.redo_queue_size is not null and ahs.redo_queue_size >= @_redo_queue_size_gb*1024*1024)\n\t)\n'+(case when @_filter_out_offline_sqlagent = 0 then '--' else '' end)+'and exists (select 1/0 from dbo.services_all_servers sas where sas.sql_instance = ahs.sql_instance and sas.service_type = ''Agent''\tand sas.status_desc = ''Running'')\n\n'+(case when @_has_inventory = 0 then '--' else '' end)+'and exists (select * from dbo.sma_servers s where s.is_decommissioned = 0 and s.is_onboarded = 1 and s.server = ahs.sql_instance)\n';\n\nexec sp_executesql @_sql, @_params, @_latency_minutes, @_redo_queue_size_gb, @_log_send_queue_size_gb;\n", + "refresh": 2, + "regex": "", + "type": "query" + }, + { + "current": {}, + "datasource": { + "type": "mssql", + "uid": "${sqlmonitor_datasource}" + }, + "definition": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(max);\ndeclare @start_time_utc datetime2;\ndeclare @end_time_utc datetime2;\ndeclare @_has_inventory bit = 0;\nset @_has_inventory = convert(bit,'${has_inventory}');\n\n--set @sql_instance = case when ltrim(rtrim(@database)) = '__All__' then null else @database end;\n\nset @start_time_utc = $__timeFrom();\nset @end_time_utc = $__timeTo();\n\nset @params = N'@start_time_utc datetime2, @end_time_utc datetime2';\n\nset quoted_identifier off;\nset @sql = \"/* SQLMonitor - All Server Alert History */\nset nocount on;\nselect count(*)\nfrom dbo.alert_history_all_servers a\nwhere 1 = 1\nand a.collection_time_utc between @start_time_utc and @end_time_utc\n\"+(case when @_has_inventory = 0 then '--' else '' end)+\"and exists (select * from dbo.sma_servers s where s.is_decommissioned = 0 and s.is_onboarded = 1 and s.server = a.sql_instance)\n\"\nset quoted_identifier on;\n\nexec dbo.sp_executesql @sql, @params, @start_time_utc, @end_time_utc;", + "description": "Alert History Row Count", + "hide": 2, + "includeAll": false, + "label": "Alert History Row Count", + "name": "alert_history_row_count", + "options": [], + "query": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(max);\ndeclare @start_time_utc datetime2;\ndeclare @end_time_utc datetime2;\ndeclare @_has_inventory bit = 0;\nset @_has_inventory = convert(bit,'${has_inventory}');\n\n--set @sql_instance = case when ltrim(rtrim(@database)) = '__All__' then null else @database end;\n\nset @start_time_utc = $__timeFrom();\nset @end_time_utc = $__timeTo();\n\nset @params = N'@start_time_utc datetime2, @end_time_utc datetime2';\n\nset quoted_identifier off;\nset @sql = \"/* SQLMonitor - All Server Alert History */\nset nocount on;\nselect count(*)\nfrom dbo.alert_history_all_servers a\nwhere 1 = 1\nand a.collection_time_utc between @start_time_utc and @end_time_utc\n\"+(case when @_has_inventory = 0 then '--' else '' end)+\"and exists (select * from dbo.sma_servers s where s.is_decommissioned = 0 and s.is_onboarded = 1 and s.server = a.sql_instance)\n\"\nset quoted_identifier on;\n\nexec dbo.sp_executesql @sql, @params, @start_time_utc, @end_time_utc;", + "refresh": 2, + "regex": "", + "type": "query" + }, + { + "current": {}, + "datasource": { + "type": "mssql", + "uid": "${DS_SQLMONITOR}" + }, + "definition": "select all_server_stable_info__collection_time_utc = DATEADD(mi, DATEDIFF(mi, getdate(), getutcdate()), max(collection_time))\nfrom dbo.all_server_stable_info", + "hide": 2, + "includeAll": false, + "label": "StableInfo Collection Time", + "name": "all_server_stable_info__collection_time_utc", + "options": [], + "query": "select all_server_stable_info__collection_time_utc = DATEADD(mi, DATEDIFF(mi, getdate(), getutcdate()), max(collection_time))\nfrom dbo.all_server_stable_info", + "refresh": 2, + "regex": "", + "type": "query" + }, + { + "current": {}, + "datasource": { + "type": "mssql", + "uid": "${sqlmonitor_datasource}" + }, + "definition": "select all_server_volatile_info__collection_time_utc = DATEADD(mi, DATEDIFF(mi, getdate(), getutcdate()), max(collection_time))\nfrom dbo.all_server_volatile_info", + "hide": 2, + "includeAll": false, + "label": "Volatile Info Collection Time", + "name": "all_server_volatile_info__collection_time_utc", + "options": [], + "query": "select all_server_volatile_info__collection_time_utc = DATEADD(mi, DATEDIFF(mi, getdate(), getutcdate()), max(collection_time))\nfrom dbo.all_server_volatile_info", + "refresh": 2, + "regex": "", + "type": "query" + }, + { + "current": {}, + "datasource": { + "type": "mssql", + "uid": "${DS_SQLMONITOR}" + }, + "definition": "select all_server_collection_latency_info__collection_time_utc = DATEADD(mi, DATEDIFF(mi, getdate(), getutcdate()), max(collection_time))\nfrom dbo.all_server_collection_latency_info cli", + "hide": 2, + "includeAll": false, + "label": "Collection Latency Time", + "name": "collection_latency_info__collection_time_utc", + "options": [], + "query": "select all_server_collection_latency_info__collection_time_utc = DATEADD(mi, DATEDIFF(mi, getdate(), getutcdate()), max(collection_time))\nfrom dbo.all_server_collection_latency_info cli", + "refresh": 2, + "regex": "", + "type": "query" + }, + { + "current": {}, + "datasource": { + "type": "mssql", + "uid": "${sqlmonitor_datasource}" + }, + "definition": "select services_all_servers__collection_time_utc = max(collection_time_utc)\nfrom dbo.services_all_servers sas", + "hide": 2, + "includeAll": false, + "label": "Services Collection Time", + "name": "services_all_servers__collection_time_utc", + "options": [], + "query": "select services_all_servers__collection_time_utc = max(collection_time_utc)\nfrom dbo.services_all_servers sas", + "refresh": 2, + "regex": "", + "type": "query" + }, + { + "current": {}, + "datasource": { + "type": "mssql", + "uid": "${DS_SQLMONITOR}" + }, + "definition": "select backups_all_servers__collection_time_utc = max(bas.collection_time_utc)\nfrom dbo.backups_all_servers bas", + "hide": 2, + "includeAll": false, + "label": "Backups Collection Time", + "name": "backups_all_servers__collection_time_utc", + "options": [], + "query": "select backups_all_servers__collection_time_utc = max(bas.collection_time_utc)\nfrom dbo.backups_all_servers bas", + "refresh": 2, + "regex": "", + "type": "query" + }, + { + "current": {}, + "datasource": { + "type": "mssql", + "uid": "${sqlmonitor_datasource}" + }, + "definition": "select sql_agent_jobs__collection_time_utc = max(sj.CollectionTimeUTC)\nfrom dbo.sql_agent_jobs_all_servers sj", + "hide": 2, + "includeAll": false, + "label": "SQLAgent Jobs collection Time", + "name": "sql_agent_jobs__collection_time_utc", + "options": [], + "query": "select sql_agent_jobs__collection_time_utc = max(sj.CollectionTimeUTC)\nfrom dbo.sql_agent_jobs_all_servers sj", + "refresh": 2, + "regex": "", + "type": "query" + }, + { + "current": {}, + "datasource": { + "type": "mssql", + "uid": "${DS_SQLMONITOR}" + }, + "definition": "select disk_space__collection_time_utc = max(ds.collection_time_utc)\nfrom dbo.disk_space_all_servers ds", + "hide": 2, + "includeAll": false, + "label": "Disk Space Collection Time", + "name": "disk_space__collection_time_utc", + "options": [], + "query": "select disk_space__collection_time_utc = max(ds.collection_time_utc)\nfrom dbo.disk_space_all_servers ds", + "refresh": 1, + "regex": "", + "type": "query" + }, + { + "current": {}, + "datasource": { + "type": "mssql", + "uid": "${sqlmonitor_datasource}" + }, + "definition": "select ag_health_state__collection_time_utc = max(ahs.collection_time_utc)\nfrom dbo.ag_health_state_all_servers ahs", + "hide": 2, + "includeAll": false, + "label": "Ag Health State Collection Time", + "name": "ag_health_state__collection_time_utc", + "options": [], + "query": "select ag_health_state__collection_time_utc = max(ahs.collection_time_utc)\nfrom dbo.ag_health_state_all_servers ahs", + "refresh": 2, + "regex": "", + "type": "query" + }, + { + "current": {}, + "datasource": { + "type": "mssql", + "uid": "${DS_SQLMONITOR}" + }, + "definition": "select log_space_consumers__collection_time_utc = max(ls.collection_time_utc)\nfrom dbo.log_space_consumers_all_servers ls", + "hide": 2, + "includeAll": false, + "label": "Log Space Consumers Collection Time", + "name": "log_space_consumers__collection_time_utc", + "options": [], + "query": "select log_space_consumers__collection_time_utc = max(ls.collection_time_utc)\nfrom dbo.log_space_consumers_all_servers ls", + "refresh": 2, + "regex": "", + "type": "query" + }, + { + "current": {}, + "datasource": { + "type": "mssql", + "uid": "${sqlmonitor_datasource}" + }, + "definition": "select tempdb_space_usage__collection_time_utc = max(su.collection_time_utc)\nfrom dbo.tempdb_space_usage_all_servers su", + "hide": 2, + "includeAll": false, + "label": "Tempdb Space Usage Collection Time", + "name": "tempdb_space_usage__collection_time_utc", + "options": [], + "query": "select tempdb_space_usage__collection_time_utc = max(su.collection_time_utc)\nfrom dbo.tempdb_space_usage_all_servers su", + "refresh": 2, + "regex": "", + "type": "query" + }, + { + "current": {}, + "datasource": { + "type": "mssql", + "uid": "${DS_SQLMONITOR}" + }, + "definition": "if object_id('dbo.sma_servers') is not null\n select [has_inventory] = 1\nelse\n select [has_inventory] = 0", + "hide": 2, + "includeAll": false, + "label": "Is Inventory Present", + "name": "has_inventory", + "options": [], + "query": "if object_id('dbo.sma_servers') is not null\n select [has_inventory] = 1\nelse\n select [has_inventory] = 0", + "refresh": 1, + "regex": "", + "type": "query" + }, + { + "current": {}, + "datasource": { + "type": "mssql", + "uid": "${sqlmonitor_datasource}" + }, + "definition": "-- alert_history_aggregated_row_count\ndeclare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(max);\ndeclare @start_time_utc datetime2;\ndeclare @end_time_utc datetime2;\ndeclare @_has_inventory bit = 0;\nset @_has_inventory = convert(bit,'${has_inventory}');\n\n--set @sql_instance = case when ltrim(rtrim(@database)) = '__All__' then null else @database end;\n\nset @start_time_utc = $__timeFrom();\nset @end_time_utc = $__timeTo();\n\nset @params = N'@start_time_utc datetime2, @end_time_utc datetime2';\n\nset quoted_identifier off;\nset @sql = \"/* SQLMonitor - All Server Alert History */\nset nocount on;\n;with cte_aggregated as (\n select a.sql_instance, a.error_number, a.error_severity, occurrences = count(*), error_message = max(m.text)\n --a.collection_time_utc, a.sql_instance, a.server_name, a.database_name, a.error_number, \n --a.error_severity, a.error_message, a.host_instance, a.updated_time_utc\n from dbo.alert_history_all_servers a\n left join sys.messages m \n on m.language_id = 1033 and m.message_id = a.error_number\n where 1 = 1\n and a.collection_time_utc between @start_time_utc and @end_time_utc\n and (case when a.error_number = 50000 and error_severity = 20 and a.error_message like '%application intent is set to read only%'\n then 0\n when a.error_number = 1204 then 0\n when a.error_number = 50000 and error_severity = 20 and a.error_message like 'Error: 50000 Severity: 20 State: 1 Could not create constraint or index. See previous errors. '\n then 0\n when a.error_number = 50000 and error_severity = 20 and a.error_message like 'Error: 50000 Severity: 20 State: 1 The instance of the SQL Server Database Engine cannot obtain a LOCK resource at this time%'\n then 0\n when a.error_number = 17806 and error_severity = 20 and a.error_message like 'SSPI handshake failed with error code 0x8009030c%'\n then 0\n when a.error_number = 50000 and error_severity = 20 and a.error_message like 'Error: 50000 Severity: 20 State: 1 Lock request time out period exceeded. '\n then 0\n when a.error_number = 976 and error_severity = 14 and a.error_message like '%Either data movement is suspended or the availability replica is not enabled for read access%'\n then 0\n else 1\n end\n ) = 1\n \"+(case when @_has_inventory = 0 then '--' else '' end)+\"and exists (select * from dbo.sma_servers s where s.is_decommissioned = 0 and s.is_onboarded = 1 and s.server = a.sql_instance)\n group by a.sql_instance, a.error_number, a.error_severity\n)\nselect count(*) from cte_aggregated\n\"\nset quoted_identifier on;\n\nexec dbo.sp_executesql @sql, @params, @start_time_utc, @end_time_utc;", + "description": "Alert History Aggregated Row Count", + "hide": 2, + "label": "Alert History Aggregated Row Count", + "name": "alert_history_aggregated_row_count", + "options": [], + "query": "-- alert_history_aggregated_row_count\ndeclare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(max);\ndeclare @start_time_utc datetime2;\ndeclare @end_time_utc datetime2;\ndeclare @_has_inventory bit = 0;\nset @_has_inventory = convert(bit,'${has_inventory}');\n\n--set @sql_instance = case when ltrim(rtrim(@database)) = '__All__' then null else @database end;\n\nset @start_time_utc = $__timeFrom();\nset @end_time_utc = $__timeTo();\n\nset @params = N'@start_time_utc datetime2, @end_time_utc datetime2';\n\nset quoted_identifier off;\nset @sql = \"/* SQLMonitor - All Server Alert History */\nset nocount on;\n;with cte_aggregated as (\n select a.sql_instance, a.error_number, a.error_severity, occurrences = count(*), error_message = max(m.text)\n --a.collection_time_utc, a.sql_instance, a.server_name, a.database_name, a.error_number, \n --a.error_severity, a.error_message, a.host_instance, a.updated_time_utc\n from dbo.alert_history_all_servers a\n left join sys.messages m \n on m.language_id = 1033 and m.message_id = a.error_number\n where 1 = 1\n and a.collection_time_utc between @start_time_utc and @end_time_utc\n and (case when a.error_number = 50000 and error_severity = 20 and a.error_message like '%application intent is set to read only%'\n then 0\n when a.error_number = 1204 then 0\n when a.error_number = 50000 and error_severity = 20 and a.error_message like 'Error: 50000 Severity: 20 State: 1 Could not create constraint or index. See previous errors. '\n then 0\n when a.error_number = 50000 and error_severity = 20 and a.error_message like 'Error: 50000 Severity: 20 State: 1 The instance of the SQL Server Database Engine cannot obtain a LOCK resource at this time%'\n then 0\n when a.error_number = 17806 and error_severity = 20 and a.error_message like 'SSPI handshake failed with error code 0x8009030c%'\n then 0\n when a.error_number = 50000 and error_severity = 20 and a.error_message like 'Error: 50000 Severity: 20 State: 1 Lock request time out period exceeded. '\n then 0\n when a.error_number = 976 and error_severity = 14 and a.error_message like '%Either data movement is suspended or the availability replica is not enabled for read access%'\n then 0\n else 1\n end\n ) = 1\n \"+(case when @_has_inventory = 0 then '--' else '' end)+\"and exists (select * from dbo.sma_servers s where s.is_decommissioned = 0 and s.is_onboarded = 1 and s.server = a.sql_instance)\n group by a.sql_instance, a.error_number, a.error_severity\n)\nselect count(*) from cte_aggregated\n\"\nset quoted_identifier on;\n\nexec dbo.sp_executesql @sql, @params, @start_time_utc, @end_time_utc;", + "refresh": 2, + "regex": "", + "type": "query" + } + ] + }, + "time": { + "from": "now-4h", + "to": "now" + }, + "timepicker": { + "refresh_intervals": [ + "5s", + "30s", + "1m", + "2m", + "5m" + ] + }, + "timezone": "browser", + "title": "Monitoring - Live - All Servers", + "uid": "distributed_live_dashboard_all_servers", + "version": 28, + "weekStart": "" } \ No newline at end of file diff --git a/Grafana-Dashboards/Monitoring - Live - Distributed.json b/Grafana-Dashboards/Monitoring - Live - Distributed.json index 8667af3..06c58b8 100644 --- a/Grafana-Dashboards/Monitoring - Live - Distributed.json +++ b/Grafana-Dashboards/Monitoring - Live - Distributed.json @@ -15,13 +15,6 @@ "value": "dbo.vw_performance_counters", "description": "" }, - { - "name": "VAR_OS_TASK_LIST_TABLE_NAME", - "type": "constant", - "label": "OS Tasks Table Name", - "value": "dbo.vw_os_task_list", - "description": "" - }, { "name": "VAR_WHOISACTIVE_TABLE_NAME", "type": "constant", @@ -469,22 +462,34 @@ "mode": "absolute", "steps": [ { - "color": "dark-blue", + "color": "green", "value": null + }, + { + "color": "yellow", + "value": 70 + }, + { + "color": "orange", + "value": 80 + }, + { + "color": "red", + "value": 90 } ] }, - "unit": "s" + "unit": "percent" }, "overrides": [] }, "gridPos": { - "h": 2, - "w": 5, + "h": 3, + "w": 3, "x": 11, "y": 1 }, - "id": 83, + "id": 158, "options": { "colorMode": "value", "graphMode": "none", @@ -492,17 +497,11 @@ "orientation": "auto", "percentChangeColorMode": "standard", "reduceOptions": { - "calcs": [ - "last" - ], + "calcs": [], "fields": "/.*/", - "values": true + "values": false }, "showPercentChange": false, - "text": { - "titleSize": 8, - "valueSize": 18 - }, "textMode": "auto", "wideLayout": true }, @@ -514,31 +513,72 @@ "type": "mssql", "uid": "${DS_SQLMONITOR}" }, - "editorMode": "code", "format": "table", - "rawQuery": true, - "rawSql": "select [processor_info] = '$processor_name'", - "refId": "A", - "sql": { - "columns": [ - { - "parameters": [], - "type": "function" - } - ], - "groupBy": [ + "rawSql": "SELECT $ring_buffer_os_cpu;", + "refId": "A" + } + ], + "title": "OS CPU @ ${ring_buffer_event_time:date:YYYY-MM-DD}", + "type": "stat" + }, + { + "datasource": { + "type": "mssql", + "uid": "${sqlmonitor_datasource}" + }, + "description": "", + "fieldConfig": { + "defaults": { + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ { - "property": { - "type": "string" - }, - "type": "groupBy" + "color": "green", + "value": null } - ], - "limit": 50 - } + ] + }, + "unit": "percent" + }, + "overrides": [] + }, + "gridPos": { + "h": 3, + "w": 3, + "x": 14, + "y": 1 + }, + "id": 161, + "options": { + "colorMode": "value", + "graphMode": "none", + "justifyMode": "center", + "orientation": "auto", + "percentChangeColorMode": "standard", + "reduceOptions": { + "calcs": [], + "fields": "/.*/", + "values": false + }, + "showPercentChange": false, + "textMode": "auto", + "wideLayout": true + }, + "pluginVersion": "11.3.1", + "targets": [ + { + "alias": "", + "datasource": { + "type": "mssql", + "uid": "${DS_SQLMONITOR}" + }, + "format": "table", + "rawSql": "SELECT $ring_buffer_idle_cpu;", + "refId": "A" } ], - "title": "Processor Info", + "title": "Idle CPU @ ${ring_buffer_event_time:date:HH.mm}", "type": "stat" }, { @@ -549,14 +589,29 @@ "description": "", "fieldConfig": { "defaults": { - "decimals": 2, "mappings": [], "thresholds": { "mode": "absolute", "steps": [ { - "color": "dark-blue", + "color": "dark-red", "value": null + }, + { + "color": "yellow", + "value": 300 + }, + { + "color": "orange", + "value": 600 + }, + { + "color": "light-green", + "value": 601 + }, + { + "color": "dark-green", + "value": 1200 } ] }, @@ -565,12 +620,12 @@ "overrides": [] }, "gridPos": { - "h": 2, - "w": 3, - "x": 16, + "h": 3, + "w": 2, + "x": 17, "y": 1 }, - "id": 69, + "id": 15, "options": { "colorMode": "value", "graphMode": "none", @@ -578,17 +633,11 @@ "orientation": "auto", "percentChangeColorMode": "standard", "reduceOptions": { - "calcs": [ - "last" - ], + "calcs": [], "fields": "/.*/", - "values": true + "values": false }, "showPercentChange": false, - "text": { - "titleSize": 8, - "valueSize": 18 - }, "textMode": "auto", "wideLayout": true }, @@ -600,12 +649,31 @@ "type": "mssql", "uid": "${DS_SQLMONITOR}" }, + "editorMode": "code", "format": "table", - "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @params = N'@perfmon_host_name varchar(255)';\n\nset quoted_identifier off;\nset @sql = \"\nselect virtual_machine_type_desc\nfrom sys.dm_os_sys_info as osi\n\"\nset quoted_identifier on;\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nif ($is_local = 1)\n exec dbo.sp_executesql @sql , @params, @perfmon_host_name;\nelse\n exec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name;", - "refId": "A" + "rawQuery": true, + "rawSql": "select $ple;", + "refId": "A", + "sql": { + "columns": [ + { + "parameters": [], + "type": "function" + } + ], + "groupBy": [ + { + "property": { + "type": "string" + }, + "type": "groupBy" + } + ], + "limit": 50 + } } ], - "title": "Machine Type", + "title": "PLE", "type": "stat" }, { @@ -966,12 +1034,31 @@ "type": "mssql", "uid": "${DS_SQLMONITOR}" }, + "editorMode": "code", "format": "table", - "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @params = N'@perfmon_host_name varchar(255)';\n\nset quoted_identifier off;\nset @sql = \"\nselect count(*) as counts\nfrom $os_task_list_table_name otl with (nolock)\nwhere collection_time_utc = (select top 1 i.collection_time_utc from $os_task_list_table_name i with (nolock)\n where i.host_name = @perfmon_host_name order by i.collection_time_utc desc)\nand otl.host_name = @perfmon_host_name\n\"\nset quoted_identifier on;\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nif ($is_local = 1)\n exec dbo.sp_executesql @sql , @params, @perfmon_host_name;\nelse\n exec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name;", - "refId": "A" + "rawQuery": true, + "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\ndeclare @start_time_utc datetime2;\ndeclare @end_time_utc datetime2;\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @start_time_utc = $__timeFrom();\nset @end_time_utc = $__timeTo();\nset @params = N'@perfmon_host_name varchar(255), @start_time_utc datetime2, @end_time_utc datetime2';\n\nset quoted_identifier off;\nset @sql = \"\nselect proc_counts = count(*)\nfrom $perfmon_table_name pc\nwhere 1=1\n--and collection_time_utc between @start_time_utc and @end_time_utc\nand collection_time_utc = (\n select max(i.collection_time_utc) from $perfmon_table_name i \n where i.collection_time_utc >= dateadd(minute, -15, getutcdate())\n and i.host_name = @perfmon_host_name and object = 'process' and counter = '% processor time'\n )\nand pc.host_name = @perfmon_host_name\nand object = 'process' and counter = '% processor time'\nand pc.instance not in ('_total','idle')\n\"\nset quoted_identifier on;\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nif ($is_local = 1)\n exec dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;\nelse\n exec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;", + "refId": "A", + "sql": { + "columns": [ + { + "parameters": [], + "type": "function" + } + ], + "groupBy": [ + { + "property": { + "type": "string" + }, + "type": "groupBy" + } + ], + "limit": 50 + } } ], - "title": "OS Processes @ ${os_task_list_collection_time_utc:date:YYYY-MM-DD HH.mm}", + "title": "OS Processes @ ${perfmon_collection_time_utc:date:YYYY-MM-DD HH.mm}", "type": "stat" }, { @@ -1052,34 +1139,22 @@ "mode": "absolute", "steps": [ { - "color": "green", + "color": "dark-blue", "value": null - }, - { - "color": "yellow", - "value": 70 - }, - { - "color": "orange", - "value": 80 - }, - { - "color": "red", - "value": 90 } ] }, - "unit": "percent" + "unit": "s" }, "overrides": [] }, "gridPos": { - "h": 3, - "w": 3, + "h": 2, + "w": 5, "x": 11, - "y": 3 + "y": 4 }, - "id": 158, + "id": 83, "options": { "colorMode": "value", "graphMode": "none", @@ -1087,11 +1162,17 @@ "orientation": "auto", "percentChangeColorMode": "standard", "reduceOptions": { - "calcs": [], + "calcs": [ + "last" + ], "fields": "/.*/", - "values": false + "values": true }, "showPercentChange": false, + "text": { + "titleSize": 8, + "valueSize": 18 + }, "textMode": "auto", "wideLayout": true }, @@ -1103,12 +1184,31 @@ "type": "mssql", "uid": "${DS_SQLMONITOR}" }, + "editorMode": "code", "format": "table", - "rawSql": "SELECT $ring_buffer_os_cpu;", - "refId": "A" + "rawQuery": true, + "rawSql": "select [processor_info] = '$processor_name'", + "refId": "A", + "sql": { + "columns": [ + { + "parameters": [], + "type": "function" + } + ], + "groupBy": [ + { + "property": { + "type": "string" + }, + "type": "groupBy" + } + ], + "limit": 50 + } } ], - "title": "OS CPU @ ${ring_buffer_event_time:date:YYYY-MM-DD}", + "title": "Processor Info", "type": "stat" }, { @@ -1119,27 +1219,28 @@ "description": "", "fieldConfig": { "defaults": { + "decimals": 2, "mappings": [], "thresholds": { "mode": "absolute", "steps": [ { - "color": "green", + "color": "dark-blue", "value": null } ] }, - "unit": "percent" + "unit": "s" }, "overrides": [] }, "gridPos": { - "h": 3, + "h": 2, "w": 3, - "x": 14, - "y": 3 + "x": 16, + "y": 4 }, - "id": 161, + "id": 69, "options": { "colorMode": "value", "graphMode": "none", @@ -1147,87 +1248,17 @@ "orientation": "auto", "percentChangeColorMode": "standard", "reduceOptions": { - "calcs": [], + "calcs": [ + "last" + ], "fields": "/.*/", - "values": false + "values": true }, "showPercentChange": false, - "textMode": "auto", - "wideLayout": true - }, - "pluginVersion": "11.3.1", - "targets": [ - { - "alias": "", - "datasource": { - "type": "mssql", - "uid": "${DS_SQLMONITOR}" - }, - "format": "table", - "rawSql": "SELECT $ring_buffer_idle_cpu;", - "refId": "A" - } - ], - "title": "Idle CPU @ ${ring_buffer_event_time:date:HH.mm}", - "type": "stat" - }, - { - "datasource": { - "type": "mssql", - "uid": "${sqlmonitor_datasource}" - }, - "description": "", - "fieldConfig": { - "defaults": { - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "dark-red", - "value": null - }, - { - "color": "yellow", - "value": 300 - }, - { - "color": "orange", - "value": 600 - }, - { - "color": "light-green", - "value": 601 - }, - { - "color": "dark-green", - "value": 1200 - } - ] - }, - "unit": "s" - }, - "overrides": [] - }, - "gridPos": { - "h": 3, - "w": 2, - "x": 17, - "y": 3 - }, - "id": 15, - "options": { - "colorMode": "value", - "graphMode": "none", - "justifyMode": "center", - "orientation": "auto", - "percentChangeColorMode": "standard", - "reduceOptions": { - "calcs": [], - "fields": "/.*/", - "values": false + "text": { + "titleSize": 8, + "valueSize": 18 }, - "showPercentChange": false, "textMode": "auto", "wideLayout": true }, @@ -1239,31 +1270,12 @@ "type": "mssql", "uid": "${DS_SQLMONITOR}" }, - "editorMode": "code", "format": "table", - "rawQuery": true, - "rawSql": "select $ple;", - "refId": "A", - "sql": { - "columns": [ - { - "parameters": [], - "type": "function" - } - ], - "groupBy": [ - { - "property": { - "type": "string" - }, - "type": "groupBy" - } - ], - "limit": 50 - } + "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @params = N'@perfmon_host_name varchar(255)';\n\nset quoted_identifier off;\nset @sql = \"\nselect virtual_machine_type_desc\nfrom sys.dm_os_sys_info as osi\n\"\nset quoted_identifier on;\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nif ($is_local = 1)\n exec dbo.sp_executesql @sql , @params, @perfmon_host_name;\nelse\n exec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name;", + "refId": "A" } ], - "title": "PLE", + "title": "Machine Type", "type": "stat" }, { @@ -1738,7 +1750,7 @@ { "matcher": { "id": "byName", - "options": "IsClustered" + "options": "IsHadrEnabled" }, "properties": [ { @@ -1758,7 +1770,7 @@ "x": 14, "y": 7 }, - "id": 74, + "id": 168, "options": { "colorMode": "value", "graphMode": "none", @@ -1786,11 +1798,11 @@ "uid": "${DS_SQLMONITOR}" }, "format": "table", - "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @params = N'@perfmon_host_name varchar(255)';\n\nset quoted_identifier off;\nset @sql = \"\n--select CONVERT(varchar,SERVERPROPERTY('IsClustered'))+' / '+CONVERT(varchar,SERVERPROPERTY('IsHadrEnabled'))\nselect CONVERT(bit,SERVERPROPERTY('IsClustered')) as IsClustered --, CONVERT(bit,SERVERPROPERTY('IsHadrEnabled')) as IsHadrEnabled\n\"\nset quoted_identifier on;\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nif ($is_local = 1)\n exec dbo.sp_executesql @sql , @params, @perfmon_host_name;\nelse\n exec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name;", + "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @params = N'@perfmon_host_name varchar(255)';\n\nset quoted_identifier off;\nset @sql = \"\n--select CONVERT(varchar,SERVERPROPERTY('IsClustered'))+' / '+CONVERT(varchar,SERVERPROPERTY('IsHadrEnabled'))\nselect CONVERT(bit,SERVERPROPERTY('IsHadrEnabled')) as IsHadrEnabled\n\"\nset quoted_identifier on;\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nif ($is_local = 1)\n exec dbo.sp_executesql @sql , @params, @perfmon_host_name;\nelse\n exec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name;", "refId": "A" } ], - "title": "IsClustered", + "title": "IsHadrEnabled", "type": "stat" }, { @@ -1817,7 +1829,7 @@ { "matcher": { "id": "byName", - "options": "IsHadrEnabled" + "options": "IsClustered" }, "properties": [ { @@ -1837,7 +1849,7 @@ "x": 16, "y": 7 }, - "id": 168, + "id": 74, "options": { "colorMode": "value", "graphMode": "none", @@ -1865,11 +1877,11 @@ "uid": "${DS_SQLMONITOR}" }, "format": "table", - "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @params = N'@perfmon_host_name varchar(255)';\n\nset quoted_identifier off;\nset @sql = \"\n--select CONVERT(varchar,SERVERPROPERTY('IsClustered'))+' / '+CONVERT(varchar,SERVERPROPERTY('IsHadrEnabled'))\nselect CONVERT(bit,SERVERPROPERTY('IsHadrEnabled')) as IsHadrEnabled\n\"\nset quoted_identifier on;\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nif ($is_local = 1)\n exec dbo.sp_executesql @sql , @params, @perfmon_host_name;\nelse\n exec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name;", + "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @params = N'@perfmon_host_name varchar(255)';\n\nset quoted_identifier off;\nset @sql = \"\n--select CONVERT(varchar,SERVERPROPERTY('IsClustered'))+' / '+CONVERT(varchar,SERVERPROPERTY('IsHadrEnabled'))\nselect CONVERT(bit,SERVERPROPERTY('IsClustered')) as IsClustered --, CONVERT(bit,SERVERPROPERTY('IsHadrEnabled')) as IsHadrEnabled\n\"\nset quoted_identifier on;\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nif ($is_local = 1)\n exec dbo.sp_executesql @sql , @params, @perfmon_host_name;\nelse\n exec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name;", "refId": "A" } ], - "title": "IsHadrEnabled", + "title": "IsClustered", "type": "stat" }, { @@ -3339,7 +3351,7 @@ "h": 9, "w": 24, "x": 0, - "y": 18 + "y": 632 }, "id": 181, "options": { @@ -3454,7 +3466,8 @@ "mode": "absolute", "steps": [ { - "color": "transparent" + "color": "transparent", + "value": null } ] }, @@ -3466,14 +3479,14 @@ "h": 8, "w": 24, "x": 0, - "y": 28 + "y": 62 }, "id": 16, "options": { "legend": { "calcs": [ "lastNotNull", - "p99" + "p98" ], "displayMode": "table", "placement": "right", @@ -3520,213 +3533,109 @@ ], "title": "CPU - @ ${perfmon_collection_time_utc:date:YYYY-MM-DD HH.mm}", "type": "timeseries" - } - ], - "repeat": "datasource", - "title": "Trend - CPU Utilization", - "type": "row" - }, - { - "collapsed": true, - "gridPos": { - "h": 1, - "w": 24, - "x": 0, - "y": 19 - }, - "id": 113, - "panels": [ + }, { "datasource": { "type": "mssql", "uid": "${sqlmonitor_datasource}" }, - "description": "Blocking Details____In Selected Time Duration____Since____${__from:date:YYYY-MM-DD HH.mm}___till___${whoisactive_collection_time_utc:date:YYYY-MM-DD HH.mm}____", + "description": "https://sqlperformance.com/2014/10/sql-performance/knee-jerk-page-life-expectancy", "fieldConfig": { "defaults": { "color": { - "mode": "thresholds" + "mode": "palette-classic" }, "custom": { - "align": "auto", - "cellOptions": { - "type": "auto" + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "% CPU", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 10, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false }, - "filterable": true, - "inspect": false + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": true, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "line+area" + } }, "mappings": [], + "max": 100, + "min": 0, "thresholds": { "mode": "absolute", "steps": [ { - "color": "green" + "color": "transparent", + "value": null } ] - } + }, + "unit": "percent" }, - "overrides": [ - { - "matcher": { - "id": "byName", - "options": "BLOCKING_TREE" - }, - "properties": [ + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 24, + "x": 0, + "y": 240 + }, + "id": 193, + "options": { + "legend": { + "calcs": [ + "lastNotNull", + "p98" + ], + "displayMode": "table", + "placement": "right", + "showLegend": true, + "sortBy": "98th %", + "sortDesc": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.3.1", + "targets": [ + { + "alias": "", + "datasource": { + "type": "mssql", + "uid": "${DS_SQLMONITOR}" + }, + "editorMode": "code", + "format": "time_series", + "rawQuery": true, + "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\ndeclare @start_time_utc datetime2;\ndeclare @end_time_utc datetime2;\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @start_time_utc = $__timeFrom();\nset @end_time_utc = $__timeTo();\nset @params = N'@perfmon_host_name varchar(255), @start_time_utc datetime2, @end_time_utc datetime2';\n\nset quoted_identifier off;\nset @sql = \"\n;with cte_process_cpu as (\n\tselect pc.collection_time_utc, pc.host_name, pc.object, pc.counter,\n\t\t\tpc.value, \n\t\t\tpc.instance,\n\t\t\tprocess = case when CHARINDEX('#',s1.instance) > 0 then left(s1.instance, CHARINDEX('#',s1.instance)-1) else s1.instance end\n\tfrom $perfmon_table_name pc\n\touter apply (select instance = case when CHARINDEX('$',pc.instance) > 0 then left(pc.instance, CHARINDEX('$',pc.instance)-1) else pc.instance end ) s1\n\twhere collection_time_utc between @start_time_utc and @end_time_utc\n\tand pc.host_name = @perfmon_host_name\n\t--and collection_time_utc = (select max(i.collection_time_utc) from dbo.performance_counters i)\n\tand object = 'process' and counter = '% processor time'\n\tand pc.instance not in ('_total','idle')\n)\nselect\t[time] = collection_time_utc, --p.host_name, p.object, p.counter, \n\t\t[metric] = p.process,\n\t\t[value] = ceiling(sum(p.value)*1.0/si.cpu_count)\nfrom cte_process_cpu p\nouter apply (select si.cpu_count from sys.dm_os_sys_info si) si\ngroup by collection_time_utc, p.process, si.cpu_count\nhaving ceiling(sum(p.value)*1.0/si.cpu_count) > 0\norder by [time]\n\"\nset quoted_identifier on;\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nif ($is_local = 1)\n exec dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;\nelse\n exec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;", + "refId": "A", + "sql": { + "columns": [ { - "id": "custom.width", - "value": 308 - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "CPU" - }, - "properties": [ - { - "id": "unit", - "value": "ms" - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "writes" - }, - "properties": [ - { - "id": "unit", - "value": "short" - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "used_memory_kb" - }, - "properties": [ - { - "id": "unit", - "value": "kbytes" - }, - { - "id": "displayName", - "value": "used_memory" - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "reads_kb" - }, - "properties": [ - { - "id": "unit", - "value": "kbytes" - }, - { - "id": "displayName", - "value": "reads" - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "tempdb_allocations_kb" - }, - "properties": [ - { - "id": "unit", - "value": "kbytes" - }, - { - "id": "displayName", - "value": "tempdb_allocations" - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "tempdb_current_kb" - }, - "properties": [ - { - "id": "unit", - "value": "kbytes" - }, - { - "id": "displayName", - "value": "tempdb_current" - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "granted_memory_kb" - }, - "properties": [ - { - "id": "unit", - "value": "kbytes" - }, - { - "id": "displayName", - "value": "granted_memory" - } - ] - } - ] - }, - "gridPos": { - "h": 8, - "w": 24, - "x": 0, - "y": 251 - }, - "id": 111, - "options": { - "cellHeight": "sm", - "footer": { - "countRows": false, - "fields": "", - "reducer": [ - "sum" - ], - "show": false - }, - "showHeader": true, - "sortBy": [ - { - "desc": false, - "displayName": "collection_time" - } - ] - }, - "pluginVersion": "11.3.1", - "targets": [ - { - "alias": "", - "datasource": { - "type": "mssql", - "uid": "${DS_SQLMONITOR}" - }, - "editorMode": "code", - "format": "table", - "rawQuery": true, - "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\ndeclare @start_time_utc datetime2;\ndeclare @end_time_utc datetime2;\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @start_time_utc = $__timeFrom();\nset @end_time_utc = $__timeTo();\nset @params = N'@perfmon_host_name varchar(255), @start_time_utc datetime2, @end_time_utc datetime2';\n\nset quoted_identifier off;\nset @sql = \"\nset nocount on;\n\ndeclare @collection_time datetime;\nselect @collection_time = max(l.collection_time) from dbo.WhoIsActive l;\n\n-- Get Blocking Tree\nif exists (select 1/0 from dbo.WhoIsActive w with (nolock) where w.collection_time = @collection_time and (blocking_session_id is not null or blocked_session_count > 0))\nbegin\n\t;WITH T_BLOCKERS AS (\n\t\t-- Find block Leaders\n\t\tSELECT\t[duration_s] = datediff(SECOND, start_time, r.collection_time), [collection_time], [session_id], \n\t\t\t\t[sql_text] = REPLACE(REPLACE(REPLACE(REPLACE(CAST(COALESCE([sql_command],[sql_text]) AS VARCHAR(MAX)),char(13),''),CHAR(10),''),'',''), \n\t\t\t\tcommand = additional_info.value('(/additional_info/command_type)[1]','varchar(125)'), [login_name], wait_info, [blocking_session_id], [blocked_session_count] = replace(blocked_session_count,',',''),\n\t\t\t\t[status], open_tran_count, [host_name], [database_name], [program_name], tasks, granted_memory, r.CPU, r.used_memory, r.[tempdb_allocations], r.[tempdb_current], r.[reads], r.[writes], r.[physical_io], additional_info,\n\t\t\t\t[LEVEL] = CAST (REPLICATE ('0', 4-LEN (CAST (r.session_id AS VARCHAR))) + CAST (r.session_id AS VARCHAR) AS VARCHAR (1000))\n\t\t\t\t,[head_blocker] = session_id ,query_plan\n\t\tFROM\tdbo.WhoIsActive AS r with (nolock) WHERE r.collection_time = @collection_time and (r.blocking_session_id IS NULL AND blocked_session_count > 0)\n\t\t--\t\n\t\tUNION ALL\n\t\t--\n\t\tSELECT\t[duration_s] = datediff(SECOND, r.start_time, r.collection_time), r.[collection_time], r.[session_id], \n\t\t\t\t[sql_text] = REPLACE(REPLACE(REPLACE(REPLACE(CAST(COALESCE(r.[sql_command],r.[sql_text]) AS VARCHAR(MAX)),char(13),''),CHAR(10),''),'',''), \n\t\t\t\tcommand = r.additional_info.value('(/additional_info/command_type)[1]','varchar(125)'), r.[login_name], r.wait_info, r.[blocking_session_id], [blocked_session_count] = replace(r.blocked_session_count,',',''),\n\t\t\t\tr.[status], r.open_tran_count, r.[host_name], r.[database_name], r.[program_name], r.tasks, r.granted_memory, r.CPU, r.used_memory, r.[tempdb_allocations], r.[tempdb_current], r.[reads], r.[writes], r.[physical_io], r.additional_info,\n\t\t\t\tCAST (B.LEVEL + RIGHT (CAST ((1000 + r.session_id) AS VARCHAR (100)), 4) AS VARCHAR (1000)) AS LEVEL\n\t\t\t\t,[head_blocker] = case when B.[head_blocker] is null then B.session_id else B.[head_blocker] end ,r.query_plan\n\t\tFROM\tdbo.WhoIsActive AS r with (nolock)\n\t\tINNER JOIN T_BLOCKERS AS B ON\tr.collection_time = B.collection_time AND r.blocking_session_id = B.session_id\n\t\tWHERE\t r.blocking_session_id <> r.session_id\n\t)\n\tSELECT\t[collection_time] = DATEADD(mi, DATEDIFF(mi, getdate(), getutcdate()), [collection_time]), \n\t\t\t[ddd hh:mm:ss] = right('0000'+convert(varchar, duration_s/86400),3)+ ' '+convert(varchar,dateadd(SECOND,duration_s,'1900-01-01 00:00:00'),108), \n\t\t\t[session_id], \n\t\t\t[BLOCKING_TREE] = N' ' + REPLICATE (N'| ', LEN (LEVEL)/4 - 1) \n\t\t\t\t\t\t\t+\tCASE\tWHEN (LEN(LEVEL)/4 - 1) = 0\n\t\t\t\t\t\t\t\t\t\tTHEN 'HEAD - '\n\t\t\t\t\t\t\t\t\t\tELSE '|------ ' \n\t\t\t\t\t\t\t\tEND\n\t\t\t\t\t\t\t+\tCAST (r.session_id AS NVARCHAR (10)) + N' ' + ISNULL((CASE WHEN LEFT(ISNULL(r.[sql_text],''),1) = '(' THEN SUBSTRING(ISNULL(r.[sql_text],''),CHARINDEX('exec',ISNULL(r.[sql_text],'')),LEN(ISNULL(r.[sql_text],''))) ELSE ISNULL(r.[sql_text],'') END),''),\n\t\t\t[blocking_session_id], [blocked_session_count] = case when [blocked_session_count] = 0 then null else [blocked_session_count] end, r.wait_info, [login_name], [program_name], [host_name], tasks, command, [database_name], status, r.open_tran_count, r.CPU, [used_memory_kb] = (r.used_memory*8.0), [reads_kb] = (r.[reads]*8.0), r.[writes], [tempdb_allocations_kb] = tempdb_allocations*8.0, tempdb_current_kb = tempdb_current*8.0, granted_memory_kb = granted_memory * 8.0\n\t\t\t--,r.query_plan ,r.additional_info\n\tFROM\tT_BLOCKERS AS r ORDER BY collection_time, LEVEL;\nend\nelse\n select 'No Blocking Found for Time Window' as [No Result]\n\"\nset quoted_identifier on;\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nif ($is_local = 1)\n exec dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;\nelse\n exec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;", - "refId": "A", - "sql": { - "columns": [ - { - "parameters": [], - "type": "function" + "parameters": [], + "type": "function" } ], "groupBy": [ @@ -3741,12 +3650,12 @@ } } ], - "title": "Blocking Details - ACTIVE - [sp_WhoIsActive] @ ${whoisactive_collection_time_utc:date:YYYY-MM-DD HH.mm}", - "type": "table" + "title": "OS Processes CPU Utilization - @ ${perfmon_collection_time_utc:date:YYYY-MM-DD HH.mm}", + "type": "timeseries" } ], "repeat": "datasource", - "title": "Blocking Tree (Queries) - ACTIVE - [sp_WhoIsActive] @ ${whoisactive_collection_time_utc:date:YYYY-MM-DD HH.mm}", + "title": "Trend - CPU Utilization @ ${perfmon_collection_time_utc:date:YYYY-MM-DD HH.mm}", "type": "row" }, { @@ -3755,16 +3664,17 @@ "h": 1, "w": 24, "x": 0, - "y": 20 + "y": 19 }, - "id": 151, + "id": 195, "panels": [ { "datasource": { + "default": false, "type": "mssql", "uid": "${sqlmonitor_datasource}" }, - "description": "select * from $whoisactive_table_name\nwhere (w.blocking_session_id is null and blocked_session_count > 0)", + "description": "select physical_memory_in_use_kb from sys.dm_os_process_memory", "fieldConfig": { "defaults": { "color": { @@ -3779,7 +3689,7 @@ "barAlignment": 0, "barWidthFactor": 0.6, "drawStyle": "line", - "fillOpacity": 0, + "fillOpacity": 10, "gradientMode": "none", "hideFrom": { "legend": false, @@ -3788,20 +3698,16 @@ }, "insertNulls": false, "lineInterpolation": "linear", - "lineStyle": { - "fill": "solid" - }, "lineWidth": 1, "pointSize": 5, "scaleDistribution": { - "log": 10, - "type": "log" + "type": "linear" }, - "showPoints": "always", - "spanNulls": false, + "showPoints": "never", + "spanNulls": true, "stacking": { "group": "A", - "mode": "normal" + "mode": "none" }, "thresholdsStyle": { "mode": "off" @@ -3812,29 +3718,31 @@ "mode": "absolute", "steps": [ { - "color": "green" + "color": "green", + "value": null } ] }, - "unit": "short" + "unit": "kbytes" }, "overrides": [] }, "gridPos": { - "h": 11, + "h": 10, "w": 24, "x": 0, - "y": 252 + "y": 305 }, - "id": 149, + "id": 194, "options": { "legend": { "calcs": [ - "mean", - "max" + "last", + "max", + "mean" ], "displayMode": "table", - "placement": "right", + "placement": "bottom", "showLegend": true, "sortBy": "Mean", "sortDesc": true @@ -3852,12 +3760,31 @@ "type": "mssql", "uid": "${DS_SQLMONITOR}" }, + "editorMode": "code", "format": "time_series", - "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\ndeclare @start_time_utc datetime2;\ndeclare @end_time_utc datetime2;\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @start_time_utc = $__timeFrom();\nset @end_time_utc = $__timeTo();\nset @params = N'@perfmon_host_name varchar(255), @start_time_utc datetime2, @end_time_utc datetime2';\n\nset quoted_identifier off;\nset @sql = \"\nset nocount on;\nselect DATEADD(mi, DATEDIFF(mi, getdate(), getutcdate()), collection_time) as [time], w.login_name as metric, sum(convert(int,replace(w.blocked_session_count,',',''))) as [value]\nfrom $whoisactive_table_name w with (nolock)\nwhere (collection_time between DATEADD(mi, DATEDIFF(mi, GETUTCDATE(), GETDATE()), @start_time_utc) and DATEADD(mi, DATEDIFF(mi, GETUTCDATE(), GETDATE()), @end_time_utc))\nand (w.blocking_session_id is null and replace(w.blocked_session_count,',','') > 0) -- get lead blockers only\ngroup by collection_time, w.login_name\norder by time\n\"\nset quoted_identifier on;\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nif ($is_local = 1)\n exec dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;\nelse\n exec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;", - "refId": "A" + "rawQuery": true, + "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @start_time_utc datetime2;\ndeclare @end_time_utc datetime2;\n\nset @sql_instance = '$server';\nset @start_time_utc = $__timeFrom();\nset @end_time_utc = $__timeTo();\nset @params = N'@sql_instance varchar(255), @start_time_utc datetime2, @end_time_utc datetime2';\n\nset quoted_identifier off;\nset @sql = \"\nset nocount on;\nselect\t[time] = DATEADD(mi, DATEDIFF(mi, getdate(), getutcdate()), h.collection_time),\n\t\t\t\t[SqlServer] = h.physical_memory_in_use_kb,\n\t\t\t\t[Total_Ram] = asi.total_physical_memory_kb,\n\t\t\t\t[Available_Memory] = h.available_physical_memory_kb\nfrom dbo.all_server_volatile_info_history h\njoin dbo.all_server_stable_info asi\ton asi.srv_name = h.srv_name\nwhere h.collection_time between DATEADD(mi, DATEDIFF(mi, GETUTCDATE(), GETDATE()), @start_time_utc) and DATEADD(mi, DATEDIFF(mi, GETUTCDATE(), GETDATE()), @end_time_utc)\nand h.srv_name = @sql_instance\norder by time\n\"\nset quoted_identifier on;\n\nexec dbo.sp_executesql @sql , @params, @sql_instance, @start_time_utc, @end_time_utc;", + "refId": "A", + "sql": { + "columns": [ + { + "parameters": [], + "type": "function" + } + ], + "groupBy": [ + { + "property": { + "type": "string" + }, + "type": "groupBy" + } + ], + "limit": 50 + } } ], - "title": "[${server}] - Lead Blockers - Logins - Blocked Count", + "title": "SQL Server Process Memory", "type": "timeseries" }, { @@ -3865,44 +3792,43 @@ "type": "mssql", "uid": "${sqlmonitor_datasource}" }, - "description": "select * from $whoisactive_table_name\nwhere (w.blocking_session_id is null and blocked_session_count > 0)", + "description": "https://sqlperformance.com/2014/10/sql-performance/knee-jerk-page-life-expectancy", "fieldConfig": { "defaults": { "color": { "mode": "palette-classic" }, "custom": { + "axisBorderShow": false, "axisCenteredZero": false, "axisColorMode": "text", - "axisLabel": "", + "axisLabel": "% CPU", "axisPlacement": "auto", "barAlignment": 0, + "barWidthFactor": 0.6, "drawStyle": "line", - "fillOpacity": 0, + "fillOpacity": 10, "gradientMode": "none", "hideFrom": { "legend": false, "tooltip": false, "viz": false }, + "insertNulls": false, "lineInterpolation": "linear", - "lineStyle": { - "fill": "solid" - }, "lineWidth": 1, "pointSize": 5, "scaleDistribution": { - "log": 10, - "type": "log" + "type": "linear" }, - "showPoints": "always", - "spanNulls": false, + "showPoints": "never", + "spanNulls": true, "stacking": { "group": "A", - "mode": "normal" + "mode": "none" }, "thresholdsStyle": { - "mode": "off" + "mode": "line+area" } }, "mappings": [], @@ -3910,31 +3836,33 @@ "mode": "absolute", "steps": [ { - "color": "green" + "color": "transparent", + "value": null } ] }, - "unit": "short" + "unit": "mbytes" }, "overrides": [] }, "gridPos": { - "h": 11, + "h": 10, "w": 24, "x": 0, - "y": 410 + "y": 315 }, - "id": 152, + "id": 196, "options": { "legend": { "calcs": [ - "mean", + "lastNotNull", + "p98", "max" ], "displayMode": "table", "placement": "right", "showLegend": true, - "sortBy": "Mean", + "sortBy": "98th %", "sortDesc": true }, "tooltip": { @@ -3942,7 +3870,7 @@ "sort": "desc" } }, - "pluginVersion": "8.4.4", + "pluginVersion": "11.3.1", "targets": [ { "alias": "", @@ -3950,130 +3878,138 @@ "type": "mssql", "uid": "${DS_SQLMONITOR}" }, + "editorMode": "code", "format": "time_series", - "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\ndeclare @start_time_utc datetime2;\ndeclare @end_time_utc datetime2;\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @start_time_utc = $__timeFrom();\nset @end_time_utc = $__timeTo();\nset @params = N'@perfmon_host_name varchar(255), @start_time_utc datetime2, @end_time_utc datetime2';\n\nset quoted_identifier off;\nset @sql = \"\nset nocount on;\nselect DATEADD(mi, DATEDIFF(mi, getdate(), getutcdate()), collection_time) as [time], \n w.login_name+' {{'+(case when len(w.program_name)>35 then left(w.program_name,35)+'..' else w.program_name end)+'}}' as metric, sum(convert(int,replace(w.blocked_session_count,',',''))) as [value]\nfrom $whoisactive_table_name w with (nolock)\nwhere (collection_time between DATEADD(mi, DATEDIFF(mi, GETUTCDATE(), GETDATE()), @start_time_utc) and DATEADD(mi, DATEDIFF(mi, GETUTCDATE(), GETDATE()), @end_time_utc))\nand (w.blocking_session_id is null and replace(w.blocked_session_count,',','') > 0) -- get lead blockers only\ngroup by collection_time, w.login_name, w.program_name\norder by time\n\"\nset quoted_identifier on;\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nif ($is_local = 1)\n exec dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;\nelse\n exec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;", - "refId": "A" - } - ], - "title": "[${server}] - Lead Blockers - Programs - Blocked Count", - "type": "timeseries" - } - ], - "repeat": "datasource", - "title": "Lead Blockers - @ ${perfmon_collection_time_utc:date:YYYY-MM-DD HH.mm}", - "type": "row" - }, - { - "collapsed": true, - "gridPos": { - "h": 1, + "rawQuery": true, + "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\ndeclare @start_time_utc datetime2;\ndeclare @end_time_utc datetime2;\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @start_time_utc = $__timeFrom();\nset @end_time_utc = $__timeTo();\nset @params = N'@perfmon_host_name varchar(255), @start_time_utc datetime2, @end_time_utc datetime2';\n\nset quoted_identifier off;\nset @sql = \"\n;with cte_process_cpu as (\n\tselect pc.collection_time_utc, pc.host_name, pc.object, pc.counter,\n\t\t\tpc.value, \n\t\t\tpc.instance,\n\t\t\tprocess = case when CHARINDEX('#',s1.instance) > 0 then left(s1.instance, CHARINDEX('#',s1.instance)-1) else s1.instance end\n\tfrom $perfmon_table_name pc\n\touter apply (select instance = case when CHARINDEX('$',pc.instance) > 0 then left(pc.instance, CHARINDEX('$',pc.instance)-1) else pc.instance end ) s1\n\twhere collection_time_utc between @start_time_utc and @end_time_utc\n\tand pc.host_name = @perfmon_host_name\n\tand object = 'process' and counter = 'working set'\n\tand pc.instance not in ('_total','idle')\n)\nselect\t[time] = collection_time_utc, --p.host_name, p.object, p.counter, \n\t\t[metric] = p.process,\n\t\t[value] = floor(sum(p.value)*1.0/1024.0/1024.0)\nfrom cte_process_cpu p\ngroup by collection_time_utc, p.process\nhaving floor(sum(p.value)*1.0/1024.0/1024.0) > 0\norder by [time]\n\"\nset quoted_identifier on;\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nif ($is_local = 1)\n exec dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;\nelse\n exec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;", + "refId": "A", + "sql": { + "columns": [ + { + "parameters": [], + "type": "function" + } + ], + "groupBy": [ + { + "property": { + "type": "string" + }, + "type": "groupBy" + } + ], + "limit": 50 + } + } + ], + "title": "OS Processes Memory Utilization - @ ${perfmon_collection_time_utc:date:YYYY-MM-DD HH.mm}", + "type": "timeseries" + } + ], + "title": "Trend - Memory Utilization @ ${perfmon_collection_time_utc:date:YYYY-MM-DD HH.mm}", + "type": "row" + }, + { + "collapsed": true, + "gridPos": { + "h": 1, "w": 24, "x": 0, - "y": 21 + "y": 20 }, - "id": 59, + "id": 198, "panels": [ { "datasource": { "type": "mssql", "uid": "${sqlmonitor_datasource}" }, + "description": "select * from dbo.alert_history where error_number = 15457;", "fieldConfig": { "defaults": { "color": { - "mode": "palette-classic" + "mode": "thresholds" }, "custom": { - "axisBorderShow": false, - "axisCenteredZero": false, - "axisColorMode": "text", - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "barWidthFactor": 0.6, - "drawStyle": "line", - "fillOpacity": 10, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "insertNulls": false, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "log": 2, - "type": "log" - }, - "showPoints": "never", - "spanNulls": true, - "stacking": { - "group": "A", - "mode": "none" + "align": "center", + "cellOptions": { + "type": "auto", + "wrapText": false }, - "thresholdsStyle": { - "mode": "line+area" - } + "filterable": true, + "inspect": true }, "mappings": [], "thresholds": { "mode": "absolute", "steps": [ { - "color": "transparent" - }, - { - "color": "orange", - "value": 0 - }, + "color": "green", + "value": null + } + ] + } + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "time" + }, + "properties": [ { - "color": "red", - "value": 2 + "id": "custom.width", + "value": 227 } ] }, - "unit": "short" - }, - "overrides": [] + { + "matcher": { + "id": "byName", + "options": "error_number" + }, + "properties": [ + { + "id": "custom.width", + "value": 172 + } + ] + } + ] }, "gridPos": { - "h": 7, + "h": 8, "w": 24, "x": 0, - "y": 31 + "y": 44 }, - "id": 57, + "id": 197, "options": { - "legend": { - "calcs": [ - "mean", - "lastNotNull", - "max" + "cellHeight": "sm", + "footer": { + "countRows": false, + "enablePagination": false, + "fields": "", + "reducer": [ + "sum" ], - "displayMode": "table", - "placement": "bottom", - "showLegend": true + "show": false }, - "tooltip": { - "mode": "multi", - "sort": "desc" - } + "showHeader": true, + "sortBy": [] }, "pluginVersion": "11.3.1", "targets": [ { - "alias": "", + "dataset": "AdventureWorks2019", "datasource": { "type": "mssql", "uid": "${DS_SQLMONITOR}" }, "editorMode": "code", - "format": "time_series", - "hide": false, + "format": "table", "rawQuery": true, - "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\ndeclare @start_time_utc datetime2;\ndeclare @end_time_utc datetime2;\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @start_time_utc = $__timeFrom();\nset @end_time_utc = $__timeTo();\nset @params = N'@perfmon_host_name varchar(255), @start_time_utc datetime2, @end_time_utc datetime2';\n\nset quoted_identifier off;\nset @sql = \"\nset nocount on;\ndeclare @object_name varchar(255);\nset @object_name = (case when '$perfmon_service_name' = 'MSSQLSERVER' then 'sqlserver' else LOWER('$perfmon_service_name') end);\nselect pc.collection_time_utc as time, \n\tcounter as metric\n\t--,instance,\n\t,pc.value\nfrom $perfmon_table_name pc with (nolock)\nwhere collection_time_utc between @start_time_utc and @end_time_utc\nand pc.host_name = @perfmon_host_name\nand (\t(pc.object = (@object_name+':memory manager')\n\t\tand pc.counter in ('memory grants outstanding','memory grants pending'))\n\t)\norder by time\n\"\nset quoted_identifier on;\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nif ($is_local = 1)\n exec dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;\nelse\n exec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;", + "rawSql": "declare @sql nvarchar(max);\r\ndeclare @params nvarchar(max);\r\ndeclare @sql_instance varchar(255);\r\ndeclare @perfmon_host_name varchar(255);\r\ndeclare @start_time_utc datetime2;\r\ndeclare @end_time_utc datetime2;\r\n\r\nset @sql_instance = '$server';\r\nset @perfmon_host_name = '$perfmon_host_name';\r\nset @start_time_utc = $__timeFrom();\r\nset @end_time_utc = $__timeTo();\r\nset @params = N'@perfmon_host_name varchar(255), @start_time_utc datetime2, @end_time_utc datetime2';\r\n\r\nset quoted_identifier off;\r\nset @sql = \"\r\nselect\t[time] = collection_time_utc, ah.error_number,\r\n\t\t--[database] = case when ah.error_number = 15457 then null else database_name end,\r\n\t\t[remarks] = ah.[error_message]\r\nfrom dbo.alert_history ah\r\nwhere collection_time_utc between @start_time_utc and @end_time_utc\r\nand ah.error_number in (15457)\r\n--and ah.error_number in (5084)\r\norder by time\r\n\"\r\nset quoted_identifier on;\r\n\r\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\r\nif ($is_local = 1)\r\n exec dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;\r\nelse\r\n exec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;", "refId": "A", "sql": { "columns": [ @@ -4094,52 +4030,36 @@ } } ], - "title": "Memory Grants Pending", - "type": "timeseries" - } - ], - "repeat": "datasource", - "title": "Trend - Memory Grants Pending", - "type": "row" - }, - { - "collapsed": true, - "gridPos": { - "h": 1, - "w": 24, - "x": 0, - "y": 22 - }, - "id": 179, - "panels": [ + "title": "Server Configuration Changes", + "type": "table" + }, { "datasource": { "type": "mssql", "uid": "${sqlmonitor_datasource}" }, + "description": "select * from dbo.alert_history where error_number = 5084;", "fieldConfig": { "defaults": { "color": { "mode": "thresholds" }, "custom": { - "align": "auto", + "align": "center", "cellOptions": { - "type": "auto" + "type": "auto", + "wrapText": false }, "filterable": true, - "inspect": false + "inspect": true }, "mappings": [], "thresholds": { "mode": "absolute", "steps": [ { - "color": "green" - }, - { - "color": "red", - "value": 80 + "color": "green", + "value": null } ] } @@ -4148,92 +4068,218 @@ { "matcher": { "id": "byName", - "options": "sql_command" + "options": "time" }, "properties": [ { "id": "custom.width", - "value": 352 + "value": 173 } ] }, { "matcher": { "id": "byName", - "options": "program_name" + "options": "error_number" }, "properties": [ { "id": "custom.width", - "value": 169 + "value": 133 } ] }, { "matcher": { "id": "byName", - "options": "session_id" + "options": "database" }, "properties": [ { "id": "custom.width", - "value": 105 - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "CPU" - }, - "properties": [ - { - "id": "unit", - "value": "ms" + "value": 227 } ] }, { "matcher": { "id": "byName", - "options": "granted_memory_kb" + "options": "remarks" }, "properties": [ { - "id": "unit", - "value": "kbytes" - }, - { - "id": "displayName", - "value": "granted_memory" + "id": "custom.align", + "value": "left" } ] + } + ] + }, + "gridPos": { + "h": 8, + "w": 24, + "x": 0, + "y": 52 + }, + "id": 199, + "options": { + "cellHeight": "sm", + "footer": { + "countRows": false, + "enablePagination": false, + "fields": "", + "reducer": [ + "sum" + ], + "show": false + }, + "showHeader": true, + "sortBy": [] + }, + "pluginVersion": "11.3.1", + "targets": [ + { + "dataset": "AdventureWorks2019", + "datasource": { + "type": "mssql", + "uid": "${DS_SQLMONITOR}" }, - { - "matcher": { - "id": "byName", - "options": "reads_kb" - }, - "properties": [ - { - "id": "unit", - "value": "kbytes" - }, + "editorMode": "code", + "format": "table", + "rawQuery": true, + "rawSql": "declare @sql nvarchar(max);\r\ndeclare @params nvarchar(max);\r\ndeclare @sql_instance varchar(255);\r\ndeclare @perfmon_host_name varchar(255);\r\ndeclare @start_time_utc datetime2;\r\ndeclare @end_time_utc datetime2;\r\n\r\nset @sql_instance = '$server';\r\nset @perfmon_host_name = '$perfmon_host_name';\r\nset @start_time_utc = $__timeFrom();\r\nset @end_time_utc = $__timeTo();\r\nset @params = N'@perfmon_host_name varchar(255), @start_time_utc datetime2, @end_time_utc datetime2';\r\n\r\nset quoted_identifier off;\r\nset @sql = \"\r\nselect\t[time] = collection_time_utc, ah.error_number,\r\n\t\t[database] = database_name,\r\n\t\t[remarks] = ah.[error_message]\r\nfrom dbo.alert_history ah\r\nwhere collection_time_utc between @start_time_utc and @end_time_utc\r\n--and ah.error_number in (15457)\r\nand ah.error_number in (5084)\r\norder by time\r\n\"\r\nset quoted_identifier on;\r\n\r\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\r\nif ($is_local = 1)\r\n exec dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;\r\nelse\r\n exec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;", + "refId": "A", + "sql": { + "columns": [ { - "id": "displayName", - "value": "reads" + "parameters": [], + "type": "function" } - ] - }, - { - "matcher": { - "id": "byName", - "options": "writes" - }, - "properties": [ + ], + "groupBy": [ { - "id": "unit", - "value": "short" + "property": { + "type": "string" + }, + "type": "groupBy" + } + ], + "limit": 50 + } + } + ], + "title": "Database Configuration Changes", + "type": "table" + } + ], + "title": "Server & Database Config Changes", + "type": "row" + }, + { + "collapsed": true, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 21 + }, + "id": 113, + "panels": [ + { + "datasource": { + "type": "mssql", + "uid": "${sqlmonitor_datasource}" + }, + "description": "Blocking Details____In Selected Time Duration____Since____${__from:date:YYYY-MM-DD HH.mm}___till___${whoisactive_collection_time_utc:date:YYYY-MM-DD HH.mm}____", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "custom": { + "align": "auto", + "cellOptions": { + "type": "auto" + }, + "filterable": true, + "inspect": false + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + } + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "BLOCKING_TREE" + }, + "properties": [ + { + "id": "custom.width", + "value": 308 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "CPU" + }, + "properties": [ + { + "id": "unit", + "value": "ms" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "writes" + }, + "properties": [ + { + "id": "unit", + "value": "short" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "used_memory_kb" + }, + "properties": [ + { + "id": "unit", + "value": "kbytes" + }, + { + "id": "displayName", + "value": "used_memory" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "reads_kb" + }, + "properties": [ + { + "id": "unit", + "value": "kbytes" + }, + { + "id": "displayName", + "value": "reads" } ] }, @@ -4272,7 +4318,7 @@ { "matcher": { "id": "byName", - "options": "used_memory_kb" + "options": "granted_memory_kb" }, "properties": [ { @@ -4281,19 +4327,19 @@ }, { "id": "displayName", - "value": "used_memory" + "value": "granted_memory" } ] } ] }, "gridPos": { - "h": 11, + "h": 8, "w": 24, "x": 0, - "y": 439 + "y": 982 }, - "id": 177, + "id": 111, "options": { "cellHeight": "sm", "footer": { @@ -4305,9 +4351,14 @@ "show": false }, "showHeader": true, - "sortBy": [] + "sortBy": [ + { + "desc": false, + "displayName": "collection_time" + } + ] }, - "pluginVersion": "10.1.0", + "pluginVersion": "11.3.1", "targets": [ { "alias": "", @@ -4318,7 +4369,7 @@ "editorMode": "code", "format": "table", "rawQuery": true, - "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\ndeclare @start_time_utc datetime2;\ndeclare @end_time_utc datetime2;\ndeclare @crlf nchar(2) = nchar(13)+nchar(10);\n\n--declare @delta_minutes int;\ndeclare @program_name nvarchar(500);\ndeclare @login_name nvarchar(255);\ndeclare @database nvarchar(500) = '$database';\ndeclare @session_id int;\ndeclare @session_host_name nvarchar(125);\ndeclare @query_pattern nvarchar(500);\ndeclare @duration int;\ndeclare @memory_grant_threshold_mb int = $memory_grant_threshold_mb;\n\nset @database = case when ltrim(rtrim(@database)) = '__All__' then null else @database end;\nset @duration = case when ltrim(rtrim('$duration')) <> '' then $duration else 0 end;\nif len(ltrim(rtrim('$program_name'))) > 0\n set @program_name = '$program_name'\nif len(ltrim(rtrim('$login_name'))) > 0\n set @login_name = '$login_name'\nif len(ltrim(rtrim('$session_host_name'))) > 0\n set @session_host_name = '$session_host_name'\nif len(ltrim(rtrim('$query_pattern'))) > 0\n set @query_pattern = '$query_pattern'\nif len(ltrim(rtrim('$session_id'))) > 0 and (case when '$session_id' like '%[^0-9.]%' then 'invalid' when '$session_id' like '%.%.%' then 'invalid' else 'valid' end) = 'valid'\n set @session_id = convert(int,'$session_id');\n\nset @sql_instance = '$server';\n--set @perfmon_host_name = '$perfmon_host_name';\nset @start_time_utc = $__timeFrom();\n--set @start_time_utc = dateadd(second,$sqlserver_start_time_utc/1000,'1970-01-01 00:00:00');\nset @end_time_utc = $__timeTo();\n--set @end_time_utc = $__timeFrom();\n--set @delta_minutes = $cpu_delta_minutes;\nset @params = N'@perfmon_host_name varchar(255), @start_time_utc datetime2, @end_time_utc datetime2,\n\t\t\t\t@program_name nvarchar(500), @login_name nvarchar(255), @database nvarchar(500),\n\t\t\t\t@session_id int, @session_host_name nvarchar(125), @query_pattern nvarchar(500),\n\t\t\t\t@duration int, @memory_grant_threshold_mb int';\n\nset quoted_identifier off;\nset @sql = \"/* SQLMonitor Dashboard $__dashboard: LongRunningQueries */\nset nocount on;\t\t\t\nif exists ( select * from $whoisactive_table_name w with (nolock)\n where w.collection_time = (select max(i.collection_time) from $whoisactive_table_name i with (nolock)) \n and granted_memory >= (@memory_grant_threshold_mb*1024/8) )\nbegin\n ;with t_WhoIsActive as (\n select [collection_time] = convert(varchar,w.collection_time,120), w.session_id, \n w.program_name, w.login_name, w.database_name, w.host_name,\n w.status, w.CPU, w.used_memory, w.open_tran_count, [duration_ms] = datediff(MILLISECOND, start_time, w.collection_time),\n w.wait_info, granted_memory, tempdb_current,\n sql_command = case when w.sql_command is not null then left(replace(replace(convert(nvarchar(max),w.sql_command),char(13)+char(10),''),'= (@memory_grant_threshold_mb*1024/8)\n )\n select [collection_time] = DATEADD(mi, DATEDIFF(mi, getdate(), getutcdate()), [collection_time]), w.session_id,\n [ddd hh:mm:ss.mss] = right('0000'+convert(varchar, duration_ms/86400000),3)+ ' '+convert(varchar,dateadd(MILLISECOND,duration_ms,'1900-01-01 00:00:00'),114), \n w.program_name, w.login_name, w.database_name, w.host_name, w.status, w.CPU, \n granted_memory_kb = (w.granted_memory * 8.0), w.open_tran_count, w.wait_info, w.sql_command, w.blocked_session_count, \n w.blocking_session_id, [reads_kb] = (w.[reads]*8.0), w.writes, [tempdb_allocations_kb] = (w.tempdb_allocations*8.0), \n tempdb_current_kb = (tempdb_current*8.0), w.tasks, w.percent_complete, [used_memory_kb] = (w.used_memory*8.0),\n start_time = DATEADD(mi, DATEDIFF(mi, getdate(), getutcdate()), [start_time])\n from t_WhoIsActive w\n order by granted_memory desc, used_memory desc, collection_time\nend\nELSE\n select 'No long running query found for time window' as [No Result]\n\"\nset quoted_identifier on;\n--print @sql\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nif ($is_local = 1)\n exec dbo.sp_executesql @sql, @params, @perfmon_host_name, @start_time_utc, @end_time_utc, \n\t\t\t\t\t@program_name, @login_name, @database, @session_id, @session_host_name, \n\t\t\t\t\t@query_pattern, @duration, @memory_grant_threshold_mb;\nelse\n exec [$server].[$dba_db].dbo.sp_executesql @sql, @params, @perfmon_host_name, @start_time_utc, @end_time_utc,\n\t\t\t\t\t@program_name, @login_name, @database, @session_id, @session_host_name, \n\t\t\t\t\t@query_pattern, @duration, @memory_grant_threshold_mb;", + "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\ndeclare @start_time_utc datetime2;\ndeclare @end_time_utc datetime2;\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @start_time_utc = $__timeFrom();\nset @end_time_utc = $__timeTo();\nset @params = N'@perfmon_host_name varchar(255), @start_time_utc datetime2, @end_time_utc datetime2';\n\nset quoted_identifier off;\nset @sql = \"\nset nocount on;\n\ndeclare @collection_time datetime;\nselect @collection_time = max(l.collection_time) from dbo.WhoIsActive l;\n\n-- Get Blocking Tree\nif exists (select 1/0 from dbo.WhoIsActive w with (nolock) where w.collection_time = @collection_time and (blocking_session_id is not null or blocked_session_count > 0))\nbegin\n\t;WITH T_BLOCKERS AS (\n\t\t-- Find block Leaders\n\t\tSELECT\t[duration_s] = datediff(SECOND, start_time, r.collection_time), [collection_time], [session_id], \n\t\t\t\t[sql_text] = REPLACE(REPLACE(REPLACE(REPLACE(CAST(COALESCE([sql_command],[sql_text]) AS VARCHAR(MAX)),char(13),''),CHAR(10),''),'',''), \n\t\t\t\tcommand = additional_info.value('(/additional_info/command_type)[1]','varchar(125)'), [login_name], wait_info, [blocking_session_id], [blocked_session_count] = replace(blocked_session_count,',',''),\n\t\t\t\t[status], open_tran_count, [host_name], [database_name], [program_name], tasks, granted_memory, r.CPU, r.used_memory, r.[tempdb_allocations], r.[tempdb_current], r.[reads], r.[writes], r.[physical_io], additional_info,\n\t\t\t\t[LEVEL] = CAST (REPLICATE ('0', 4-LEN (CAST (r.session_id AS VARCHAR))) + CAST (r.session_id AS VARCHAR) AS VARCHAR (1000))\n\t\t\t\t,[head_blocker] = session_id ,query_plan\n\t\tFROM\tdbo.WhoIsActive AS r with (nolock) WHERE r.collection_time = @collection_time and (r.blocking_session_id IS NULL AND blocked_session_count > 0)\n\t\t--\t\n\t\tUNION ALL\n\t\t--\n\t\tSELECT\t[duration_s] = datediff(SECOND, r.start_time, r.collection_time), r.[collection_time], r.[session_id], \n\t\t\t\t[sql_text] = REPLACE(REPLACE(REPLACE(REPLACE(CAST(COALESCE(r.[sql_command],r.[sql_text]) AS VARCHAR(MAX)),char(13),''),CHAR(10),''),'',''), \n\t\t\t\tcommand = r.additional_info.value('(/additional_info/command_type)[1]','varchar(125)'), r.[login_name], r.wait_info, r.[blocking_session_id], [blocked_session_count] = replace(r.blocked_session_count,',',''),\n\t\t\t\tr.[status], r.open_tran_count, r.[host_name], r.[database_name], r.[program_name], r.tasks, r.granted_memory, r.CPU, r.used_memory, r.[tempdb_allocations], r.[tempdb_current], r.[reads], r.[writes], r.[physical_io], r.additional_info,\n\t\t\t\tCAST (B.LEVEL + RIGHT (CAST ((1000 + r.session_id) AS VARCHAR (100)), 4) AS VARCHAR (1000)) AS LEVEL\n\t\t\t\t,[head_blocker] = case when B.[head_blocker] is null then B.session_id else B.[head_blocker] end ,r.query_plan\n\t\tFROM\tdbo.WhoIsActive AS r with (nolock)\n\t\tINNER JOIN T_BLOCKERS AS B ON\tr.collection_time = B.collection_time AND r.blocking_session_id = B.session_id\n\t\tWHERE\t r.blocking_session_id <> r.session_id\n\t)\n\tSELECT\t[collection_time] = DATEADD(mi, DATEDIFF(mi, getdate(), getutcdate()), [collection_time]), \n\t\t\t[ddd hh:mm:ss] = right('0000'+convert(varchar, duration_s/86400),3)+ ' '+convert(varchar,dateadd(SECOND,duration_s,'1900-01-01 00:00:00'),108), \n\t\t\t[session_id], \n\t\t\t[BLOCKING_TREE] = N' ' + REPLICATE (N'| ', LEN (LEVEL)/4 - 1) \n\t\t\t\t\t\t\t+\tCASE\tWHEN (LEN(LEVEL)/4 - 1) = 0\n\t\t\t\t\t\t\t\t\t\tTHEN 'HEAD - '\n\t\t\t\t\t\t\t\t\t\tELSE '|------ ' \n\t\t\t\t\t\t\t\tEND\n\t\t\t\t\t\t\t+\tCAST (r.session_id AS NVARCHAR (10)) + N' ' + ISNULL((CASE WHEN LEFT(ISNULL(r.[sql_text],''),1) = '(' THEN SUBSTRING(ISNULL(r.[sql_text],''),CHARINDEX('exec',ISNULL(r.[sql_text],'')),LEN(ISNULL(r.[sql_text],''))) ELSE ISNULL(r.[sql_text],'') END),''),\n\t\t\t[blocking_session_id], [blocked_session_count] = case when [blocked_session_count] = 0 then null else [blocked_session_count] end, r.wait_info, [login_name], [program_name], [host_name], tasks, command, [database_name], status, r.open_tran_count, r.CPU, [used_memory_kb] = (r.used_memory*8.0), [reads_kb] = (r.[reads]*8.0), r.[writes], [tempdb_allocations_kb] = tempdb_allocations*8.0, tempdb_current_kb = tempdb_current*8.0, granted_memory_kb = granted_memory * 8.0\n\t\t\t--,r.query_plan ,r.additional_info\n\tFROM\tT_BLOCKERS AS r ORDER BY collection_time, LEVEL;\nend\nelse\n select 'No Blocking Found for Time Window' as [No Result]\n\"\nset quoted_identifier on;\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nif ($is_local = 1)\n exec dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;\nelse\n exec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;", "refId": "A", "sql": { "columns": [ @@ -4339,11 +4390,12 @@ } } ], - "title": "Memory Consumers Over __ $memory_grant_threshold_mb MB__ \"- WhoIsActive Data @ ${whoisactive_collection_time_utc:date:YYYY-MM-DD HH.mm}", + "title": "Blocking Details - ACTIVE - [sp_WhoIsActive] @ ${whoisactive_collection_time_utc:date:YYYY-MM-DD HH.mm}", "type": "table" } ], - "title": "M/r Consumers - ACTIVE - [sp_WhoIsActive] @ ${whoisactive_collection_time_utc:date:YYYY-MM-DD HH.mm}", + "repeat": "datasource", + "title": "Blocking Tree (Queries) - ACTIVE - [sp_WhoIsActive] @ ${whoisactive_collection_time_utc:date:YYYY-MM-DD HH.mm}", "type": "row" }, { @@ -4352,28 +4404,57 @@ "h": 1, "w": 24, "x": 0, - "y": 23 + "y": 22 }, - "id": 188, + "id": 151, "panels": [ { "datasource": { "type": "mssql", "uid": "${sqlmonitor_datasource}" }, - "description": "select [collection_time], [data_size_mb], [data_used_mb], [data_used_pct], [log_size_mb], [log_used_mb], [log_used_pct], [version_store_mb], [version_store_pct]\nfrom dbo.tempdb_space_usage tsu\nwhere 1=1\nand tsu.collection_time = (select top 1 i.collection_time from dbo.tempdb_space_usage i order by i.collection_time desc)", + "description": "select * from $whoisactive_table_name\nwhere (w.blocking_session_id is null and blocked_session_count > 0)", "fieldConfig": { "defaults": { "color": { - "mode": "thresholds" + "mode": "palette-classic" }, "custom": { - "align": "center", - "cellOptions": { - "type": "auto" + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false }, - "filterable": false, - "inspect": true + "insertNulls": false, + "lineInterpolation": "linear", + "lineStyle": { + "fill": "solid" + }, + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "log": 10, + "type": "log" + }, + "showPoints": "always", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "normal" + }, + "thresholdsStyle": { + "mode": "off" + } }, "mappings": [], "thresholds": { @@ -4381,47 +4462,619 @@ "steps": [ { "color": "green" - }, - { - "color": "red", - "value": 80 } ] - } + }, + "unit": "short" }, - "overrides": [ - { - "matcher": { - "id": "byName", - "options": "collection_time_utc" - }, - "properties": [ - { - "id": "displayName", - "value": "Collection Time" - }, - { - "id": "custom.cellOptions", - "value": { - "type": "color-background" - } - }, - { - "id": "thresholds", - "value": { - "mode": "absolute", - "steps": [ - { - "color": "super-light-purple" - } - ] - } - } - ] + "overrides": [] + }, + "gridPos": { + "h": 11, + "w": 24, + "x": 0, + "y": 983 + }, + "id": 149, + "options": { + "legend": { + "calcs": [ + "mean", + "max" + ], + "displayMode": "table", + "placement": "right", + "showLegend": true, + "sortBy": "Mean", + "sortDesc": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.3.1", + "targets": [ + { + "alias": "", + "datasource": { + "type": "mssql", + "uid": "${DS_SQLMONITOR}" }, - { - "matcher": { - "id": "byName", + "format": "time_series", + "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\ndeclare @start_time_utc datetime2;\ndeclare @end_time_utc datetime2;\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @start_time_utc = $__timeFrom();\nset @end_time_utc = $__timeTo();\nset @params = N'@perfmon_host_name varchar(255), @start_time_utc datetime2, @end_time_utc datetime2';\n\nset quoted_identifier off;\nset @sql = \"\nset nocount on;\nselect DATEADD(mi, DATEDIFF(mi, getdate(), getutcdate()), collection_time) as [time], w.login_name as metric, sum(convert(int,replace(w.blocked_session_count,',',''))) as [value]\nfrom $whoisactive_table_name w with (nolock)\nwhere (collection_time between DATEADD(mi, DATEDIFF(mi, GETUTCDATE(), GETDATE()), @start_time_utc) and DATEADD(mi, DATEDIFF(mi, GETUTCDATE(), GETDATE()), @end_time_utc))\nand (w.blocking_session_id is null and replace(w.blocked_session_count,',','') > 0) -- get lead blockers only\ngroup by collection_time, w.login_name\norder by time\n\"\nset quoted_identifier on;\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nif ($is_local = 1)\n exec dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;\nelse\n exec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;", + "refId": "A" + } + ], + "title": "[${server}] - Lead Blockers - Logins - Blocked Count", + "type": "timeseries" + }, + { + "datasource": { + "type": "mssql", + "uid": "${sqlmonitor_datasource}" + }, + "description": "select * from $whoisactive_table_name\nwhere (w.blocking_session_id is null and blocked_session_count > 0)", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineInterpolation": "linear", + "lineStyle": { + "fill": "solid" + }, + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "log": 10, + "type": "log" + }, + "showPoints": "always", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "normal" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "short" + }, + "overrides": [] + }, + "gridPos": { + "h": 11, + "w": 24, + "x": 0, + "y": 1141 + }, + "id": 152, + "options": { + "legend": { + "calcs": [ + "mean", + "max" + ], + "displayMode": "table", + "placement": "right", + "showLegend": true, + "sortBy": "Mean", + "sortDesc": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "8.4.4", + "targets": [ + { + "alias": "", + "datasource": { + "type": "mssql", + "uid": "${DS_SQLMONITOR}" + }, + "format": "time_series", + "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\ndeclare @start_time_utc datetime2;\ndeclare @end_time_utc datetime2;\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @start_time_utc = $__timeFrom();\nset @end_time_utc = $__timeTo();\nset @params = N'@perfmon_host_name varchar(255), @start_time_utc datetime2, @end_time_utc datetime2';\n\nset quoted_identifier off;\nset @sql = \"\nset nocount on;\nselect DATEADD(mi, DATEDIFF(mi, getdate(), getutcdate()), collection_time) as [time], \n w.login_name+' {{'+(case when len(w.program_name)>35 then left(w.program_name,35)+'..' else w.program_name end)+'}}' as metric, sum(convert(int,replace(w.blocked_session_count,',',''))) as [value]\nfrom $whoisactive_table_name w with (nolock)\nwhere (collection_time between DATEADD(mi, DATEDIFF(mi, GETUTCDATE(), GETDATE()), @start_time_utc) and DATEADD(mi, DATEDIFF(mi, GETUTCDATE(), GETDATE()), @end_time_utc))\nand (w.blocking_session_id is null and replace(w.blocked_session_count,',','') > 0) -- get lead blockers only\ngroup by collection_time, w.login_name, w.program_name\norder by time\n\"\nset quoted_identifier on;\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nif ($is_local = 1)\n exec dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;\nelse\n exec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;", + "refId": "A" + } + ], + "title": "[${server}] - Lead Blockers - Programs - Blocked Count", + "type": "timeseries" + } + ], + "repeat": "datasource", + "title": "Lead Blockers - @ ${perfmon_collection_time_utc:date:YYYY-MM-DD HH.mm}", + "type": "row" + }, + { + "collapsed": true, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 23 + }, + "id": 59, + "panels": [ + { + "datasource": { + "type": "mssql", + "uid": "${sqlmonitor_datasource}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 10, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "log": 2, + "type": "log" + }, + "showPoints": "never", + "spanNulls": true, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "line+area" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "transparent", + "value": null + }, + { + "color": "orange", + "value": 0 + }, + { + "color": "red", + "value": 2 + } + ] + }, + "unit": "short" + }, + "overrides": [] + }, + "gridPos": { + "h": 7, + "w": 24, + "x": 0, + "y": 444 + }, + "id": 57, + "options": { + "legend": { + "calcs": [ + "mean", + "lastNotNull", + "max" + ], + "displayMode": "table", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "multi", + "sort": "desc" + } + }, + "pluginVersion": "11.3.1", + "targets": [ + { + "alias": "", + "datasource": { + "type": "mssql", + "uid": "${DS_SQLMONITOR}" + }, + "editorMode": "code", + "format": "time_series", + "hide": false, + "rawQuery": true, + "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\ndeclare @start_time_utc datetime2;\ndeclare @end_time_utc datetime2;\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @start_time_utc = $__timeFrom();\nset @end_time_utc = $__timeTo();\nset @params = N'@perfmon_host_name varchar(255), @start_time_utc datetime2, @end_time_utc datetime2';\n\nset quoted_identifier off;\nset @sql = \"\nset nocount on;\ndeclare @object_name varchar(255);\nset @object_name = (case when '$perfmon_service_name' = 'MSSQLSERVER' then 'sqlserver' else LOWER('$perfmon_service_name') end);\nselect pc.collection_time_utc as time, \n\tcounter as metric\n\t--,instance,\n\t,pc.value\nfrom $perfmon_table_name pc with (nolock)\nwhere collection_time_utc between @start_time_utc and @end_time_utc\nand pc.host_name = @perfmon_host_name\nand (\t(pc.object = (@object_name+':memory manager')\n\t\tand pc.counter in ('memory grants outstanding','memory grants pending'))\n\t)\norder by time\n\"\nset quoted_identifier on;\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nif ($is_local = 1)\n exec dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;\nelse\n exec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;", + "refId": "A", + "sql": { + "columns": [ + { + "parameters": [], + "type": "function" + } + ], + "groupBy": [ + { + "property": { + "type": "string" + }, + "type": "groupBy" + } + ], + "limit": 50 + } + } + ], + "title": "Memory Grants Pending", + "type": "timeseries" + } + ], + "repeat": "datasource", + "title": "Trend - Memory Grants Pending", + "type": "row" + }, + { + "collapsed": true, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 24 + }, + "id": 179, + "panels": [ + { + "datasource": { + "type": "mssql", + "uid": "${sqlmonitor_datasource}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "custom": { + "align": "auto", + "cellOptions": { + "type": "auto" + }, + "filterable": true, + "inspect": false + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "sql_command" + }, + "properties": [ + { + "id": "custom.width", + "value": 352 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "program_name" + }, + "properties": [ + { + "id": "custom.width", + "value": 169 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "session_id" + }, + "properties": [ + { + "id": "custom.width", + "value": 105 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "CPU" + }, + "properties": [ + { + "id": "unit", + "value": "ms" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "granted_memory_kb" + }, + "properties": [ + { + "id": "unit", + "value": "kbytes" + }, + { + "id": "displayName", + "value": "granted_memory" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "reads_kb" + }, + "properties": [ + { + "id": "unit", + "value": "kbytes" + }, + { + "id": "displayName", + "value": "reads" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "writes" + }, + "properties": [ + { + "id": "unit", + "value": "short" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "tempdb_allocations_kb" + }, + "properties": [ + { + "id": "unit", + "value": "kbytes" + }, + { + "id": "displayName", + "value": "tempdb_allocations" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "tempdb_current_kb" + }, + "properties": [ + { + "id": "unit", + "value": "kbytes" + }, + { + "id": "displayName", + "value": "tempdb_current" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "used_memory_kb" + }, + "properties": [ + { + "id": "unit", + "value": "kbytes" + }, + { + "id": "displayName", + "value": "used_memory" + } + ] + } + ] + }, + "gridPos": { + "h": 11, + "w": 24, + "x": 0, + "y": 67 + }, + "id": 177, + "options": { + "cellHeight": "sm", + "footer": { + "countRows": false, + "fields": "", + "reducer": [ + "sum" + ], + "show": false + }, + "showHeader": true, + "sortBy": [] + }, + "pluginVersion": "11.3.1", + "targets": [ + { + "alias": "", + "datasource": { + "type": "mssql", + "uid": "${DS_SQLMONITOR}" + }, + "editorMode": "code", + "format": "table", + "rawQuery": true, + "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\ndeclare @start_time_utc datetime2;\ndeclare @end_time_utc datetime2;\ndeclare @crlf nchar(2) = nchar(13)+nchar(10);\n\n--declare @delta_minutes int;\ndeclare @program_name nvarchar(500);\ndeclare @login_name nvarchar(255);\ndeclare @database nvarchar(500) = '$database';\ndeclare @session_id int;\ndeclare @session_host_name nvarchar(125);\ndeclare @query_pattern nvarchar(500);\ndeclare @duration int;\ndeclare @memory_grant_threshold_mb int = $memory_grant_threshold_mb;\n\nset @database = case when ltrim(rtrim(@database)) = '__All__' then null else @database end;\nset @duration = case when ltrim(rtrim('$duration')) <> '' then $duration else 0 end;\nif len(ltrim(rtrim('$program_name'))) > 0\n set @program_name = '$program_name'\nif len(ltrim(rtrim('$login_name'))) > 0\n set @login_name = '$login_name'\nif len(ltrim(rtrim('$session_host_name'))) > 0\n set @session_host_name = '$session_host_name'\nif len(ltrim(rtrim('$query_pattern'))) > 0\n set @query_pattern = '$query_pattern'\nif len(ltrim(rtrim('$session_id'))) > 0 and (case when '$session_id' like '%[^0-9.]%' then 'invalid' when '$session_id' like '%.%.%' then 'invalid' else 'valid' end) = 'valid'\n set @session_id = convert(int,'$session_id');\n\nset @sql_instance = '$server';\n--set @perfmon_host_name = '$perfmon_host_name';\nset @start_time_utc = $__timeFrom();\n--set @start_time_utc = dateadd(second,$sqlserver_start_time_utc/1000,'1970-01-01 00:00:00');\nset @end_time_utc = $__timeTo();\n--set @end_time_utc = $__timeFrom();\n--set @delta_minutes = $cpu_delta_minutes;\nset @params = N'@perfmon_host_name varchar(255), @start_time_utc datetime2, @end_time_utc datetime2,\n\t\t\t\t@program_name nvarchar(500), @login_name nvarchar(255), @database nvarchar(500),\n\t\t\t\t@session_id int, @session_host_name nvarchar(125), @query_pattern nvarchar(500),\n\t\t\t\t@duration int, @memory_grant_threshold_mb int';\n\nset quoted_identifier off;\nset @sql = \"/* SQLMonitor Dashboard $__dashboard: LongRunningQueries */\nset nocount on;\t\t\t\nif exists ( select * from $whoisactive_table_name w with (nolock)\n where w.collection_time = (select max(i.collection_time) from $whoisactive_table_name i with (nolock)) \n and granted_memory >= (@memory_grant_threshold_mb*1024/8) )\nbegin\n ;with t_WhoIsActive as (\n select [collection_time] = convert(varchar,w.collection_time,120), w.session_id, \n w.program_name, w.login_name, w.database_name, w.host_name,\n w.status, w.CPU, w.used_memory, w.open_tran_count, [duration_ms] = datediff(MILLISECOND, start_time, w.collection_time),\n w.wait_info, granted_memory, tempdb_current,\n sql_command = case when w.sql_command is not null then left(replace(replace(convert(nvarchar(max),w.sql_command),char(13)+char(10),''),'= (@memory_grant_threshold_mb*1024/8)\n )\n select [collection_time] = DATEADD(mi, DATEDIFF(mi, getdate(), getutcdate()), [collection_time]), w.session_id,\n [ddd hh:mm:ss.mss] = right('0000'+convert(varchar, duration_ms/86400000),3)+ ' '+convert(varchar,dateadd(MILLISECOND,duration_ms,'1900-01-01 00:00:00'),114), \n w.program_name, w.login_name, w.database_name, w.host_name, w.status, w.CPU, \n granted_memory_kb = (w.granted_memory * 8.0), w.open_tran_count, w.wait_info, w.sql_command, w.blocked_session_count, \n w.blocking_session_id, [reads_kb] = (w.[reads]*8.0), w.writes, [tempdb_allocations_kb] = (w.tempdb_allocations*8.0), \n tempdb_current_kb = (tempdb_current*8.0), w.tasks, w.percent_complete, [used_memory_kb] = (w.used_memory*8.0),\n start_time = DATEADD(mi, DATEDIFF(mi, getdate(), getutcdate()), [start_time])\n from t_WhoIsActive w\n order by granted_memory desc, used_memory desc, collection_time\nend\nELSE\n select 'No long running query found for time window' as [No Result]\n\"\nset quoted_identifier on;\n--print @sql\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nif ($is_local = 1)\n exec dbo.sp_executesql @sql, @params, @perfmon_host_name, @start_time_utc, @end_time_utc, \n\t\t\t\t\t@program_name, @login_name, @database, @session_id, @session_host_name, \n\t\t\t\t\t@query_pattern, @duration, @memory_grant_threshold_mb;\nelse\n exec [$server].[$dba_db].dbo.sp_executesql @sql, @params, @perfmon_host_name, @start_time_utc, @end_time_utc,\n\t\t\t\t\t@program_name, @login_name, @database, @session_id, @session_host_name, \n\t\t\t\t\t@query_pattern, @duration, @memory_grant_threshold_mb;", + "refId": "A", + "sql": { + "columns": [ + { + "parameters": [], + "type": "function" + } + ], + "groupBy": [ + { + "property": { + "type": "string" + }, + "type": "groupBy" + } + ], + "limit": 50 + } + } + ], + "title": "Memory Consumers Over __ $memory_grant_threshold_mb MB__ \"- WhoIsActive Data @ ${whoisactive_collection_time_utc:date:YYYY-MM-DD HH.mm}", + "type": "table" + } + ], + "title": "M/r Consumers - ACTIVE - [sp_WhoIsActive] @ ${whoisactive_collection_time_utc:date:YYYY-MM-DD HH.mm}", + "type": "row" + }, + { + "collapsed": true, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 25 + }, + "id": 188, + "panels": [ + { + "datasource": { + "type": "mssql", + "uid": "${sqlmonitor_datasource}" + }, + "description": "select [collection_time], [data_size_mb], [data_used_mb], [data_used_pct], [log_size_mb], [log_used_mb], [log_used_pct], [version_store_mb], [version_store_pct]\nfrom dbo.tempdb_space_usage tsu\nwhere 1=1\nand tsu.collection_time = (select top 1 i.collection_time from dbo.tempdb_space_usage i order by i.collection_time desc)", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "custom": { + "align": "center", + "cellOptions": { + "type": "auto" + }, + "filterable": false, + "inspect": true + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "collection_time_utc" + }, + "properties": [ + { + "id": "displayName", + "value": "Collection Time" + }, + { + "id": "custom.cellOptions", + "value": { + "type": "color-background" + } + }, + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "super-light-purple", + "value": null + } + ] + } + } + ] + }, + { + "matcher": { + "id": "byName", "options": "data_size_mb" }, "properties": [ @@ -4497,7 +5150,8 @@ "mode": "absolute", "steps": [ { - "color": "green" + "color": "green", + "value": null }, { "color": "#EAB839", @@ -4608,7 +5262,8 @@ "mode": "absolute", "steps": [ { - "color": "green" + "color": "green", + "value": null }, { "color": "#EAB839", @@ -4679,7 +5334,8 @@ "mode": "absolute", "steps": [ { - "color": "green" + "color": "green", + "value": null }, { "color": "#EAB839", @@ -4714,7 +5370,7 @@ "h": 4, "w": 24, "x": 0, - "y": 255 + "y": 68 }, "id": 189, "options": { @@ -4789,7 +5445,8 @@ "mode": "absolute", "steps": [ { - "color": "green" + "color": "green", + "value": null }, { "color": "red", @@ -4821,7 +5478,8 @@ "mode": "absolute", "steps": [ { - "color": "super-light-purple" + "color": "super-light-purple", + "value": null } ] } @@ -4906,7 +5564,8 @@ "mode": "absolute", "steps": [ { - "color": "green" + "color": "green", + "value": null }, { "color": "#EAB839", @@ -5017,7 +5676,8 @@ "mode": "absolute", "steps": [ { - "color": "green" + "color": "green", + "value": null }, { "color": "#EAB839", @@ -5088,7 +5748,8 @@ "mode": "absolute", "steps": [ { - "color": "green" + "color": "green", + "value": null }, { "color": "#EAB839", @@ -5123,7 +5784,7 @@ "h": 4, "w": 24, "x": 0, - "y": 391 + "y": 72 }, "id": 190, "options": { @@ -5184,7 +5845,7 @@ "h": 1, "w": 24, "x": 0, - "y": 24 + "y": 26 }, "id": 191, "panels": [ @@ -5212,7 +5873,8 @@ "mode": "absolute", "steps": [ { - "color": "green" + "color": "green", + "value": null }, { "color": "red", @@ -5244,7 +5906,8 @@ "mode": "absolute", "steps": [ { - "color": "super-light-purple" + "color": "super-light-purple", + "value": null } ] } @@ -5329,7 +5992,8 @@ "mode": "absolute", "steps": [ { - "color": "green" + "color": "green", + "value": null }, { "color": "#EAB839", @@ -5384,7 +6048,8 @@ "mode": "absolute", "steps": [ { - "color": "blue" + "color": "blue", + "value": null } ] } @@ -5593,7 +6258,7 @@ "h": 11, "w": 24, "x": 0, - "y": 441 + "y": 77 }, "id": 192, "options": { @@ -5609,7 +6274,7 @@ }, "showHeader": true }, - "pluginVersion": "10.1.0", + "pluginVersion": "11.3.1", "targets": [ { "dataset": "AdventureWorks2019", @@ -5654,7 +6319,7 @@ "h": 1, "w": 24, "x": 0, - "y": 25 + "y": 27 }, "id": 140, "panels": [ @@ -5763,7 +6428,7 @@ "h": 8, "w": 24, "x": 0, - "y": 257 + "y": 988 }, "id": 138, "options": { @@ -5829,7 +6494,7 @@ "h": 1, "w": 24, "x": 0, - "y": 26 + "y": 28 }, "id": 117, "panels": [ @@ -6012,7 +6677,7 @@ "h": 7, "w": 24, "x": 0, - "y": 258 + "y": 989 }, "id": 115, "options": { @@ -6074,7 +6739,7 @@ "h": 1, "w": 24, "x": 0, - "y": 27 + "y": 29 }, "id": 29, "panels": [ @@ -6119,142 +6784,7 @@ "mode": "none" }, "thresholdsStyle": { - "mode": "line+area" - } - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "red" - }, - { - "color": "transparent", - "value": 600 - } - ] - }, - "unit": "s" - }, - "overrides": [] - }, - "gridPos": { - "h": 10, - "w": 24, - "x": 0, - "y": 259 - }, - "id": 8, - "options": { - "legend": { - "calcs": [ - "lastNotNull", - "min" - ], - "displayMode": "table", - "placement": "bottom", - "showLegend": true - }, - "tooltip": { - "mode": "multi", - "sort": "desc" - } - }, - "pluginVersion": "11.3.1", - "targets": [ - { - "alias": "", - "datasource": { - "type": "mssql", - "uid": "${DS_SQLMONITOR}" - }, - "editorMode": "code", - "format": "time_series", - "rawQuery": true, - "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\ndeclare @start_time_utc datetime2;\ndeclare @end_time_utc datetime2;\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @start_time_utc = $__timeFrom();\nset @end_time_utc = $__timeTo();\nset @params = N'@perfmon_host_name varchar(255), @start_time_utc datetime2, @end_time_utc datetime2';\n\nset quoted_identifier off;\nset @sql = \"\nset nocount on;\ndeclare @object_name varchar(255);\nset @object_name = (case when '$perfmon_service_name' = 'MSSQLSERVER' \n\t\t\t\t\t\t then 'sqlserver' else LOWER('$perfmon_service_name') end);\n\nselect pc.collection_time_utc as time\n\t,counter as metric\n\t--,object, counter, instance\n\t,pc.value\nfrom $perfmon_table_name pc with (nolock)\nwhere collection_time_utc between @start_time_utc and @end_time_utc \nand host_name = @perfmon_host_name and pc.object = (@object_name+':buffer manager')\nand pc.counter = 'page life expectancy'\norder by time\n\"\nset quoted_identifier on;\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nif ($is_local = 1)\n exec dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;\nelse\n exec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;", - "refId": "A", - "sql": { - "columns": [ - { - "parameters": [], - "type": "function" - } - ], - "groupBy": [ - { - "property": { - "type": "string" - }, - "type": "groupBy" - } - ], - "limit": 50 - } - } - ], - "title": "Page Life Expectancy", - "type": "timeseries" - } - ], - "repeat": "datasource", - "title": "Trend - Page Life Expectancy", - "type": "row" - }, - { - "collapsed": true, - "gridPos": { - "h": 1, - "w": 24, - "x": 0, - "y": 28 - }, - "id": 27, - "panels": [ - { - "datasource": { - "type": "mssql", - "uid": "${sqlmonitor_datasource}" - }, - "description": "https://sqlperformance.com/2014/10/sql-performance/knee-jerk-page-life-expectancy", - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisBorderShow": false, - "axisCenteredZero": false, - "axisColorMode": "text", - "axisGridShow": true, - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "barWidthFactor": 0.6, - "drawStyle": "line", - "fillOpacity": 10, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "insertNulls": false, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "log": 10, - "type": "log" - }, - "showPoints": "never", - "spanNulls": true, - "stacking": { - "group": "A", - "mode": "none" - }, - "thresholdsStyle": { - "mode": "off" + "mode": "line+area" } }, "mappings": [], @@ -6262,31 +6792,30 @@ "mode": "absolute", "steps": [ { - "color": "green" + "color": "red" }, { - "color": "red", - "value": 80 + "color": "transparent", + "value": 600 } ] }, - "unit": "short" + "unit": "s" }, "overrides": [] }, "gridPos": { - "h": 7, + "h": 10, "w": 24, "x": 0, - "y": 260 + "y": 990 }, - "id": 18, + "id": 8, "options": { "legend": { "calcs": [ "lastNotNull", - "max", - "p99" + "min" ], "displayMode": "table", "placement": "bottom", @@ -6308,7 +6837,7 @@ "editorMode": "code", "format": "time_series", "rawQuery": true, - "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\ndeclare @start_time_utc datetime2;\ndeclare @end_time_utc datetime2;\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @start_time_utc = $__timeFrom();\nset @end_time_utc = $__timeTo();\nset @params = N'@perfmon_host_name varchar(255), @start_time_utc datetime2, @end_time_utc datetime2';\n\nset quoted_identifier off;\nset @sql = \"\nset nocount on;\ndeclare @object_name varchar(255);\nset @object_name = (case when '$perfmon_service_name' = 'MSSQLSERVER' then 'sqlserver' else LOWER('$perfmon_service_name') end);\nselect pc.collection_time_utc as time, \n\tcounter as metric\n\t--,instance,\n\t,pc.value\nfrom $perfmon_table_name pc with (nolock)\nwhere collection_time_utc between @start_time_utc and @end_time_utc \nand host_name = @perfmon_host_name and pc.object = (@object_name+':sql statistics') \nand pc.counter = 'batch requests/sec'\nand pc.value <> 0.0\norder by time\n\"\nset quoted_identifier on;\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nif ($is_local = 1)\n exec dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;\nelse\n exec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;", + "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\ndeclare @start_time_utc datetime2;\ndeclare @end_time_utc datetime2;\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @start_time_utc = $__timeFrom();\nset @end_time_utc = $__timeTo();\nset @params = N'@perfmon_host_name varchar(255), @start_time_utc datetime2, @end_time_utc datetime2';\n\nset quoted_identifier off;\nset @sql = \"\nset nocount on;\ndeclare @object_name varchar(255);\nset @object_name = (case when '$perfmon_service_name' = 'MSSQLSERVER' \n\t\t\t\t\t\t then 'sqlserver' else LOWER('$perfmon_service_name') end);\n\nselect pc.collection_time_utc as time\n\t,counter as metric\n\t--,object, counter, instance\n\t,pc.value\nfrom $perfmon_table_name pc with (nolock)\nwhere collection_time_utc between @start_time_utc and @end_time_utc \nand host_name = @perfmon_host_name and pc.object = (@object_name+':buffer manager')\nand pc.counter = 'page life expectancy'\norder by time\n\"\nset quoted_identifier on;\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nif ($is_local = 1)\n exec dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;\nelse\n exec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;", "refId": "A", "sql": { "columns": [ @@ -6329,12 +6858,12 @@ } } ], - "title": "Batch Requests Per Second", + "title": "Page Life Expectancy", "type": "timeseries" } ], "repeat": "datasource", - "title": "Trend - Batch Request/Sec", + "title": "Trend - Page Life Expectancy", "type": "row" }, { @@ -6343,255 +6872,95 @@ "h": 1, "w": 24, "x": 0, - "y": 29 + "y": 30 }, - "id": 126, + "id": 27, "panels": [ { "datasource": { "type": "mssql", "uid": "${sqlmonitor_datasource}" }, - "description": "select * from sys.dm_exec_requests r where blocking_session_id <> 0", - "fieldConfig": { - "defaults": { - "color": { - "mode": "thresholds" - }, - "custom": { - "align": "auto", - "cellOptions": { - "type": "auto" - }, - "inspect": false - }, - "mappings": [], - "max": 100, - "min": 0, - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green" - }, - { - "color": "dark-orange", - "value": 500 - }, - { - "color": "dark-red", - "value": 700 - } - ] - }, - "unit": "none" - }, - "overrides": [] - }, - "gridPos": { - "h": 7, - "w": 24, - "x": 0, - "y": 261 - }, - "id": 124, - "options": { - "cellHeight": "sm", - "footer": { - "countRows": false, - "fields": "", - "reducer": [ - "sum" - ], - "show": false - }, - "showHeader": true - }, - "pluginVersion": "11.3.1", - "targets": [ - { - "alias": "", - "datasource": { - "type": "mssql", - "uid": "${DS_SQLMONITOR}" - }, - "format": "table", - "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\ndeclare @start_time_utc datetime2;\ndeclare @end_time_utc datetime2;\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @start_time_utc = $__timeFrom();\nset @end_time_utc = $__timeTo();\nset @params = N'@perfmon_host_name varchar(255), @start_time_utc datetime2, @end_time_utc datetime2';\n\nset quoted_identifier off;\nset @sql = \"\nset nocount on;\nselect host_name, login_name, status, client_net_address, client_interface_name, count(*) as counts\nfrom sys.dm_exec_connections as dec with (nolock) \njoin sys.dm_exec_sessions as des on des.session_id = dec.session_id\ngroup by host_name, login_name, status, client_net_address, client_interface_name\norder by counts desc, login_name\n\"\nset quoted_identifier on;\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nif ($is_local = 1)\n exec dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;\nelse\n exec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;", - "refId": "A" - } - ], - "title": "Connections", - "type": "table" - }, - { - "datasource": { - "type": "mssql", - "uid": "${sqlmonitor_datasource}" - }, - "description": "select * from sys.dm_exec_connections", + "description": "https://sqlperformance.com/2014/10/sql-performance/knee-jerk-page-life-expectancy", "fieldConfig": { "defaults": { "color": { - "mode": "thresholds" + "mode": "palette-classic" }, "custom": { - "align": "auto", - "cellOptions": { - "type": "auto" - }, - "filterable": true, - "inspect": false - }, - "mappings": [], - "min": 0, - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green" - } - ] - }, - "unit": "none" - }, - "overrides": [ - { - "matcher": { - "id": "byType", - "options": "string" + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisGridShow": true, + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 10, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false }, - "properties": [ - { - "id": "custom.width" - } - ] - }, - { - "matcher": { - "id": "byType", - "options": "number" + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "log": 10, + "type": "log" }, - "properties": [ - { - "id": "custom.width", - "value": 100 - } - ] - } - ] - }, - "gridPos": { - "h": 6, - "w": 8, - "x": 0, - "y": 309 - }, - "id": 131, - "options": { - "cellHeight": "sm", - "footer": { - "countRows": false, - "fields": "", - "reducer": [ - "sum" - ], - "show": false - }, - "showHeader": true, - "sortBy": [] - }, - "pluginVersion": "11.3.1", - "targets": [ - { - "alias": "", - "datasource": { - "type": "mssql", - "uid": "${DS_SQLMONITOR}" - }, - "format": "table", - "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\ndeclare @start_time_utc datetime2;\ndeclare @end_time_utc datetime2;\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @start_time_utc = $__timeFrom();\nset @end_time_utc = $__timeTo();\nset @params = N'@perfmon_host_name varchar(255), @start_time_utc datetime2, @end_time_utc datetime2';\n\nset quoted_identifier off;\nset @sql = \"\nset nocount on;\nselect client_interface_name, count(*) as counts\nfrom sys.dm_exec_connections as dec with (nolock) \njoin sys.dm_exec_sessions as des with (nolock) on des.session_id = dec.session_id\nwhere len(ltrim(rtrim(client_interface_name))) > 0\ngroup by client_interface_name\norder by counts desc, client_interface_name\n\"\nset quoted_identifier on;\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nif ($is_local = 1)\n exec dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;\nelse\n exec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;", - "refId": "A" - } - ], - "title": "Connections by Interface", - "type": "table" - }, - { - "datasource": { - "type": "mssql", - "uid": "${sqlmonitor_datasource}" - }, - "description": "select * from sys.dm_exec_connections", - "fieldConfig": { - "defaults": { - "color": { - "mode": "thresholds" - }, - "custom": { - "align": "auto", - "cellOptions": { - "type": "auto" + "showPoints": "never", + "spanNulls": true, + "stacking": { + "group": "A", + "mode": "none" }, - "filterable": true, - "inspect": false + "thresholdsStyle": { + "mode": "off" + } }, "mappings": [], - "min": 0, "thresholds": { "mode": "absolute", "steps": [ { - "color": "green" - } - ] - }, - "unit": "none" - }, - "overrides": [ - { - "matcher": { - "id": "byType", - "options": "string" - }, - "properties": [ - { - "id": "custom.width" - } - ] - }, - { - "matcher": { - "id": "byType", - "options": "number" - }, - "properties": [ + "color": "green" + }, { - "id": "custom.width", - "value": 100 + "color": "red", + "value": 80 } ] - } - ] + }, + "unit": "short" + }, + "overrides": [] }, "gridPos": { - "h": 12, - "w": 8, - "x": 8, - "y": 309 + "h": 7, + "w": 24, + "x": 0, + "y": 991 }, - "id": 128, + "id": 18, "options": { - "cellHeight": "sm", - "footer": { - "countRows": false, - "fields": "", - "reducer": [ - "sum" + "legend": { + "calcs": [ + "lastNotNull", + "max", + "p99" ], - "show": false + "displayMode": "table", + "placement": "bottom", + "showLegend": true }, - "showHeader": true, - "sortBy": [] + "tooltip": { + "mode": "multi", + "sort": "desc" + } }, "pluginVersion": "11.3.1", "targets": [ @@ -6601,20 +6970,54 @@ "type": "mssql", "uid": "${DS_SQLMONITOR}" }, - "format": "table", - "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\ndeclare @start_time_utc datetime2;\ndeclare @end_time_utc datetime2;\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @start_time_utc = $__timeFrom();\nset @end_time_utc = $__timeTo();\nset @params = N'@perfmon_host_name varchar(255), @start_time_utc datetime2, @end_time_utc datetime2';\n\nset quoted_identifier off;\nset @sql = \"\nset nocount on;\nselect host_name, count(*) as counts\nfrom sys.dm_exec_connections as dec with (nolock) \njoin sys.dm_exec_sessions as des with (nolock) on des.session_id = dec.session_id\ngroup by host_name\norder by counts desc, host_name\n\"\nset quoted_identifier on;\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nif ($is_local = 1)\n exec dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;\nelse\n exec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;", - "refId": "A" + "editorMode": "code", + "format": "time_series", + "rawQuery": true, + "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\ndeclare @start_time_utc datetime2;\ndeclare @end_time_utc datetime2;\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @start_time_utc = $__timeFrom();\nset @end_time_utc = $__timeTo();\nset @params = N'@perfmon_host_name varchar(255), @start_time_utc datetime2, @end_time_utc datetime2';\n\nset quoted_identifier off;\nset @sql = \"\nset nocount on;\ndeclare @object_name varchar(255);\nset @object_name = (case when '$perfmon_service_name' = 'MSSQLSERVER' then 'sqlserver' else LOWER('$perfmon_service_name') end);\nselect pc.collection_time_utc as time, \n\tcounter as metric\n\t--,instance,\n\t,pc.value\nfrom $perfmon_table_name pc with (nolock)\nwhere collection_time_utc between @start_time_utc and @end_time_utc \nand host_name = @perfmon_host_name and pc.object = (@object_name+':sql statistics') \nand pc.counter = 'batch requests/sec'\nand pc.value <> 0.0\norder by time\n\"\nset quoted_identifier on;\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nif ($is_local = 1)\n exec dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;\nelse\n exec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;", + "refId": "A", + "sql": { + "columns": [ + { + "parameters": [], + "type": "function" + } + ], + "groupBy": [ + { + "property": { + "type": "string" + }, + "type": "groupBy" + } + ], + "limit": 50 + } } ], - "title": "Host Connections", - "type": "table" - }, + "title": "Batch Requests Per Second", + "type": "timeseries" + } + ], + "repeat": "datasource", + "title": "Trend - Batch Request/Sec", + "type": "row" + }, + { + "collapsed": true, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 31 + }, + "id": 126, + "panels": [ { "datasource": { "type": "mssql", "uid": "${sqlmonitor_datasource}" }, - "description": "select * from sys.dm_exec_connections", + "description": "select * from sys.dm_exec_requests r where blocking_session_id <> 0", "fieldConfig": { "defaults": { "color": { @@ -6625,54 +7028,38 @@ "cellOptions": { "type": "auto" }, - "filterable": true, "inspect": false }, "mappings": [], + "max": 100, "min": 0, "thresholds": { "mode": "absolute", "steps": [ { "color": "green" + }, + { + "color": "dark-orange", + "value": 500 + }, + { + "color": "dark-red", + "value": 700 } ] }, "unit": "none" }, - "overrides": [ - { - "matcher": { - "id": "byName", - "options": "login_name" - }, - "properties": [ - { - "id": "custom.width" - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "counts" - }, - "properties": [ - { - "id": "custom.width", - "value": 100 - } - ] - } - ] + "overrides": [] }, "gridPos": { - "h": 12, - "w": 8, - "x": 16, - "y": 309 + "h": 7, + "w": 24, + "x": 0, + "y": 992 }, - "id": 129, + "id": 124, "options": { "cellHeight": "sm", "footer": { @@ -6683,8 +7070,7 @@ ], "show": false }, - "showHeader": true, - "sortBy": [] + "showHeader": true }, "pluginVersion": "11.3.1", "targets": [ @@ -6695,11 +7081,11 @@ "uid": "${DS_SQLMONITOR}" }, "format": "table", - "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\ndeclare @start_time_utc datetime2;\ndeclare @end_time_utc datetime2;\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @start_time_utc = $__timeFrom();\nset @end_time_utc = $__timeTo();\nset @params = N'@perfmon_host_name varchar(255), @start_time_utc datetime2, @end_time_utc datetime2';\n\nset quoted_identifier off;\nset @sql = \"\nset nocount on;\nselect login_name, count(*) as counts\nfrom sys.dm_exec_connections as dec with (nolock) \njoin sys.dm_exec_sessions as des with (nolock) on des.session_id = dec.session_id\ngroup by login_name\norder by counts desc, login_name\n\"\nset quoted_identifier on;\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nif ($is_local = 1)\n exec dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;\nelse\n exec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;", + "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\ndeclare @start_time_utc datetime2;\ndeclare @end_time_utc datetime2;\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @start_time_utc = $__timeFrom();\nset @end_time_utc = $__timeTo();\nset @params = N'@perfmon_host_name varchar(255), @start_time_utc datetime2, @end_time_utc datetime2';\n\nset quoted_identifier off;\nset @sql = \"\nset nocount on;\nselect host_name, login_name, status, client_net_address, client_interface_name, count(*) as counts\nfrom sys.dm_exec_connections as dec with (nolock) \njoin sys.dm_exec_sessions as des on des.session_id = dec.session_id\ngroup by host_name, login_name, status, client_net_address, client_interface_name\norder by counts desc, login_name\n\"\nset quoted_identifier on;\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nif ($is_local = 1)\n exec dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;\nelse\n exec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;", "refId": "A" } ], - "title": "Login Connections", + "title": "Connections", "type": "table" }, { @@ -6736,162 +7122,48 @@ "overrides": [ { "matcher": { - "id": "byName", - "options": "counts" + "id": "byType", + "options": "string" }, "properties": [ { - "id": "custom.width", - "value": 100 - } - ] - } - ] - }, - "gridPos": { - "h": 6, - "w": 8, - "x": 0, - "y": 315 - }, - "id": 130, - "options": { - "cellHeight": "sm", - "footer": { - "countRows": false, - "fields": "", - "reducer": [ - "sum" - ], - "show": false - }, - "showHeader": true, - "sortBy": [] - }, - "pluginVersion": "11.3.1", - "targets": [ - { - "alias": "", - "datasource": { - "type": "mssql", - "uid": "${DS_SQLMONITOR}" - }, - "format": "table", - "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\ndeclare @start_time_utc datetime2;\ndeclare @end_time_utc datetime2;\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @start_time_utc = $__timeFrom();\nset @end_time_utc = $__timeTo();\nset @params = N'@perfmon_host_name varchar(255), @start_time_utc datetime2, @end_time_utc datetime2';\n\nset quoted_identifier off;\nset @sql = \"\nset nocount on;\nselect status, count(*) as counts\nfrom sys.dm_exec_connections as dec with (nolock) \njoin sys.dm_exec_sessions as des with (nolock) on des.session_id = dec.session_id\ngroup by status\norder by counts desc, status\n\"\nset quoted_identifier on;\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nif ($is_local = 1)\n exec dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;\nelse\n exec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;", - "refId": "A" - } - ], - "title": "Connections By Status", - "type": "table" - } - ], - "repeat": "datasource", - "title": "SQL Connections - Distribution", - "type": "row" - }, - { - "collapsed": true, - "gridPos": { - "h": 1, - "w": 24, - "x": 0, - "y": 30 - }, - "id": 79, - "panels": [ - { - "datasource": { - "type": "mssql", - "uid": "${sqlmonitor_datasource}" - }, - "description": "select * from [$inventory_db].$os_task_list_table_name", - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisBorderShow": false, - "axisCenteredZero": false, - "axisColorMode": "text", - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "barWidthFactor": 0.6, - "drawStyle": "bars", - "fillOpacity": 100, - "gradientMode": "hue", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "insertNulls": false, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 1, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "auto", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "normal" - }, - "thresholdsStyle": { - "mode": "off" - } - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green" + "id": "custom.width" } ] }, - "unit": "s" - }, - "overrides": [ { "matcher": { - "id": "byFrameRefID", - "options": "A" + "id": "byType", + "options": "number" }, "properties": [ { - "id": "unit", - "value": "s" + "id": "custom.width", + "value": 100 } ] } ] }, "gridPos": { - "h": 11, - "w": 24, + "h": 6, + "w": 8, "x": 0, - "y": 40 + "y": 1040 }, - "id": 144, + "id": 131, "options": { - "legend": { - "calcs": [ - "last", - "mean" + "cellHeight": "sm", + "footer": { + "countRows": false, + "fields": "", + "reducer": [ + "sum" ], - "displayMode": "table", - "placement": "right", - "showLegend": true, - "sortBy": "Mean", - "sortDesc": false + "show": false }, - "tooltip": { - "mode": "multi", - "sort": "none" - } + "showHeader": true, + "sortBy": [] }, "pluginVersion": "11.3.1", "targets": [ @@ -6901,81 +7173,35 @@ "type": "mssql", "uid": "${DS_SQLMONITOR}" }, - "editorMode": "code", - "format": "time_series", - "rawQuery": true, - "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\ndeclare @start_time_utc datetime2;\ndeclare @end_time_utc datetime2;\ndeclare @delta_minutes int;\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @start_time_utc = $__timeFrom();\nset @end_time_utc = $__timeTo();\nset @delta_minutes = $cpu_delta_minutes;\nset @params = N'@perfmon_host_name varchar(255), @start_time_utc datetime2, @end_time_utc datetime2, @delta_minutes int';\n\nset quoted_identifier off;\nset @sql = \"\nset nocount on;\ndeclare @TopRowFilter tinyint = 100;\n\nif object_id('tempdb..#dates') is not null\n\tdrop table #dates;\ncreate table #dates (collection_time_utc datetime2 not null primary key);\ndeclare @_collection_time_utc datetime2;\ndeclare @_collection_time_utc_prev datetime2;\n\ndeclare cur_dates cursor local fast_forward for\n\tselect collection_time_utc\n\tfrom $os_task_list_table_name\n\twhere host_name = @perfmon_host_name\n\tand collection_time_utc between @start_time_utc and @end_time_utc\n\tgroup by collection_time_utc\n\torder by collection_time_utc\n\toption(recompile);\n\nopen cur_dates;\nfetch next from cur_dates into @_collection_time_utc;\n\nwhile @@fetch_status = 0\nbegin\n\t-- Set start timestamp\n\tif(@_collection_time_utc_prev is null)\n\tbegin\n\t\tinsert #dates values (@_collection_time_utc);\n\t\tset @_collection_time_utc_prev = @_collection_time_utc;\n\tend\n\t\n\t-- Choose next timestamp based on @delta_minutes\n\tif (@_collection_time_utc_prev is not null)\n\t\tand (@_collection_time_utc >= dateadd(minute,@delta_minutes,@_collection_time_utc_prev))\n\tbegin\n\t\tinsert #dates values (@_collection_time_utc);\n\t\tset @_collection_time_utc_prev = @_collection_time_utc;\n\tend\n\t\n\tfetch next from cur_dates into @_collection_time_utc;\nend\n\nclose cur_dates;\ndeallocate cur_dates;\n\n--select *\n--from #dates;\n\nif object_id('tempdb..#os_task_list') is not null\n\tdrop table #os_task_list;\nwith cte_tasks as (\n\tselect tl.collection_time_utc, tl.task_name, [cpu_s] = sum(cpu_time_seconds), [counts] = count(*)\n\tfrom $os_task_list_table_name tl join #dates d on d.collection_time_utc = tl.collection_time_utc\n\twhere (tl.collection_time_utc between @start_time_utc and @end_time_utc)\n\tand tl.host_name = @perfmon_host_name\n\tand task_name not in ('System Idle Process','') -- add other harmless processes here\n\tgroup by tl.collection_time_utc, tl.task_name\n)\nselect\tcollection_time_utc, task_name, cpu_s, counts\n\t\t,[cpu_s__delta] = isnull(cpu_s - (lag(cpu_s) over (partition by task_name order by collection_time_utc)),0)\n\t\t,[CpuRank] = ROW_NUMBER() OVER(PARTITION BY [collection_time_utc] ORDER BY cpu_s DESC)\ninto #os_task_list\nfrom cte_tasks;\n\n\nselect collection_time_utc as time, task_name as metric, (case when [cpu_s__delta] < 0 then 0 else [cpu_s__delta] end) as value\nfrom #os_task_list\nwhere CpuRank <= @TopRowFilter\nand collection_time_utc > (select min(m.collection_time_utc) from #os_task_list m)\norder by collection_time_utc, CpuRank, cpu_s desc;\n\"\nset quoted_identifier on;\n\nif '$InstanceScopeFeaturesOnly' = 'true'\n\tselect [time], remarks as metric, [value]\n\tfrom (values ('This feature is not available for this SQLInstance',getutcdate(), 0)) dummy(remarks, [time], value)\n\torder by [time]\nelse\nbegin\n\tif ($is_local = 1)\n\t\texec dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc, @delta_minutes;\n\telse\n\t\texec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc, @delta_minutes;\nend", - "refId": "A", - "sql": { - "columns": [ - { - "parameters": [], - "type": "function" - } - ], - "groupBy": [ - { - "property": { - "type": "string" - }, - "type": "groupBy" - } - ], - "limit": 50 - } + "format": "table", + "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\ndeclare @start_time_utc datetime2;\ndeclare @end_time_utc datetime2;\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @start_time_utc = $__timeFrom();\nset @end_time_utc = $__timeTo();\nset @params = N'@perfmon_host_name varchar(255), @start_time_utc datetime2, @end_time_utc datetime2';\n\nset quoted_identifier off;\nset @sql = \"\nset nocount on;\nselect client_interface_name, count(*) as counts\nfrom sys.dm_exec_connections as dec with (nolock) \njoin sys.dm_exec_sessions as des with (nolock) on des.session_id = dec.session_id\nwhere len(ltrim(rtrim(client_interface_name))) > 0\ngroup by client_interface_name\norder by counts desc, client_interface_name\n\"\nset quoted_identifier on;\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nif ($is_local = 1)\n exec dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;\nelse\n exec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;", + "refId": "A" } ], - "title": "[${server}] - OS Process - CPU Time - Histrogram - $cpu_delta_minutes Minute Interval", - "type": "timeseries" + "title": "Connections by Interface", + "type": "table" }, { "datasource": { "type": "mssql", "uid": "${sqlmonitor_datasource}" }, - "description": "select * from [$inventory_db].$os_task_list_table_name", + "description": "select * from sys.dm_exec_connections", "fieldConfig": { "defaults": { "color": { - "mode": "palette-classic" + "mode": "thresholds" }, "custom": { - "axisBorderShow": false, - "axisCenteredZero": false, - "axisColorMode": "text", - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "barWidthFactor": 0.6, - "drawStyle": "line", - "fillOpacity": 0, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "insertNulls": false, - "lineInterpolation": "linear", - "lineStyle": { - "fill": "solid" - }, - "lineWidth": 1, - "pointSize": 3, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "auto", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "normal" + "align": "auto", + "cellOptions": { + "type": "auto" }, - "thresholdsStyle": { - "mode": "off" - } + "filterable": true, + "inspect": false }, "mappings": [], + "min": 0, "thresholds": { "mode": "absolute", "steps": [ @@ -6984,46 +7210,53 @@ } ] }, - "unit": "s" + "unit": "none" }, "overrides": [ { "matcher": { - "id": "byFrameRefID", - "options": "A" + "id": "byType", + "options": "string" }, "properties": [ { - "id": "unit", - "value": "s" + "id": "custom.width" + } + ] + }, + { + "matcher": { + "id": "byType", + "options": "number" + }, + "properties": [ + { + "id": "custom.width", + "value": 100 } ] } ] }, "gridPos": { - "h": 10, - "w": 24, - "x": 0, - "y": 118 + "h": 12, + "w": 8, + "x": 8, + "y": 1040 }, - "id": 145, + "id": 128, "options": { - "legend": { - "calcs": [ - "last", - "mean" + "cellHeight": "sm", + "footer": { + "countRows": false, + "fields": "", + "reducer": [ + "sum" ], - "displayMode": "table", - "placement": "right", - "showLegend": true, - "sortBy": "Mean", - "sortDesc": true + "show": false }, - "tooltip": { - "mode": "multi", - "sort": "none" - } + "showHeader": true, + "sortBy": [] }, "pluginVersion": "11.3.1", "targets": [ @@ -7033,93 +7266,35 @@ "type": "mssql", "uid": "${DS_SQLMONITOR}" }, - "editorMode": "code", - "format": "time_series", - "rawQuery": true, - "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\ndeclare @start_time_utc datetime2;\ndeclare @end_time_utc datetime2;\ndeclare @delta_minutes int;\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @start_time_utc = $__timeFrom();\nset @end_time_utc = $__timeTo();\nset @delta_minutes = $cpu_delta_minutes;\nset @params = N'@perfmon_host_name varchar(255), @start_time_utc datetime2, @end_time_utc datetime2, @delta_minutes int';\n\nset quoted_identifier off;\nset @sql = \"\nset nocount on;\ndeclare @TopRowFilter tinyint = 100;\n\nif object_id('tempdb..#dates') is not null\n\tdrop table #dates;\ncreate table #dates (collection_time_utc datetime2 not null primary key);\ndeclare @_collection_time_utc datetime2;\ndeclare @_collection_time_utc_prev datetime2;\n\ndeclare cur_dates cursor local fast_forward for\n\tselect collection_time_utc\n\tfrom $os_task_list_table_name\n\twhere host_name = @perfmon_host_name\n\tand collection_time_utc between @start_time_utc and @end_time_utc\n\tgroup by collection_time_utc\n\torder by collection_time_utc;\n\nopen cur_dates;\nfetch next from cur_dates into @_collection_time_utc;\n\nwhile @@fetch_status = 0\nbegin\n\t-- Set start timestamp\n\tif(@_collection_time_utc_prev is null)\n\tbegin\n\t\tinsert #dates values (@_collection_time_utc);\n\t\tset @_collection_time_utc_prev = @_collection_time_utc;\n\tend\n\t\n\t-- Choose next timestamp based on @delta_minutes\n\tif (@_collection_time_utc_prev is not null)\n\t\tand (@_collection_time_utc >= dateadd(minute,@delta_minutes,@_collection_time_utc_prev))\n\tbegin\n\t\tinsert #dates values (@_collection_time_utc);\n\t\tset @_collection_time_utc_prev = @_collection_time_utc;\n\tend\n\t\n\tfetch next from cur_dates into @_collection_time_utc;\nend\n\nclose cur_dates;\ndeallocate cur_dates;\n\n--select *\n--from #dates;\n\nif object_id('tempdb..#os_task_list') is not null\n\tdrop table #os_task_list;\nwith cte_tasks as (\n\tselect tl.collection_time_utc, tl.task_name, [cpu_s] = sum(cpu_time_seconds), [counts] = count(*)\n\tfrom $os_task_list_table_name tl join #dates d on d.collection_time_utc = tl.collection_time_utc\n\twhere (tl.collection_time_utc between @start_time_utc and @end_time_utc)\n\tand tl.host_name = @perfmon_host_name\n\tand task_name not in ('System Idle Process','') -- add other harmless processes here\n\tgroup by tl.collection_time_utc, tl.task_name\n)\nselect\tcollection_time_utc, task_name, cpu_s, counts\n\t\t,[cpu_s__delta] = isnull(cpu_s - (lag(cpu_s) over (partition by task_name order by collection_time_utc)),0)\n\t\t,[CpuRank] = ROW_NUMBER() OVER(PARTITION BY [collection_time_utc] ORDER BY cpu_s DESC)\ninto #os_task_list\nfrom cte_tasks;\n\n\nselect collection_time_utc as time, task_name as metric, (case when [cpu_s__delta] < 0 then 0 else [cpu_s__delta] end) as value\nfrom #os_task_list\nwhere CpuRank <= @TopRowFilter\nand collection_time_utc > (select min(m.collection_time_utc) from #os_task_list m)\norder by collection_time_utc, CpuRank, cpu_s desc;\n\"\nset quoted_identifier on;\n\nif '$InstanceScopeFeaturesOnly' = 'true'\n\tselect [time], remarks as metric, [value]\n\tfrom (values ('This feature is not available for this SQLInstance',getutcdate(), 0)) dummy(remarks, [time], value)\n\torder by [time]\nelse\nbegin\n\tif ($is_local = 1)\n\t\texec dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc, @delta_minutes;\n\telse\n\t\texec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc, @delta_minutes;\nend", - "refId": "A", - "sql": { - "columns": [ - { - "parameters": [], - "type": "function" - } - ], - "groupBy": [ - { - "property": { - "type": "string" - }, - "type": "groupBy" - } - ], - "limit": 50 - } + "format": "table", + "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\ndeclare @start_time_utc datetime2;\ndeclare @end_time_utc datetime2;\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @start_time_utc = $__timeFrom();\nset @end_time_utc = $__timeTo();\nset @params = N'@perfmon_host_name varchar(255), @start_time_utc datetime2, @end_time_utc datetime2';\n\nset quoted_identifier off;\nset @sql = \"\nset nocount on;\nselect host_name, count(*) as counts\nfrom sys.dm_exec_connections as dec with (nolock) \njoin sys.dm_exec_sessions as des with (nolock) on des.session_id = dec.session_id\ngroup by host_name\norder by counts desc, host_name\n\"\nset quoted_identifier on;\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nif ($is_local = 1)\n exec dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;\nelse\n exec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;", + "refId": "A" } ], - "title": "[${server}] - OS Process - CPU Time - Utilization - $cpu_delta_minutes Minute Interval", - "type": "timeseries" - } - ], - "repeat": "datasource", - "title": "OS Tasks (Processes) - CPU Utilization", - "type": "row" - }, - { - "collapsed": true, - "gridPos": { - "h": 1, - "w": 24, - "x": 0, - "y": 31 - }, - "id": 82, - "panels": [ + "title": "Host Connections", + "type": "table" + }, { "datasource": { "type": "mssql", "uid": "${sqlmonitor_datasource}" }, - "description": "select * from [$inventory_db].$os_task_list_table_name", + "description": "select * from sys.dm_exec_connections", "fieldConfig": { "defaults": { "color": { - "mode": "palette-classic" + "mode": "thresholds" }, "custom": { - "axisBorderShow": false, - "axisCenteredZero": false, - "axisColorMode": "text", - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "barWidthFactor": 0.6, - "drawStyle": "bars", - "fillOpacity": 100, - "gradientMode": "hue", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "insertNulls": false, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 1, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "auto", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "normal" + "align": "auto", + "cellOptions": { + "type": "auto" }, - "thresholdsStyle": { - "mode": "off" - } + "filterable": true, + "inspect": false }, "mappings": [], + "min": 0, "thresholds": { "mode": "absolute", "steps": [ @@ -7128,46 +7303,53 @@ } ] }, - "unit": "kbytes" + "unit": "none" }, "overrides": [ { "matcher": { - "id": "byFrameRefID", - "options": "A" + "id": "byName", + "options": "login_name" }, "properties": [ { - "id": "unit", - "value": "kbytes" + "id": "custom.width" + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "counts" + }, + "properties": [ + { + "id": "custom.width", + "value": 100 } ] } ] }, "gridPos": { - "h": 10, - "w": 24, - "x": 0, - "y": 41 - }, - "id": 146, - "options": { - "legend": { - "calcs": [ - "mean", - "max" + "h": 12, + "w": 8, + "x": 16, + "y": 1040 + }, + "id": 129, + "options": { + "cellHeight": "sm", + "footer": { + "countRows": false, + "fields": "", + "reducer": [ + "sum" ], - "displayMode": "table", - "placement": "right", - "showLegend": true, - "sortBy": "Mean", - "sortDesc": true + "show": false }, - "tooltip": { - "mode": "multi", - "sort": "none" - } + "showHeader": true, + "sortBy": [] }, "pluginVersion": "11.3.1", "targets": [ @@ -7177,81 +7359,35 @@ "type": "mssql", "uid": "${DS_SQLMONITOR}" }, - "editorMode": "code", - "format": "time_series", - "rawQuery": true, - "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\ndeclare @start_time_utc datetime2;\ndeclare @end_time_utc datetime2;\ndeclare @delta_minutes int;\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @start_time_utc = $__timeFrom();\nset @end_time_utc = $__timeTo();\nset @delta_minutes = $cpu_delta_minutes;\nset @params = N'@perfmon_host_name varchar(255), @start_time_utc datetime2, @end_time_utc datetime2, @delta_minutes int';\n\nset quoted_identifier off;\nset @sql = \"\nset nocount on;\ndeclare @TopRowFilter tinyint = 10;\n\nif object_id('tempdb..#dates') is not null\n\tdrop table #dates;\ncreate table #dates (collection_time_utc datetime2 not null primary key);\ndeclare @_collection_time_utc datetime2;\ndeclare @_collection_time_utc_prev datetime2;\n\ndeclare cur_dates cursor local fast_forward for\n\tselect collection_time_utc\n\tfrom $os_task_list_table_name\n\twhere host_name = @perfmon_host_name\n\tand collection_time_utc between @start_time_utc and @end_time_utc\n\tgroup by collection_time_utc\n\torder by collection_time_utc\n\toption(recompile);\n\nopen cur_dates;\nfetch next from cur_dates into @_collection_time_utc;\n\nwhile @@fetch_status = 0\nbegin\n\t-- Set start timestamp\n\tif(@_collection_time_utc_prev is null)\n\tbegin\n\t\tinsert #dates values (@_collection_time_utc);\n\t\tset @_collection_time_utc_prev = @_collection_time_utc;\n\tend\n\t\n\t-- Choose next timestamp based on @delta_minutes\n\tif (@_collection_time_utc_prev is not null)\n\t\tand (@_collection_time_utc >= dateadd(minute,@delta_minutes,@_collection_time_utc_prev))\n\tbegin\n\t\tinsert #dates values (@_collection_time_utc);\n\t\tset @_collection_time_utc_prev = @_collection_time_utc;\n\tend\n\t\n\tfetch next from cur_dates into @_collection_time_utc;\nend\n\nclose cur_dates;\ndeallocate cur_dates;\n\n--select * from #dates;\n\nif object_id('tempdb..#os_task_list') is not null\n\tdrop table #os_task_list;\nwith cte_tasks as (\n\tselect tl.collection_time_utc, tl.task_name, [memory_kb] = sum([memory_kb]), [counts] = count(*)\n\tfrom $os_task_list_table_name tl join #dates d on d.collection_time_utc = tl.collection_time_utc\n\twhere (tl.collection_time_utc between @start_time_utc and @end_time_utc)\n\tand tl.host_name = @perfmon_host_name\n\tand task_name not in ('System Idle Process','') -- add other harmless processes here\n\tgroup by tl.collection_time_utc, tl.task_name\n)\nselect\tcollection_time_utc, task_name, [memory_kb], counts\n\t\t--,[cpu_s__delta] = isnull(cpu_s - (lag(cpu_s) over (partition by task_name order by collection_time_utc)),0)\n\t\t,[RowRank] = ROW_NUMBER() OVER(PARTITION BY [collection_time_utc] ORDER BY [memory_kb] DESC)\ninto #os_task_list\nfrom cte_tasks;\n\n\nselect collection_time_utc as time, task_name as metric, [memory_kb] as value\nfrom #os_task_list\nwhere [RowRank] <= @TopRowFilter\nand collection_time_utc > (select min(m.collection_time_utc) from #os_task_list m)\norder by [time], [RowRank], [memory_kb] desc;\n\"\nset quoted_identifier on;\n\nif '$InstanceScopeFeaturesOnly' = 'true'\n\tselect [time], remarks as metric, [value]\n\tfrom (values ('This feature is not available for this SQLInstance',getutcdate(), 0)) dummy(remarks, [time], value)\n\torder by [time]\nelse\nbegin\n\tif ($is_local = 1)\n\t\texec dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc, @delta_minutes;\n\telse\n\t\texec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc, @delta_minutes;\nend", - "refId": "A", - "sql": { - "columns": [ - { - "parameters": [], - "type": "function" - } - ], - "groupBy": [ - { - "property": { - "type": "string" - }, - "type": "groupBy" - } - ], - "limit": 50 - } + "format": "table", + "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\ndeclare @start_time_utc datetime2;\ndeclare @end_time_utc datetime2;\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @start_time_utc = $__timeFrom();\nset @end_time_utc = $__timeTo();\nset @params = N'@perfmon_host_name varchar(255), @start_time_utc datetime2, @end_time_utc datetime2';\n\nset quoted_identifier off;\nset @sql = \"\nset nocount on;\nselect login_name, count(*) as counts\nfrom sys.dm_exec_connections as dec with (nolock) \njoin sys.dm_exec_sessions as des with (nolock) on des.session_id = dec.session_id\ngroup by login_name\norder by counts desc, login_name\n\"\nset quoted_identifier on;\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nif ($is_local = 1)\n exec dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;\nelse\n exec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;", + "refId": "A" } ], - "title": "[${server}] - OS Processes - Memory - Histrogram - $cpu_delta_minutes Minute Interval", - "type": "timeseries" + "title": "Login Connections", + "type": "table" }, { "datasource": { "type": "mssql", "uid": "${sqlmonitor_datasource}" }, - "description": "select * from [$inventory_db].$os_task_list_table_name", + "description": "select * from sys.dm_exec_connections", "fieldConfig": { "defaults": { "color": { - "mode": "palette-classic" + "mode": "thresholds" }, "custom": { - "axisBorderShow": false, - "axisCenteredZero": false, - "axisColorMode": "text", - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "barWidthFactor": 0.6, - "drawStyle": "line", - "fillOpacity": 0, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "insertNulls": false, - "lineInterpolation": "linear", - "lineStyle": { - "fill": "solid" - }, - "lineWidth": 1, - "pointSize": 3, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "auto", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "normal" + "align": "auto", + "cellOptions": { + "type": "auto" }, - "thresholdsStyle": { - "mode": "off" - } + "filterable": true, + "inspect": false }, "mappings": [], + "min": 0, "thresholds": { "mode": "absolute", "steps": [ @@ -7260,46 +7396,42 @@ } ] }, - "unit": "kbytes" + "unit": "none" }, "overrides": [ { "matcher": { - "id": "byFrameRefID", - "options": "A" + "id": "byName", + "options": "counts" }, "properties": [ { - "id": "unit", - "value": "kbytes" + "id": "custom.width", + "value": 100 } ] } ] }, "gridPos": { - "h": 10, - "w": 24, + "h": 6, + "w": 8, "x": 0, - "y": 98 + "y": 1046 }, - "id": 147, + "id": 130, "options": { - "legend": { - "calcs": [ - "mean", - "max" + "cellHeight": "sm", + "footer": { + "countRows": false, + "fields": "", + "reducer": [ + "sum" ], - "displayMode": "table", - "placement": "right", - "showLegend": true, - "sortBy": "Mean", - "sortDesc": true + "show": false }, - "tooltip": { - "mode": "multi", - "sort": "none" - } + "showHeader": true, + "sortBy": [] }, "pluginVersion": "11.3.1", "targets": [ @@ -7309,36 +7441,17 @@ "type": "mssql", "uid": "${DS_SQLMONITOR}" }, - "editorMode": "code", - "format": "time_series", - "rawQuery": true, - "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\ndeclare @start_time_utc datetime2;\ndeclare @end_time_utc datetime2;\ndeclare @delta_minutes int;\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @start_time_utc = $__timeFrom();\nset @end_time_utc = $__timeTo();\nset @delta_minutes = $cpu_delta_minutes;\nset @params = N'@perfmon_host_name varchar(255), @start_time_utc datetime2, @end_time_utc datetime2, @delta_minutes int';\n\nset quoted_identifier off;\nset @sql = \"\nset nocount on;\ndeclare @TopRowFilter tinyint = 10;\n\nif object_id('tempdb..#dates') is not null\n\tdrop table #dates;\ncreate table #dates (collection_time_utc datetime2 not null primary key);\ndeclare @_collection_time_utc datetime2;\ndeclare @_collection_time_utc_prev datetime2;\n\ndeclare cur_dates cursor local fast_forward for\n\tselect collection_time_utc\n\tfrom $os_task_list_table_name\n\twhere host_name = @perfmon_host_name\n\tand collection_time_utc between @start_time_utc and @end_time_utc\n\tgroup by collection_time_utc\n\torder by collection_time_utc\n\toption(recompile);\n\nopen cur_dates;\nfetch next from cur_dates into @_collection_time_utc;\n\nwhile @@fetch_status = 0\nbegin\n\t-- Set start timestamp\n\tif(@_collection_time_utc_prev is null)\n\tbegin\n\t\tinsert #dates values (@_collection_time_utc);\n\t\tset @_collection_time_utc_prev = @_collection_time_utc;\n\tend\n\t\n\t-- Choose next timestamp based on @delta_minutes\n\tif (@_collection_time_utc_prev is not null)\n\t\tand (@_collection_time_utc >= dateadd(minute,@delta_minutes,@_collection_time_utc_prev))\n\tbegin\n\t\tinsert #dates values (@_collection_time_utc);\n\t\tset @_collection_time_utc_prev = @_collection_time_utc;\n\tend\n\t\n\tfetch next from cur_dates into @_collection_time_utc;\nend\n\nclose cur_dates;\ndeallocate cur_dates;\n\n--select * from #dates;\n\nif object_id('tempdb..#os_task_list') is not null\n\tdrop table #os_task_list;\nwith cte_tasks as (\n\tselect tl.collection_time_utc, tl.task_name, [memory_kb] = sum([memory_kb]), [counts] = count(*)\n\tfrom $os_task_list_table_name tl join #dates d on d.collection_time_utc = tl.collection_time_utc\n\twhere (tl.collection_time_utc between @start_time_utc and @end_time_utc)\n\tand tl.host_name = @perfmon_host_name\n\tand task_name not in ('System Idle Process','') -- add other harmless processes here\n\tgroup by tl.collection_time_utc, tl.task_name\n)\nselect\tcollection_time_utc, task_name, [memory_kb], counts\n\t\t--,[cpu_s__delta] = isnull(cpu_s - (lag(cpu_s) over (partition by task_name order by collection_time_utc)),0)\n\t\t,[RowRank] = ROW_NUMBER() OVER(PARTITION BY [collection_time_utc] ORDER BY [memory_kb] DESC)\ninto #os_task_list\nfrom cte_tasks;\n\n\nselect collection_time_utc as time, task_name as metric, [memory_kb] as value\nfrom #os_task_list\nwhere [RowRank] <= @TopRowFilter\nand collection_time_utc > (select min(m.collection_time_utc) from #os_task_list m)\norder by [time], [RowRank], [memory_kb] desc;\n\"\nset quoted_identifier on;\n\nif '$InstanceScopeFeaturesOnly' = 'true'\n\tselect [time], remarks as metric, [value]\n\tfrom (values ('This feature is not available for this SQLInstance',getutcdate(), 0)) dummy(remarks, [time], value)\n\torder by [time]\nelse\nbegin\n\tif ($is_local = 1)\n\t\texec dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc, @delta_minutes;\n\telse\n\t\texec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc, @delta_minutes;\nend", - "refId": "A", - "sql": { - "columns": [ - { - "parameters": [], - "type": "function" - } - ], - "groupBy": [ - { - "property": { - "type": "string" - }, - "type": "groupBy" - } - ], - "limit": 50 - } + "format": "table", + "rawSql": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\ndeclare @start_time_utc datetime2;\ndeclare @end_time_utc datetime2;\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @start_time_utc = $__timeFrom();\nset @end_time_utc = $__timeTo();\nset @params = N'@perfmon_host_name varchar(255), @start_time_utc datetime2, @end_time_utc datetime2';\n\nset quoted_identifier off;\nset @sql = \"\nset nocount on;\nselect status, count(*) as counts\nfrom sys.dm_exec_connections as dec with (nolock) \njoin sys.dm_exec_sessions as des with (nolock) on des.session_id = dec.session_id\ngroup by status\norder by counts desc, status\n\"\nset quoted_identifier on;\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nif ($is_local = 1)\n exec dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;\nelse\n exec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name, @start_time_utc, @end_time_utc;", + "refId": "A" } ], - "title": "[${server}] - OS Processes - Memory Utilization - $cpu_delta_minutes Minute Interval", - "type": "timeseries" + "title": "Connections By Status", + "type": "table" } ], - "repeat": "cpu_delta_minutes", - "title": "OS Tasks (Processes) - Memory Utilization", + "repeat": "datasource", + "title": "SQL Connections - Distribution", "type": "row" }, { @@ -7530,7 +7643,7 @@ "h": 8, "w": 24, "x": 0, - "y": 874 + "y": 1681 }, "id": 86, "options": { @@ -8185,7 +8298,7 @@ "h": 16, "w": 24, "x": 0, - "y": 875 + "y": 1682 }, "id": 185, "options": { @@ -8419,7 +8532,7 @@ "h": 16, "w": 24, "x": 0, - "y": 111 + "y": 918 }, "id": 173, "options": { @@ -8525,7 +8638,7 @@ "h": 15, "w": 24, "x": 0, - "y": 112 + "y": 919 }, "id": 133, "options": { @@ -8604,7 +8717,7 @@ "h": 7, "w": 24, "x": 0, - "y": 923 + "y": 1730 }, "id": 119, "options": { @@ -8943,43 +9056,6 @@ "regex": "", "type": "query" }, - { - "hide": 2, - "label": "OS Tasks Table Name", - "name": "os_task_list_table_name", - "query": "${VAR_OS_TASK_LIST_TABLE_NAME}", - "skipUrlSync": true, - "type": "constant", - "current": { - "value": "${VAR_OS_TASK_LIST_TABLE_NAME}", - "text": "${VAR_OS_TASK_LIST_TABLE_NAME}", - "selected": false - }, - "options": [ - { - "value": "${VAR_OS_TASK_LIST_TABLE_NAME}", - "text": "${VAR_OS_TASK_LIST_TABLE_NAME}", - "selected": false - } - ] - }, - { - "current": {}, - "datasource": { - "type": "mssql", - "uid": "${sqlmonitor_datasource}" - }, - "definition": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @params = N'@perfmon_host_name varchar(255)';\n\nset quoted_identifier off;\nset @sql = \"select top 1 collection_time_utc\nfrom $os_task_list_table_name with (nolock)\nwhere host_name = @perfmon_host_name\norder by collection_time_utc desc;\n\"\nset quoted_identifier on;\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nif ($is_local = 1)\n exec dbo.sp_executesql @sql , @params, @perfmon_host_name;\nelse\n exec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name;", - "hide": 2, - "includeAll": false, - "label": "Collection Time UTC", - "name": "os_task_list_collection_time_utc", - "options": [], - "query": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @params = N'@perfmon_host_name varchar(255)';\n\nset quoted_identifier off;\nset @sql = \"select top 1 collection_time_utc\nfrom $os_task_list_table_name with (nolock)\nwhere host_name = @perfmon_host_name\norder by collection_time_utc desc;\n\"\nset quoted_identifier on;\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nif ($is_local = 1)\n exec dbo.sp_executesql @sql , @params, @perfmon_host_name;\nelse\n exec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name;", - "refresh": 2, - "regex": "", - "type": "query" - }, { "hide": 2, "label": "WhoIsActive Table Name", @@ -9004,7 +9080,7 @@ "current": {}, "datasource": { "type": "mssql", - "uid": "${DS_SQLMONITOR}" + "uid": "${sqlmonitor_datasource}" }, "definition": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @params = N'@perfmon_host_name varchar(255)';\n\nset quoted_identifier off;\nset @sql = \"select top 1 DATEADD(mi, DATEDIFF(mi, getdate(), getutcdate()), collection_time )\nfrom $whoisactive_table_name with (nolock)\norder by collection_time desc\n\"\nset quoted_identifier on;\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nif ($is_local = 1)\n exec dbo.sp_executesql @sql , @params, @perfmon_host_name;\nelse\n exec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name;", "hide": 2, @@ -9021,7 +9097,7 @@ "current": {}, "datasource": { "type": "mssql", - "uid": "${sqlmonitor_datasource}" + "uid": "${DS_SQLMONITOR}" }, "definition": "declare @start_time datetime = $__timeFrom()\ndeclare @end_time datetime = $__timeTo();\n\ndeclare @_duration_minute int = datediff(minute,@start_time,@end_time);\nselect [@delta_minutes] = (case when @_duration_minute <= 30 then 1 \n when @_duration_minute <= 60 then 2\n when @_duration_minute <= 120 then 5\n when @_duration_minute <= 480 then 10\n when @_duration_minute <= 1440 then 15\n when @_duration_minute <= 2880 then 20\n when @_duration_minute <= 10080 then 30\n else 60 end);\n", "hide": 2, @@ -9037,7 +9113,7 @@ "current": {}, "datasource": { "type": "mssql", - "uid": "${DS_SQLMONITOR}" + "uid": "${sqlmonitor_datasource}" }, "definition": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @params = N'@perfmon_host_name varchar(255)';\n\nset quoted_identifier off;\nset @sql = \"select count(*) as counts from sys.dm_os_schedulers dos where status = 'VISIBLE ONLINE' and is_online = 1;\"\nset quoted_identifier on;\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nif ($is_local = 1)\n exec dbo.sp_executesql @sql , @params, @perfmon_host_name;\nelse\n exec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name;", "hide": 2, @@ -9054,7 +9130,7 @@ "current": {}, "datasource": { "type": "mssql", - "uid": "${sqlmonitor_datasource}" + "uid": "${DS_SQLMONITOR}" }, "definition": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @params = N'@perfmon_host_name varchar(255)';\n\nset quoted_identifier off;\nset @sql = \"select DATEADD(mi, DATEDIFF(mi, getdate(), getutcdate()), sqlserver_start_time) from sys.dm_os_sys_info as osi;\"\nset quoted_identifier on;\n\n--if (@sql_instance = SERVERPROPERTY('SERVERNAME'))\nif ($is_local = 1)\n exec dbo.sp_executesql @sql , @params, @perfmon_host_name;\nelse\n exec [$server].[$dba_db].dbo.sp_executesql @sql , @params, @perfmon_host_name;", "hide": 2, @@ -9071,7 +9147,7 @@ "current": {}, "datasource": { "type": "mssql", - "uid": "${DS_SQLMONITOR}" + "uid": "${sqlmonitor_datasource}" }, "definition": "declare @sql nvarchar(max);\ndeclare @params nvarchar(max);\ndeclare @sql_instance varchar(255);\ndeclare @perfmon_host_name varchar(255);\n\nset @sql_instance = '$server';\nset @perfmon_host_name = '$perfmon_host_name';\nset @params = N'@perfmon_host_name varchar(255)';\n\nset quoted_identifier off;\nset @sql = \"\nSELECT --event_time\n\t\tevent_time_utc\n\t\t/*\n\t\t,system_cpu\n\t\t,sql_cpu\n\t\t,idle_system_cpu\n\t\t,user_mode_time_ms * 100 / (user_mode_time_ms + kernel_mode_time_ms) as [pcnt_user_mode]\n\t\t,kernel_mode_time_ms * 100 / (user_mode_time_ms + kernel_mode_time_ms) as [pcnt_kernel_mode]\n\t\t,page_faults_kb\n\t\t*/\nFROM (\n\t\tSELECT\tDATEADD (ms, -1 * (ts_now - [timestamp]), GETDATE()) AS event_time\n\t\t\t\t,DATEADD(mi, DATEDIFF(mi, getdate(), getutcdate()), DATEADD (ms, -1 * (ts_now - [timestamp]), GETDATE())) AS event_time_utc\n\t\t\t\t,100-record.value('(Record/SchedulerMonitorEvent/SystemHealth/SystemIdle)[1]', 'int') AS system_cpu\n\t\t\t\t,record.value('(Record/SchedulerMonitorEvent/SystemHealth/ProcessUtilization)[1]', 'int') AS sql_cpu\n\t\t\t\t,record.value('(Record/SchedulerMonitorEvent/SystemHealth/SystemIdle)[1]', 'int') AS idle_system_cpu\n\t\t\t\t,record.value('(Record/SchedulerMonitorEvent/SystemHealth/UserModeTime)[1]', 'bigint')/10000 AS user_mode_time_ms\n\t\t\t\t,record.value('(Record/SchedulerMonitorEvent/SystemHealth/KernelModeTime)[1]', 'bigint')/10000 AS kernel_mode_time_ms\n\t\t\t\t,record.value('(Record/SchedulerMonitorEvent/SystemHealth/PageFaults)[1]', 'bigint')*8.0 AS page_faults_kb\n\t\t\t\t,record\n\t\tFROM (\tSELECT\tTOP 1 timestamp, CONVERT (xml, record) AS record, cpu_ticks / (cpu_ticks/ms_ticks) as ts_now\n\t\t\t\tFROM sys.dm_os_ring_buffers orb cross apply sys.dm_os_sys_info osi\n\t\t\t\tWHERE ring_buffer_type = 'RING_BUFFER_SCHEDULER_MONITOR'\n\t\t\t\tAND record LIKE '%Use /pastetheplan-bridge.html"
+ "?key=<unique_key>&server=<instance>
key (unique_key) is required.
" + str(exc) + "
" + "Is Prometheus running at " + PROM_URL + "?
No metric for unique_key=" + _html_escape.escape(key)
+ + " within the last 24 hours.
PromQL used: " + _html_escape.escape(promql) + "
Is the proxy pointing at the right Prometheus? "
+ "Current: " + PROM_URL + "
"
+ "Override: python3 pastetheplan-proxy.py 8080 http://<prom-host>:<port>
The query_plan label is empty — "
+ "this session had no execution plan at collection time.
" + str(exc.reason) + "
" + err_body + "") + return + except urllib.error.URLError as exc: + self._html(502, "
" + str(exc.reason) + "
") + return + except Exception as exc: + self._html(500, "" + str(exc) + "
") + return + + if result.get("error"): + preview = _html_escape.escape((xml[:600] + " …") if len(xml) > 600 else xml) + self._html(400, "" + str(result.get("message", "")) + "
" + "" + + preview + "") + return + + plan_id = result.get("id") + if not plan_id: + self._html(502, "
" + json.dumps(result, indent=2) + "") + return + + location = PTP_VIEWER + urllib.parse.quote(str(plan_id), safe="") + print(f"[PTP proxy] Redirecting → {location}") + self.send_response(302) + self.send_header("Location", location) + self.send_header("Content-Length", "0") + self.end_headers() + + def _html(self, code, body_html): + page = ( + "" + "