Home
%3CLINGO-SUB%20id%3D%22lingo-sub-882790%22%20slang%3D%22en-US%22%3EMonitoring%20Azure%20SQL%20Database%20with%20Telegraf%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-882790%22%20slang%3D%22en-US%22%3E%3CP%3EIn%20a%20prior%20blog%2C%20we%20have%20described%20the%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2FDataCAT%2FReal-time-performance-monitoring-for-Azure-SQL-Database-Managed%2Fba-p%2F305537%22%20target%3D%22_blank%22%20rel%3D%22noopener%22%3EReal-time%20monitoring%20%3C%2FA%3Efor%20Azure%20SQL%20Database%20Managed%20Instance%20using%20the%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Finfluxdata%2Ftelegraf%2Ftree%2Fmaster%2Fplugins%2Finputs%2Fsqlserver%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3ETelegraf%20SQL%20plugin%3C%2FA%3E.%20In%20addition%20to%20Managed%20Instance%20support%2C%20Telegraf%20now%20also%20includes%20support%20for%20Azure%20SQL%20Database%20single%20databases%2C%20and%20can%20be%20used%20to%20monitor%20them%20in%20near-real%20time%20in%20a%20similar%20fashion.%20This%20is%20one%20of%20several%20monitoring%20solutions%20for%20Azure%20SQL%20Database%2C%20which%20also%20include%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fazure-monitor%2Finsights%2Fazure-sql%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EAzure%20SQL%20Analytics%3C%2FA%3E%2C%20and%20many%20third%20party%20solutions.%3C%2FP%3E%0A%3CP%3EIn%20addition%2C%20Azure%20SQL%20Database%20also%20provides%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fsql-database%2Fsql-database-query-performance%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EPerformance%20insights%3C%2FA%3E%2C%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fsql-database%2Fsql-database-automatic-tuning%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EAutomatic%20tuning%3C%2FA%3E%2C%20and%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fsql-database%2Fsql-database-metrics-diag-logging%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EDiagnostics%20logging%3C%2FA%3E%20features%20to%20support%20insights%20into%20query%20performance.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-1823834753%22%20id%3D%22toc-hId-1823834753%22%3ESolution%20setup%3C%2FH2%3E%0A%3CP%3EFor%20this%20solution%20using%20Telegraf%2C%20detailed%20setup%20instructions%20and%20setup%20shell%20scripts%20are%20in%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fdenzilribeiro%2Fsqldbmonitoring%2Ftree%2Fmaster%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EAzure%20SQL%20DB%20monitoring%3C%2FA%3E%20GitHub%20repo.%20For%20detailed%20setup%20steps%2C%20see%20the%20readme%20file%20in%20that%20repo.%20As%20an%20outline%2C%20the%20setup%20steps%20are%20as%20follows%3A%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3ECreate%20an%20Ubuntu%20VM.%20Other%20Linux%20distributions%20can%20be%20used%20as%20well%2C%20but%20commands%20have%20to%20be%20adjusted%20accordingly.%3C%2FLI%3E%0A%3CLI%3EClone%20the%20repo.%3C%2FLI%3E%0A%3CLI%3ERun%20the%20monitoringsetup.sh%20script%20which%20does%20the%20following%3A%3CUL%3E%0A%3CLI%3EInstalls%20Docker%3C%2FLI%3E%0A%3CLI%3EInstalls%20the%20latest%20Telegraf%20release%20build%20for%20Ubuntu.%20If%20you%20prefer%20a%20nightly%20build%20for%20the%20latest%20changes%2C%20pass%20the%20parameter%20%E2%80%9Cnightly%E2%80%9D%20on%20command%20line.%3C%2FLI%3E%0A%3CLI%3EPulls%20the%20Grafana%20docker%20image%3C%2FLI%3E%0A%3CLI%3EOpens%20TCP%20port%203000%20in%20the%20firewall%20for%20accessing%20Grafana%3C%2FLI%3E%0A%3CLI%3ECopies%20the%20telegraf.conf%20sample%20file%2C%20and%20adjusts%20permissions%20on%20that%20file%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FLI%3E%0A%3CLI%3EInstall%2C%20configure%20and%20start%20InfluxDB.%3C%2FLI%3E%0A%3CLI%3ECreate%20logins%2Fusers%20for%20each%20Azure%20SQL%20Database%20being%20monitored%2C%20and%20grant%20permissions.%3C%2FLI%3E%0A%3CLI%3EEdit%20Telegraf%20configuration%20file%3A%3CUL%3E%0A%3CLI%3EAdd%20the%20appropriate%20connection%20strings%2C%20one%20per%20database%20being%20monitored.%3C%2FLI%3E%0A%3CLI%3ESet%20the%20azuredb%3Dtrue%20flag%20to%20monitor%20Azure%20SQL%20database.%3C%2FLI%3E%0A%3CLI%3EExclude%20the%20collectors%20you%20do%20not%20need.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FLI%3E%0A%3CLI%3EStart%20Telegraf%20service.%3C%2FLI%3E%0A%3CLI%3EConfigure%20Grafana%20data%20source%2C%20and%20import%20Grafana%20dashboards%20located%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fdenzilribeiro%2Fsqldbmonitoring%2Ftree%2Fmaster%2Fdashboards%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehere%3C%2FA%3E.%20There%20are%20separate%20dashboards%20for%20Managed%20instance%20as%20compared%20to%20Azure%20SQL%20Database.%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3EThe%20Telegraf%20configuration%20file%20(telegraf.conf)%20instructs%20the%20SQL%20plugin%20to%20run%20the%20collectors%20below%20by%20default.%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3EPerformanceCounters%20%E2%80%93%20Performance%20counters%20from%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fsql%2Frelational-databases%2Fsystem-dynamic-management-views%2Fsys-dm-os-performance-counters-transact-sql%3Fview%3Dsql-server-2017%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Edm_os_performance_counters%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3EDatabaseIO%20-%20IO%20Statistics%20from%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fsql%2Frelational-databases%2Fsystem-dynamic-management-views%2Fsys-dm-io-virtual-file-stats-transact-sql%3Fview%3Dsql-server-2017%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Edm_io_virtual_file_stats%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3EWaitStatsCategorized%20%E2%80%93%20Database%20level%20wait%20statistics%20from%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fsql%2Frelational-databases%2Fsystem-dynamic-management-views%2Fsys-dm-db-wait-stats-azure-sql-database%3Fview%3Dazuresqldb-current%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Edm_db_wait_stats%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3EAzureDBResourceStats%20%E2%80%93%20Azure%20SQL%20Database%20resource%20stats%20from%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fsql%2Frelational-databases%2Fsystem-dynamic-management-views%2Fsys-dm-db-resource-stats-azure-sql-database%3Fview%3Dazuresqldb-current%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Edm_db_resource_stats%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3EAzureDBResourceGovernance%20%E2%80%93%20Resource%20Governance%20limits%20from%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fsql%2Frelational-databases%2Fsystem-dynamic-management-views%2Fsys-dm-user-db-resource-governor-azure-sql-database%3Fview%3Dazuresqldb-current%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Edm_user_db_resource_governance%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3EMemoryClerk%20%E2%80%93%20Memory%20consumption%20from%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fsql%2Frelational-databases%2Fsystem-dynamic-management-views%2Fsys-dm-os-memory-clerks-transact-sql%3Fview%3Dsql-server-2017%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Edm_os_memory_clerks%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3ESchedulers%20%E2%80%93%20Scheduler%20utilization%20from%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fsql%2Frelational-databases%2Fsystem-dynamic-management-views%2Fsys-dm-os-schedulers-transact-sql%3Fview%3Dsql-server-2017%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Edm_os_schedulers%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3ESqlRequests%20%E2%80%93%20Requests%20from%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fsql%2Frelational-databases%2Fsystem-dynamic-management-views%2Fsys-dm-exec-requests-transact-sql%3Fview%3Dsql-server-2017%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Edm_exec_requests%3C%2FA%3E%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--728322208%22%20id%3D%22toc-hId--728322208%22%3EGrafana%20Dashboards%3C%2FH2%3E%0A%3CP%3EThere%20are%20three%20dashboards.%20You%20can%20switch%20between%20dashboards%20while%20keeping%20the%20target%20database%20and%20time%20interval%20unchanged%2C%20to%20focus%20on%20different%20performance%20monitoring%20areas.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId-817974622%22%20id%3D%22toc-hId-817974622%22%3ESQL%20DB%20Performance%3C%2FH3%3E%0A%3CP%3EThis%20is%20the%20primary%20dashboard%2C%20providing%20an%20overview%20of%20performance%20at%20the%20SQL%20Server%20instance%20level%2C%20and%20at%20the%20database%20level.%20Note%20that%20in%20Azure%20SQL%20Database%2C%20the%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fsql-database%2Fsql-database-servers%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Eserver%3C%2FA%3E%20is%20just%20a%20logical%20construct%20(a%20logical%20grouping%20of%20databases).%20This%20dashboard%20allows%20you%20to%20choose%20a%20logical%20server%2C%20and%20then%20drill%20down%20into%20a%20specific%20database%20on%20that%20server.%20The%20logical%20server%20is%20different%20from%20the%20physical%20SQL%20Server%20instance%20hosting%20each%20database.%3C%2FP%3E%0A%3CP%3EThe%20dashboard%20is%20organized%20into%20collapsible%20sections%20including%20properties%20and%20limits%20based%20on%20the%20database%20tier%20and%20service%20level%2C%20database%20activity%2C%20database%20waits%2C%20log%20activity%2C%20CPU%2C%20workload%20groups%2C%20and%20memory.%3C%2FP%3E%0A%3CP%3EThe%20%3CEM%3E%E2%80%9COverview%E2%80%9D%20and%20%E2%80%9CAzure%20SQL%20DB%20Activity%E2%80%9D%3C%2FEM%3E%20depicts%20and%20overall%20picture%20including%20resource%20governance%20properties%2C%20database%20level%20restoure%20stats%20and%20a%20measure%20of%20workload%20throughput%20in%20batch%20requests%2Fsec%20and%20transactions%2Fsec.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F134137i7641017275FE540C%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22Blog1.png%22%20title%3D%22Blog1.png%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3ESQL%20DB%20Overview%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20%E2%80%9CWaits%20and%20queues%E2%80%9D%20sections%20depicts%20waits%20on%20SQL%20Server%20and%20is%20a%20primary%20step%20in%20troubleshooting%20bottlenecks.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F134138i175491C4238D1869%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22Blog1_waitstats.png%22%20title%3D%22Blog1_waitstats.png%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3ESQL%20DB%20Waitstats%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20%3CEM%3E%E2%80%9CLog%20Activity%E2%80%9D%3C%2FEM%3E%20section%20shows%20the%20log%20generation%20rate%20an%20important%20metric%20when%20loading%20data.%20The%20%3CEM%3E%E2%80%9CCPU%20and%20workload%20group%E2%80%9D%3C%2FEM%3E%20section%20gives%20visibility%20into%20CPU%20usage%20by%20workload%20groups.%20The%20UserPrimary%20group%20is%20the%20workload%20group%20that%20all%20user%20activity%20lands%20in%2C%20the%20other%20workload%20groups%20are%20internal%20workload%20groups%20mainly%20for%20background%20and%20system%20level%20activities.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F134136i917F76F39DFA9C66%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22Blog1_log_cpu.png%22%20title%3D%22Blog1_log_cpu.png%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3ESQL%20DB%20Log%20%26amp%3B%20Workload%20Group%20activity%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CDIV%20id%3D%22lia-teaserTinyMceEditorclipboard_image_0%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CH3%20id%3D%22toc-hId--1734182339%22%20id%3D%22toc-hId--1734182339%22%3ESQL%20DB%20Storage%3C%2FH3%3E%0A%3CP%3EThis%20is%20the%20dashboard%20for%20monitoring%20file%20size%20and%20space%20used%2C%20IO%20latency%2C%20and%20IO%20throughput%2C%20for%20each%20file%20in%20the%20database.%20When%20using%20Standard%20or%20General%20Purpose%20databases%2C%20which%20use%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fsql%2Frelational-databases%2Fdatabases%2Fsql-server-data-files-in-microsoft-azure%3Fview%3Dsql-server-2017%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Edata%20files%20in%20Azure%20blob%20storage%3C%2FA%3E%2C%20storage%20performance%20depends%20on%20several%20blob%20properties%2C%20exposed%20via%20the%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fsql%2Ft-sql%2Ffunctions%2Ffilepropertyex-transact-sql%3Fview%3Dsql-server-2017%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EFILEPROPERTYEX()%3C%2FA%3E%20function.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFor%20example%2C%20for%20the%20General%20Purpose%20tier%2C%20you%20could%20determine%20the%20blob%20type%20for%20your%20files%20from%20the%20query%20below%20and%20then%20understand%20the%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fvirtual-machines%2Fwindows%2Fdisks-types%23premium-ssd%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EIO%20Limits%20for%20specific%20blob%20tier%3C%2FA%3E.%20%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3ESELECT%20s.file_id%2C%0A%20%20%20%20%20%20%20%20s.type_desc%2C%0A%20%20%20%20%20%20%20%20s.name%2C%0A%20%20%20%20%20%20%20%20FILEPROPERTYEX(s.name%2C%20'BlobTier')%20AS%20BlobTier%2C%0A%20%20%20%20%20%20%20%20FILEPROPERTYEX(s.name%2C%20'AccountType')%20AS%20AccountType%2C%0A%20%20%20%20%20%20%20%20FILEPROPERTYEX(s.name%2C%20'IsInferredTier')%20AS%20IsInferredTier%2C%0A%20%20%20%20%20%20%20%20FILEPROPERTYEX(s.name%2C%20'IsPageBlob')%20AS%20IsPageBlob%0A%20%20%20%20%20%20%20%2C%20size%20*8%2F(1024*1024*1.0)%20as%20size_GB%0AFROM%20sys.database_files%20AS%20s%0AWHERE%20s.type_desc%20IN%20('ROWS'%2C%20'LOG')%3B%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F134133i0EC164EC6AA7E58C%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22blog2.png%22%20title%3D%22blog2.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId-8627996%22%20id%3D%22toc-hId-8627996%22%3ESQL%20DB%20Estate%3C%2FH3%3E%0A%3CP%3EThis%20dashboard%20gives%20you%20an%20overview%20of%20your%20Azure%20SQL%20Database%20estate%20(as%20referenced%20in%20telegraf.conf).%20There%20is%20a%20single%20row%20per%20logical%20server%2C%20and%20a%20view%20of%20the%20databases%20under%20it.%20For%20each%20database%2C%20you%20can%20drill%20through%20to%20the%20performance%20dashboard%20for%20closer%20investigation.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F134134i79ED6337E34B4460%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22Blog3.png%22%20title%3D%22Blog3.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-1947951836%22%20id%3D%22toc-hId-1947951836%22%3EConclusion%3C%2FH2%3E%0A%3CP%3EThe%20Telegraf%20based%20solution%20described%20in%20this%20article%20can%20be%20deployed%20quickly%20to%20enable%20in-depth%20near-real%20time%20performance%20monitoring%20for%20your%20Azure%20SQL%20DB%20databases.%20The%20solution%20uses%20lightweight%20DMV%20queries%20to%20collect%20performance%20data%20and%20present%20it%20on%20easy%20to%20use%20Grafana%20dashboards.%20Historical%20performance%20data%20is%20retained%2C%20up%20to%20the%20retention%20period%20configured%20in%20the%20InfluxDB%20database.%3C%2FP%3E%0A%3CP%3EThe%20solution%20is%20open%20source%2C%20and%20we%20will%20welcome%20and%20appreciate%20contributions%20from%20the%20community.%20Contributions%20to%20the%20Telegraf%20collector%20should%20be%20made%20via%20pull%20requests%20to%20the%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Finfluxdata%2Ftelegraf%2Ftree%2Fmaster%2Fplugins%2Finputs%2Fsqlserver%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3ESQL%20Server%20Input%20Plugin%3C%2FA%3E%20GotHub%20repo%20for%20Telegraf.%20For%20changes%20to%20Grafana%20dashboards%2C%20pull%20requests%20should%20be%20made%20to%20the%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fdenzilribeiro%2Fsqldbmonitoring%2Ftree%2Fmaster%2Fdashboards%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Esqldbmonitoring%26nbsp%3B%3C%2FA%3EGitHub%20repo.%3C%2FP%3E%0A%3CP%3EThe%20solution%20we%20described%20runs%20on%20Linux.%20However%2C%20if%20using%20Windows%20is%20preferred%2C%20Telegraf%20can%20be%20run%20as%20a%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Finfluxdata%2Ftelegraf%2Fblob%2Fmaster%2Fdocs%2FWINDOWS_SERVICE.md%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EWindows%20service%3C%2FA%3E.%20You%20can%20also%20install%20the%20Windows%20versions%20of%20%3CA%20href%3D%22https%3A%2F%2Fgrafana.com%2Fdocs%2Finstallation%2Fwindows%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3EGrafana%3C%2FA%3E%20and%20%3CA%20href%3D%22https%3A%2F%2Fportal.influxdata.com%2Fdownloads%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3EInfluxDB%3C%2FA%3E%2C%20to%20have%20the%20entire%20solution%20working%20on%20Windows%20or%20run%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fvirtualization%2Fwindowscontainers%2Fdeploy-containers%2Flinux-containers%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3ELinux%20containers%20on%20windows%3C%2FA%3E.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-882790%22%20slang%3D%22en-US%22%3E%3CP%3EIn%20addition%20to%20Managed%20Instance%20support%2C%20Telegraf%20now%20also%20includes%20support%20for%20Azure%20SQL%20Database%20single%20databases%2C%20and%20can%20be%20used%20to%20monitor%20them%20in%20near-real%20time%20in%20a%20similar%20fashion.%20This%20is%20one%20of%20several%20monitoring%20solutions%20for%20Azure%20SQL%20Database%2C%20which%20also%20include%20Azure%20SQL%20Analytics%2C%20and%20many%20third%20party%20solutions.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-882790%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EMonitoring%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EPerformance%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Microsoft

In a prior blog, we have described the Real-time monitoring for Azure SQL Database Managed Instance using the Telegraf SQL plugin. In addition to Managed Instance support, Telegraf now also includes support for Azure SQL Database single databases, and can be used to monitor them in near-real time in a similar fashion. This is one of several monitoring solutions for Azure SQL Database, which also include Azure SQL Analytics, and many third party solutions.

In addition, Azure SQL Database also provides Performance insights, Automatic tuning, and Diagnostics logging features to support insights into query performance.

 

Solution setup

For this solution using Telegraf, detailed setup instructions and setup shell scripts are in Azure SQL DB monitoring GitHub repo. For detailed setup steps, see the readme file in that repo. As an outline, the setup steps are as follows:

  1. Create an Ubuntu VM. Other Linux distributions can be used as well, but commands have to be adjusted accordingly.
  2. Clone the repo.
  3. Run the monitoringsetup.sh script which does the following:
    • Installs Docker
    • Installs the latest Telegraf release build for Ubuntu. If you prefer a nightly build for the latest changes, pass the parameter “nightly” on command line.
    • Pulls the Grafana docker image
    • Opens TCP port 3000 in the firewall for accessing Grafana
    • Copies the telegraf.conf sample file, and adjusts permissions on that file
  4. Install, configure and start InfluxDB.
  5. Create logins/users for each Azure SQL Database being monitored, and grant permissions.
  6. Edit Telegraf configuration file:
    • Add the appropriate connection strings, one per database being monitored.
    • Set the azuredb=true flag to monitor Azure SQL database.
    • Exclude the collectors you do not need.
  7. Start Telegraf service.
  8. Configure Grafana data source, and import Grafana dashboards located here. There are separate dashboards for Managed instance as compared to Azure SQL Database.

The Telegraf configuration file (telegraf.conf) instructs the SQL plugin to run the collectors below by default.

  1. PerformanceCounters – Performance counters from dm_os_performance_counters
  2. DatabaseIO - IO Statistics from dm_io_virtual_file_stats
  3. WaitStatsCategorized – Database level wait statistics from dm_db_wait_stats
  4. AzureDBResourceStats – Azure SQL Database resource stats from dm_db_resource_stats
  5. AzureDBResourceGovernance – Resource Governance limits from dm_user_db_resource_governance
  6. MemoryClerk – Memory consumption from dm_os_memory_clerks
  7. Schedulers – Scheduler utilization from dm_os_schedulers
  8. SqlRequests – Requests from dm_exec_requests

 

Grafana Dashboards

There are three dashboards. You can switch between dashboards while keeping the target database and time interval unchanged, to focus on different performance monitoring areas.

 

SQL DB Performance

This is the primary dashboard, providing an overview of performance at the SQL Server instance level, and at the database level. Note that in Azure SQL Database, the server is just a logical construct (a logical grouping of databases). This dashboard allows you to choose a logical server, and then drill down into a specific database on that server. The logical server is different from the physical SQL Server instance hosting each database.

The dashboard is organized into collapsible sections including properties and limits based on the database tier and service level, database activity, database waits, log activity, CPU, workload groups, and memory.

The “Overview” and “Azure SQL DB Activity” depicts and overall picture including resource governance properties, database level restoure stats and a measure of workload throughput in batch requests/sec and transactions/sec.

 

Blog1.pngSQL DB Overview

 

The “Waits and queues” sections depicts waits on SQL Server and is a primary step in troubleshooting bottlenecks.

Blog1_waitstats.pngSQL DB Waitstats

 

The “Log Activity” section shows the log generation rate an important metric when loading data. The “CPU and workload group” section gives visibility into CPU usage by workload groups. The UserPrimary group is the workload group that all user activity lands in, the other workload groups are internal workload groups mainly for background and system level activities.

Blog1_log_cpu.pngSQL DB Log & Workload Group activity

 

SQL DB Storage

This is the dashboard for monitoring file size and space used, IO latency, and IO throughput, for each file in the database. When using Standard or General Purpose databases, which use data files in Azure blob storage, storage performance depends on several blob properties, exposed via the FILEPROPERTYEX() function.

 

For example, for the General Purpose tier, you could determine the blob type for your files from the query below and then understand the IO Limits for specific blob tier.  

 

 

 

 

SELECT s.file_id,
        s.type_desc,
        s.name,
        FILEPROPERTYEX(s.name, 'BlobTier') AS BlobTier,
        FILEPROPERTYEX(s.name, 'AccountType') AS AccountType,
        FILEPROPERTYEX(s.name, 'IsInferredTier') AS IsInferredTier,
        FILEPROPERTYEX(s.name, 'IsPageBlob') AS IsPageBlob
       , size *8/(1024*1024*1.0) as size_GB
FROM sys.database_files AS s
WHERE s.type_desc IN ('ROWS', 'LOG');

 

 

 

 

 

blog2.png

 

SQL DB Estate

This dashboard gives you an overview of your Azure SQL Database estate (as referenced in telegraf.conf). There is a single row per logical server, and a view of the databases under it. For each database, you can drill through to the performance dashboard for closer investigation.

 

Blog3.png

 

Conclusion

The Telegraf based solution described in this article can be deployed quickly to enable in-depth near-real time performance monitoring for your Azure SQL DB databases. The solution uses lightweight DMV queries to collect performance data and present it on easy to use Grafana dashboards. Historical performance data is retained, up to the retention period configured in the InfluxDB database.

The solution is open source, and we will welcome and appreciate contributions from the community. Contributions to the Telegraf collector should be made via pull requests to the SQL Server Input Plugin GotHub repo for Telegraf. For changes to Grafana dashboards, pull requests should be made to the sqldbmonitoring GitHub repo.

The solution we described runs on Linux. However, if using Windows is preferred, Telegraf can be run as a Windows service. You can also install the Windows versions of Grafana and InfluxDB, to have the entire solution working on Windows or run Linux containers on windows.