├── .gitignore ├── .vscode └── launch.json ├── .vscodeignore ├── Build.ps1 ├── LICENSE ├── README.md ├── extension-definition.json ├── src ├── CHANGELOG.md ├── README.md ├── images │ ├── icon.png │ ├── mssql-db-insights-tab-details.png │ ├── mssql-db-insights-tab.png │ ├── mssql-db-spaceused-details.png │ ├── mssql-db-spaceused-filetype.png │ ├── mssql-db-spaceused.png │ ├── mssql-db-vlfs-details.png │ ├── mssql-db-vlfs.png │ └── show-detail.png ├── media │ ├── diagram.svg │ ├── diagram_inverse.svg │ ├── monitor.svg │ ├── monitor_inverse.svg │ ├── performance.svg │ ├── performance_inverse.svg │ ├── pie.svg │ └── pie_inverse.svg ├── package.json └── sql │ ├── mssql-db-CpuMemDisk.sql │ ├── mssql-db-sessions-detail.sql │ ├── mssql-db-sessions.sql │ ├── mssql-db-spaceused-detail.sql │ ├── mssql-db-spaceused-filetype.sql │ ├── mssql-db-spaceused.sql │ ├── mssql-db-vlfs-detail.sql │ ├── mssql-db-vlfs.sql │ ├── mssql-db-waits-detail.sql │ └── mssql-db-waits.sql └── vsc-extension-quickstart.md /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | *.vsix 3 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | // A launch configuration that launches the extension inside a new window 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | 6 | // To debug the extension: 7 | // 1. please install the "SQL Operations Studio Debug" extension into VSCode 8 | // 2. Ensure sqlops is added to your path: 9 | // - open SQL Operations Studio 10 | // - run the command "Install 'sqlops' command in PATH" 11 | { 12 | "version": "0.2.0", 13 | "configurations": [ 14 | { 15 | "name": "Extension", 16 | "type": "sqlopsExtensionHost", 17 | "request": "launch", 18 | "runtimeExecutable": "sqlops", 19 | "args": [ 20 | "--extensionDevelopmentPath=${workspaceFolder}\\src" 21 | ] 22 | } 23 | ] 24 | } -------------------------------------------------------------------------------- /.vscodeignore: -------------------------------------------------------------------------------- 1 | .vscode/** 2 | .vscode-test/** 3 | .gitignore 4 | vsc-extension-quickstart.md 5 | -------------------------------------------------------------------------------- /Build.ps1: -------------------------------------------------------------------------------- 1 | [CmdLetBinding()] 2 | Param ( 3 | [Parameter()] 4 | [string]$BuildDir 5 | ) 6 | 7 | [string]$scriptPath = $PSScriptRoot; 8 | 9 | # set the location history 10 | Push-Location; 11 | 12 | # make sure the releases folder exists 13 | if ($null -eq $BuildDir -or $BuildDir.Length -eq 0) 14 | { 15 | $BuildDir = Join-Path -Path $scriptPath -ChildPath 'build'; 16 | } 17 | if (-not(Test-Path -Path $BuildDir)) 18 | { 19 | New-Item -Path $BuildDir -ItemType Directory -Force | Out-Null; 20 | } 21 | 22 | # Get the packages to build in this repo 23 | $packageFiles = Get-ChildItem -Path $scriptPath -Recurse -Filter 'package.json' 24 | 25 | if ($packageFiles.Count -eq 0) 26 | { 27 | Write-Error -Message 'No Extensions found to package' 28 | Exit 29 | } 30 | 31 | # set our working location to the build folder 32 | Set-Location -Path $BuildDir; 33 | 34 | # process each package found 35 | foreach ($package in $packageFiles) 36 | { 37 | Write-Verbose -Message "Processing $($package.fullname)"; 38 | 39 | # try 40 | # { 41 | Set-Location -Path $package.DirectoryName; 42 | vsce.cmd package; 43 | Get-ChildItem -Path $package.DirectoryName -Filter '*.vsix' | Move-Item -Destination $BuildDir -Force; 44 | # } 45 | # catch 46 | # { 47 | 48 | # } 49 | 50 | Write-Verbose -Message ('Finished processing package {0}' -f $packageJson.name); 51 | 52 | } 53 | 54 | # return to the previous user location 55 | Pop-Location; 56 | 57 | Write-Verbose -Message 'Extension Packaging Complete'; -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Matt 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MSSQL-Database-Insights widget 2 | 3 | This collection of widgets are designed to provide insights into MSSQL Database to further extend the built-in default widgets. 4 | 5 | Where possible all of these widgets will include more detail when you click *_Show Details_* from the widget menu. 6 | 7 | See the [package README](./src/README.md) for more information. 8 | 9 | ## Installation 10 | 11 | The current release will be available through the Extensions Marketplace in Sql Ops Studio. 12 | 13 | Current and Pre-releases will be available from the [Releases](https://github.com/Matticusau/sqlops-mssql-db-insights/releases) tab of the projects repository. Simply download the VSIX of the release you want, and use the ***Install Extension from VSIX Package*** option in Sql Ops Studio. 14 | 15 | ## Change Log 16 | 17 | See the [Change Log](./src/CHANGELOG.md) for the full changes. 18 | 19 | ## License 20 | 21 | This project is released under the [MIT License](./LICENSE) 22 | 23 | ## Contributors 24 | 25 | * Matticusau [GitHub](https://github.com/Matticusau) | [twitter](https://twitter.com/matticusau) 26 | -------------------------------------------------------------------------------- /extension-definition.json: -------------------------------------------------------------------------------- 1 | { 2 | "extensionId": "", 3 | "extensionName": "mssql-db-insights", 4 | "displayName": "MSSQL Db Insights", 5 | "shortDescription": "Sql Server Database insights", 6 | "publisher": { 7 | "displayName":"matticusau", 8 | "publisherId": "matticusau", 9 | "publisherName":"matticusau" 10 | }, 11 | "versions": [ 12 | { 13 | "version": "0.2.1", 14 | "lastUpdated": "04/21/2018", 15 | "assetUri": "", 16 | "fallbackAssetUri": "fallbackAssetUri", 17 | "files": [ 18 | { 19 | "assetType": "Microsoft.SQLOps.DownloadPage", 20 | "source": "https://github.com/Matticusau/sqlops-mssql-db-insights/releases/tag/0.2.1" 21 | }, 22 | { 23 | "assetType": "Microsoft.VisualStudio.Services.Links.Source", 24 | "source": "https://github.com/Matticusau/sqlops-mssql-db-insights" 25 | }, 26 | { 27 | "assetType": "Microsoft.VisualStudio.Services.Icons.Default", 28 | "source": "https://raw.githubusercontent.com/Matticusau/sqlops-mssql-db-insights/master/src/images/icon.png" 29 | }, 30 | { 31 | "assetType": "Microsoft.VisualStudio.Services.Content.Details", 32 | "source": "https://raw.githubusercontent.com/Matticusau/sqlops-mssql-db-insights/master/src/README.md" 33 | }, 34 | { 35 | "assetType": "Microsoft.VisualStudio.Code.Manifest", 36 | "source": "https://raw.githubusercontent.com/Matticusau/sqlops-mssql-db-insights/master/src/package.json" 37 | }, 38 | { 39 | "assetType": "Microsoft.VisualStudio.Services.Content.License", 40 | "source": "https://raw.githubusercontent.com/Matticusau/sqlops-mssql-db-insights/master/LICENSE" 41 | } 42 | ], 43 | "properties": [ 44 | { "key": "Microsoft.VisualStudio.Code.ExtensionDependencies", "value":""}, 45 | { "key": "Microsoft.VisualStudio.Code.Engine", "value":"*"} 46 | ] 47 | } 48 | ], 49 | "statistics": [], 50 | "flags": "preview" 51 | } -------------------------------------------------------------------------------- /src/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to the "mssql-db-insights" extension will be documented in this file. Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file. 4 | 5 | ## [Unreleased] 6 | 7 | - None 8 | 9 | ## [0.2.2] 10 | 11 | ### Added 12 | 13 | - Multiple containers/dashboards 14 | - DB Session insight 15 | - DB Resource Consumption insight 16 | - Autorefreh for certain insights 17 | 18 | ### Changed 19 | 20 | - New gallery logo 21 | - Fixed license url in TSQL 22 | - Friendly column names in charts 23 | - Fixed icon colors in fly out window 24 | 25 | ## [0.2.0] 26 | 27 | ### Added 28 | 29 | - VLFs widget 30 | 31 | ### Changed 32 | 33 | - Minor documentation fixes for marketplace support 34 | 35 | ## [0.2.0-beta1] 36 | 37 | ### Added 38 | 39 | - Migration of code from [https://github.com/Matticusau/sqlops-widgets](https://github.com/Matticusau/sqlops-widgets) -------------------------------------------------------------------------------- /src/README.md: -------------------------------------------------------------------------------- 1 | # MSSQL-Database-Insights widget 2 | 3 | This collection of widgets are designed to provide insights into MSSQL Database to further extend the built-in default widgets. 4 | 5 | Where possible all of these widgets will include more detail when you click *_Show Details_* from the widget menu. 6 | 7 | Show Details 8 | 9 | ## Installation 10 | 11 | The current release will be available through the Extensions Marketplace in Sql Ops Studio. 12 | 13 | Current and Pre-releases will be available from the [Releases](https://github.com/Matticusau/sqlops-mssql-db-insights/releases) tab of the projects repository. Simply download the VSIX of the release you want, and use the ***Install Extension from VSIX Package*** option in Sql Ops Studio. 14 | 15 | ## Supported SQL Server Versions 16 | 17 | These widgets have been tested against the following SQL Server versions: 18 | 19 | * SQL Server 2008R2 20 | * SQL Server 2012 21 | * SQL Server 2014 22 | * SQL Server 2016 23 | * SQL Server 2017 (Windows & linux) 24 | * Azure SQL Db 25 | 26 | If you find any issues using these widgets on these supported SQL Server versions, or any other versions please create an issue as we would like to make these available for as many releases as possible. 27 | 28 | Thanks to the following people for testing: 29 | 30 | * Sreekanth [@mssqltrek](https://twitter.com/mssqltrek) 31 | 32 | ***We are looking for testers to confirm other environments.*** So if you find they do work on other releases let me know, and credit will be given. 33 | 34 | ## Dashboard Tab 35 | 36 | When the extension is loaded it will add a Dashboard tab. You can edit your workspace settings in the *dashboard.server.tabs* section to include this on your specific projects. 37 | 38 | mssql-db-insights-tab.png 39 | 40 | ## mssql-db-spaceused 41 | 42 | This Database Dashboard widget includes information on the current used space within a Database. Information will be shown in the form of a pie chart displaying the percentage of used space verses free space. 43 | 44 | mssql-db-spaceused.png 45 | 46 | You can access more information about the space usaged in the detailed fly-out displayed when you select "..." on the widget. 47 | 48 | mssql-db-spaceused-details.png 49 | 50 | To enable this widget add the following json to either your user or workspace settings in the *dashboard.database.widgets* section. 51 | 52 | ```json 53 | { 54 | "widget": { 55 | "mssql-db-spaceused.insight": { 56 | "cacheId": "1d7cba8b-c87a-4bcc-ae54-2f40a5503a90" 57 | } 58 | } 59 | } 60 | ``` 61 | 62 | ## mssql-db-spaceused-filetype 63 | 64 | This Database Dashboard widget includes information on the current used space within a Database broken down by the various file types (ROWS, LOG). Information will be shown in the form of a bar chart displaying the percentage of used space verses free space for each file type. 65 | 66 | mssql-db-spaceused-filetype.png 67 | 68 | You can access more information about the space usaged in the detailed fly-out displayed when you select "..." on the widget. 69 | 70 | mssql-db-spaceused-details.png 71 | 72 | To enable this widget add the following json to either your user or workspace settings in the *dashboard.database.widgets* section. 73 | 74 | ```json 75 | { 76 | "widget": { 77 | "mssql-db-spaceused-filetype.insight": { 78 | "cacheId": "1d7cba8b-c87a-4bcc-ae54-2f40a5503a90" 79 | } 80 | } 81 | } 82 | ``` 83 | 84 | ## mssql-db-vlfs 85 | 86 | This Database Dashboard widget includes information on the number of VLfs in the current database on the SQL Instance. Information will be shown in the form of a bar chart. 87 | 88 | This insight is ***not*** supported on Azure SQL Db. 89 | 90 | mssql-db-vlfs.png 91 | 92 | You can access more information about the vlfs in the detailed fly-out displayed when you select "..." on the widget. 93 | 94 | mssql-db-vlfs-details.png 95 | 96 | To enable this widget add the following json to either your user or workspace settings in the *dashboard.database.widgets* section. 97 | 98 | ```json 99 | { 100 | "widget": { 101 | "mssql-db-vlfs.insight": { 102 | "cacheId": "1d7cba8b-c87a-4bcc-ae54-2f40a5503a90" 103 | } 104 | } 105 | } 106 | ``` -------------------------------------------------------------------------------- /src/images/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Matticusau/sqlops-mssql-db-insights/8f3c2241ddab2fc400b91146bddce3b815a46132/src/images/icon.png -------------------------------------------------------------------------------- /src/images/mssql-db-insights-tab-details.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Matticusau/sqlops-mssql-db-insights/8f3c2241ddab2fc400b91146bddce3b815a46132/src/images/mssql-db-insights-tab-details.png -------------------------------------------------------------------------------- /src/images/mssql-db-insights-tab.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Matticusau/sqlops-mssql-db-insights/8f3c2241ddab2fc400b91146bddce3b815a46132/src/images/mssql-db-insights-tab.png -------------------------------------------------------------------------------- /src/images/mssql-db-spaceused-details.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Matticusau/sqlops-mssql-db-insights/8f3c2241ddab2fc400b91146bddce3b815a46132/src/images/mssql-db-spaceused-details.png -------------------------------------------------------------------------------- /src/images/mssql-db-spaceused-filetype.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Matticusau/sqlops-mssql-db-insights/8f3c2241ddab2fc400b91146bddce3b815a46132/src/images/mssql-db-spaceused-filetype.png -------------------------------------------------------------------------------- /src/images/mssql-db-spaceused.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Matticusau/sqlops-mssql-db-insights/8f3c2241ddab2fc400b91146bddce3b815a46132/src/images/mssql-db-spaceused.png -------------------------------------------------------------------------------- /src/images/mssql-db-vlfs-details.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Matticusau/sqlops-mssql-db-insights/8f3c2241ddab2fc400b91146bddce3b815a46132/src/images/mssql-db-vlfs-details.png -------------------------------------------------------------------------------- /src/images/mssql-db-vlfs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Matticusau/sqlops-mssql-db-insights/8f3c2241ddab2fc400b91146bddce3b815a46132/src/images/mssql-db-vlfs.png -------------------------------------------------------------------------------- /src/images/show-detail.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Matticusau/sqlops-mssql-db-insights/8f3c2241ddab2fc400b91146bddce3b815a46132/src/images/show-detail.png -------------------------------------------------------------------------------- /src/media/diagram.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/media/diagram_inverse.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/media/monitor.svg: -------------------------------------------------------------------------------- 1 | usage -------------------------------------------------------------------------------- /src/media/monitor_inverse.svg: -------------------------------------------------------------------------------- 1 | usage_inverse -------------------------------------------------------------------------------- /src/media/performance.svg: -------------------------------------------------------------------------------- 1 | health -------------------------------------------------------------------------------- /src/media/performance_inverse.svg: -------------------------------------------------------------------------------- 1 | health_inverse -------------------------------------------------------------------------------- /src/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "mssql-db-insights", 3 | "displayName": "MSSQL Db Insights", 4 | "description": "Sql Server Database insights", 5 | "version": "0.2.2", 6 | "publisher": "matticusau", 7 | "license": "MIT", 8 | "icon": "images/icon.png", 9 | "author": { 10 | "email": "matt.lavery@outlook.com", 11 | "name": "Matt Lavery", 12 | "url": "http://www.matticus.net" 13 | }, 14 | "repository": { 15 | "type": "git", 16 | "url": "https://github.com/matticusau/sqlops-mssql-db-insights" 17 | }, 18 | "bugs": { 19 | "url": "https://github.com/matticusau/sqlops-mssql-db-insights/issues" 20 | }, 21 | "engines": { 22 | "vscode": "^1.22.0", 23 | "sqlops": "*" 24 | }, 25 | "categories": [ 26 | "Other" 27 | ], 28 | "homepage": "https://github.com/matticusau/sqlops-mssql-db-insights", 29 | "contributes": { 30 | "configuration": [], 31 | "commands": [], 32 | "views": { 33 | 34 | }, 35 | "menus":{ 36 | 37 | }, 38 | "dashboard.tabs": [ 39 | { 40 | "id": "mssql-db-insights.tab", 41 | "title": "MSSQL Db Insights", 42 | "description": "SQL Server Database insights and widgets", 43 | "container": { 44 | "nav-section": [ 45 | { 46 | "id": "dbactivity-container", 47 | "title": "DB Activity", 48 | "icon": { 49 | "light": "./media/diagram.svg", 50 | "dark": "./media/diagram_inverse.svg" 51 | }, 52 | "container": { 53 | "dbactivity-container": {} 54 | } 55 | }, 56 | { 57 | "id": "dbhealth-container", 58 | "title": "DB Health", 59 | "icon": { 60 | "light": "./media/pie.svg", 61 | "dark": "./media/pie_inverse.svg" 62 | }, 63 | "container": { 64 | "dbhealth-container": {} 65 | } 66 | } 67 | ] 68 | } 69 | } 70 | ], 71 | "dashboard.insights": [ 72 | { 73 | "id": "mssql-db-spaceused.insight", 74 | "contrib": { 75 | "queryFile": "./sql/mssql-db-spaceused.sql", 76 | "type": { 77 | "pie": { 78 | "dataDirection": "horizontal", 79 | "dataType": "number", 80 | "legendPosition": "bottom", 81 | "labelFirstColumn": false, 82 | "columnsAsLabels": false 83 | } 84 | }, 85 | "details": { 86 | "queryFile": "./sql/mssql-db-spaceused-detail.sql", 87 | "label": { 88 | "icon": "database", 89 | "column": "Logical Name", 90 | "state": [ 91 | { 92 | "condition": { 93 | "if": "greaterThanOrEquals", 94 | "equals": "95" 95 | }, 96 | "color": "red" 97 | }, 98 | { 99 | "condition": { 100 | "if": "greaterThan", 101 | "equals": "85" 102 | }, 103 | "color": "orange" 104 | }, 105 | { 106 | "condition": { 107 | "if": "lessThanOrEquals", 108 | "equals": "85" 109 | }, 110 | "color": "green" 111 | } 112 | ] 113 | }, 114 | "value": "% Used", 115 | "actions": null 116 | } 117 | } 118 | }, 119 | { 120 | "id": "mssql-db-spaceused-filetype.insight", 121 | "contrib": { 122 | "queryFile": "./sql/mssql-db-spaceused-filetype.sql", 123 | "type": { 124 | "horizontalBar": { 125 | "dataDirection": "vertical", 126 | "dataType": "number", 127 | "legendPosition": "bottom", 128 | "labelFirstColumn": true, 129 | "columnsAsLabels": true 130 | } 131 | }, 132 | "details": { 133 | "queryFile": "./sql/mssql-db-spaceused-detail.sql", 134 | "label": { 135 | "icon": "database", 136 | "column": "Logical Name", 137 | "state": [ 138 | { 139 | "condition": { 140 | "if": "greaterThanOrEquals", 141 | "equals": "95" 142 | }, 143 | "color": "red" 144 | }, 145 | { 146 | "condition": { 147 | "if": "greaterThan", 148 | "equals": "85" 149 | }, 150 | "color": "orange" 151 | }, 152 | { 153 | "condition": { 154 | "if": "lessThanOrEquals", 155 | "equals": "85" 156 | }, 157 | "color": "green" 158 | } 159 | ] 160 | }, 161 | "value": "% Used", 162 | "actions": null 163 | } 164 | } 165 | }, 166 | { 167 | "id": "mssql-db-vlfs.insight", 168 | "contrib": { 169 | "queryFile": "./sql/mssql-db-vlfs.sql", 170 | "type": { 171 | "bar": { 172 | "dataDirection": "horizontal", 173 | "dataType": "number", 174 | "legendPosition": "none", 175 | "labelFirstColumn": false, 176 | "columnsAsLabels": false 177 | } 178 | }, 179 | "details": { 180 | "queryFile": "./sql/mssql-db-vlfs-detail.sql", 181 | "label": { 182 | "icon": "database", 183 | "column": "DB Name", 184 | "state": [ 185 | { 186 | "condition": { 187 | "if": "greaterThanOrEquals", 188 | "equals": "10000" 189 | }, 190 | "color": "red" 191 | }, 192 | { 193 | "condition": { 194 | "if": "greaterThan", 195 | "equals": "1000" 196 | }, 197 | "color": "orange" 198 | }, 199 | { 200 | "condition": { 201 | "if": "lessThanOrEquals", 202 | "equals": "1000" 203 | }, 204 | "color": "green" 205 | } 206 | ] 207 | }, 208 | "value": "Total VLFs", 209 | "actions": null 210 | } 211 | } 212 | }, 213 | { 214 | "id": "mssql-db-sessionschart.insight", 215 | "contrib": { 216 | "queryFile": "./sql/mssql-db-sessions.sql", 217 | "autoRefreshInterval": 1, 218 | "type": { 219 | "bar": { 220 | "dataDirection": "vertical", 221 | "dataType": "number", 222 | "legendPosition": "none", 223 | "labelFirstColumn": false, 224 | "columnsAsLabels": false, 225 | "yAxisLabel": "Sessions", 226 | "xAxisLabel": "Status" 227 | } 228 | }, 229 | "details": { 230 | "queryFile": "./sql/mssql-db-sessions-detail.sql", 231 | "label": { 232 | "icon": "database", 233 | "column": "Session Id", 234 | "state": [ 235 | { 236 | "condition": { 237 | "if": "equals", 238 | "equals": "suspended" 239 | }, 240 | "color": "red" 241 | }, 242 | { 243 | "condition": { 244 | "if": "equals", 245 | "equals": "runnable" 246 | }, 247 | "color": "orange" 248 | }, 249 | { 250 | "condition": { 251 | "if": "equals", 252 | "equals": "sleeping" 253 | }, 254 | "color": "black" 255 | }, 256 | { 257 | "condition": { 258 | "if": "equals", 259 | "equals": "running" 260 | }, 261 | "color": "green" 262 | } 263 | ] 264 | }, 265 | "value": "Status", 266 | "actions": null 267 | } 268 | } 269 | }, 270 | { 271 | "id": "mssql-db-cpumemdisk.insight", 272 | "contrib": { 273 | "queryFile": "./sql/mssql-db-cpumemdisk.sql", 274 | "autoRefreshInterval": 1, 275 | "type": { 276 | "bar": { 277 | "dataDirection": "vertical", 278 | "dataType": "number", 279 | "legendPosition": "bottom", 280 | "labelFirstColumn": false, 281 | "columnsAsLabels": true, 282 | "yAxisLabel": "Resource Consumption", 283 | "xAxisLabel": "Session Status and Resource" 284 | } 285 | }, 286 | "details": { 287 | "queryFile": "./sql/mssql-db-sessions-detail.sql", 288 | "label": { 289 | "icon": "database", 290 | "column": "Session Id", 291 | "state": [ 292 | { 293 | "condition": { 294 | "if": "equals", 295 | "equals": "suspended" 296 | }, 297 | "color": "red" 298 | }, 299 | { 300 | "condition": { 301 | "if": "equals", 302 | "equals": "runnable" 303 | }, 304 | "color": "orange" 305 | }, 306 | { 307 | "condition": { 308 | "if": "equals", 309 | "equals": "sleeping" 310 | }, 311 | "color": "black" 312 | }, 313 | { 314 | "condition": { 315 | "if": "equals", 316 | "equals": "running" 317 | }, 318 | "color": "green" 319 | } 320 | ] 321 | }, 322 | "value": "Status", 323 | "actions": null 324 | } 325 | } 326 | } 327 | ] 328 | , 329 | "dashboard.containers": [ 330 | { 331 | "id": "dbactivity-container", 332 | "container": { 333 | "widgets-container": [ 334 | { 335 | "name": "Database Sessions", 336 | "gridItemConfig": { 337 | "sizex": 2, 338 | "sizey": 1 339 | }, 340 | "widget": { 341 | "mssql-db-sessionschart.insight": {} 342 | } 343 | }, 344 | { 345 | "name": "Database Resource Usage", 346 | "gridItemConfig": { 347 | "sizex": 2, 348 | "sizey": 1 349 | }, 350 | "widget": { 351 | "mssql-db-cpumemdisk.insight": {} 352 | } 353 | } 354 | ] 355 | } 356 | }, 357 | { 358 | "id": "dbhealth-container", 359 | "container": { 360 | "widgets-container": [ 361 | { 362 | "name": "Database Space Used", 363 | "gridItemConfig": { 364 | "sizex": 1, 365 | "sizey": 1 366 | }, 367 | "widget": { 368 | "mssql-db-spaceused.insight": {} 369 | } 370 | }, 371 | { 372 | "name": "Database Space Used (File Type)", 373 | "gridItemConfig": { 374 | "sizex": 1, 375 | "sizey": 1 376 | }, 377 | "widget": { 378 | "mssql-db-spaceused-filetype.insight": {} 379 | } 380 | }, 381 | { 382 | "name": "Database VLFs", 383 | "gridItemConfig": { 384 | "sizex": 1, 385 | "sizey": 1 386 | }, 387 | "widget": { 388 | "mssql-db-vlfs.insight": {} 389 | } 390 | } 391 | ] 392 | } 393 | } 394 | ] 395 | } 396 | } -------------------------------------------------------------------------------- /src/sql/mssql-db-CpuMemDisk.sql: -------------------------------------------------------------------------------- 1 | -- 2 | -- Author: Matticusau 3 | -- Purpose: Provides insights into session resource usage in the current database 4 | -- License: https://github.com/Matticusau/sqlops-mssql-db-insights/blob/master/LICENSE 5 | -- 6 | -- When Who What 7 | -- 2018-06-27 Matticusau Friendly column names 8 | -- 9 | 10 | SELECT er.[status] 11 | , SUM(er.[cpu_time]) [CPU] 12 | , SUM(er.[reads]) [Reads] 13 | , SUM(er.[logical_reads]) [Logical Reads] 14 | , SUM(er.[writes]) [Writes] 15 | FROM [sys].[dm_exec_requests] er 16 | WHERE er.[database_id] = DB_ID() 17 | GROUP BY er.[status] 18 | ORDER BY SUM(er.[cpu_time]) DESC, er.[status] 19 | -------------------------------------------------------------------------------- /src/sql/mssql-db-sessions-detail.sql: -------------------------------------------------------------------------------- 1 | -- 2 | -- Author: Matticusau 3 | -- Purpose: Provides insights into open sessions in the current database 4 | -- License: https://github.com/Matticusau/sqlops-mssql-db-insights/blob/master/LICENSE 5 | -- 6 | -- When Who What 7 | -- 2018-06-27 Matticusau Friendly column names 8 | -- 9 | 10 | SELECT es.[session_id] [Session Id] 11 | , es.[status] [Status] 12 | , es.[login_name] [Login Name] 13 | , es.[login_time] [Login Time] 14 | , es.[host_name] [Host Name] 15 | , es.[program_name] [Program Name] 16 | , es.[client_interface_name] [Client Interface Name] 17 | , es.[cpu_time] [CPU Time] 18 | , es.[memory_usage] [Memory Usage] 19 | , es.[reads] [Reads] 20 | , es.[writes] [Writes] 21 | , es.[logical_reads] [Logical Reads] 22 | , es.[last_request_start_time] [Last Request Start Time] 23 | , es.[last_request_end_time] [Last Request End Time] 24 | , es.[total_elapsed_time] [Total Elapsed Time] 25 | , es.[open_transaction_count] [Open Transaction Count] 26 | FROM [sys].[dm_exec_sessions] es 27 | WHERE es.[database_id] = DB_ID() 28 | ORDER BY es.[session_id] 29 | -------------------------------------------------------------------------------- /src/sql/mssql-db-sessions.sql: -------------------------------------------------------------------------------- 1 | -- 2 | -- Author: Matticusau 3 | -- Purpose: Provides insights into open sessions in the current database 4 | -- License: https://github.com/Matticusau/sqlops-mssql-db-insights/blob/master/LICENSE 5 | -- 6 | -- When Who What 7 | -- 2018-06-27 Matticusau Friendly column names 8 | -- 9 | 10 | SELECT es.[status] [Status] 11 | , COUNT(es.[session_id]) [Count] 12 | FROM [sys].[dm_exec_sessions] es 13 | WHERE es.[database_id] = DB_ID() 14 | GROUP BY es.[status] 15 | ORDER BY es.[status] 16 | -------------------------------------------------------------------------------- /src/sql/mssql-db-spaceused-detail.sql: -------------------------------------------------------------------------------- 1 | -- 2 | -- Author: Matticusau 3 | -- Purpose: Provides detailed data for the DB Space Used Insights Widget 4 | -- License: https://github.com/Matticusau/sqlops-mssql-db-insights/blob/master/LICENSE 5 | -- 6 | -- When Who What 7 | -- 2018-06-27 Matticusau Friendly column names 8 | -- 9 | SELECT file_id [File Id] 10 | , name [Logical Name] 11 | , type_desc [Type] 12 | , physical_name [Physical Name] 13 | , CONVERT(decimal(18,2), size/128.0) [File Size Mb] 14 | , CONVERT(decimal(18,2), max_size/128.0) [Max Growth Size Mb] 15 | , CONVERT(decimal(18,2), FILEPROPERTY(name, 'SpaceUsed')/128.0) [Used Mb] 16 | , CONVERT(decimal(18,2), size/128.0) - CONVERT(decimal(18,2), FILEPROPERTY(name,'SpaceUsed')/128.0) AS [Free Mb] 17 | , CONVERT(decimal(18,2), (FILEPROPERTY(name, 'SpaceUsed')/128.0) / (size/128.0) * 100) [% Used] 18 | , 100 - CONVERT(decimal(18,2), (FILEPROPERTY(name, 'SpaceUsed')/128.0) / (size/128.0) * 100) AS [% Free] 19 | FROM sys.database_files 20 | ORDER BY type_desc 21 | , file_id -------------------------------------------------------------------------------- /src/sql/mssql-db-spaceused-filetype.sql: -------------------------------------------------------------------------------- 1 | -- 2 | -- Author: Matticusau 3 | -- Purpose: Provides summary data for the DB Space Used Insights Widget 4 | -- License: https://github.com/Matticusau/sqlops-mssql-db-insights/blob/master/LICENSE 5 | -- 6 | -- When Who What 7 | -- 2018-06-27 Matticusau Friendly column names 8 | -- 9 | SELECT type_desc 10 | -- , CONVERT(decimal(18,2), SUM(size)/128.0) [file_size_mb] 11 | -- , CONVERT(decimal(18,2), SUM(max_size)/128.0) [max_growth_size_mb] 12 | -- , CONVERT(decimal(18,2), SUM(FILEPROPERTY(name, 'SpaceUsed'))/128.0) [used_space_mb] 13 | -- , CONVERT(decimal(18,2), SUM(size)/128.0) - CONVERT(decimal(18,2), SUM(FILEPROPERTY(name,'SpaceUsed'))/128.0) AS [free_space_mb] 14 | , CONVERT(decimal(18,2), (SUM(FILEPROPERTY(name, 'SpaceUsed'))/128.0) / (SUM(size)/128.0) * 100) [% Used] 15 | , 100 - CONVERT(decimal(18,2), (SUM(FILEPROPERTY(name, 'SpaceUsed'))/128.0) / (SUM(size)/128.0) * 100) AS [% Free] 16 | FROM sys.database_files 17 | WHERE type_desc IN ('ROWS','LOG') 18 | GROUP BY type_desc 19 | ORDER BY type_desc -------------------------------------------------------------------------------- /src/sql/mssql-db-spaceused.sql: -------------------------------------------------------------------------------- 1 | -- 2 | -- Author: Matticusau 3 | -- Purpose: Provides summary data for the DB Space Used Insights Widget 4 | -- License: https://github.com/Matticusau/sqlops-mssql-db-insights/blob/master/LICENSE 5 | -- 6 | -- When Who What 7 | -- 2018-06-27 Matticusau Friendly column names 8 | -- 9 | SELECT 10 | -- CONVERT(decimal(18,2), SUM(size)/128.0) [file_size_mb] , 11 | -- CONVERT(decimal(18,2), SUM(max_size)/128.0) [max_growth_size_mb] , 12 | -- CONVERT(decimal(18,2), SUM(FILEPROPERTY(name, 'SpaceUsed'))/128.0) [used_space_mb] , 13 | -- CONVERT(decimal(18,2), SUM(size)/128.0) - CONVERT(decimal(18,2), SUM(FILEPROPERTY(name,'SpaceUsed'))/128.0) AS [free_space_mb] , 14 | CONVERT(decimal(18,2), (SUM(FILEPROPERTY(name, 'SpaceUsed'))/128.0) / (SUM(size)/128.0) * 100) [% Used], 15 | 100 - CONVERT(decimal(18,2), (SUM(FILEPROPERTY(name, 'SpaceUsed'))/128.0) / (SUM(size)/128.0) * 100) AS [% Free] 16 | FROM sys.database_files 17 | WHERE type_desc IN ('ROWS','LOG') -------------------------------------------------------------------------------- /src/sql/mssql-db-vlfs-detail.sql: -------------------------------------------------------------------------------- 1 | -- 2 | -- Author: Matticusau 3 | -- Purpose: Provides insights into all VLFs in the current database 4 | -- License: https://github.com/Matticusau/sqlops-mssql-db-insights/blob/master/LICENSE 5 | -- Original script: https://github.com/Microsoft/DataInsightsAsia/blob/Dev/Scripts/VLFs/VLFsReport.sql 6 | -- 7 | -- When Who What 8 | -- 2018-06-27 Matticusau Friendly column names 9 | -- 10 | 11 | -- check if we are running on Azure PaaS 12 | DECLARE @isAzurePaaS BIT; 13 | IF ((SELECT @@Version) LIKE 'Microsoft SQL Azure%') 14 | SET @isAzurePaaS = 1; 15 | ELSE 16 | SET @isAzurePaaS = 0; 17 | 18 | 19 | IF (@isAzurePaaS = 0) 20 | BEGIN 21 | 22 | SET NOCOUNT ON; 23 | 24 | -- declare variables required 25 | DECLARE @majorVer SMALLINT, @minorVer SMALLINT, @build SMALLINT 26 | DECLARE @DatabaseId INT; 27 | DECLARE @TSQL varchar(MAX); 28 | DECLARE cur_DBs CURSOR FOR 29 | SELECT database_id 30 | FROM sys.databases 31 | --WHERE name NOT IN (N'master',N'model',N'msdb',N'tempdb'); 32 | WHERE database_id = DB_ID(); -- filter to just the current 33 | OPEN cur_DBs; 34 | FETCH NEXT FROM cur_DBs INTO @DatabaseId 35 | 36 | -- Get the version 37 | SELECT @majorVer = (@@microsoftversion / 0x1000000) & 0xff, @minorVer = (@@microsoftversion / 0x10000) & 0xff, @build = @@microsoftversion & 0xffff 38 | 39 | -- These table variables will be used to store the data 40 | DECLARE @tblAllDBs Table (DBName sysname 41 | , FileId INT 42 | , FileSize BIGINT 43 | , StartOffset BIGINT 44 | , FSeqNo INT 45 | , Status TinyInt 46 | , Parity INT 47 | , CreateLSN NUMERIC(25,0) 48 | ) 49 | IF ( @majorVer >= 11 ) 50 | BEGIN 51 | DECLARE @tblVLFs2012 Table (RecoveryUnitId BIGINT 52 | , FileId INT 53 | , FileSize BIGINT 54 | , StartOffset BIGINT 55 | , FSeqNo INT 56 | , Status TinyInt 57 | , Parity INT 58 | , CreateLSN NUMERIC(25,0) 59 | ); 60 | END 61 | ELSE 62 | BEGIN 63 | DECLARE @tblVLFs Table ( 64 | FileId INT 65 | , FileSize BIGINT 66 | , StartOffset BIGINT 67 | , FSeqNo INT 68 | , Status TinyInt 69 | , Parity INT 70 | , CreateLSN NUMERIC(25,0) 71 | ); 72 | END 73 | 74 | --loop through each database and get the info 75 | WHILE @@FETCH_STATUS = 0 76 | BEGIN 77 | 78 | PRINT 'DB: ' + CONVERT(varchar(200), DB_NAME(@DatabaseId)); 79 | SET @TSQL = 'dbcc loginfo('+CONVERT(varchar(12), @DatabaseId)+');'; 80 | 81 | IF ( @majorVer >= 11 ) 82 | BEGIN 83 | DELETE FROM @tblVLFs2012; 84 | INSERT INTO @tblVLFs2012 85 | EXEC(@TSQL); 86 | INSERT INTO @tblAllDBs 87 | SELECT DB_NAME(@DatabaseId) 88 | , FileId 89 | , FileSize 90 | , StartOffset 91 | , FSeqNo 92 | , Status 93 | , Parity 94 | , CreateLSN 95 | FROM @tblVLFs2012; 96 | END 97 | ELSE 98 | BEGIN 99 | DELETE FROM @tblVLFs; 100 | INSERT INTO @tblVLFs 101 | EXEC(@TSQL); 102 | INSERT INTO @tblAllDBs 103 | SELECT DB_NAME(@DatabaseId) 104 | , FileId 105 | , FileSize 106 | , StartOffset 107 | , FSeqNo 108 | , Status 109 | , Parity 110 | , CreateLSN 111 | FROM @tblVLFs; 112 | END 113 | 114 | FETCH NEXT FROM cur_DBs INTO @DatabaseId 115 | END 116 | CLOSE cur_DBs; 117 | DEALLOCATE cur_DBs; 118 | 119 | --just for formating if output to Text 120 | PRINT ''; 121 | PRINT ''; 122 | PRINT ''; 123 | 124 | --Return the data based on what we have found 125 | SELECT a.DBName AS [DB Name] 126 | , COUNT(a.FileId) AS [Total VLFs] 127 | , MAX(b.[ActiveVLFs]) AS [Active VLFs] 128 | , (SUM(a.FileSize) / COUNT(a.FileId) / 1024) AS [Avg File Size Kb] 129 | FROM @tblAllDBs a 130 | INNER JOIN ( 131 | SELECT DBName 132 | , COUNT(FileId) [ActiveVLFs] 133 | FROM @tblAllDBs 134 | WHERE Status = 2 135 | GROUP BY DBName 136 | ) b 137 | ON b.DBName = a.DBName 138 | GROUP BY a.DBName 139 | ORDER BY COUNT(a.FileId) DESC; 140 | 141 | 142 | SET NOCOUNT OFF; 143 | 144 | END 145 | ELSE 146 | BEGIN 147 | -- not supported on Azure so return an empty recordset 148 | SELECT 'NotSupportedOnAzure' AS [DB Name] 149 | , 0 AS [Total VLFs] 150 | , 0 AS [Active VLFs] 151 | , 0 AS [Avg File Size Kb] 152 | END -------------------------------------------------------------------------------- /src/sql/mssql-db-vlfs.sql: -------------------------------------------------------------------------------- 1 | -- 2 | -- Author: Matticusau 3 | -- Purpose: Provides insights into all VLFs in the current database 4 | -- License: https://github.com/Matticusau/sqlops-mssql-db-insights/blob/master/LICENSE 5 | -- Original script: https://github.com/Microsoft/DataInsightsAsia/blob/Dev/Scripts/VLFs/VLFsReport.sql 6 | -- 7 | -- When Who What 8 | -- 2018-06-27 Matticusau Friendly column names 9 | -- 10 | 11 | -- check if we are running on Azure PaaS 12 | DECLARE @isAzurePaaS BIT; 13 | IF ((SELECT @@Version) LIKE 'Microsoft SQL Azure%') 14 | SET @isAzurePaaS = 1; 15 | ELSE 16 | SET @isAzurePaaS = 0; 17 | 18 | 19 | IF (@isAzurePaaS = 0) 20 | BEGIN 21 | 22 | SET NOCOUNT ON; 23 | 24 | -- declare variables required 25 | DECLARE @majorVer SMALLINT, @minorVer SMALLINT, @build SMALLINT 26 | DECLARE @DatabaseId INT; 27 | DECLARE @TSQL varchar(MAX); 28 | DECLARE cur_DBs CURSOR FOR 29 | SELECT database_id 30 | FROM sys.databases 31 | --WHERE name NOT IN (N'master',N'model',N'msdb',N'tempdb'); 32 | WHERE database_id = DB_ID(); -- filter to just the current 33 | OPEN cur_DBs; 34 | FETCH NEXT FROM cur_DBs INTO @DatabaseId 35 | 36 | -- Get the version 37 | SELECT @majorVer = (@@microsoftversion / 0x1000000) & 0xff, @minorVer = (@@microsoftversion / 0x10000) & 0xff, @build = @@microsoftversion & 0xffff 38 | 39 | -- These table variables will be used to store the data 40 | DECLARE @tblAllDBs Table (DBName sysname 41 | , FileId INT 42 | , FileSize BIGINT 43 | , StartOffset BIGINT 44 | , FSeqNo INT 45 | , Status TinyInt 46 | , Parity INT 47 | , CreateLSN NUMERIC(25,0) 48 | ) 49 | IF ( @majorVer >= 11 ) 50 | BEGIN 51 | DECLARE @tblVLFs2012 Table (RecoveryUnitId BIGINT 52 | , FileId INT 53 | , FileSize BIGINT 54 | , StartOffset BIGINT 55 | , FSeqNo INT 56 | , Status TinyInt 57 | , Parity INT 58 | , CreateLSN NUMERIC(25,0) 59 | ); 60 | END 61 | ELSE 62 | BEGIN 63 | DECLARE @tblVLFs Table ( 64 | FileId INT 65 | , FileSize BIGINT 66 | , StartOffset BIGINT 67 | , FSeqNo INT 68 | , Status TinyInt 69 | , Parity INT 70 | , CreateLSN NUMERIC(25,0) 71 | ); 72 | END 73 | 74 | --loop through each database and get the info 75 | WHILE @@FETCH_STATUS = 0 76 | BEGIN 77 | 78 | PRINT 'DB: ' + CONVERT(varchar(200), DB_NAME(@DatabaseId)); 79 | SET @TSQL = 'dbcc loginfo('+CONVERT(varchar(12), @DatabaseId)+');'; 80 | 81 | IF ( @majorVer >= 11 ) 82 | BEGIN 83 | DELETE FROM @tblVLFs2012; 84 | INSERT INTO @tblVLFs2012 85 | EXEC(@TSQL); 86 | INSERT INTO @tblAllDBs 87 | SELECT DB_NAME(@DatabaseId) 88 | , FileId 89 | , FileSize 90 | , StartOffset 91 | , FSeqNo 92 | , Status 93 | , Parity 94 | , CreateLSN 95 | FROM @tblVLFs2012; 96 | END 97 | ELSE 98 | BEGIN 99 | DELETE FROM @tblVLFs; 100 | INSERT INTO @tblVLFs 101 | EXEC(@TSQL); 102 | INSERT INTO @tblAllDBs 103 | SELECT DB_NAME(@DatabaseId) 104 | , FileId 105 | , FileSize 106 | , StartOffset 107 | , FSeqNo 108 | , Status 109 | , Parity 110 | , CreateLSN 111 | FROM @tblVLFs; 112 | END 113 | 114 | FETCH NEXT FROM cur_DBs INTO @DatabaseId 115 | END 116 | CLOSE cur_DBs; 117 | DEALLOCATE cur_DBs; 118 | 119 | --just for formating if output to Text 120 | PRINT ''; 121 | PRINT ''; 122 | PRINT ''; 123 | 124 | --Return the data based on what we have found 125 | SELECT --a.DBName 126 | --, 127 | COUNT(a.FileId) AS [Total VLFs] 128 | , MAX(b.[ActiveVLFs]) AS [Active VLFs] 129 | --, (SUM(a.FileSize) / COUNT(a.FileId) / 1024) AS [Avg File Size Kb] 130 | FROM @tblAllDBs a 131 | INNER JOIN ( 132 | SELECT DBName 133 | , COUNT(FileId) [ActiveVLFs] 134 | FROM @tblAllDBs 135 | WHERE Status = 2 136 | GROUP BY DBName 137 | ) b 138 | ON b.DBName = a.DBName 139 | GROUP BY a.DBName 140 | ORDER BY COUNT(a.FileId) DESC; 141 | 142 | 143 | SET NOCOUNT OFF; 144 | 145 | END 146 | ELSE 147 | BEGIN 148 | -- not supported on Azure so return an empty recordset 149 | SELECT --'NotSupportedOnAzure' AS [DBName] 150 | --, 151 | 0 AS [Total VLFs] 152 | , 0 AS [Active VLFs] 153 | --, 0 AS [AvgFileSizeKb] 154 | END -------------------------------------------------------------------------------- /src/sql/mssql-db-waits-detail.sql: -------------------------------------------------------------------------------- 1 | -- 2 | -- Author: Matticusau 3 | -- Purpose: Provides insights into WAITING sessions in the current database 4 | -- License: https://github.com/Matticusau/sqlops-mssql-db-insights/blob/master/LICENSE 5 | -- 6 | -- When Who What 7 | -- 2018-06-27 Matticusau Friendly column names 8 | -- 9 | 10 | SELECT er.[session_id] [Session Id] 11 | , er.[wait_type] [Wait Type] 12 | , er.[wait_time] [Wait Time] 13 | FROM [sys].[dm_exec_requests] er 14 | WHERE er.[database_id] = DB_ID() 15 | GROUP BY er.[wait_type] 16 | HAVING er.[wait_type] <> 'NULL' 17 | ORDER BY er.[wait_time] DESC 18 | , er.[wait_type] 19 | -------------------------------------------------------------------------------- /src/sql/mssql-db-waits.sql: -------------------------------------------------------------------------------- 1 | -- 2 | -- Author: Matticusau 3 | -- Purpose: Provides insights into WAITING sessions in the current database 4 | -- License: https://github.com/Matticusau/sqlops-mssql-db-insights/blob/master/LICENSE 5 | -- 6 | -- When Who What 7 | -- 2018-06-27 Matticusau Friendly column names 8 | -- 9 | 10 | SELECT er.[wait_type] [Wait Type] 11 | , SUM(er.[wait_time]) [Wait Time] 12 | FROM [sys].[dm_exec_requests] er 13 | WHERE er.[database_id] = DB_ID() 14 | GROUP BY er.[wait_type] 15 | HAVING er.[wait_type] <> 'NULL' 16 | ORDER BY SUM(er.[wait_time]) DESC, er.[wait_type] 17 | 18 | -------------------------------------------------------------------------------- /vsc-extension-quickstart.md: -------------------------------------------------------------------------------- 1 | # Welcome to your SQL Operations Studio Extension 2 | 3 | ## What's in the folder 4 | * This folder contains all of the files necessary for your dashboard insight extension. 5 | * `package.json` - this is the manifest file that defines the list of insights and new dashboard tabs for the extension. Open this in SQL Operations Studio and edit the `contributes` section to add new features. 6 | * `dashboard.insights` section is where your insight definition is added. This is a bar chart insight by default. You can add additional insights here 7 | * `dashboard.tabs` section is where you register a new "tab" or area in the dashboard for your extension, and include your new insight. If you select `No` for the `Add a full dashboard tab?` question this will not be added, and instead you can use the insight in other tabs / in the home tab. 8 | * `sql/query.sql` - this is the file your first insight widget query should be added to. 9 | 10 | 11 | ## Get up and running straight away 12 | * Press `F5` to open a new window with your extension loaded. 13 | * Press `Ctrl + .` instead of `Ctrl + Shift + P` 14 | * Verify that it will launch the Command Palette listing all available commands. The `Ctrl + .` keyboard shortcut was added as an example to you. 15 | 16 | ## Make changes 17 | * You can relaunch the extension from the debug toolbar after making changes to the files listed above. 18 | * You can also reload (`Ctrl+R` or `Cmd+R` on Mac) the SQL Operations Studio window with your extension to load your changes. 19 | 20 | ## Install your extension 21 | * To start using your extension with SQL Operations Studio copy it into the `/.sqlops/extensions` folder and restart SqlOps. 22 | * To share your extension with the world, read on https://github.com/microsoft/sqlopsstudio/wiki/Getting-started-with-Extensibility about publishing an extension. 23 | --------------------------------------------------------------------------------