Presentation is loading. Please wait.

Presentation is loading. Please wait.

SQL Advanced Monitoring Using DMV, Extended Events and Service Broker Javier Villegas – DBA | MCP | MCTS.

Similar presentations


Presentation on theme: "SQL Advanced Monitoring Using DMV, Extended Events and Service Broker Javier Villegas – DBA | MCP | MCTS."— Presentation transcript:

1 SQL Advanced Monitoring Using DMV, Extended Events and Service Broker Javier Villegas – DBA | MCP | MCTS

2 Speaker Bio 2 Javier Villegas Buenos Aires, Argentina. Database Administrator Since 1997 – SQL 6.0 -> SQL 2016 MCP - MCTS DBA at Mediterranean Shipping Company Since 2006 PASS Member Since 2008 Picture Here @javier_vill http://sql-javier-villegas.blogspot.com.ar/ https://ar.linkedin.com/in/javiervillegas

3 Agenda 3  Analyzing SQL activity  Continuous monitoring with Extended Events (XEvents)  Proactive monitoring(DMV / Powershell)  Auditing using Service Broker

4 Analyzing SQL Server Activity 4 dbo.SP_DBA_CurrentlyExec http://1drv.ms/1j9es6f Allow us to quickly see all the SQL Activity Each row represents an active sessions We can see below: SPID, CPU usage, Status, Start Time, Elapsed time, Read/Write times, SQL Statement, Database name and it’s transaction log usage, Object Name, Wait Stat, Login, Host and Application name If detects a blocking situation it will show a second result set with all the sessions involved Useful to quickly detect performance problems

5 5 dbo.SP_DBA_CurrentlyExec Example Blocks 5

6 6 dbo.SP_DBA_CurrentlyExec dbo.SP_DBA_CurrentlyExec @info=1 dbo.SP_DBA_CurrentlyExec @Filter_Name=‘App_Name’, @Filter_Value=‘SSIS’ dbo.SP_DBA_CurrentlyExec @Filter_Name=‘Host_Name’, @Filter_Value=‘WORKSTS01’ 6

7 7 dbo.SP_WhoIsActive 7

8 8 sp_server_diagnostics Captures diagnostic information and health data from SQL to detect possible system failures. This process is running in background constantly and periodically updates the results for the output 8

9 9 sp_server_diagnostics Create_Time Timestamp Component_Type Indicates whether the row contains information for the SQL Server instance level component or for an AlwaysOn availability group Component_Name system, resource, query_processing, io_subsystem, events, State 0, 1, 2 or 3 State_Desc “Unknown”, “Clean”, “Warning”, “Error” Data XML 9

10 10 sp_server_diagnostics System CPU, Dumps, Pages, etc. Resource Memory Query_processing Tasks, Wait Stats, bloques, etc. IO_subsystem I/O info Events Server events Availability Group 10

11 11 sp_server_diagnostics 11 Examples

12 12 Analyzing SQL Server Activity Other Tools Performance Monitor Activity Monitor SQL Server Performance Dashboard https://www.microsoft.com/en-us/download/details.aspx?id=29063 SQL Profiler * Extended Events 12

13 13 Continuous monitoring with Extended Events Extended Events General events control system Correlates database and operating system events Follow-up tool(Performance Monitor / SQL Trace) Configurable with T-SQL Useful to troubleshoot without performance impact (minimal extra load) Collects data from: I/O Waits Query Parameters Execution Plans Lock 13

14 14 Continuous monitoring with Extended Events Extended Events - Components Session Definition of what is going to collected as well as when to start and where to store the collected data Target Memory (Ring Buffer) File Package Logical containers SQLOS, SQLSERVER, SecAudit, SQLCLR, etc. Events Data collection 14

15 15 Continuous monitoring with Extended Events Extended Events We can collect same events as with SQL Profiler (Even more since MS keep updating them) Lighter than SQL Profiler. Easy to work with (T-SQL, XML) 15

16 16 DEMO Analyzing SQL Server Activity SP_DBA_CurrentlyExec SP_Server_Diagnostics Extended Events SQL Errors Deadlocks Long running SQL Statements 16

17 17 Proactive monitoring(DMV / Powershell) Continuously collecting key data and vital signs from the SQL Instance SQL Server and Windows Version and Edition MAXDOP Cluster Database Mirroring/AlwaysOn Network Active Transactions Transactions per second Active connections Performance Monitor counters related to I/O using PowerShell I/O Latency 17

18 18 Proactive monitoring(DMV / Powershell) Also… SQL Job running every minute that perform below tasks Runs “currently executing”. Storing the results just if detects blocks or if there is an statement running for over X minutes Sends email with the blocking reports The table used to keep data from “Currently Executing” is very useful when we have to investigate performance issues from the past Check transaction log usage for all the databases (Sends emails with reports) Disks Usage Used vs Free Space (Sends email when there is less than 1 GB or 7% from total – This can be configurable) Detects open transactions for more than X minutes Detects SQL Dumps Detects critical errors from SQL Error Log Disks Usage and performance info using PerfMon Disks latencies reports 18

19 19 Auditing We can create a system using Service Broker to help us to audit objects manipulation within an user database Table with rows identifying every CREATE, DROP or ALTER Each row contains below: Event Timestamp Event type CREATE_PROCEDURE, DROP_TABLE, etc. Login used for the event Schema and object name Object type Session ID for the event HostName (*) XML with the details 19

20 20 Proactive monitoring(DMV / Powershell) 20

21 21 Proactive monitoring(DMV / Powershell) 21

22 22 Proactive monitoring(DMV / Powershell) 22

23 23 Proactive monitoring(DMV / Powershell) 23

24 24 Proactive monitoring(DMV / Powershell) 24

25 25 DEMO Proactive monitoring Audit 25

26 Questions? @javier_vill http://sql-javier-villegas.blogspot.com.ar/ https://ar.linkedin.com/in/javiervillegas


Download ppt "SQL Advanced Monitoring Using DMV, Extended Events and Service Broker Javier Villegas – DBA | MCP | MCTS."

Similar presentations


Ads by Google