Repository: microsoft/Azure_Synapse_Toolbox Branch: master Commit: af39147d2449 Files: 156 Total size: 2.5 MB Directory structure: gitextract_s92epeuo/ ├── .gitignore ├── Archive/ │ └── Tools/ │ └── GetObjectsFromExplain.ps1 ├── Azure_Resource_Graph_Queries/ │ ├── Inventory-DedicatedSqlPool.kql │ ├── Inventory-SparkPools.kql │ └── README.md ├── Distribution_Advisor/ │ ├── CreateDistributionAdvisor_PublicPreview.sql │ ├── README.md │ ├── RunDistributionAdvisor.sql │ └── e2e_queries_used_for_recommendations.sql ├── LICENSE ├── Log_Analytics_queries/ │ ├── Pipelines/ │ │ ├── CompletedPipelineDurationInSeconds.kql │ │ └── TopNLongestRunningPipelines.kql │ ├── ServerlessSql/ │ │ ├── CostPerQuery.txt │ │ ├── CostPerQuery.txt.bak │ │ ├── CostPerUser.txt │ │ └── CostPerUser.txt.bak │ ├── Spark/ │ │ └── CoresAndMemoryByApplication.kql │ ├── StandaloneSQLPool/ │ │ ├── CreateAnAzureSynapseDashboard.docx │ │ ├── DedicatedSqlPoolUsage.kql │ │ ├── LargestBroadcastSteps.kql │ │ ├── LargestDataMovementSteps.kql │ │ ├── LogAnalyticsBasicQueries.sql │ │ ├── LongestBuildReplicatedTableCache │ │ ├── MostReplicatedTableRebuilds.txt │ │ ├── QueriesByExecutionTime.kql │ │ ├── RepTableBuildCacheExecutionCount │ │ ├── RowsProcessedPerHour │ │ ├── SingletonInserts.kql │ │ ├── TempTablesNotCreatedAsHeap.kql │ │ └── UnionVsUnionAll.kql │ └── WorkspacesSQLPool/ │ ├── FindLargeBroadcasts.kql │ ├── IdentifySingletonInserts.kql │ ├── LongestRunningQueriesByExecutionTime.kql │ ├── QueriesWithResourceGrant.kql │ ├── QueryList_withResultSetCacheData.kql │ ├── TempTableASHeap.kql │ └── UnionVsUnionAll.kql ├── Monitor_Workbooks/ │ ├── DW_Summary_v1.1.workbook │ ├── DedicatedSQLPool_workspace_v1.2.workbook │ ├── DedicatedSqlPool_Non-Workspace_v1.4.workbook │ ├── README.md │ ├── SynapsePipelines_v1.1.workbook │ ├── SynapseServerlessWorkbook.workbook │ └── archive/ │ ├── DW_Summary.workbook.bak │ ├── DedicatedSQLPool_workspace_v1.0.workbook │ ├── DedicatedSQLPool_workspace_v1.1.workbook │ ├── DedicatedSQLPool_workspace_v1.1.workbook.bak │ ├── DedicatedSqlPool_Non-Workspace_v1.32.workbook │ ├── StandaloneSqlPoolWorkbook_v1.31.json │ ├── SynapsePipelines.workbook │ ├── SynapsePipelines.workbook.bak │ ├── SynapsePipelines_v1.1.workbook.bak │ ├── SynapseServerlessWorkbook.workbook │ ├── SynapseServerlessWorkbook.workbook.bak │ ├── SynapseWorkbook_WIP_v01.json │ ├── SynapseWorkbook_WIP_v02.json │ ├── SynapseWorkbook_v1.00.json │ ├── SynapseWorkbook_v1.01.json │ ├── SynapseWorkbook_v1.1.json │ ├── SynapseWorkbook_v1.3.json │ ├── WorkspaceSQLPoolWorkbook_WIP_v0.60.JSON │ ├── WorkspaceSQLPoolWorkbook_WIP_v0.73.JSON │ └── WorkspaceSQLPoolWorkbook_WIP_v0.77.JSON ├── PowerBI/ │ ├── README.md │ └── Templates/ │ ├── AzureSynapse_DbHealth_08_21_20.pbit │ ├── AzureSynapse_Permissions_07172020.pbit │ └── AzureSynapse_Realtime_07172020.pbit ├── README.md ├── SECURITY.md ├── Synapse_Analyzer/ │ ├── README.md │ └── Synapse_BPA_Report/ │ ├── ArchivedVersions/ │ │ ├── README.md │ │ └── Synapse best practice analyzer_v1.0.pbit │ ├── ForLargeDBwithCTAS/ │ │ ├── CreateTablesForSynapseAnalyzer.sql │ │ ├── README.md │ │ └── Synapse best practice analyzer_with_CTAS.pbit │ ├── InstallationGuide.md │ ├── PublishToPowerBIService.md │ ├── README.md │ ├── Synapse best practice analyzer.pbit │ ├── TroubleshootingGuide.md │ └── UpdatestoSynapseAnalyzerReport.md ├── Synapse_Toolkit/ │ ├── README.md │ ├── SynapseToolkit.sql │ ├── SynapseToolkit_beta.sql │ └── SynapseToolkit_beta.sql.bak └── TSQL_Queries/ ├── Current_Activity/ │ ├── CollectNodeMemoryUsage.sql │ ├── CountGrantedConcurrencySlots.sql │ ├── DMSHeavyHitters.sql │ ├── IdentifyBlocking1.sql │ ├── IdentifyBlocking2.sql │ ├── IdentifyResourceWaits.sql │ ├── MemoryGrantPerDistribution.sql │ ├── QueuedQueryTime.sql │ ├── RecentQueries.sql │ ├── ResourceWaitConsumptionByQuery.sql │ └── UsedConcurrencySlotsInfo.sql ├── Delta Lake/ │ ├── README.md │ └── delta.sql ├── Identity_Columns/ │ └── IdentityColumns.sql ├── Indexes/ │ ├── CCIHealthByTable.sql │ ├── CCIHealthWithTrimReasons │ ├── CCITrimReason_BETA.sql │ ├── CreateRowgroupHealthView.sql │ ├── ReorgOrRebuildColumnstoreByPartition_All.sql │ └── ReorgOrRebuildColumnstore_LatestPartitionsOnly.sql ├── Partitions/ │ ├── GetPartitionColumn.sql │ ├── MaxPartitionWithData.sql │ └── RowsPerPartition.sql ├── Permissions/ │ └── All_Database_Permissions.sql ├── Query_Store/ │ ├── GetApproxTimeRemaining_QueryStore.sql │ ├── GetFullQueryText.sql │ ├── GetQueriesWithBiggestIOReads.sql │ ├── GetQueriesWithMultiplePlans.sql │ ├── GetQueryExecutionTime.sql │ ├── GetQueryStoreSpaceUsage.sql │ ├── GetQueryStoreState.sql │ ├── GetRecentlyRegressedQueries.sql │ ├── GetTopQueriesByExecutionCount.sql │ ├── GetTopQueriesByExecutionTime.sql │ ├── PerfRegressionPlanChoiceChange.sql │ └── QueriesWithPerfRegression.sql ├── Replicated_Tables/ │ └── RepTablesRebuildNeeded.sql ├── SLO-DWU/ │ ├── ChangeDwuSetting.sql │ ├── CheckDwuChangeStatus.sql │ ├── CreateColumnstoreDensityView.sql │ └── GetDwuSetting.sql ├── ServerlessSql/ │ └── CostPerQuery.sql ├── Statistics/ │ ├── CheckAutoStatsEnabled.sql │ ├── CreateSP_CreateStatsAllColumnsAllTables.sql │ ├── CreateSP_GenUpdateStatsStatements.sql │ ├── CreateStatsAllColumnsAllTables.sql │ ├── GetStatsLastUpdateDate.sql │ ├── ListAllStats.sql │ ├── ListAllStats.sql.bak │ └── StatisticsAccuracy.sql ├── Table_Information/ │ ├── CollectTableInformation.sql │ ├── CreateTableInfoView.sql │ ├── DataTypeMismatch.sql │ ├── DistributionSpaceSummary.sql │ ├── FindNullableDistColumns.sql │ ├── GenerateTableSchemas.sql │ ├── IdentifyLargeDataTypes.sql │ ├── MostUsedTables_BETA.sql │ ├── TableSizeByDistType.sql │ ├── TableSizeByIndexType.sql │ ├── TableSizeSummary.sql │ ├── TableSkew.sql │ ├── TableUsageInformation.sql │ └── TablesWithMostLargeTypes.sql ├── TempDB/ │ ├── TempDbPerNode.sql │ ├── TempDbPerQuery.sql │ └── TotalTempDbUsage.sql ├── Workarounds/ │ └── RecursionWorkaround_HierarchicalTableSample.sql └── Workload_Management/ ├── CurrentRoleByUser.sql ├── ViewWorkloadGroups.sql └── WorkloadManagementMappingsAndUsage.sql ================================================ FILE CONTENTS ================================================ ================================================ FILE: .gitignore ================================================ ## Ignore Visual Studio temporary files, build results, and ## files generated by popular Visual Studio add-ons. ## ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore # User-specific files *.suo *.user *.userosscache *.sln.docstates # User-specific files (MonoDevelop/Xamarin Studio) *.userprefs # Build results [Dd]ebug/ [Dd]ebugPublic/ [Rr]elease/ [Rr]eleases/ x64/ x86/ bld/ [Bb]in/ [Oo]bj/ [Ll]og/ # Visual Studio 2015/2017 cache/options directory .vs/ # Uncomment if you have tasks that create the project's static files in wwwroot #wwwroot/ # Visual Studio 2017 auto generated files Generated\ Files/ # MSTest test Results [Tt]est[Rr]esult*/ [Bb]uild[Ll]og.* # NUNIT *.VisualState.xml TestResult.xml # Build Results of an ATL Project [Dd]ebugPS/ [Rr]eleasePS/ dlldata.c # Benchmark Results BenchmarkDotNet.Artifacts/ # .NET Core project.lock.json project.fragment.lock.json artifacts/ **/Properties/launchSettings.json # StyleCop StyleCopReport.xml # Files built by Visual Studio *_i.c *_p.c *_i.h *.ilk *.meta *.obj *.iobj *.pch *.pdb *.ipdb *.pgc *.pgd *.rsp *.sbr *.tlb *.tli *.tlh *.tmp *.tmp_proj *.log *.vspscc *.vssscc .builds *.pidb *.svclog *.scc # Chutzpah Test files _Chutzpah* # Visual C++ cache files ipch/ *.aps *.ncb *.opendb *.opensdf *.sdf *.cachefile *.VC.db *.VC.VC.opendb # Visual Studio profiler *.psess *.vsp *.vspx *.sap # Visual Studio Trace Files *.e2e # TFS 2012 Local Workspace $tf/ # Guidance Automation Toolkit *.gpState # ReSharper is a .NET coding add-in _ReSharper*/ *.[Rr]e[Ss]harper *.DotSettings.user # JustCode is a .NET coding add-in .JustCode # TeamCity is a build add-in _TeamCity* # DotCover is a Code Coverage Tool *.dotCover # AxoCover is a Code Coverage Tool .axoCover/* !.axoCover/settings.json # Visual Studio code coverage results *.coverage *.coveragexml # NCrunch _NCrunch_* .*crunch*.local.xml nCrunchTemp_* # MightyMoose *.mm.* AutoTest.Net/ # Web workbench (sass) .sass-cache/ # Installshield output folder [Ee]xpress/ # DocProject is a documentation generator add-in DocProject/buildhelp/ DocProject/Help/*.HxT DocProject/Help/*.HxC DocProject/Help/*.hhc DocProject/Help/*.hhk DocProject/Help/*.hhp DocProject/Help/Html2 DocProject/Help/html # Click-Once directory publish/ # Publish Web Output *.[Pp]ublish.xml *.azurePubxml # Note: Comment the next line if you want to checkin your web deploy settings, # but database connection strings (with potential passwords) will be unencrypted *.pubxml *.publishproj # Microsoft Azure Web App publish settings. Comment the next line if you want to # checkin your Azure Web App publish settings, but sensitive information contained # in these scripts will be unencrypted PublishScripts/ # NuGet Packages *.nupkg # The packages folder can be ignored because of Package Restore **/[Pp]ackages/* # except build/, which is used as an MSBuild target. !**/[Pp]ackages/build/ # Uncomment if necessary however generally it will be regenerated when needed #!**/[Pp]ackages/repositories.config # NuGet v3's project.json files produces more ignorable files *.nuget.props *.nuget.targets # Microsoft Azure Build Output csx/ *.build.csdef # Microsoft Azure Emulator ecf/ rcf/ # Windows Store app package directories and files AppPackages/ BundleArtifacts/ Package.StoreAssociation.xml _pkginfo.txt *.appx # Visual Studio cache files # files ending in .cache can be ignored *.[Cc]ache # but keep track of directories ending in .cache !*.[Cc]ache/ # Others ClientBin/ ~$* *~ *.dbmdl *.dbproj.schemaview *.jfm *.pfx *.publishsettings orleans.codegen.cs # Including strong name files can present a security risk # (https://github.com/github/gitignore/pull/2483#issue-259490424) #*.snk # Since there are multiple workflows, uncomment next line to ignore bower_components # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) #bower_components/ # RIA/Silverlight projects Generated_Code/ # Backup & report files from converting an old project file # to a newer Visual Studio version. Backup files are not needed, # because we have git ;-) _UpgradeReport_Files/ Backup*/ UpgradeLog*.XML UpgradeLog*.htm ServiceFabricBackup/ *.rptproj.bak # SQL Server files *.mdf *.ldf *.ndf # Business Intelligence projects *.rdl.data *.bim.layout *.bim_*.settings *.rptproj.rsuser # Microsoft Fakes FakesAssemblies/ # GhostDoc plugin setting file *.GhostDoc.xml # Node.js Tools for Visual Studio .ntvs_analysis.dat node_modules/ # Visual Studio 6 build log *.plg # Visual Studio 6 workspace options file *.opt # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) *.vbw # Visual Studio LightSwitch build output **/*.HTMLClient/GeneratedArtifacts **/*.DesktopClient/GeneratedArtifacts **/*.DesktopClient/ModelManifest.xml **/*.Server/GeneratedArtifacts **/*.Server/ModelManifest.xml _Pvt_Extensions # Paket dependency manager .paket/paket.exe paket-files/ # FAKE - F# Make .fake/ # JetBrains Rider .idea/ *.sln.iml # CodeRush .cr/ # Python Tools for Visual Studio (PTVS) __pycache__/ *.pyc # Cake - Uncomment if you are using it # tools/** # !tools/packages.config # Tabs Studio *.tss # Telerik's JustMock configuration file *.jmconfig # BizTalk build output *.btp.cs *.btm.cs *.odx.cs *.xsd.cs # OpenCover UI analysis results OpenCover/ # Azure Stream Analytics local run output ASALocalRun/ # MSBuild Binary and Structured Log *.binlog # NVidia Nsight GPU debugger configuration file *.nvuser # MFractors (Xamarin productivity tool) working folder .mfractor/ ================================================ FILE: Archive/Tools/GetObjectsFromExplain.ps1 ================================================ <# Get_Objects_From_Explain.ps1 Author: Nick.salch@Microsoft.com (Nicksalc) This tool will take in an explain XML, then detect all fo the following that are mentioned in the explain plan: Databases Tables Columns It will also output update stats statements for all tables invovled in the query. Output is placed under c:\temp\Timestamp_Folder #> param($ExplainXmlPath) If(!$ExplainXmlPath) { do { $ExplainXmlPath = Read-host "Please enter full path to XML" if (!(test-path $ExplainXmlPath)) { Write-host -foregroundcolor red -backgroundcolor black "path not found" }ELSE{$goodPath=$true} } while(!$goodPath) } $date = get-date -Format MMddyyyy_hhmmss $OutputFolder="C:\temp\$date\" mkdir $OutputFolder -Force | out-null $explainXml = Get-Content $ExplainXmlPath #Remove the user query part of the query (this part can be messy so I jsut remove it) $i=0 while (!($explainXml[$i] | select-string "total_number_operations=")) { $i++ } $explainXml = $explainXml[$i..$explainXml.Length] #Extract the db.schema.table names $objectList = $explainXml | Select-String "\[([^\[]*)\].\[([^\[]*)\].\[([^\[]*)\]" | select-string -NotMatch "qtabledb" |select-string -NotMatch "tempdb" | % {$_.matches.value} $objectList = $objectList | select -Unique $objectList > "$OutputFolder\ObjectList.txt" $tableList = $objectList | % {$_.split(".")[1] + "." + $_.split(".")[2]} #Extract Shuffle Columns $shuffleColumnLines = ($explainXml | select-string "shuffle_columns") $ShuffleColumns = @() Foreach ($column in $shuffleColumnLines) { $column = $column.ToString() $ShuffleColumns += $column.Substring($column.IndexOf(">")+1,$column.IndexOf(";")-$column.IndexOf(">")-1) } $ShuffleColumns = $ShuffleColumns | select -Unique |sort $ShuffleColumns > "$OutputFolder\ShuffleColumns.txt" #Extract the columns used $involvedColumns=@() Foreach ($string in (($explainXml | select-string " AND "," OR "," WHERE "," WHEN "," GROUP BY "," ELSE ") )) { $SplitString = $string -split "]\.\[" #$splitString.Count $counter = 1 While ($counter -lt $splitString.count) { if($splitString[$counter].indexOf("]") -gt 0) { $involvedColumns += $splitString[$counter].Substring(0,$splitString[$counter].indexOf("]")) } $counter++ } } $involvedColumns += $ShuffleColumns $involvedColumns = $involvedColumns | select -Unique | sort #Write-host -foregroundcolor Cyan "`nInvolved Columns`n" $involvedColumns > "$OutputFolder\involvedColumns.txt" Write-Host -Foregroundcolor Cyan "$($tableList.Count) Involved Tables Detected" Write-host -Foregroundcolor Cyan "$($ShuffleColumns.count) Shuffle Columns Detected" Write-Host -Foregroundcolor Cyan "$($involvedColumns.Count) Involved Columns Detected" #create the update stats statements $UpdateStatsStatements = @() $UpdateStatsStatements += $tableList | % {"UPDATE STATISTICS $_"} $UpdateStatsStatements > "$OutputFolder\tsql_UpdateStatsCommands.txt" Write-host -ForegroundColor Cyan "`nOutput folder: $OutputFolder" #> ================================================ FILE: Azure_Resource_Graph_Queries/Inventory-DedicatedSqlPool.kql ================================================ Resources | where type == 'microsoft.sql/servers' | project name, id, resourceGroup, location, subscriptionId, tags | join kind=inner (Resources | where type == 'microsoft.sql/servers/databases' | where sku.tier == 'DataWarehouse' | extend CurrentServiceObjective = properties.currentServiceObjectiveName | extend RequestedServiceObjective = properties.requestedServiceObjectiveName | extend IsSynapseWorkspaceAssociated = iff(kind contains 'analytics', true, false) | parse CurrentServiceObjective with "DW" CurrentDWU "c" | extend status = tostring(properties.status) | parse id with ParentSqlServerId "/databases/" Discard) on $left.id == $right.ParentSqlServerId | project-rename DatabaseName = name1, ServerName = name, ServerResourceId = id, DatabaseResourceId = id1, ServerTags = tags, DatabaseTags = tags1 | project-away managedBy, plan, resourceGroup1, subscriptionId1, type, tenantId, sku, identity, zones, Discard, ParentSqlServerId, kind, apiVersion, properties, extendedLocation | join kind=leftouter (ResourceContainers | where type == 'microsoft.resources/subscriptions' | project SubscriptionName = name, subscriptionId) on subscriptionId | project-away subscriptionId1 | project-rename SubscriptionId = subscriptionId, ResourceGroup = resourceGroup, Location = location | project SubscriptionName, SubscriptionId, ResourceGroup, ServerName, ServerResourceId, ServerTags, DatabaseName, DatabaseResourceId, DatabaseTags, Location, CurrentDWU, CurrentServiceObjective, RequestedServiceObjective, IsSynapseWorkspaceAssociated ================================================ FILE: Azure_Resource_Graph_Queries/Inventory-SparkPools.kql ================================================ Resources | where type == "microsoft.synapse/workspaces/bigdatapools" | project name, id, resourceGroup, location, subscriptionId, tags, NodeSizeFamily = properties.nodeSizeFamily, NodeSize = properties.nodeSize, SparkVersion = properties.sparkVersion, AutoPause = properties.autoPause.enabled, AutoScale = properties.autoScale.enabled, MinNodeCount = properties.autoScale.minNodeCount, MaxNodeCount = properties.autoScale.maxNodeCount | parse id with * "/workspaces/" AssociatedSynapseWorkspaceName "/bigDataPools/" Discard | join kind=leftouter (Resources | where type == "microsoft.synapse/workspaces" | extend WorkspaceResourceId = id | extend WorkspaceName = name | project WorkspaceName, WorkspaceResourceId) on $left.AssociatedSynapseWorkspaceName == $right.WorkspaceName | join kind=leftouter (ResourceContainers | where type == 'microsoft.resources/subscriptions' | project SubscriptionName = name, subscriptionId) on subscriptionId | project-away subscriptionId1, Discard, AssociatedSynapseWorkspaceName | project-rename SparkPoolName = name, SparkPoolResourceId = id, ResourceGroup = resourceGroup, Location = location, SubscriptionId = subscriptionId, Tags = tags | project SparkPoolName, SparkPoolResourceId, ResourceGroup, Location, SubscriptionName, SubscriptionId, Tags, NodeSizeFamily, NodeSize, SparkVersion, AutoPause, AutoScale, MinNodeCount, MaxNodeCount, WorkspaceName, WorkspaceResourceId ================================================ FILE: Azure_Resource_Graph_Queries/README.md ================================================ # Azure Synapse Inventory via Azure Resource Graph The following [Azure Resource Graph](https://azure.microsoft.com/en-us/features/resource-graph/) queries assist with gathering Azure tenant inventory for Azure resources related to Azure Synapse Analytics. They are intended to aid cost optimization, general inventory needs, normalizing or standardization of configuration, and more. ## Pre-Requisites 1. RBAC 'Reader' or equivalent access to Azure Synapse related resources. See [Azure Resource Graph permissions](https://docs.microsoft.com/en-us/azure/governance/resource-graph/overview#permissions-in-azure-resource-graph) documentation for specifics. 2. Access to the Azure Portal or an Azure PowerShell or CLI session. ## To use these queries: 1. Navigate to the Azure Portal. Search or select the [Azure Resource Graph Explorer](https://docs.microsoft.com/en-us/azure/governance/resource-graph/first-query-portal) and paste the text of the desired query into the query window. Select run query. 2. Alternatively you may programmatically execute these queries programmatically via CLI or SDKs. - Execute Azure Resource Graph queries via [Azure PowerShell](https://docs.microsoft.com/en-us/azure/governance/resource-graph/first-query-powershell) - Execute Azure Resource Graph queries via [Azure CLI](https://docs.microsoft.com/en-us/azure/governance/resource-graph/first-query-azurecli) - Execute Azure Resource Graph queries via language specific [SDK or REST API](https://docs.microsoft.com/en-us/azure/governance/resource-graph/first-query-rest-api) # Sample queries for gathering inventory: ## Dedicated SQL Pools [Inventory-DedicatedSqlPool](Inventory-DedicatedSqlPool.kql) - Lists dedicated SQL pools (formerly SQL DW) visible to the executing Azure context returning the subscription, resource group, parent Azure SQL Server, current SKU, standalone or association with Azure Synapse Workspace, and more. ## Serverless SQL Pools To be completed. ## Spark Pools [Inventory-SparkPools](Inventory-SparkPools.kql) - Lists Spark pools (Synapse Spark) visible to the executing Azure context returning the subscription, resource group, parent Azure Synapse Analytics workspace, SKU, and more. ## Kusto Pools To be completed. # Troubleshooting ## Runtime errors with Azure Resource Graph [Checklist to review](https://docs.microsoft.com/en-us/azure/governance/resource-graph/troubleshoot/general) if errors are returned or no data is returned from these queries. If not data is returned the root cause is RBAC access to the Azure Synapse related Azure resources. ================================================ FILE: Distribution_Advisor/CreateDistributionAdvisor_PublicPreview.sql ================================================ IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'dbo.write_dist_recommendation')) DROP PROCEDURE dbo.write_dist_recommendation go IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'dbo.read_dist_recommendation')) DROP PROCEDURE dbo.read_dist_recommendation go IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'dbo.format_recommendation')) DROP PROCEDURE dbo.format_recommendation go CREATE PROCEDURE dbo.format_recommendation @recommendation NVARCHAR(MAX) AS BEGIN IF (@recommendation IS NULL OR len(@recommendation) = 0) BEGIN RAISERROR (N'No recommendation was found', 18, - 1); END ELSE BEGIN -- Parse the recommendation result DECLARE @FirstDistribBegin INT = PATINDEX('%Table Distribution Changes%', @recommendation); DECLARE @FirstDistribEnd INT = PATINDEX('%------------------------------------------------------------%', @recommendation); DECLARE @JumpPast NVARCHAR(max) = 'Table Distribution Changes'; SET @FirstDistribBegin = @FirstDistribBegin + LEN(@JumpPast) + 2; -- +1 to eat newline at the beginning DECLARE @DistribLength int = @FirstDistribEnd - @FirstDistribBegin - 2; -- extra -2 to remove newlines at the end IF (@DistribLength <= 0) BEGIN RAISERROR (N'No distribution to show. The query does not involve any tables, or the tables do not exist.', 18, - 1); END ELSE DECLARE @FirstDistrib NVARCHAR(max); SELECT @FirstDistrib = REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(SUBSTRING(@recommendation, @FirstDistribBegin, @DistribLength), CHAR(9), ''), CHAR(13), ''), '->', ''), ' ', ' '), ' ', '","'), CHAR(10), '"],["'); SELECT @FirstDistrib = REPLACE(REPLACE(@FirstDistrib, 'Distributed', 'Hash'), ':', ''); SELECT @FirstDistrib = '[["' + @FirstDistrib + '"]]'; -- Format the recommendation output SELECT y.TableName , CurrentDistribution , SuggestedDistribution , ChangeCommand = CASE WHEN CurrentDistribution = SuggestedDistribution THEN N'' ELSE CONCAT ( N'CREATE TABLE ', y.TableName, N'_changed WITH (DISTRIBUTION=', REPLACE(REPLACE(SuggestedDistribution, 'replicated', 'REPLICATE'), 'Hash', 'HASH'), N', ', i.TableIndex, ') AS SELECT * FROM ', y.TableName, N'; DROP TABLE ', y.TableName, '; RENAME OBJECT ', y.TableName, N'_changed TO ', i.tableName, ';') END , Remarks = CASE WHEN PATINDEX('%Hash%', CurrentDistribution) > 0 AND CHARINDEX(',', CurrentDistribution) > 0 THEN N'MCD tables are not considered by the current DA version.' ELSE '' END FROM ( SELECT [0] AS TableName , [1] AS CurrentDistribution , [2] AS SuggestedDistribution FROM ( SELECT pvt.* FROM ( SELECT row_no = [rows].[key] , col_no = [cols].[key] , cols.[value] FROM ( SELECT [json] = @FirstDistrib ) step1 CROSS APPLY openjson([json]) [rows] CROSS APPLY openjson([rows].[value]) [cols] ) base pivot(max(base.[value]) FOR base.col_no IN ([0], [1], [2])) pvt ) x WHERE [1] IS NOT NULL AND [2] IS NOT NULL ) y JOIN ( SELECT CONCAT ( DB_NAME() , '.' , OBJECT_SCHEMA_NAME(t.object_id) , '.' , t.name ) AS FullObjectName , OBJECT_SCHEMA_NAME(t.object_id) AS schemaName , t.name AS tableName , i.type , CASE i.type WHEN 0 THEN 'HEAP' WHEN 1 THEN CONCAT ('CLUSTERED INDEX (', STRING_AGG(CAST(c.Name as VARCHAR(MAX)), ', ') WITHIN GROUP (ORDER BY ic.key_ordinal ASC), ')') WHEN 5 THEN 'CLUSTERED COLUMNSTORE INDEX' END AS TableIndex FROM sys.tables t LEFT JOIN sys.indexes i ON t.object_id = i.object_id AND i.type IN (0, 1, 5) LEFT JOIN sys.index_columns ic ON i.index_id = ic.index_id AND i.object_id = ic.object_id LEFT JOIN sys.columns c ON ic.column_id = c.column_id AND ic.object_id = c.object_id GROUP BY t.name , t.object_id , i.name , i.type ) i ON y.TableName = i.FullObjectName END END GO CREATE PROCEDURE write_dist_recommendation @NumMaxQueries int, @Queries NVARCHAR(MAX) AS BEGIN DECLARE @sql nvarchar(MAX); DECLARE @sessionid nvarchar(max) = SESSION_ID(); DECLARE @guid nvarchar(100) = REPLACE(NEWID(), '-', ''); DECLARE @guidpusher nvarchar(max) = CONCAT(N' --distrib_advisor_correlation_id_', @guid, CHAR(13), CHAR(10)); DECLARE @recostring nvarchar(max); if not exists ( select * from sys.tables where name = 'DistributionAdvisorSelectedQueries') create table DistributionAdvisorSelectedQueries(command nvarchar(4000), tot_te bigint) with(clustered columnstore index, distribution = ROUND_ROBIN); -- Filter queries that will not be considered by DA. IF (@Queries is NULL) BEGIN if (@NumMaxQueries is NULL or @NumMaxQueries < 1 or @NumMaxQueries > 100) BEGIN RAISERROR(N'Max queries value must be in [1...100] range, changing to 100.', 0, -1); SET @NumMaxQueries = 100; END SET @sql = 'with topnqueries as (select top(@nmq) command, MIN(total_elapsed_time) AS min_te, AVG(total_elapsed_time) AS avg_te, COUNT(*) AS num_runs, SUM(total_elapsed_time) AS tot_te from (select command = case when command2 is null then command else command2 end, total_elapsed_time from sys.dm_pdw_exec_requests where command not like ''%USE [[]DWShellDb%\'' and command not like ''%DistributionAdvisor%'' and command not like ''--Backing up Logical Azure Database%\'' and command not like ''%select % as ConnectionProtocol%'' and command like ''%select%'' and command not like ''%set recommendations%'' and command not like ''USE [[]%]'' and command not like ''%sys.system_sql_modules%'' and command not like ''%insert%'' and command not like ''%sys.indexes%'' and command not like ''%merge%'' and command not like ''%CREATE%TABLE%'' and command not like ''%dm_pdw_exec_requests%'' and command not like ''%sys.databases%'' and command not like ''%trancount%'' and command not like ''%spid%'' and total_elapsed_time > 300 and command not like ''%SERVERPROPERTY%'' and resource_class != ''NULL'' and command not like ''%sys.objects%'' and command not like ''%sys.tables%'' and command not like ''%sys.schemas%'' and command not like ''%sys.dm_pdw_%'' and status = ''Completed'') x GROUP BY command ORDER BY tot_te desc), allqueries as (select command, tot_te from topnqueries union all select * from DistributionAdvisorSelectedQueries), allqueriesgrouped as (select command, sum(tot_te) as tot_te from allqueries group by command), topnqueriesranked as (select REPLACE(command, '''''';'''''', ''CHAR(59)'') as command, tot_te, row_number() over (order by tot_te desc) as rn from allqueriesgrouped) select @recostring = ''set recommendations on;'' + CHAR(13) + CHAR(10) + CHAR(13) + CHAR(10) + ''/****************** Actual queries follow ****************************/'' + CHAR(13) + CHAR(10) + STRING_AGG( ''/************************** Query q'' + cast (rn-1 as nvarchar(max)) + '' ********************************/'' + CHAR(13) + CHAR(10) + (case when charindex('';'', command) > 0 then REPLACE(REPLACE(cast(command AS nvarchar(max)), ''--distrib_advisor_correlation_id_'', ''--''), '';'', @guidpusher) else concat(command, @guidpusher) end), '';'' + CHAR(13) + CHAR(10) + CHAR(13) + CHAR(10) + CHAR(13) + CHAR(10) + CHAR(13) + CHAR(10)) + + CHAR(13) + CHAR(10) + ''/******************** End actual queries **************************/'' + CHAR(13) + CHAR(10) + ''set recommendations off;'' from topnqueriesranked'; END ELSE BEGIN SET @NumMaxQueries = 100; SET @Queries = REPLACE(@Queries, ''';''', 'char(59)'); SET @sql = 'with userqueries as (select CONCAT(value,'';'') as command, ordinal as tot_te from STRING_SPLIT(@customQueries, '';'', 1) where trim(value) <> '''' union all select * from DistributionAdvisorSelectedQueries), topnqueriesranked as (select *, row_number() over (order by tot_te desc) as rn from userqueries) select @recostring = ''set recommendations on;'' + CHAR(13) + CHAR(10) + CHAR(13) + CHAR(10) + ''/****************** Actual queries follow ****************************/'' + CHAR(13) + CHAR(10) + STRING_AGG( ''/************************** Query q'' + cast (rn-1 as nvarchar(max)) + '' ********************************/'' + CHAR(13) + CHAR(10) + (case when charindex('';'', command) > 0 then REPLACE(REPLACE(cast(command AS nvarchar(max)), ''--distrib_advisor_correlation_id_'', ''--''), '';'', @guidpusher) else concat(command, @guidpusher) end), '';'' + CHAR(13) + CHAR(10) + CHAR(13) + CHAR(10) + CHAR(13) + CHAR(10) + CHAR(13) + CHAR(10)) + + CHAR(13) + CHAR(10) + ''/******************** End actual queries **************************/'' + CHAR(13) + CHAR(10) + ''set recommendations off;'' from topnqueriesranked'; END EXEC sp_executesql @sql, N'@recostring nvarchar(max) OUTPUT, @guidpusher nvarchar(max), @nmq int, @customQueries nvarchar(max)', @recostring OUTPUT, @guidpusher, @NumMaxQueries, @Queries; IF (@recostring is null or len(@recostring) = 0) BEGIN RAISERROR(N'Cannot construct the set of queries to feed to advisor. This often happens if there are not enough queries in sys.dm_pdw_exec_requests.', 18, -1); END ELSE BEGIN -- For debugging purposes. SELECT @recostring AS Command_To_Invoke_Distribution_Advisor; -- A command to invoke Distribution Advisor with the above string. EXEC sp_executesql @recostring; RAISERROR(N'Please use ''read_dist_recommendation'' stored procedure after recommendation is created to retrieve it', 0, -1); END END GO -- This stored procedure reads the recommendation advice generated in write_dist_recommendation. CREATE PROCEDURE read_dist_recommendation AS BEGIN DECLARE @sessionid nvarchar(max) = SESSION_ID(); -- get the answer from ring buffer; we may have to wait a bit, so we do a few tries for the ring buffer to get ready DECLARE @recommendation nvarchar(max); DECLARE @readrecommendation nvarchar(max) = N'select @recommendation = recommendation from sys.dm_pdw_distrib_advisor_results where @sessionid = session_id '; DECLARE @DelayStart datetime = GETDATE(); -- Retrying for 10 seconds WHILE (@recommendation is null or len(@recommendation) = 0) and DATEDIFF(second, @DelayStart, GETDATE()) < 10 BEGIN EXEC sp_executesql @readrecommendation, N'@recommendation nvarchar(max) OUTPUT, @sessionid nvarchar(max)', @recommendation OUTPUT, @sessionid; if (@recommendation is null or len(@recommendation) = 0) BEGIN RAISERROR(N'No recommendation yet in ring buffer; waiting...', 0, -1); END END -- parsing and formatting the recommendation EXEC dbo.format_recommendation @recommendation; END GO ================================================ FILE: Distribution_Advisor/README.md ================================================ # Distirbution Advisor Please follow [these instructions](https://docs.microsoft.com/en-us/azure/synapse-analytics/sql/distribution-advisor) to run Distribution Advisor. ================================================ FILE: Distribution_Advisor/RunDistributionAdvisor.sql ================================================ -- ******************************************************************************************* -- This portion is for a user input queries. -- PDW doesn't allow default values for stored procedures. So the input queries needs to be single string divided by a semicolon between each queries. -- This can be simply done by declaring a variable for each query string, and then combine them by using CONCAT() function. -- Max query number parameter is ignored in this scenario. EXEC dbo.write_dist_recommendation NULL, 'select count (*) from t1; select * from t1 join t2 on t1.a1 = t2.a1; select count (*) from t1; select * from t1 join t2 on t1.a1 = t2.a1;'; go -- Notice that the read_dist_recommendation and write_dist_recommendation stored procs need to be called together and seperated by go. EXEC dbo.read_dist_recommendation; go -- ******************************************************************************************* -- This portion is for running DA on top @MaxNumQueries queries. -- @MaxNumQueries parameter value can be in [1...100] range. -- if both parameters passed as NULL, the stored procedure will generate recommendation for top 100 queries. EXEC dbo.write_dist_recommendation 100, NULL go EXEC dbo.read_dist_recommendation; go -- ******************************************************************************************* -- The below is an example usage of format_recommendation stored procedure. -- It takes the recommendation result as a parameter and displays in a formatted readable manner. set recommendations on; go select 1; set recommendations off; go DECLARE @sessionid nvarchar(100); DECLARE @recommendation nvarchar(MAX); select @sessionid = SESSION_ID(); select @recommendation = recommendation from sys.dm_pdw_distrib_advisor_results where session_id = @sessionid EXEC dbo.format_recommendation @recommendation; ================================================ FILE: Distribution_Advisor/e2e_queries_used_for_recommendations.sql ================================================ DECLARE @NumMaxQueries int = 100; -- change this to match the variable in mvp script; looks at different numbers of queries. -- the below where clauses should match those in the mvp script with topnqueries as (select top(@NumMaxQueries) command, COUNT(*) AS number_of_runs, SUM(total_elapsed_time) AS total_execution_time from sys.dm_pdw_exec_requests where command like '%select%' and command not like '%insert%' and command not like '%USE [[]DWShellDb%\' and command not like '--Backing up Logical Azure Database%\' and command not like '%select % as ConnectionProtocol%' and command not like '%set recommendations on%' and command not like '%set recommendations off%' and command not like 'USE [[]%]' and command not like '%sys.system_sql_modules%' and command not like '%sys.indexes%' and command not like '%merge%' and command not like '%CREATE%TABLE%' and command not like '%dm_pdw_exec_requests%' and command not like '%sys.databases%' and command not like '%trancount%' and command not like '%spid%' and total_elapsed_time > 300 and command not like '%SERVERPROPERTY%' and resource_class != 'NULL' and command not like '%sys.objects%' and command not like '%sys.tables%' and command not like '%sys.schemas%' and command not like '%sys.dm_pdw_%' and status = 'Completed' GROUP BY command ORDER BY total_execution_time desc) select * from topnqueries; ================================================ FILE: LICENSE ================================================ MIT License Copyright (c) Microsoft Corporation. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE ================================================ FILE: Log_Analytics_queries/Pipelines/CompletedPipelineDurationInSeconds.kql ================================================ // Pipeline Durations in Seconds SynapseIntegrationPipelineRuns | where Status in ('Succeeded', 'Failed') | extend PipelineDuration = iif(Status in ('Succeeded', 'Failed'),datetime_diff('second', End, Start),0) | extend TriggerId = tostring(parse_json(Predecessors)[0].Id) | join kind = leftouter ( SynapseIntegrationTriggerRuns | project TriggerId, TriggerName ) on $left.TriggerId == $right.TriggerId | project Start, TriggerName, TriggerId, PipelineName, RunId, PipelineDuration, Status ================================================ FILE: Log_Analytics_queries/Pipelines/TopNLongestRunningPipelines.kql ================================================ // Synapse Pipelines - Chart - Top N Longest Running Pipelines // N == 5 SynapseIntegrationActivityRuns | extend e_Resource = tostring(array_reverse(split(tolower(_ResourceId), '/'))[0]) | join kind = leftouter ( SynapseIntegrationPipelineRuns | extend TriggerId = tostring(parse_json(Predecessors)[0].Id) | join kind = leftouter ( SynapseIntegrationTriggerRuns | project TriggerId, TriggerName ) on $left.TriggerId == $right.TriggerId | project TriggerName, TriggerId, RunId ) on $left.PipelineRunId == $right.RunId | extend ActivityDuration = iif(Status in ('Succeeded', 'Failed'), datetime_diff('second', End, Start), 0) | project e_Resource, ActivityName, Start, End, ActivityDuration, PipelineName, TriggerName, ActivityType | summarize Avg_Duration = avg(ActivityDuration), Max_Duration = max(ActivityDuration) by e_Resource, TriggerName, PipelineName, ActivityName, ActivityType | order by Max_Duration, Avg_Duration | limit 5 ================================================ FILE: Log_Analytics_queries/ServerlessSql/CostPerQuery.txt ================================================ //Cost per query SynapseBuiltinSqlPoolRequestsEnded //| where _ResourceId has 'contosoprod' | project BytesProcessed=Properties.dataProcessedBytes, tostring(Identity), QueryHash=tostring(Properties.queryHash), QueryText=tostring(Properties.queryText), _ResourceId | extend MbProcessed = case (BytesProcessed < 10000000,10000000, BytesProcessed)/1000/1000 | summarize MaxSingleQueryMBProcessed=max(toint(MbProcessed)), TotalMBProcessed=sum(toint(MbProcessed)), QueryCount=count(), QueryHash=any(QueryHash) , Resource=any(_ResourceId) by QueryText //using queryText because queryHash doesn’t change if only literals are different | extend Approx_Accumulated_Cost=((TotalMBProcessed)*5.0/100000.0)/100 | extend Approx_Cost_Per_Execution=((TotalMBProcessed)*5.0/100000.0)/100/QueryCount | order by TotalMBProcessed ================================================ FILE: Log_Analytics_queries/ServerlessSql/CostPerQuery.txt.bak ================================================ //Cost per query SynapseBuiltinSqlPoolRequestsEnded //| where _ResourceId has 'contosoprod' | project BytesProcessed=Properties.dataProcessedBytes, tostring(Identity), QueryHash=tostring(Properties.queryHash), QueryText=tostring(Properties.queryText), _ResourceId | summarize MaxSingleQueryMBProcessed=max(toint(BytesProcessed)/1024/1024), TotalMBProcessed=sum(toint(BytesProcessed)/1024/1024), QueryCount=count(), QueryHash=any(QueryHash) , Resource=any(_ResourceId) by QueryText //using queryText because queryHash doesn’t change if only literals are different | extend Approx_Accumulated_Cost=((TotalMBProcessed)*0.000476837158203125)/100 //multiply by price per mb ($5 per TB from Microsoft Docs: https://azure.microsoft.com/en-us/pricing/details/synapse-analytics/) | extend Approx_Cost_Per_Execution=((TotalMBProcessed)*0.000476837158203125)/100/QueryCount | order by TotalMBProcessed ================================================ FILE: Log_Analytics_queries/ServerlessSql/CostPerUser.txt ================================================ //Query cost by User SynapseBuiltinSqlPoolRequestsEnded //| where _ResourceId has 'contosoprod' | project BytesProcessed=Properties.dataProcessedBytes , tostring(Identity) | extend MbProcessed = case (BytesProcessed < 10000000,10000000, BytesProcessed)/1000/1000 | summarize TotalMBProcessed=sum(toint(MbProcessed)), QueryCount=count(), MaxSingleQueryMBProcessed=max(toint(MbProcessed) ) by Identity | extend Approx_Cost=((TotalMBProcessed) *5.0/100000.0) / 100 | order by TotalMBProcessed ================================================ FILE: Log_Analytics_queries/ServerlessSql/CostPerUser.txt.bak ================================================ //Query cost by User SynapseBuiltinSqlPoolRequestsEnded //| where _ResourceId has 'contosoprod' | project BytesProcessed=Properties.dataProcessedBytes,tostring(Identity),_ResourceId | summarize TotalMBProcessed=sum(toint(BytesProcessed)/1024/1024),QueryCount=count(),MaxSingleQueryMBProcessed=max(toint(BytesProcessed)/1024/1024),Resource=any(_ResourceId) by Identity | extend Approx_Cost=((TotalMBProcessed)*0.000476837158203125)/100 //multiply by price per mb ($5 per TB from Microsoft Docs: https://azure.microsoft.com/en-us/pricing/details/synapse-analytics/) | order by TotalMBProcessed ================================================ FILE: Log_Analytics_queries/Spark/CoresAndMemoryByApplication.kql ================================================ SparkListenerEvent_CL | summarize Total_vCores_Used=sum(Executor_Info_Total_Cores_d), Total_Memory_Used_GB=sum(Maximum_Memory_d)/(1024*1024*1024) by applicationId_s, clusterName_s, livyId_s; ================================================ FILE: Log_Analytics_queries/StandaloneSQLPool/DedicatedSqlPoolUsage.kql ================================================ // Intended to aid cost management of dedicated SQL pools // Set the UsageBucket to the level of granularity desired e.g. 1 hour, 4 hours, 1 day // Set the Lookback window to the duration of history to look back // Essentially this is a simple % of total usage bucketed by UsageBucket. If the values // are consistently low for PercentOfMaxDTU_Used the dedicated SQL pool may be a candidate // for scale down and/or for dynamic scaling by ETL/ELT orchestration. let UsageBucket = 1d; let Lookback = 14d; AzureMetrics | where TimeGenerated > ago(Lookback) | where MetricName == 'dwu_used' | summarize Max_DWU_Used = max(Maximum) by bin(TimeGenerated, UsageBucket), MetricName, Resource | join kind=inner ( AzureMetrics | where TimeGenerated > ago(Lookback) | where MetricName == 'dwu_limit' | summarize DWU_Limit = max(Maximum) by bin(TimeGenerated, UsageBucket), MetricName, Resource) on (($left.TimeGenerated == $right.TimeGenerated) and ($left.Resource == $right.Resource)) | project-away MetricName, MetricName1, Resource1 | extend PercentOfMaxDTU_Used = ((1.0 * Max_DWU_Used) / (1.0 * DWU_Limit)) * 100.0 | project TimeGenerated, Resource, Max_DWU_Used, DWU_Limit, PercentOfMaxDTU_Used ================================================ FILE: Log_Analytics_queries/StandaloneSQLPool/LargestBroadcastSteps.kql ================================================ let databaseName=""; AzureDiagnostics | where Resource == databaseName | where Category == 'RequestSteps' | where OperationType_s == 'BroadcastMoveOperation' | summarize rowcount=max(RowCount_d),max(TimeGenerated) by RequestId_s,StepIndex_d | order by rowcount ================================================ FILE: Log_Analytics_queries/StandaloneSQLPool/LargestDataMovementSteps.kql ================================================ //Most Rows Moved by step // These are the largest data movement steps. Use this to identify a request ID to investigate let databaseName = ''; AzureDiagnostics | where Category == 'RequestSteps' | where Resource == databaseName | extend elapsedTime = EndTime_t - StartTime_t | extend elapsedTime_min = elapsedTime/1m | order by RowCount_d desc | project RequestId_s,OperationType_s, RowCount_d,elapsedTime_min , StartTime_t, EndTime_t, Status_s //| limit 20 ================================================ FILE: Log_Analytics_queries/StandaloneSQLPool/LogAnalyticsBasicQueries.sql ================================================ //List all queries AzureDiagnostics | where Category == "ExecRequests" | project TimeGenerated , ErrorId_g , RequestId_s , SessionId_s , Status_s , SubmitTime_t , StartTime_t , EndCompileTime_t , EndTime_t , Label_s , DatabaseId_d , Command_s , ResourceClass_s , StatementType_s //Chart the most active resource classes AzureDiagnostics | where Category contains "ExecRequests" | where Status_s == "Completed" | summarize totalQueries = dcount(RequestId_s) by ResourceClass_s | render barchart //Count of all queued queries AzureDiagnostics | where Category contains "waits" | where Type_s == "UserConcurrencyResourceType" | summarize totalQueuedQueries = dcount(RequestId_s) //Longest Running Query Steps AzureDiagnostics | where Category == "RequestSteps" | where OperationType_s in ("ShuffleMoveOperation", "BroadcastMoveOperation", "PartitionMoveOperation", "RoundRobinMoveOperation", "SingleSourceRoundRobinMoveOperation", "MoveOperation", "TrimMoveOperation") | where Status_s == "Complete" | project RequestId_s, OperationType_s, duration_ms=datetime_diff('millisecond',EndTime_t, StartTime_t), RowCount_d , TimeGenerated | order by duration_ms desc //Request Steps AzureDiagnostics | where Category == "RequestSteps" | project TimeGenerated , ErrorId_g , OperationType_s , DistributionType_s , LocationType_s , StepIndex_d , RowCount_d , RequestId_s , Status_s , StartTime_t , EndTime_t , Command_s //SQL Requests AzureDiagnostics | where Category == "SqlRequests" | project TimeGenerated , StepIndex_d , PdwNodeId_d , DistributionId_d , RowCount_d , Spid_d , RequestId_s , Status_s , StartTime_t , EndTime_t , Command_s //Blocked By Firewall AzureMetrics | where ResourceProvider == "MICROSOFT.SQL" | where Resource == "NICKSALCSQLDW1" | where MetricName =="blocked_by_firewall" | project MetricName , Maximum, TimeGenerated //Cache Hit Percent AzureMetrics | where ResourceProvider == "MICROSOFT.SQL" | where Resource == "NICKSALCSQLDW1" | where MetricName =="cache_hit_percent" | project MetricName , Maximum, TimeGenerated //Connection Failed AzureMetrics | where ResourceProvider == "MICROSOFT.SQL" | where Resource == "NICKSALCSQLDW1" | where MetricName =="connection_failed" | project MetricName , Maximum, TimeGenerated //Connection Success AzureMetrics | where ResourceProvider == "MICROSOFT.SQL" | where Resource == "NICKSALCSQLDW1" | where MetricName =="connection_successful" | project MetricName , Maximum, TimeGenerated //CPU Percent AzureMetrics | where ResourceProvider == "MICROSOFT.SQL" | where Resource == "NICKSALCSQLDW1" | where MetricName =="cpu_percent" | project MetricName , Maximum, TimeGenerated //DWU Consumption Percent AzureMetrics | where ResourceProvider == "MICROSOFT.SQL" | where Resource == "NICKSALCSQLDW1" | where MetricName =="dwu_consumption_percent" //Tempdb ConsumptionPercent AzureMetrics | where ResourceProvider == "MICROSOFT.SQL" | where Resource == "NICKSALCSQLDW1" | where MetricName =="local_tempdb_usage_percent" | project MetricName , Maximum, TimeGenerated //Memory Usage Percent AzureMetrics | where ResourceProvider == "MICROSOFT.SQL" | where Resource == "NICKSALCSQLDW1" | where MetricName =="memory_usage_percent" | project MetricName , Maximum, TimeGenerated //Physical Data Read Percent AzureMetrics | where ResourceProvider == "MICROSOFT.SQL" | where Resource == "NICKSALCSQLDW1" | where MetricName =="physical_data_read_percent" | project MetricName , Maximum, TimeGenerated //Current DWU AzureMetrics | where MetricName == 'dwu_limit' | where Resource == 'NICKSALCSQLDW1' | project TimeGenerated , MetricName , Maximum | sort by TimeGenerated | limit 1 | project MetricName , Maximum, TimeGenerated ================================================ FILE: Log_Analytics_queries/StandaloneSQLPool/LongestBuildReplicatedTableCache ================================================ let databaseName = ''; //Longest running BuildReplicatedTableCache AzureDiagnostics | where Category == 'ExecRequests' | where Resource == databaseName | where StatementType_s !in ('Batch','Execute') | summarize Session_ID=max(SessionId_s), Request_ID=max(RequestId_s), Submit_Time=max(SubmitTime_t), Start_Time=max(StartTime_t), End_Time=max(EndTime_t), Command=max(Command_s), Statement_Type=max(StatementType_s), Resource_class=max(ResourceClass_s) by RequestId_s | join kind= inner ( AzureDiagnostics | where Category == 'ExecRequests' | where Resource == databaseName //| where StatementType_s !in ('Batch','Execute') | where StatementType_s == 'BuildReplicatedTableCache' | where EndTime_t > ago(7d) | where StartTime_t > ago(7d) | extend elapsedTime = EndTime_t - StartTime_t | extend elapsedTime_min = elapsedTime/1m | order by elapsedTime_min desc | project Request_ID=RequestId_s,elapsedTime_min ) on Request_ID | order by elapsedTime_min desc | project Session_ID,Request_ID,Submit_Time,Start_Time,End_Time,Elapsed_Time=elapsedTime_min,Command | limit 10 ///////////////////////////////////////////////////////////////// // Uncomment these sections to investigate further // // To comment lines in bulk - select multiple lines and press // // Uncomment block: ctrl+k then ctrl+u // // Comment block: ctrl+k then ctrl+c // ///////////////////////////////////////////////////////////////// // let databaseName = ''; // //Get Query Text snippet // AzureDiagnostics // | where Category == 'ExecRequests' // | where Resource == databaseName // | where RequestId_s == 'QID117009708' //Put your QueryID here // | order by TimeGenerated asc // | project TimeGenerated,SubmitTime_t,EndCompileTime_t,StartTime_t,EndTime_t,StatementType_s,ResourceClass_s,SessionId_s,RequestId_s,RootQueryId_s,Command_s,Status_s // let databaseName = ''; // //View the query steps with rowcounts // AzureDiagnostics // | where Category == 'RequestSteps' // | where Resource == databaseName // | where RequestId_s == 'QID117009708' //Put your QueryID here // | where Status_s != 'Running' // | summarize max(StartTime_t),max(EndTime_t),max(RequestId_s),max(OperationType_s),max(RowCount_d),max(Command_s),max(Status_s) by StepIndex_d // | order by StepIndex_d asc ================================================ FILE: Log_Analytics_queries/StandaloneSQLPool/MostReplicatedTableRebuilds.txt ================================================ let databaseName = ''; AzureDiagnostics | where Category == 'ExecRequests' | where Resource == databaseName | where StatementType_s == 'BuildReplicatedTableCache' | where Command_s != "" | where ResourceClass_s != "" | project Command_s, TimeGenerated, RequestId_s | summarize LastRebuild=max(TimeGenerated), RebuildCount_7Days=count(RequestId_s), AvgRebuildsPerDay=count(RequestId_s) / 7 by Command_s | order by RebuildCount_7Days desc | limit 20 ================================================ FILE: Log_Analytics_queries/StandaloneSQLPool/QueriesByExecutionTime.kql ================================================ //Queries by Execution Time let databaseName = ''; AzureDiagnostics | where Category == 'ExecRequests' | where Resource == databaseName | where StatementType_s !in ('Batch','Execute') | summarize Session_ID=max(SessionId_s), Request_ID=max(RequestId_s), Submit_Time=min(SubmitTime_t), Start_Time=max(StartTime_t), End_Time=max(EndTime_t), Command=max(Command_s), Last_Status=min(Status_s), Statement_Type=max(StatementType_s), Resource_class=max(ResourceClass_s) by RequestId_s | extend elapsedTime_min = (End_Time - Submit_Time)/1m //| where Command contains " 0 | summarize Rows_Processed=sum(RowCount_d) by bin(TimeGenerated, 1hr) | limit 50 ================================================ FILE: Log_Analytics_queries/StandaloneSQLPool/SingletonInserts.kql ================================================ //This query identifies Sessions with large numbers of insert statements, including the max rows inserted. It is mainly used to identify singleton or small inserts. let databaseName=""; AzureDiagnostics | where Resource == databaseName | where Category == 'ExecRequests' | where StatementType_s in ('InsertIntoValues') | summarize SessionId_s=max(SessionId_s),max(StatementType_s),max(SessionId_s),min(Status_s),max(Command_s) by RequestId_s | join (AzureDiagnostics | where Resource == databaseName | where Category == 'RequestSteps' | summarize max(RowCount_d) by RequestId_s ) on RequestId_s | join (AzureDiagnostics | where Resource == databaseName | where Category == 'ExecRequests' | where StatementType_s in ('InsertIntoValues') | summarize count() by SessionId_s ) on SessionId_s | order by count_ | project SessionId=SessionId_s,RequestId=RequestId_s,StatementType=max_StatementType_s,StatementsFound=count_,MaxRowcount=max_RowCount_d,Status=min_Status_s,Command=max_Command_s | limit 100 ================================================ FILE: Log_Analytics_queries/StandaloneSQLPool/TempTablesNotCreatedAsHeap.kql ================================================ let databaseName = 'DatabaseName_AllCaps'; //Long-Running Queries - Just Actual Queries //If 'Command' is empty - you need to set a bigger time window, the older record with the command is outside of your window AzureDiagnostics | where Category == 'ExecRequests' | where Resource == databaseName | where StatementType_s !in ('Batch','Execute') | where tolower(Command_s) contains "create table #" and tolower(Command_s) !contains "HEAP" | summarize Session_ID=any(SessionId_s), Request_ID=any(RequestId_s), Submit_Time=max(SubmitTime_t), Start_Time=max(StartTime_t), End_Time=max(EndTime_t), Command=any(Command_s), Status=min(Status_s), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status Statement_Type=any(StatementType_s), Resource_class=any(ResourceClass_s) by RequestId_s | summarize ElapsedTime_min=anyif((End_Time - Start_Time)/1m,Start_Time > ago(30d)),Session_ID=any(Session_ID), Submit_Time=any(Submit_Time) ,Start_Time=any(Start_Time), End_Time=any(End_Time),Command=any(Command),Status=any(Status),Statement_Type=any(Statement_Type),Resource_class=any(Resource_class) by Request_ID | order by ElapsedTime_min desc ================================================ FILE: Log_Analytics_queries/StandaloneSQLPool/UnionVsUnionAll.kql ================================================ let databaseName = ''; //Usage of Union vs Union ALL - this query is approximate since query text is limited to 4000 characters AzureDiagnostics | where Category == 'ExecRequests' | where Resource == databaseName | where StatementType_s !in ('Batch','Execute') | summarize Session_Id=max(SessionId_s), Request_Id=max(RequestId_s), Submit_Time=max(SubmitTime_t), Start_Time=max(StartTime_t), End_Time=max(EndTime_t), Command=max(Command_s), Status=min(Status_s), Statement_Type=max(StatementType_s), Resource_class=max(ResourceClass_s) by RequestId_s | extend elapsedTime_min = (End_Time - Submit_Time)/1m | where Command has 'Union' and Command !has 'union all' | order by elapsedTime_min | project Session_Id,Request_Id,Submit_Time,Start_Time,End_Time,elapsedTime_min,Command,Status,Statement_Type,Resource_class | limit 50 ================================================ FILE: Log_Analytics_queries/WorkspacesSQLPool/FindLargeBroadcasts.kql ================================================ let databaseName=""; SynapseSqlPoolRequestSteps | where _ResourceId endswith databaseName | where OperationType == 'BroadcastMoveOperation' | summarize rowcount=max(RowCount),max(TimeGenerated),max(OperationType) by RequestId,StepIndex | order by rowcount ================================================ FILE: Log_Analytics_queries/WorkspacesSQLPool/IdentifySingletonInserts.kql ================================================ //This query identifies Sessions with large numbers of insert statements, including the max rows inserted. It is mainly used to identify singleton or small inserts. let databaseName=""; SynapseSqlPoolExecRequests | where _ResourceId endswith databaseName | where StatementType in ('InsertIntoValues') | summarize max(StatementType),min(Status),max(Command) by RequestId | join (SynapseSqlPoolRequestSteps | where _ResourceId endswith databaseName | summarize max(RowCount) by RequestId | where max_RowCount == 1 ) on RequestId | limit 100 ================================================ FILE: Log_Analytics_queries/WorkspacesSQLPool/LongestRunningQueriesByExecutionTime.kql ================================================ //Long-Running Queries let databaseName = '1'; SynapseSqlPoolExecRequests | where _ResourceId endswith databaseName | where StatementType !in ('Batch','Execute') | summarize Request_ID=any(RequestId), Submit_Time=min(TimeGenerated), Start_Time=max(StartTime), End_Time=max(EndTime), Command=any(Command), Status=min(Status), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status Statement_Type=any(StatementType), Resource_class=any(ResourceClass) by RequestId | summarize ElapsedTime_min=anyif((End_Time - Start_Time)/1m,Start_Time > ago(30d)),Submit_Time=any(Submit_Time) ,Start_Time=any(Start_Time), End_Time=any(End_Time),Command=any(Command),Status=any(Status),Statement_Type=any(Statement_Type),Resource_class=any(Resource_class) by Request_ID | order by ElapsedTime_min desc | limit 20 //paste the request ID into teh 'query investigation' tab of the monitoring workbook if you want to investigate a query further ================================================ FILE: Log_Analytics_queries/WorkspacesSQLPool/QueriesWithResourceGrant.kql ================================================ //Queries including SLO and resource grant % until the resource grant % field is avaialble in log analytics covers DW500-DW6000 let snapshotTelemetryInterval = 1s;//1h;//30m;//Do not change SynapseSqlPoolExecRequests | where StatementType !in ('Batch','Execute') | where ResourceClass != '' | summarize //Session_ID=any(SessionId), Request_ID=any(RequestId), //Submit_Time=max(SubmitTime), Start_Time=max(StartTime), End_Time=max(EndTime), Command=take_any(Command), Status=min(Status), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status Statement_Type=any(StatementType), Resource_Class=max(ResourceClass), Context=max(ClientCorrelationId), MinTimeGenerated=min(TimeGenerated), MaxTimeGenerated=max(TimeGenerated), TimeGenerated=max(TimeGenerated), ExplainOutput=max(ExplainOutput) by RequestId | extend NumberNodes=split(split(ExplainOutput,"number_nodes=")[1],"'")[1] //parse out how many nodes are used in dsql plan | extend SLO = (NumberNodes* 500) | extend Resource_Grant = todecimal( case(SLO==500, case(Resource_Class == 'smallrc', 5.0, Resource_Class == 'mediumrc', 10.0, Resource_Class == 'largerc', 22.0, Resource_Class == 'xlargerc', 70.0, Resource_Class == 'staticrc10', 4.8, Resource_Class == 'staticrc20', 9.6, Resource_Class == 'staticrc30', 19.2, Resource_Class == 'staticrc40', 38.4, Resource_Class == 'staticrc50', 76.8, Resource_Class == 'staticrc60', 100.0, Resource_Class == 'staticrc70', 100.0, Resource_Class == 'staticrc80', 100.0, Resource_Class == 'default', 5.0, 0.0) ,SLO==1000, case(Resource_Class == 'smallrc', 3.0, Resource_Class == 'mediumrc', 10.0, Resource_Class == 'largerc', 22.0, Resource_Class == 'xlargerc', 70.0, Resource_Class == 'staticrc10', 2.4, Resource_Class == 'staticrc20', 4.8, Resource_Class == 'staticrc30', 9.6, Resource_Class == 'staticrc40', 19.2, Resource_Class == 'staticrc50', 38.4, Resource_Class == 'staticrc60', 76.8, Resource_Class == 'staticrc70', 100.0, Resource_Class == 'staticrc80', 100.0, Resource_Class == 'default', 3.0, 0.0) ,SLO==1500, case(Resource_Class == 'smallrc', 3.0, Resource_Class == 'mediumrc', 10.0, Resource_Class == 'largerc', 22.0, Resource_Class == 'xlargerc', 70.0, Resource_Class == 'staticrc10', 1.6, Resource_Class == 'staticrc20', 3.2, Resource_Class == 'staticrc30', 6.4, Resource_Class == 'staticrc40', 12.8, Resource_Class == 'staticrc50', 25.6, Resource_Class == 'staticrc60', 51.2, Resource_Class == 'staticrc70', 100.0, Resource_Class == 'staticrc80', 100.0, Resource_Class == 'default', 3.0, 0.0) ,SLO==2000, case(Resource_Class == 'smallrc', 3.0, Resource_Class == 'mediumrc', 10.0, Resource_Class == 'largerc', 22.0, Resource_Class == 'xlargerc', 70.0, Resource_Class == 'staticrc10', 1.2, Resource_Class == 'staticrc20', 2.4, Resource_Class == 'staticrc30', 4.8, Resource_Class == 'staticrc40', 9.6, Resource_Class == 'staticrc50', 19.2, Resource_Class == 'staticrc60', 38.4, Resource_Class == 'staticrc70', 76.8, Resource_Class == 'staticrc80', 100.0, Resource_Class == 'default', 3.0, 0.0) ,SLO==2500, case(Resource_Class == 'smallrc', 3.0, Resource_Class == 'mediumrc', 10.0, Resource_Class == 'largerc', 22.0, Resource_Class == 'xlargerc', 70.0, Resource_Class == 'staticrc10', 0.96, Resource_Class == 'staticrc20', 1.92, Resource_Class == 'staticrc30', 3.84, Resource_Class == 'staticrc40', 7.68, Resource_Class == 'staticrc50', 16.36, Resource_Class == 'staticrc60', 30.72, Resource_Class == 'staticrc70', 61.44, Resource_Class == 'staticrc80', 100.0, Resource_Class == 'default', 3.0, 0.0) ,SLO==3000, case(Resource_Class == 'smallrc', 3.0, Resource_Class == 'mediumrc', 10.0, Resource_Class == 'largerc', 22.0, Resource_Class == 'xlargerc', 70.0, Resource_Class == 'staticrc10', 0.8, Resource_Class == 'staticrc20', 1.6, Resource_Class == 'staticrc30', 3.2, Resource_Class == 'staticrc40', 6.4, Resource_Class == 'staticrc50', 12.8, Resource_Class == 'staticrc60', 25.6, Resource_Class == 'staticrc70', 51.2, Resource_Class == 'staticrc80', 100.0, Resource_Class == 'default', 3.0, 0.0) ,SLO==5000, case(Resource_Class == 'smallrc', 3.0, Resource_Class == 'mediumrc', 10.0, Resource_Class == 'largerc', 22.0, Resource_Class == 'xlargerc', 70.0, Resource_Class == 'staticrc10', 0.48, Resource_Class == 'staticrc20', 0.96, Resource_Class == 'staticrc30', 1.92, Resource_Class == 'staticrc40', 3.84, Resource_Class == 'staticrc50', 7.68, Resource_Class == 'staticrc60', 15.36, Resource_Class == 'staticrc70', 30.72, Resource_Class == 'staticrc80', 61.44, Resource_Class == 'default', 3.0, 0.0) ,SLO==6000, case(Resource_Class == 'smallrc', 3.0, Resource_Class == 'mediumrc', 10.0, Resource_Class == 'largerc', 22.0, Resource_Class == 'xlargerc', 70.0, Resource_Class == 'staticrc10', 0.4, Resource_Class == 'staticrc20', 0.8, Resource_Class == 'staticrc30', 1.6, Resource_Class == 'staticrc40', 3.2, Resource_Class == 'staticrc50', 6.4, Resource_Class == 'staticrc60', 12.8, Resource_Class == 'staticrc70', 25.6, Resource_Class == 'staticrc80', 51.2, Resource_Class == 'default', 3.0, 0.0) ,0.0) ) //if no match ================================================ FILE: Log_Analytics_queries/WorkspacesSQLPool/QueryList_withResultSetCacheData.kql ================================================ //Query List with ResultSetCache data let databaseName = 'syntheticworkload'; SynapseSqlPoolExecRequests | where _ResourceId endswith databaseName | where StatementType !in ('Batch','Execute') | summarize Request_ID=any(RequestId), Submit_Time=min(TimeGenerated), Start_Time=max(StartTime), End_Time=max(EndTime), Command=any(Command), Status=min(Status), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status Statement_Type=any(StatementType), Resource_class=any(ResourceClass), ResultCacheHit=min(ResultCacheHit) by RequestId | summarize ResultCacheHit=min(ResultCacheHit),ElapsedTime_min=anyif((End_Time - Start_Time)/1m,Start_Time > ago(30d)),Submit_Time=any(Submit_Time) ,Start_Time=any(Start_Time), End_Time=any(End_Time),Command=any(Command),Status=any(Status),Statement_Type=any(Statement_Type),Resource_class=any(Resource_class) by Request_ID | order by ElapsedTime_min desc ================================================ FILE: Log_Analytics_queries/WorkspacesSQLPool/TempTableASHeap.kql ================================================ let databaseName = ''; //If 'Command' is empty - you need to set a bigger time window, the older record with the command is outside of your window SynapseSqlPoolExecRequests | where _ResourceId endswith databaseName | where StatementType !in ('Batch','Execute') | where tolower(Command) contains "create table #" and tolower(Command) !has 'heap' | summarize Request_ID=any(RequestId), Submit_Time=min(TimeGenerated), Start_Time=max(StartTime), End_Time=max(EndTime), Command=any(Command), Status=min(Status), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status Statement_Type=any(StatementType), Resource_class=any(ResourceClass) by RequestId | summarize ElapsedTime_min=anyif((End_Time - Start_Time)/1m,Start_Time > ago(30d)) , Submit_Time=any(Submit_Time) ,Start_Time=any(Start_Time) , End_Time=any(End_Time) ,Command=any(Command) ,Status=any(Status) ,Statement_Type=any(Statement_Type) ,Resource_class=any(Resource_class) by Request_ID | order by ElapsedTime_min desc ================================================ FILE: Log_Analytics_queries/WorkspacesSQLPool/UnionVsUnionAll.kql ================================================ //Usage of Union vs Union ALL let databaseName = ''; SynapseSqlPoolExecRequests | where _ResourceId endswith databaseName | where StatementType !in ('Batch','Execute') | summarize Request_Id=max(RequestId), Submit_Time=min(TimeGenerated), Start_Time=max(StartTime), End_Time=max(EndTime), Command=max(Command), Status=min(Status), Statement_Type=max(StatementType), Resource_class=max(ResourceClass) by RequestId | extend elapsedTime_min = (End_Time - Submit_Time)/1m | where Command has 'Union' and Command !has 'union all' | order by elapsedTime_min | project Request_Id,Submit_Time,Start_Time,End_Time,elapsedTime_min,Command,Status,Statement_Type,Resource_class | limit 50 ================================================ FILE: Monitor_Workbooks/DW_Summary_v1.1.workbook ================================================ { "version": "Notebook/1.0", "items": [ { "type": 9, "content": { "version": "KqlParameterItem/1.0", "crossComponentResources": [ "{Subscriptions}" ], "parameters": [ { "id": "15a2c4b1-1223-428f-80a0-53ec8e8e86a5", "version": "KqlParameterItem/1.0", "name": "TimeRange", "type": 4, "isRequired": true, "value": { "durationMs": 604800000 }, "typeSettings": { "selectableValues": [ { "durationMs": 300000 }, { "durationMs": 900000 }, { "durationMs": 1800000 }, { "durationMs": 3600000 }, { "durationMs": 14400000 }, { "durationMs": 43200000 }, { "durationMs": 86400000 }, { "durationMs": 172800000 }, { "durationMs": 259200000 }, { "durationMs": 604800000 }, { "durationMs": 1209600000 }, { "durationMs": 2419200000 }, { "durationMs": 2592000000 }, { "durationMs": 5184000000 }, { "durationMs": 7776000000 } ], "allowCustom": true } }, { "id": "bc3b3200-d39a-4d72-adc3-8473457d9b30", "version": "KqlParameterItem/1.0", "name": "Subscriptions", "type": 6, "isRequired": true, "multiSelect": true, "quote": "'", "delimiter": ",", "value": [ "value::all" ], "typeSettings": { "additionalResourceOptions": [ "value::1", "value::all" ], "includeAll": false } } ], "style": "pills", "queryType": 1, "resourceType": "microsoft.resourcegraph/resources" }, "name": "parameters - 1" }, { "type": 11, "content": { "version": "LinkItem/1.0", "style": "tabs", "links": [ { "id": "d29d564f-9326-433b-8b87-678461724323", "cellValue": "objectType", "linkTarget": "parameter", "linkLabel": "Dedicated Pools", "subTarget": "dedicated", "style": "link" } ] }, "name": "links - 6" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 11, "content": { "version": "LinkItem/1.0", "style": "tabs", "links": [ { "id": "933d2413-fcd3-4a62-827d-de0aeefd2632", "cellValue": "selectedTab", "linkTarget": "parameter", "linkLabel": "Synapse Dedicated Pools", "subTarget": "synapseDP", "preText": "selec", "style": "link" }, { "id": "e821e971-adcf-4c8b-8cf8-47bf91576670", "cellValue": "selectedTab", "linkTarget": "parameter", "linkLabel": "Standalone Dedicated Pools", "subTarget": "standaloneDP", "style": "link" } ] }, "name": "links - 3" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "crossComponentResources": [ "{Subscriptions}" ], "parameters": [ { "id": "8998a008-ea1b-4f4b-bcc2-44e15deba715", "version": "KqlParameterItem/1.0", "name": "SQLDWDBs", "label": "Standalone Pools", "type": 5, "isRequired": true, "multiSelect": true, "quote": "'", "delimiter": ",", "query": "resources \r\n| where type =~ 'microsoft.sql/servers/databases'\r\n| where sku has \"DataWarehouse\"\r\n| where resourceGroup !startswith \"synapseworkspace-managedrg-\" \r\n| where resourceGroup !startswith \"workspacemanagedrg-\"\r\n| project id", "crossComponentResources": [ "{Subscriptions}" ], "typeSettings": { "additionalResourceOptions": [ "value::1", "value::10", "value::all" ], "showDefault": false }, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "defaultValue": "value::all", "queryType": 1, "resourceType": "microsoft.resourcegraph/resources", "value": [ "value::all" ] } ], "style": "pills", "queryType": 1, "resourceType": "microsoft.resourcegraph/resources" }, "conditionalVisibility": { "parameterName": "selectedTab", "comparison": "isEqualTo", "value": "standaloneDP" }, "name": "Parameters - SQL DW" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "crossComponentResources": [ "{Subscriptions}" ], "parameters": [ { "id": "b8eda6e3-e18a-47bc-9d3f-8df41a29a95c", "version": "KqlParameterItem/1.0", "name": "SynapseDedicatedPools", "type": 5, "multiSelect": true, "quote": "'", "delimiter": ",", "query": "resources\r\n| where type == \"microsoft.synapse/workspaces/sqlpools\"\r\n| project id", "crossComponentResources": [ "{Subscriptions}" ], "typeSettings": { "additionalResourceOptions": [ "value::10", "value::all" ], "showDefault": false }, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "defaultValue": "value::all", "queryType": 1, "resourceType": "microsoft.resourcegraph/resources", "value": [ "value::all" ] } ], "style": "pills", "queryType": 1, "resourceType": "microsoft.resourcegraph/resources" }, "conditionalVisibility": { "parameterName": "selectedTab", "comparison": "isEqualTo", "value": "synapseDP" }, "name": "Parameters - SQL DW - Copy" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 10, "content": { "chartId": "workbookf1358ff0-0e10-4ac2-ab2d-2fdfdb74dc2f", "version": "MetricsItem/2.0", "size": 2, "chartType": 0, "resourceType": "microsoft.synapse/workspaces/sqlpools", "metricScope": 0, "resourceParameter": "SynapseDedicatedPools", "resourceIds": [ "{SynapseDedicatedPools}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 604800000 }, "metrics": [ { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-DWULimit", "aggregation": 3 }, { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-DWUUsedPercent", "aggregation": 3 }, { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-CPUPercent", "aggregation": 3 }, { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-LocalTempDBUsedPercent", "aggregation": 3 }, { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-ActiveQueries", "aggregation": 1 }, { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-QueuedQueries", "aggregation": 1 }, { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-AdaptiveCacheHitPercent", "aggregation": 3 }, { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-AdaptiveCacheUsedPercent", "aggregation": 3 } ], "gridSettings": { "formatters": [ { "columnMatch": "$gen_group", "formatter": 13, "formatOptions": { "linkTarget": "Resource", "showIcon": true } }, { "columnMatch": "Group", "formatter": 13, "formatOptions": { "linkTarget": "Resource", "showIcon": true } }, { "columnMatch": "Subscription", "formatter": 13, "formatOptions": { "linkTarget": "Resource", "showIcon": true } }, { "columnMatch": "Name", "formatter": 5, "formatOptions": { "linkTarget": "Resource" } }, { "columnMatch": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-DWULimit", "formatter": 8, "formatOptions": { "palette": "magenta" } }, { "columnMatch": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-DWULimit Timeline", "formatter": 5 }, { "columnMatch": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-DWUUsedPercent", "formatter": 8, "formatOptions": { "min": 0, "max": 100, "palette": "greenRed" } }, { "columnMatch": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-DWUUsedPercent Timeline", "formatter": 21, "formatOptions": { "palette": "blue" } }, { "columnMatch": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-CPUPercent", "formatter": 8, "formatOptions": { "min": 0, "max": 100, "palette": "greenRed" } }, { "columnMatch": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-CPUPercent Timeline", "formatter": 5 }, { "columnMatch": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-LocalTempDBUsedPercent", "formatter": 8, "formatOptions": { "min": 0, "max": 100, "palette": "greenRed" } }, { "columnMatch": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-LocalTempDBUsedPercent Timeline", "formatter": 21, "formatOptions": { "palette": "yellow" } }, { "columnMatch": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-ActiveQueries", "formatter": 1, "numberFormat": { "unit": 0, "options": null } }, { "columnMatch": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-ActiveQueries Timeline", "formatter": 5 }, { "columnMatch": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-QueuedQueries", "formatter": 1, "numberFormat": { "unit": 0, "options": null } }, { "columnMatch": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-QueuedQueries Timeline", "formatter": 5 }, { "columnMatch": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-AdaptiveCacheHitPercent", "formatter": 8, "formatOptions": { "min": 50, "max": 100, "palette": "redGreen" } }, { "columnMatch": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-AdaptiveCacheHitPercent Timeline", "formatter": 5 }, { "columnMatch": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-AdaptiveCacheUsedPercent", "formatter": 8, "formatOptions": { "min": 0, "max": 100, "palette": "greenRed" } }, { "columnMatch": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-AdaptiveCacheUsedPercent Timeline", "formatter": 5 } ], "rowLimit": 10000, "filter": true, "hierarchySettings": { "treeType": 1, "groupBy": [ "Subscription" ], "expandTopLevel": true, "finalBy": "Name" }, "labelSettings": [ { "columnId": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-DWULimit", "label": "DWU" }, { "columnId": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-DWULimit Timeline", "label": "DWU limit Timeline" }, { "columnId": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-DWUUsedPercent", "label": "DWU (Max)" }, { "columnId": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-DWUUsedPercent Timeline", "label": "DWU Timeline" }, { "columnId": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-CPUPercent", "label": "CPU (Max)" }, { "columnId": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-CPUPercent Timeline", "label": "CPU used percentage Timeline" }, { "columnId": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-LocalTempDBUsedPercent", "label": "Tempdb (Max)" }, { "columnId": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-LocalTempDBUsedPercent Timeline", "label": "Tempdb Timeline" }, { "columnId": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-ActiveQueries", "label": "Total Queries" }, { "columnId": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-ActiveQueries Timeline", "label": "Query Timeline" }, { "columnId": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-QueuedQueries", "label": "Total Queued" }, { "columnId": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-QueuedQueries Timeline", "label": "Queued queries Timeline" }, { "columnId": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-AdaptiveCacheHitPercent", "label": "Cache hit percentage (Max)" }, { "columnId": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-AdaptiveCacheHitPercent Timeline", "label": "Adaptive cache hit percentage Timeline" }, { "columnId": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-AdaptiveCacheUsedPercent", "label": "Cache used percentage (Max)" }, { "columnId": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-AdaptiveCacheUsedPercent Timeline", "label": "Adaptive cache used percentage Timeline" } ] }, "sortBy": [] }, "showPin": true, "name": "Metrics - SQL DW DTU/CPU" } ] }, "conditionalVisibility": { "parameterName": "selectedTab", "comparison": "isEqualTo", "value": "synapseDP" }, "name": "SynapseGroup" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 10, "content": { "chartId": "workbookf1358ff0-0e10-4ac2-ab2d-2fdfdb74dc2f", "version": "MetricsItem/2.0", "size": 2, "chartType": 0, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "SQLDWDBs", "resourceIds": [ "{SQLDWDBs}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 604800000 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-dwu_limit", "aggregation": 3, "columnName": "DWU" }, { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-dwu_consumption_percent", "aggregation": 3 }, { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-cpu_percent", "aggregation": 3 }, { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-physical_data_read_percent", "aggregation": 3 }, { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-local_tempdb_usage_percent", "aggregation": 3, "columnName": "TempDB Usage" }, { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-active_queries", "aggregation": 1 }, { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-queued_queries", "aggregation": 1 } ], "gridSettings": { "formatters": [ { "columnMatch": "$gen_group", "formatter": 13, "formatOptions": { "linkTarget": "Resource", "showIcon": true } }, { "columnMatch": "Group", "formatter": 13, "formatOptions": { "linkTarget": "Resource", "showIcon": true } }, { "columnMatch": "Subscription", "formatter": 13, "formatOptions": { "linkTarget": "Resource", "showIcon": true } }, { "columnMatch": "Name", "formatter": 5 }, { "columnMatch": "DWU", "formatter": 8, "formatOptions": { "palette": "magenta" } }, { "columnMatch": "DWU Timeline", "formatter": 5 }, { "columnMatch": "microsoft.sql/servers/databases-Basic-dwu_consumption_percent", "formatter": 8, "formatOptions": { "min": 0, "max": 100, "palette": "greenRed" }, "numberFormat": { "unit": 1, "options": { "style": "decimal", "useGrouping": false } } }, { "columnMatch": "microsoft.sql/servers/databases-Basic-dwu_consumption_percent Timeline", "formatter": 21, "formatOptions": { "palette": "blue" } }, { "columnMatch": "microsoft.sql/servers/databases-Basic-cpu_percent", "formatter": 8, "formatOptions": { "min": 0, "max": 100, "palette": "greenRed" }, "numberFormat": { "unit": 1, "options": { "style": "decimal" } } }, { "columnMatch": "microsoft.sql/servers/databases-Basic-cpu_percent Timeline", "formatter": 5 }, { "columnMatch": "microsoft.sql/servers/databases-Basic-physical_data_read_percent", "formatter": 8, "formatOptions": { "min": 0, "max": 100, "palette": "greenRed" }, "numberFormat": { "unit": 1, "options": { "style": "decimal" } } }, { "columnMatch": "microsoft.sql/servers/databases-Basic-physical_data_read_percent Timeline", "formatter": 5 }, { "columnMatch": "TempDB Usage", "formatter": 8, "formatOptions": { "min": 0, "max": 100, "palette": "greenRed" } }, { "columnMatch": "TempDB Usage Timeline", "formatter": 21, "formatOptions": { "palette": "red" } }, { "columnMatch": "microsoft.sql/servers/databases-Basic-active_queries", "formatter": 1, "numberFormat": { "unit": 0, "options": null } }, { "columnMatch": "microsoft.sql/servers/databases-Basic-active_queries Timeline", "formatter": 5 }, { "columnMatch": "microsoft.sql/servers/databases-Basic-queued_queries", "formatter": 8, "formatOptions": { "min": 0, "max": 1024, "palette": "yellowOrangeRed" }, "numberFormat": { "unit": 0, "options": { "style": "decimal" } } }, { "columnMatch": "microsoft.sql/servers/databases-Basic-queued_queries Timeline", "formatter": 21, "formatOptions": { "palette": "yellow" } }, { "columnMatch": "microsoft.sql/servers/databases-Basic-local_tempdb_usage_percent", "formatter": 21, "formatOptions": { "palette": "blue" }, "numberFormat": { "unit": 1, "options": { "style": "decimal" } } }, { "columnMatch": "microsoft.sql/servers/databases-Basic-local_tempdb_usage_percent Timeline", "formatter": 8, "formatOptions": { "palette": "blue" } }, { "columnMatch": "microsoft.sql/servers/databases-Basic-dwu_limit", "formatter": 21, "formatOptions": { "palette": "yellow" }, "numberFormat": { "unit": 0, "options": { "style": "decimal" } } } ], "rowLimit": 10000, "filter": true, "hierarchySettings": { "treeType": 1, "groupBy": [ "Subscription" ], "expandTopLevel": true, "finalBy": "Name" }, "sortBy": [ { "itemKey": "$gen_heatmap_DWU_3", "sortOrder": 2 } ], "labelSettings": [ { "columnId": "DWU", "label": "DWU" }, { "columnId": "DWU Timeline", "label": "DWU Timeline" }, { "columnId": "microsoft.sql/servers/databases-Basic-dwu_consumption_percent", "label": "DWU (Max)" }, { "columnId": "microsoft.sql/servers/databases-Basic-dwu_consumption_percent Timeline", "label": "DWU percentage Timeline" }, { "columnId": "microsoft.sql/servers/databases-Basic-cpu_percent", "label": "CPU (Max)" }, { "columnId": "microsoft.sql/servers/databases-Basic-cpu_percent Timeline", "label": "CPU percentage Timeline" }, { "columnId": "microsoft.sql/servers/databases-Basic-physical_data_read_percent", "label": "Data IO (Max)" }, { "columnId": "microsoft.sql/servers/databases-Basic-physical_data_read_percent Timeline", "label": "Data IO percentage Timeline" }, { "columnId": "TempDB Usage", "label": "TempDB (Max)" }, { "columnId": "TempDB Usage Timeline", "label": "TempDB Usage Timeline" }, { "columnId": "microsoft.sql/servers/databases-Basic-active_queries", "label": "Total Queries" }, { "columnId": "microsoft.sql/servers/databases-Basic-active_queries Timeline", "label": "Active queries (Sum) Timeline" }, { "columnId": "microsoft.sql/servers/databases-Basic-queued_queries", "label": "Total Queued Queries" }, { "columnId": "microsoft.sql/servers/databases-Basic-queued_queries Timeline", "label": "Queued queries Timeline" } ] }, "sortBy": [ { "itemKey": "$gen_heatmap_DWU_3", "sortOrder": 2 } ], "showExportToExcel": true }, "showPin": true, "name": "Metrics - SQL DW DTU/CPU" } ] }, "conditionalVisibility": { "parameterName": "selectedTab", "comparison": "isEqualTo", "value": "standaloneDP" }, "name": "standaloneGroup" } ] }, "conditionalVisibility": { "parameterName": "objectType", "comparison": "isEqualTo", "value": "dedicated" }, "name": "Dedicated Pool Group" } ], "fallbackResourceIds": [ "Azure Monitor" ], "$schema": "https://github.com/Microsoft/Application-Insights-Workbooks/blob/master/schema/workbook.json" } ================================================ FILE: Monitor_Workbooks/DedicatedSQLPool_workspace_v1.2.workbook ================================================ { "version": "Notebook/1.0", "items": [ { "type": 9, "content": { "version": "KqlParameterItem/1.0", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "parameters": [ { "id": "f5852627-70ca-4959-8d60-53b48864603f", "version": "KqlParameterItem/1.0", "name": "TimeRange", "type": 4, "isGlobal": true, "value": { "durationMs": 43200000 }, "typeSettings": { "selectableValues": [ { "durationMs": 300000 }, { "durationMs": 900000 }, { "durationMs": 1800000 }, { "durationMs": 3600000 }, { "durationMs": 14400000 }, { "durationMs": 43200000 }, { "durationMs": 86400000 }, { "durationMs": 172800000 }, { "durationMs": 259200000 }, { "durationMs": 604800000 }, { "durationMs": 1209600000 }, { "durationMs": 2419200000 }, { "durationMs": 2592000000 } ], "allowCustom": true }, "timeContext": { "durationMs": 86400000 } }, { "id": "28da10ec-a308-47f5-9819-92ebf810b292", "version": "KqlParameterItem/1.0", "name": "LogAnalyticsSubscription", "type": 6, "value": null, "typeSettings": { "additionalResourceOptions": [], "includeAll": true, "showDefault": false }, "timeContext": { "durationMs": 86400000 } }, { "id": "e383ed24-52ae-447b-9b80-51fd3ab6b919", "version": "KqlParameterItem/1.0", "name": "LogAnalyticsWorkspace", "type": 5, "query": "Resources\r\n| where type == 'microsoft.operationalinsights/workspaces'\r\n| project id\r\n", "crossComponentResources": [ "{LogAnalyticsSubscription}" ], "value": null, "typeSettings": { "additionalResourceOptions": [], "showDefault": false }, "timeContext": { "durationMs": 86400000 }, "queryType": 1, "resourceType": "microsoft.resourcegraph/resources" }, { "id": "9b9fe566-0f52-4a75-a35b-a79c50c6a6f0", "version": "KqlParameterItem/1.0", "name": "DatabaseResourceName", "type": 5, "query": "SynapseSqlPoolExecRequests \r\n| distinct _ResourceId", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "value": null, "typeSettings": { "additionalResourceOptions": [], "showDefault": false }, "timeContext": { "durationMs": 2592000000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "id": "6da2f63f-45a3-4b37-9108-5e8b7e358d85", "version": "KqlParameterItem/1.0", "name": "DatabaseName", "type": 1, "query": "print split (\"{DatabaseResourceName}\",\"/\")[-1]", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "id": "8bba835b-f319-43b3-8ec6-4e051fc6d446", "version": "KqlParameterItem/1.0", "name": "LogicalServerName", "type": 1, "query": "SynapseSqlPoolExecRequests\r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| distinct LogicalServerName", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "id": "b86cd4a2-2303-4288-b48c-1c119cb420ba", "version": "KqlParameterItem/1.0", "name": "AuditingState", "type": 1, "query": "let hasNonEmptyTable = (T:string) \r\n{ \r\n toscalar( \r\n union isfuzzy=true \r\n ( table(T) \r\n | where DatabaseName has '{DatabaseName}'\r\n | where TimeGenerated > ago(30d)| take 1 | count as Count ),\r\n (print Count=0) \r\n | summarize sum(Count) \r\n ) > 0\r\n};\r\nlet TableName = 'SQLSecurityAuditEvents';\r\nprint IsPresent=iif(hasNonEmptyTable(TableName ), \"enabled\", \"disabled\")", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 604800000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "id": "4025bcb8-f6d7-4e81-b805-84253835f8fb", "version": "KqlParameterItem/1.0", "name": "DiagnosticsState", "type": 1, "query": "let hasNonEmptyTable = (T:string, T2:string) \r\n{ \r\n toscalar( \r\n union isfuzzy=true \r\n ( table(T) | where TimeGenerated > ago(30d) | where _ResourceId endswith '/sqlpools/{DatabaseName}'| take 1 | count as Count ),\r\n ( table(T2) | where TimeGenerated > ago(30d) | where _ResourceId endswith '/sqlpools/{DatabaseName}'| take 1 | count as Count),\r\n (print Count=0) \r\n | summarize sum(Count) \r\n ) > 1\r\n};\r\nlet TableName = 'SynapseSqlPoolExecRequests';\r\nlet TableName2 = 'SynapseSqlPoolRequestSteps';\r\nprint IsPresent=iif(hasNonEmptyTable(TableName,TableName2 ), \"enabled\", \"disabled\")", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 2592000000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "customWidth": "90", "name": "parameters - 2" }, { "type": 1, "content": { "json": "Select your Log Analytics Workspace by setting the parameters above from left to right. ", "style": "warning" }, "conditionalVisibility": { "parameterName": "DatabaseResourceName", "comparison": "isEqualTo" }, "customWidth": "30", "name": "text - 14" }, { "type": 11, "content": { "version": "LinkItem/1.0", "style": "tabs", "links": [ { "id": "202cbbc0-8d63-416d-89ed-451d6fe7c4b3", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Overview", "subTarget": "Overview", "preText": "Workload", "style": "link" }, { "id": "a7901bd0-a1f4-4491-b953-57555d764e00", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Workload Management", "subTarget": "WorkloadManagement", "style": "link" }, { "id": "45e12a14-8548-4477-aae3-c142b906dc9f", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "TempDB", "subTarget": "TempDB", "style": "link" }, { "id": "9ef8f730-d73d-432b-9b75-55095d1155f2", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Replicated Tables", "subTarget": "ReplicatedTables", "style": "link" }, { "id": "79d10d16-0696-4214-b306-c7a0e46cd64f", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Query Investigation", "subTarget": "QueryInvestigation", "style": "link" }, { "id": "31c1cf1c-74b5-44e2-ba9a-9497834ca3dc", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Query Comparison", "subTarget": "QueryComparison", "style": "link" }, { "id": "db43bb45-1611-47ce-a2ad-517943f2aa1a", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "AutoStats", "subTarget": "Statistics", "style": "link" }, { "id": "482ccc46-8a10-4ace-bfd6-63ac73b380af", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Query Audit", "subTarget": "QueryAudit", "style": "link" }, { "id": "f42ddeea-8cc0-4095-bc90-11eac0b7f94c", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Audit Search", "subTarget": "AuditSearch", "style": "link" } ] }, "name": "links - 0" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 10, "content": { "chartId": "workbook90867bfc-5c33-464f-ac31-2c2e006b97f4", "version": "MetricsItem/2.0", "size": 0, "chartType": 2, "resourceType": "microsoft.synapse/workspaces/sqlpools", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 2592000000 }, "metrics": [ { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-DWUUsedPercent", "aggregation": 3, "splitBy": null, "columnName": "DWU Usaed %" }, { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-CPUPercent", "aggregation": 3, "columnName": "CPU Used %" } ], "title": "DWU Resource Utilization", "showOpenInMe": true, "showCreateAlertRule": true, "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "showPin": true, "name": "metric - 1" }, { "type": 10, "content": { "chartId": "workbookb954d4a0-82ef-4409-88fb-837aaff80c8d", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.synapse/workspaces/sqlpools", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 0 }, "metrics": [ { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-ActiveQueries", "aggregation": 1, "splitBy": null }, { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-QueuedQueries", "aggregation": 1 } ], "title": "Active and Queued Queries", "showOpenInMe": true, "showCreateAlertRule": true, "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "showPin": true, "name": "metric - 1" }, { "type": 10, "content": { "chartId": "workbookb954d4a0-82ef-4409-88fb-837aaff80c8d", "version": "MetricsItem/2.0", "size": 0, "chartType": 3, "resourceType": "microsoft.synapse/workspaces/sqlpools", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 2592000000 }, "metrics": [ { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-LocalTempDBUsedPercent", "aggregation": 3, "splitBy": null, "columnName": "TempDB Utilization Percentage" } ], "title": "TempDB Utilization", "showOpenInMe": true, "showCreateAlertRule": true, "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "showPin": true, "name": "metric - 1 - Copy" }, { "type": 10, "content": { "chartId": "workbookb954d4a0-82ef-4409-88fb-837aaff80c8d", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.synapse/workspaces/sqlpools", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 0 }, "metrics": [ { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool Workload management-WLGAllocationBySystemPercent", "aggregation": 3, "splitBy": null, "columnName": "Workload Group Allocation by System %" } ], "title": "Workload Group Utilization", "showOpenInMe": true, "showCreateAlertRule": true, "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "showPin": true, "name": "Workload Group Utilization" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Long-Running Queries - Just Actual Queries\r\n//If 'Command' is empty - you need to set a bigger time window, the older record with the command is outside of your window\r\nSynapseSqlPoolExecRequests \r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where StatementType !in ('Batch','Execute')\r\n| summarize //Session_ID=any(SessionId),\r\n Request_ID=any(RequestId),\r\n //Submit_Time=max(SubmitTime),\r\n Start_Time=max(StartTime),\r\n End_Time=max(EndTime),\r\n Command=any(Command),\r\n Status=min(Status), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType),\r\n Resource_class=any(ResourceClass)\r\n by RequestId\r\n| summarize ElapsedTime_min=bin(anyif(((End_Time - Start_Time)/1m),Start_Time > ago(30d)),1),\r\n //Session_ID=any(Session_ID), \r\n // Submit_Time=any(Submit_Time) ,\r\n Start_Time=any(Start_Time), \r\n End_Time=any(End_Time),\r\n Command=any(Command),\r\n Status=any(Status),\r\n Statement_Type=any(Statement_Type)\r\n ,Resource_class=any(Resource_class) \r\n by Request_ID\r\n| where End_Time > ago(365d)\r\n| summarize count() by Status, bin(End_Time,5m)\r\n| render barchart \r\n", "size": 0, "showAnalytics": true, "title": "Query Completion Count by End Time - 5m buckets", "color": "redBright", "timeContextFromParameter": "TimeRange", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "chartSettings": { "seriesLabelSettings": [ { "seriesName": "Completed", "color": "green" }, { "seriesName": "Failed", "color": "red" }, { "seriesName": "Cancelled", "color": "yellow" } ] } }, "showPin": true, "name": "query - 4" }, { "type": 1, "content": { "json": "Use the buttons below to filter the next chart for Success or Failed queries. In many cases a failed query may not have a 'Command' column populated depending on what stage the query failed in. ", "style": "info" }, "customWidth": "25", "name": "text - 3" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "e2a833ac-48b4-4ccd-bbcd-33fccf1dbd75", "version": "KqlParameterItem/1.0", "name": "QueryCompletionType", "type": 1, "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 } } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 4" }, { "type": 11, "content": { "version": "LinkItem/1.0", "style": "nav", "links": [ { "id": "8e89112f-c67f-42c0-9622-02fa306fb7a5", "cellValue": "QueryCompletionType", "linkTarget": "parameter", "linkLabel": "All Queries", "subTarget": "''", "style": "primary" }, { "id": "6abe39c7-4d4e-4c45-aa54-dc9a4c5e876e", "cellValue": "QueryCompletionType", "linkTarget": "parameter", "linkLabel": "Success Only", "subTarget": "Completed", "preText": "", "style": "secondary" }, { "id": "e41b4a0b-8464-491e-92be-a57217d6dcac", "cellValue": "QueryCompletionType", "linkTarget": "parameter", "linkLabel": "Failures Only", "subTarget": "Failed", "preText": "", "style": "secondary" } ] }, "name": "links - 11" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Long-Running Queries - Just Actual Queries\r\n//If 'Command' is empty - you need to set a bigger time window, the older record with the command is outside of your window\r\nSynapseSqlPoolExecRequests \r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where StatementType !in ('Batch','Execute')\r\n| summarize //Session_ID=any(SessionId),\r\n Request_ID=any(RequestId),\r\n Start_Time=max(StartTime),\r\n End_Time=max(EndTime),\r\n Command=any(Command),\r\n Status=min(Status), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType),\r\n Resource_class=any(ResourceClass)\r\n by RequestId\r\n| summarize ElapsedTime_min=bin(anyif(((End_Time - Start_Time)/1m),Start_Time > ago(30d)),1),\r\n Start_Time=any(Start_Time), \r\n End_Time=any(End_Time),\r\n Command=any(Command),\r\n Status=any(Status),\r\n Statement_Type=any(Statement_Type)\r\n ,Resource_class=any(Resource_class) \r\n by Request_ID\r\n| where Status has '{QueryCompletionType}'\r\n| order by Start_Time\r\n\r\n", "size": 0, "showAnalytics": true, "title": "Query Completions - use above buttons to filter", "color": "redBright", "timeContextFromParameter": "TimeRange", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "rowLimit": 100 }, "chartSettings": { "seriesLabelSettings": [ { "seriesName": "Completed", "color": "green" }, { "seriesName": "Failed", "color": "red" }, { "seriesName": "Cancelled", "color": "yellow" } ] } }, "showPin": true, "name": "query - 4 - Copy" } ] }, "name": "Query Completions", "styleSettings": { "showBorder": true } }, { "type": 10, "content": { "chartId": "workbook1afc57e6-0b32-4968-b299-db319bd21635", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.synapse/workspaces/sqlpools", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 2592000000 }, "metrics": [ { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-Connections", "aggregation": 1, "splitBy": null }, { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-ConnectionsBlockedByFirewall", "aggregation": 1 } ], "title": "Successful and Failed Connections", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "name": "metric - 5" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 3, "content": { "version": "KqlItem/1.0", "query": " SQLSecurityAuditEvents\r\n | where LogicalServerName == '{LogicalServerName}'\r\n | where ActionName in ('DATABASE AUTHENTICATION SUCCEEDED','DATABASE AUTHENTICATION FAILED')\r\n | project SourceSystem,ClientTlsVersion ,Succeeded,SessionId,ClientIp,SessionServerPrincipalName,ServerPrincipalName,DatabasePrincipalName,ApplicationName,HostName,TimeGenerated\r\n | summarize count() by Succeeded,bin(TimeGenerated,1m)\r\n | render barchart\r\n\r\n\r\n\r\n", "size": 0, "showAnalytics": true, "title": "Database Authentication success/failure rate", "timeContextFromParameter": "TimeRange", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "chartSettings": { "xAxis": "TimeGenerated", "group": "succeeded_s", "createOtherGroup": null } }, "showPin": true, "name": "query - 8" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "f7485a11-48df-4b61-a70e-9f56d6a00ec6", "version": "KqlParameterItem/1.0", "name": "AuthResult", "type": 1, "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 } } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 3" }, { "type": 11, "content": { "version": "LinkItem/1.0", "style": "nav", "links": [ { "id": "2ed22e0a-2b53-4ed0-8f65-d2c621f34dad", "cellValue": "AuthResult", "linkTarget": "parameter", "linkLabel": "All Authentications", "subTarget": "''", "style": "primary" }, { "id": "2789ab13-ae8a-472e-bad4-9c9bdc934d4d", "cellValue": "AuthResult", "linkTarget": "parameter", "linkLabel": "Success Only", "subTarget": "true", "style": "secondary" }, { "id": "5cf4ddd4-e189-4b71-b456-0d4f1572a0a3", "cellValue": "AuthResult", "linkTarget": "parameter", "linkLabel": "Failures Only", "subTarget": "false", "style": "secondary" } ] }, "name": "links - 10" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": " SQLSecurityAuditEvents\r\n | where LogicalServerName == '{LogicalServerName}'\r\n | where ActionName in ('DATABASE AUTHENTICATION SUCCEEDED','DATABASE AUTHENTICATION FAILED')\r\n | where Succeeded == '{AuthResult}'\r\n | project SourceSystem,ClientTlsVersion ,Succeeded,SessionId,ClientIp,SessionServerPrincipalName,ServerPrincipalName,DatabasePrincipalName,ApplicationName,HostName,TimeGenerated\r\n //| summarize count() by Succeeded,bin(TimeGenerated,1m)\r\n\r\n\r\n\r\n\r\n\r\n", "size": 0, "showAnalytics": true, "title": "Database Authentication success/failure rate", "noDataMessage": "No Results", "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "rowLimit": 100 }, "chartSettings": { "xAxis": "TimeGenerated", "group": "succeeded_s", "createOtherGroup": null, "showLegend": true } }, "showPin": true, "name": "query - 8 - Copy" } ] }, "conditionalVisibility": { "parameterName": "AuditingState", "comparison": "isEqualTo", "value": "enabled" }, "name": "Database Authentication Group", "styleSettings": { "showBorder": true } }, { "type": 10, "content": { "chartId": "workbook993837ad-66d6-4cbc-ae1a-7c3f6623236b", "version": "MetricsItem/2.0", "size": 0, "chartType": 2, "resourceType": "microsoft.synapse/workspaces/sqlpools", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 2592000000 }, "metrics": [ { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-AdaptiveCacheUsedPercent", "aggregation": 3, "splitBy": null }, { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-AdaptiveCacheHitPercent", "aggregation": 3 } ], "title": "Adaptive Cache Used vs Hit Percentage", "showCreateAlertRule": true, "gridSettings": { "rowLimit": 10000 } }, "showPin": true, "name": "metric - 6" } ] }, "conditionalVisibilities": [ { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "Overview" }, { "parameterName": "DiagnosticsState", "comparison": "isEqualTo", "value": "enabled" } ], "name": "overviewGroup" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 10, "content": { "chartId": "workbook4a9cf761-cce2-45b2-8947-8a9428ec7e1c", "version": "MetricsItem/2.0", "size": 0, "chartType": 3, "resourceType": "microsoft.synapse/workspaces/sqlpools", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 86400000 }, "metrics": [ { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-LocalTempDBUsedPercent", "aggregation": 3, "splitBy": null, "columnName": "TempDB Util" } ], "title": "TempDB Max and Avg Utilization", "showOpenInMe": true, "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "showPin": true, "name": "metric - 0" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "19ee48f5-8f4e-4939-a0ef-c6bf656a93f9", "version": "KqlParameterItem/1.0", "name": "WeightParameter", "type": 1, "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 } }, { "id": "00553ec8-1a41-4dd9-a024-d607639c9bbb", "version": "KqlParameterItem/1.0", "name": "RequestID", "type": 1, "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 }, "value": "" } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 3" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databaseResourceName = '{DatabaseResourceName}';\r\n//Weighted query steps\r\nSynapseSqlPoolRequestSteps \r\n| where _ResourceId == databaseResourceName\r\n| where RowCount > 0\r\n| summarize sum(RowCount) by RequestId, OperationType\r\n| order by sum_RowCount desc\r\n| limit 20\r\n| render columnchart ", "size": 0, "showAnalytics": true, "title": "20 Largest Query Steps by Most Rows Moved", "timeContextFromParameter": "TimeRange", "exportFieldName": "Request_ID", "exportParameterName": "RequestID", "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "chartSettings": { "xAxis": "RequestId", "group": "OperationType", "createOtherGroup": 20, "showLegend": true } }, "showPin": true, "name": "query - 1 - Copy" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "8afacdd5-2690-48d0-b125-fb118378e90c", "version": "KqlParameterItem/1.0", "name": "WeightParameter", "type": 1, "value": "Unweighted", "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 } } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 8" }, { "type": 11, "content": { "version": "LinkItem/1.0", "style": "nav", "links": [ { "id": "c98d3722-9907-43ab-9306-1957d6f7f858", "cellValue": "WeightParameter", "linkTarget": "parameter", "linkLabel": "Weighted Rowcounts", "subTarget": "Weighted", "preText": "", "postText": "", "style": "secondary" }, { "id": "a06ae99a-ad62-45e9-8c25-c219b81f59c0", "cellValue": "WeightParameter", "linkTarget": "parameter", "linkLabel": "Unweighted Rowcounts", "subTarget": "Unweighted", "preText": "", "postText": "", "style": "secondary" } ] }, "name": "links - 3" }, { "type": 1, "content": { "json": "Current Setting: {WeightParameter}", "style": "info" }, "customWidth": "25", "name": "text - 4" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databaseResourceName = '{DatabaseResourceName}';\r\n//Weighted query steps\r\nlet RequestSteps = SynapseSqlPoolRequestSteps\r\n| where _ResourceId == databaseResourceName\r\n//| where RowCount > 10000000\r\n| extend Step_Elapsed_Min = round((EndTime - StartTime) /1m, 2)\r\n| extend Weighted_cnt = iff('{WeightParameter}'=='Weighted',(case(OperationType == 'BroadcastMoveOperation', (RowCount*10), RowCount)),RowCount)\r\n| project-rename StepStatus = Status, StepStart = StartTime, StepEnd = EndTime//, StepResource = Resource\r\n| top 100 by Weighted_cnt desc\r\n| order by Weighted_cnt desc\r\n| project Request_ID=RequestId,OperationType, RowCount,Weighted_cnt,Step_Elapsed_Min, StepStart, StepEnd, StepStatus, StepIndex;\r\nRequestSteps | join (\r\nSynapseSqlPoolExecRequests\r\n| where _ResourceId == databaseResourceName\r\n| where StatementType !in ('Batch','Execute')\r\n| summarize //Session_ID=any(SessionId),\r\n Request_ID=any(RequestId),\r\n //Submit_Time=max(SubmitTime),\r\n Start_Time=max(StartTime),\r\n End_Time=max(EndTime),\r\n Command=any(Command),\r\n Status=min(Status), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType),\r\n Resource_class=any(ResourceClass)\r\n by RequestId\r\n| summarize //Session_ID=any(Session_ID), \r\n//Submit_Time=any(Submit_Time) ,\r\nStart_Time=any(Start_Time), End_Time=any(End_Time),Command=any(Command),Status=any(Status),Statement_Type=any(Statement_Type),Resource_class=any(Resource_class) by Request_ID\r\n//| order by Step_Elapsed_Min desc\r\n| extend Request_Elapsed_Min = round((End_Time - Start_Time)/1m, 2)\r\n| project-rename ReqStatus = Status, ReqStart = Start_Time, ReqEnd = End_Time\r\n) on Request_ID\r\n| project-reorder //Session_ID, \r\nRequest_ID, Request_Elapsed_Min, ReqStart, ReqEnd, ReqStatus,StepIndex, OperationType, RowCount,Weighted_cnt,Step_Elapsed_Min, StepStart, StepEnd, StepStatus, Statement_Type, Command, Resource_class\r\n| order by Weighted_cnt desc\r\n| limit 20", "size": 3, "showAnalytics": true, "title": "20 Largest Query Steps by Most Rows Moved", "timeContextFromParameter": "TimeRange", "exportFieldName": "Request_ID1", "exportParameterName": "RequestID", "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "sortBy": [ { "itemKey": "Weighted_cnt", "sortOrder": 2 } ] }, "sortBy": [ { "itemKey": "Weighted_cnt", "sortOrder": 2 } ] }, "showPin": true, "name": "query - 1" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databaseResourceName = '{DatabaseResourceName}';\r\n//Long-Running Queries - Just Actual Queries\r\n//If 'Command' is empty - you need to set a bigger time window, the older record with the command is outside of your window\r\nSynapseSqlPoolExecRequests\r\n| where _ResourceId == databaseResourceName\r\n| where StatementType !in ('Batch','Execute')\r\n| summarize //Session_ID=any(SessionId),\r\n Request_ID=any(RequestId),\r\n Start_Time=max(StartTime),\r\n End_Time=max(EndTime),\r\n Command=any(Command),\r\n Status=min(Status), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType),\r\n Resource_class=any(ResourceClass)\r\n by RequestId\r\n| summarize ElapsedTime_min=bin(anyif(((End_Time - Start_Time)/1m),Start_Time > ago(30d)),1),\r\n Start_Time=any(Start_Time), \r\n End_Time=any(End_Time),\r\n Command=any(Command),\r\n Status=any(Status),\r\n Statement_Type=any(Statement_Type)\r\n ,Resource_class=any(Resource_class) \r\n by Request_ID\r\n| where Request_ID == '{RequestID}' and Request_ID != ''\r\n\r\n", "size": 4, "showAnalytics": true, "title": "Selected Query", "noDataMessage": "Select a query above to view details", "noDataMessageStyle": 4, "timeContextFromParameter": "TimeRange", "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "35%" } } ] } }, "showPin": true, "name": "query - 6" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolRequestSteps \r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where RequestId == '{RequestID}' and RequestId != '' //Put your QueryID here\r\n| where Status != 'Running'\r\n| summarize max(StartTime),max(EndTime),max(RequestId),max(OperationType),max(RowCount),max(Command),max(Status) by StepIndex\r\n| order by StepIndex asc", "size": 3, "showAnalytics": true, "title": "Query Plan", "noDataMessage": "Select a query above to view the plan", "noDataMessageStyle": 4, "timeContextFromParameter": "TimeRange", "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "showPin": true, "name": "query - 7" } ] }, "conditionalVisibilities": [ { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "TempDB" }, { "parameterName": "DiagnosticsState", "comparison": "isEqualTo", "value": "enabled" } ], "name": "TempDBGroup" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 1, "content": { "json": "## Search Criteria\r\nUse the following fields to search either using a query text snippet or using a Request ID. If using a query text snippet, try to keep it as simple as possible becuase minor changes in formatting may cause your queries not to show up in the results. It's best to pick something like a table name, then choose the proper query from the list that will populate. " }, "customWidth": "50", "name": "text - 4" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "4b98dd26-4ccf-420e-a990-8d015f27fb76", "version": "KqlParameterItem/1.0", "name": "SampleQID", "type": 1, "value": "999", "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 } }, { "id": "d5524dd5-cf7e-41cf-beb3-474b3290289e", "version": "KqlParameterItem/1.0", "name": "RequestId", "type": 1, "value": "", "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 } } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "initializeQueryInvestigationParameters" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "0c2128d0-d979-4562-a28c-e7ceb955f126", "version": "KqlParameterItem/1.0", "name": "RequestId", "type": 1, "value": "", "label": "Request Id Search" }, { "id": "29880874-2d41-4bd5-bf22-3e47ae8b1145", "version": "KqlParameterItem/1.0", "name": "QueryTextSnippet", "type": 1, "value": "", "timeContext": { "durationMs": 86400000 } } ], "style": "formVertical", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "customWidth": "60", "name": "parameters - 3" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolExecRequests\r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where StatementType !in ('Batch','Execute')\r\n| summarize \r\n Request_ID=max(RequestId), \r\n Start_Time=max(StartTime),\r\n End_Compile_Time=max(EndCompileTime), \r\n End_Time=max(EndTime), \r\n QueryText = any(Command), \r\n Last_Status=min(Status),\r\n Statement_Type=max(StatementType),\r\n Resource_class=max(ResourceClass) \r\n by RequestId\r\n| extend Elapsed_Time_s=(End_Time - Start_Time)/1s\r\n| where QueryText has '{QueryTextSnippet}'\r\nand RequestId has '{RequestId}'\r\n| summarize \r\n Executions = count(),\r\n SampleQID = any(RequestId),\r\n Elapsed_Time_s=max(Elapsed_Time_s)\r\n by QueryText\r\n| order by Elapsed_Time_s\r\n\r\n\r\n\r\n", "size": 0, "showAnalytics": true, "title": "Matching Queries", "timeContextFromParameter": "TimeRange", "exportedParameters": [ { "fieldName": "SampleQID", "parameterName": "SampleQID" }, { "fieldName": "SampleQID", "parameterName": "RequestId", "parameterType": 1 }, { "fieldName": "QueryText", "parameterName": "QueryText", "parameterType": 1 } ], "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "50%" } } ], "sortBy": [ { "itemKey": "Elapsed_Time_s", "sortOrder": 2 } ] }, "sortBy": [ { "itemKey": "Elapsed_Time_s", "sortOrder": 2 } ] }, "showPin": true, "name": "query - 0" }, { "type": 1, "content": { "json": "## DSQL Command " }, "conditionalVisibility": { "parameterName": "QueryText", "comparison": "isNotEqualTo" }, "name": "text - 8" }, { "type": 1, "content": { "json": "```{QueryText}```\r\n" }, "conditionalVisibility": { "parameterName": "QueryText", "comparison": "isNotEqualTo" }, "name": "ShowQueryText", "styleSettings": { "showBorder": true } }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolExecRequests\r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where StatementType !in ('Batch','Execute')\r\n| where RequestId == '{SampleQID}'\r\n| summarize \r\n Request_ID=max(RequestId), \r\n Start_Time=max(StartTime),\r\n End_Compile_Time=max(EndCompileTime), \r\n End_Time=max(EndTime), \r\n Command=max(Command), \r\n Last_Status=min(Status),\r\n Statement_Type=max(StatementType),\r\n Resource_class=max(ResourceClass) \r\n by RequestId\r\n| extend elapsedTime_sec = iif(End_Time > ago(365d),(End_Time - Start_Time)/1s,real(null)) \r\n| join kind=inner\r\n (SynapseSqlPoolExecRequests\r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where StatementType !in ('Batch','Execute')\r\n | summarize \r\n Request_ID=max(RequestId), \r\n Start_Time=max(StartTime),\r\n End_Compile_Time=max(EndCompileTime), \r\n End_Time=max(EndTime), \r\n Command=max(Command), \r\n Last_Status=min(Status),\r\n Statement_Type=max(StatementType),\r\n Resource_class=max(ResourceClass) \r\n by RequestId\r\n //| extend elapsedTime_sec = (End_Time - Start_Time)/1s\r\n | extend elapsedTime_sec = iif(End_Time > ago(365d),(End_Time - Start_Time)/1s,real(null)) \r\n )\r\non Command \r\n| project Request_ID1,Start_Time1,End_Compile_Time1,End_Time1,Last_Status1,Statement_Type1,Resource_class1,elapsedTime_sec1\r\n", "size": 0, "showAnalytics": true, "title": "All Executions of Selected Query Text", "noDataMessage": "Select a query above to see individual executions", "noDataMessageStyle": 4, "timeContextFromParameter": "TimeRange", "exportFieldName": "Request_ID1", "exportParameterName": "RequestId", "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "sortBy": [] }, "showPin": true, "name": "query - 0 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolRequestSteps \r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where RequestId == '{RequestId}' and RequestId != ''\r\n| where Status != 'Running'\r\n| summarize max(StartTime),max(EndTime),max(RequestId),max(OperationType),max(RowCount),max(Command),max(Status) by StepIndex\r\n| order by StepIndex asc", "size": 3, "showAnalytics": true, "title": "Query Plan for Selected Query", "noDataMessage": "Select a Query Above to See the Query Plan", "noDataMessageStyle": 4, "timeContextFromParameter": "TimeRange", "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 0 - Copy - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolExecRequests\r\n | where StatementType =='CreateStatistics'\r\n | where _ResourceId has '{DatabaseName}'\r\n | summarize \r\n Root_Query_Id=max(RootQueryId), \r\n Start_Time=max(StartTime),\r\n End_Compile_Time=max(EndCompileTime), \r\n End_Time=max(EndTime), \r\n Command=max(Command), \r\n Last_Status=min(Status),\r\n Statement_Type=max(StatementType),\r\n Resource_class=max(ResourceClass) \r\n by RequestId\r\n | where Root_Query_Id == '{RequestId}'", "size": 0, "showAnalytics": true, "title": "Triggered Auto-Stats Statements", "noDataMessage": "No triggered autostats statements found", "timeContextFromParameter": "TimeRange", "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Submit_Time", "formatter": 0, "numberFormat": { "unit": 0, "options": { "style": "decimal" } } }, { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "100ch" } } ] } }, "name": "All triggered auto-stats statements" } ] }, "conditionalVisibilities": [ { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "QueryInvestigation" }, { "parameterName": "DiagnosticsState", "comparison": "isEqualTo", "value": "enabled" } ], "name": "QueryInvestigationGroup", "styleSettings": { "showBorder": true } }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 1, "content": { "json": "All Charts on this page are based on the last 7 days of data", "style": "info" }, "customWidth": "25", "name": "text - 5" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "533ff6bb-97cd-4aaa-9372-171cad378bcd", "version": "KqlParameterItem/1.0", "name": "QueryText", "type": 1, "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 } }, { "id": "99de0056-d4f3-465e-a27e-599d69b23c77", "version": "KqlParameterItem/1.0", "name": "RequestId", "type": 1, "value": "999", "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 } } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "initializeTempDBVariables" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Build cache count by day\r\nlet databaseResourceName = '{DatabaseResourceName}';\r\n//Long-Running Queries - Just Actual Queries\r\n//If 'Command' is empty - you need to set a bigger time window, the older record with the command is outside of your window\r\nSynapseSqlPoolExecRequests\r\n| where _ResourceId == databaseResourceName\r\n| where StatementType == 'BuildReplicatedTableCache'\r\n| where Command != \"\"\r\n| where ResourceClass != \"\"\r\n| project Command,TimeGenerated,RequestId\r\n| summarize LastRebuild=max(TimeGenerated),RebuildCount=count(RequestId) by Command\r\n| order by RebuildCount desc\r\n| limit 15\r\n", "size": 3, "showAnalytics": true, "title": "Top 15 Most Rebuilds by Table", "noDataMessage": "No replicated table rebuilds found in the last 7 days", "noDataMessageStyle": 4, "timeContext": { "durationMs": 604800000 }, "exportFieldName": "Command", "exportParameterName": "QueryText", "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command_s", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "40%" } } ] } }, "showPin": true, "name": "query - 0" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Build cache count by day\r\nlet databaseResourceName = '{DatabaseResourceName}';\r\nSynapseSqlPoolExecRequests\r\n| where _ResourceId == databaseResourceName\r\n| where StatementType == 'BuildReplicatedTableCache'\r\n| where Command == \"{QueryText}\"\r\n| where ResourceClass != \"\"\r\n| project Command,TimeGenerated,RequestId\r\n| summarize count() by Command,bin(TimeGenerated,24h)\r\n| limit 20\r\n| render timechart", "size": 0, "showAnalytics": true, "title": "Rebuilds per Day for Selected Table", "noDataMessage": "Select a query above to see runs by day", "noDataMessageStyle": 4, "timeContext": { "durationMs": 604800000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "chartSettings": { "group": "Command_s", "createOtherGroup": 20, "ySettings": { "min": 0 } } }, "showPin": true, "name": "query - 0 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Build cache count by day\r\nlet databaseResourceName = '{DatabaseResourceName}';\r\n//Long-Running Queries - Just Actual Queries\r\n//If 'Command' is empty - you need to set a bigger time window, the older record with the command is outside of your window\r\nSynapseSqlPoolExecRequests\r\n| where _ResourceId == databaseResourceName\r\n| where StatementType == 'BuildReplicatedTableCache'\r\n| where Command != \"\"\r\n| where ResourceClass != \"\"\r\n| project Command,TimeGenerated,RequestId\r\n| summarize count() by Command, bin(TimeGenerated,24h)\r\n//| where count_ > 7\r\n| order by count_ desc\r\n\r\n", "size": 2, "showAnalytics": true, "title": "Rebuild Count by Table by Day", "noDataMessage": " Only tables with more than 7 total rebuilds will show up. If no talbes with that many rebuilds are found this chart will be empty", "noDataMessageStyle": 4, "timeContext": { "durationMs": 604800000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "categoricalbar", "gridSettings": { "sortBy": [ { "itemKey": "count_", "sortOrder": 1 } ] }, "sortBy": [ { "itemKey": "count_", "sortOrder": 1 } ], "tileSettings": { "showBorder": false, "titleContent": { "columnMatch": "Command_s", "formatter": 1 }, "leftContent": { "columnMatch": "count_", "formatter": 12, "formatOptions": { "palette": "auto" }, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "graphSettings": { "type": 0, "topContent": { "columnMatch": "Command_s", "formatter": 1 }, "centerContent": { "columnMatch": "count_", "formatter": 1, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "chartSettings": { "group": "Command_s", "createOtherGroup": 99, "showDataPoints": true } }, "showPin": true, "name": "query - 0 - Copy - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databaseResourceName = '{DatabaseResourceName}';\r\n//Long-Running Queries - Just Actual Queries\r\n//If 'Command' is empty - you need to set a bigger time window, the older record with the command is outside of your window\r\nSynapseSqlPoolExecRequests\r\n| where _ResourceId == databaseResourceName\r\n| where StatementType == 'BuildReplicatedTableCache'\r\n| summarize Start_Time=max(StartTime), End_Time=max(EndTime), Command=max(Command), Statement_Type=max(StatementType), Resource_class=max(ResourceClass) by RequestId\r\n| join kind= inner\r\n(\r\n SynapseSqlPoolExecRequests\r\n | where _ResourceId == databaseResourceName\r\n | where StatementType == 'BuildReplicatedTableCache'\r\n | where StatementType == 'BuildReplicatedTableCache'\r\n | where EndTime > ago(7d)\r\n | where StartTime > ago(7d)\r\n | extend elapsedTime_min = (EndTime - StartTime)/1m\r\n | order by elapsedTime_min desc\r\n | project RequestId,elapsedTime_min \r\n)\r\non RequestId\r\n| order by elapsedTime_min desc\r\n| project RequestId,Start_Time,End_Time,Elapsed_Time=round(elapsedTime_min,1) ,Command\r\n| limit 15\r\n", "size": 3, "showAnalytics": true, "title": "Top 15 Elapsed Time per Rebuild", "noDataMessageStyle": 4, "timeContext": { "durationMs": 604800000 }, "exportFieldName": "RequestId", "exportParameterName": "RequestId", "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "40%" } } ] } }, "showPin": true, "name": "query - 3" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": " let databaseResourceName = '{DatabaseResourceName}';\r\nSynapseSqlPoolRequestSteps \r\n| where _ResourceId == databaseResourceName\r\n| where RequestId == '{RequestId}'\r\n| where Status != 'Running'\r\n| summarize max(StartTime),max(EndTime),max(RequestId),max(OperationType),max(RowCount),max(Command),max(Status) by StepIndex\r\n| order by StepIndex asc", "size": 3, "showAnalytics": true, "title": "Query Plan for Selected Query", "noDataMessage": "Select a query above to view plan", "noDataMessageStyle": 4, "timeContext": { "durationMs": 604800000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "showPin": true, "name": "query - 4" } ] }, "conditionalVisibilities": [ { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "ReplicatedTables" }, { "parameterName": "DiagnosticsState", "comparison": "isEqualTo", "value": "enabled" } ], "name": "ReplicatedTablesGroup" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 10, "content": { "chartId": "workbook72446028-6edb-4cb0-8952-e0c13bda488f", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.synapse/workspaces/sqlpools", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 14400000 }, "metrics": [ { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool Workload management-WLGAllocationBySystemPercent", "aggregation": 3, "splitBy": "WorkloadGroup" } ], "title": "Workload Group Allocation By System Percent", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "name": "metric - 0" }, { "type": 10, "content": { "chartId": "workbookc898119a-7381-469d-b51a-d505b4f80e73", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.synapse/workspaces/sqlpools", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 14400000 }, "metrics": [ { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool Workload management-WLGActiveQueries", "aggregation": 1, "splitBy": "WorkloadGroup" } ], "title": "Query Count by Workload Group", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "name": "metric - 1" }, { "type": 10, "content": { "chartId": "workbook8d175f6c-427b-47fc-85ea-37edd0be707c", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.synapse/workspaces/sqlpools", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 14400000 }, "metrics": [ { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-WLGQueuedQueries", "aggregation": 1, "splitBy": "WorkloadGroup" } ], "title": "Queued Queries by Workload Group", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "name": "Queued Queries by Workload Group" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "parameters": [ { "id": "6f50577d-7b00-4e4a-acf9-d45c7a5ee813", "version": "KqlParameterItem/1.0", "name": "WorkloadGroupName", "type": 2, "multiSelect": true, "quote": "'", "delimiter": ",", "query": "SynapseSqlPoolExecRequests \r\n| where _ResourceId == '{DatabaseResourceName}'\r\n and ResourceClass != \"\"\r\n| distinct ResourceClass", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "typeSettings": { "additionalResourceOptions": [ "value::all" ], "showDefault": false }, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "defaultValue": "value::all", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 2" }, { "type": 10, "content": { "chartId": "workbook3da1d18a-1bf5-46c5-b3b7-211f71d329cc", "version": "MetricsItem/2.0", "size": 0, "chartType": 2, "resourceType": "microsoft.synapse/workspaces/sqlpools", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 14400000 }, "metrics": [ { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool Workload management-WLGEffectiveCapResourcePercent", "aggregation": 3, "splitBy": null }, { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool Workload management-WLGEffectiveMinResourcePercent", "aggregation": 3 }, { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool Workload management-WLGAllocationBySystemPercent", "aggregation": 3 } ], "filters": [ { "id": "5", "key": "WorkloadGroup", "operator": 0, "valueParam": "WorkloadGroupName" } ], "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "name": "metric - 3" } ] }, "conditionalVisibilities": [ { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "WorkloadManagement" }, { "parameterName": "DiagnosticsState", "comparison": "isEqualTo", "value": "enabled" } ], "name": "WorkloadManagementGroup" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 1, "content": { "json": "## Select a Principal or Application name to filter results - leave to 'unset' to view all results\r\nSQL Auditing must be enabled and sending to the same Log Analytics Workspace for this page to work. " }, "name": "text - 5" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "parameters": [ { "id": "8d25c043-d1ff-4546-a1fa-f4bcbfdab8af", "version": "KqlParameterItem/1.0", "name": "User", "type": 2, "description": "User to filter subsequent queries - leave to 'unset' for all users", "query": "SQLSecurityAuditEvents \r\n| where LogicalServerName == '{LogicalServerName}'\r\n| summarize by ServerPrincipalName", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "value": null, "typeSettings": { "additionalResourceOptions": [], "showDefault": false }, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "id": "aa766d64-693f-4024-b4a4-b5b56b28376b", "version": "KqlParameterItem/1.0", "name": "Application", "type": 2, "query": "SQLSecurityAuditEvents \r\n| where LogicalServerName == '{LogicalServerName}'\r\n| summarize by ApplicationName", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "value": null, "typeSettings": { "additionalResourceOptions": [], "showDefault": false }, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "customWidth": "30", "name": "parameters - 1" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SQLSecurityAuditEvents \r\n| where LogicalServerName == '{LogicalServerName}'\r\n| where DurationMs > 0\r\n| extend duration_seconds = DurationMs /1000.0\r\n| where Statement != 'select @@version'\r\n| where Statement != 'SELECT @@SPID;'\r\n| where ServerPrincipalName has '{User}'\r\n| where ApplicationName has '{Application}'\r\n| project ServerPrincipalName, EventTime, LogicalServerName, DurationMs, duration_seconds, AffectedRows, Statement, ApplicationName\r\n| summarize duration_seconds = round(sum(duration_seconds)) , query_count = count() by EventDay = bin(EventTime,1d), UserName = ServerPrincipalName, Application = ApplicationName \r\n| order by EventDay, duration_seconds desc", "size": 0, "showAnalytics": true, "title": "Query Summary for Selected User {User} {Application}", "noDataMessage": "Select a user to see query activity", "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "showPin": true, "name": "query - 0 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SQLSecurityAuditEvents \r\n| where LogicalServerName == '{LogicalServerName}'\r\n| where DurationMs > 0\r\n| extend duration_seconds = DurationMs /1000.0\r\n| where Statement != 'select @@version'\r\n| where Statement != 'SELECT @@SPID;'\r\n| where ServerPrincipalName has '{User}'\r\n| where ApplicationName has '{Application}'\r\n| project ServerPrincipalName, EventTime, LogicalServerName, DurationMs, duration_seconds, AffectedRows, Statement, ApplicationName\r\n| summarize duration_seconds = round(sum(duration_seconds)) , query_count = count() by EventDay = bin(EventTime,1d), UserName = ServerPrincipalName, Application = ApplicationName \r\n| order by EventDay, duration_seconds desc", "size": 0, "showAnalytics": true, "title": "Query Summary for Selected User {User} {Application}", "noDataMessage": "Select a user to see query activity", "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "unstackedbar", "tileSettings": { "showBorder": false, "titleContent": { "columnMatch": "UserName", "formatter": 1 }, "leftContent": { "columnMatch": "duration_seconds", "formatter": 12, "formatOptions": { "palette": "auto" }, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "graphSettings": { "type": 0, "topContent": { "columnMatch": "UserName", "formatter": 1 }, "centerContent": { "columnMatch": "duration_seconds", "formatter": 1, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "chartSettings": { "xAxis": "UserName" }, "mapSettings": { "locInfo": "LatLong", "sizeSettings": "duration_seconds", "sizeAggregation": "Sum", "legendMetric": "duration_seconds", "legendAggregation": "Sum", "itemColorSettings": { "type": "heatmap", "colorAggregation": "Sum", "nodeColorField": "duration_seconds", "heatmapPalette": "greenRed" } } }, "showPin": true, "name": "query - 0 - Copy - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SQLSecurityAuditEvents \r\n | where LogicalServerName == \"{LogicalServerName}\"\r\n | where DurationMs > 0\r\n | extend duration_seconds = DurationMs /1000.0\r\n | where Statement != 'select @@version'\r\n | where Statement != 'SELECT @@SPID;'\r\n | where ServerPrincipalName has '{User}'\r\n | where ApplicationName has '{Application}'\r\n | project DatabaseName= DatabaseName, UserName= ServerPrincipalName, EventTime= EventTime, Host= HostName, duration_seconds = round(duration_seconds), Statement, QuerySource = ApplicationName , AffectedRows\r\n | project-reorder DatabaseName, UserName, Host, EventTime, duration_seconds, Statement, QuerySource\r\n\r\n\r\n\r\n\r\n\r\n", "size": 0, "showAnalytics": true, "title": "Queries {User} {Application}", "noDataMessage": "Select a user to see query activity", "timeContextFromParameter": "TimeRange", "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "showPin": true, "name": "query - 0 - Copy - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SQLSecurityAuditEvents \r\n | where LogicalServerName == \"{LogicalServerName}\"\r\n | where DurationMs > 0\r\n | extend duration_seconds = DurationMs /1000.0\r\n | where Statement != 'select @@version'\r\n | where Statement != 'SELECT @@SPID;'\r\n | where ServerPrincipalName has '{User}'\r\n | where ApplicationName has '{Application}'\r\n | project DatabaseName= DatabaseName, UserName= ServerPrincipalName, EventTime= EventTime, Host= HostName, duration_seconds = round(duration_seconds), Statement, QuerySource = ApplicationName , AffectedRows\r\n | project-reorder AffectedRows,DatabaseName, UserName, Host, EventTime, duration_seconds, Statement, QuerySource\r\n\r\n\r\n\r\n\r\n\r\n", "size": 0, "showAnalytics": true, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "barchart", "chartSettings": { "xAxis": "Host", "group": "UserName", "createOtherGroup": null, "showLegend": true } }, "showPin": true, "name": "query - 6" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SQLSecurityAuditEvents\r\n| where LogicalServerName == \"{LogicalServerName}\"\r\n | where DurationMs > 0\r\n| extend Duration = round(DurationMs /1000.0)\r\n| extend TimeBin = case (datetime_part(\"Hour\",TimeGenerated) in (6,7,8,9,10,11,12), \"Morning_6-12\", datetime_part(\"Hour\",TimeGenerated) in (13,14,15,16,17,18), \"Afternoon_12-18\", \"Overnight_18-6\")\r\n| where ServerPrincipalName has '{User}'\r\n| where ApplicationName has '{Application}'\r\n| summarize QueryDuration = sum(Duration) by EventTime = bin(EventTime, 1d), TimeBin", "size": 0, "showAnalytics": true, "title": "Query Activity by time - sum(Duration) {User} {Application}", "noDataMessage": "Select a user to see query activity", "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "barchart" }, "showPin": true, "name": "query - 0 - Copy" } ] }, "conditionalVisibilities": [ { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "QueryAudit" }, { "parameterName": "AuditingState", "comparison": "isEqualTo", "value": "enabled" } ], "name": "QueryAuditGroup", "styleSettings": { "showBorder": true } }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 1, "content": { "json": "# Use this page to search the audit logs for a particular query\r\nYou can search using a combination of: \r\n* Date: Set the time range using the parameter at the top of the workbook\r\n* User: only show queries for the specified user\r\n* Application: only show queries submitted by the specified application\r\n* Query Text Snippet(s) - mutliple fields are provided, if you enter data into multiple fields then it will look for all of those values combined in the results\r\nYou can then sort your results in teh chart below by duration or affected rows to find what you are looking for.\r\n\r\nNOTE: query text is limited to the first 4,000 characters" }, "name": "text - 3" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "parameters": [ { "id": "8d25c043-d1ff-4546-a1fa-f4bcbfdab8af", "version": "KqlParameterItem/1.0", "name": "User", "type": 2, "description": "User to filter subsequent queries - leave to 'unset' for all users", "query": "SQLSecurityAuditEvents \r\n| where LogicalServerName == '{LogicalServerName}'\r\n| summarize by ServerPrincipalName", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "value": null, "typeSettings": { "additionalResourceOptions": [], "showDefault": false }, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "id": "aa766d64-693f-4024-b4a4-b5b56b28376b", "version": "KqlParameterItem/1.0", "name": "Application", "type": 2, "query": "SQLSecurityAuditEvents \r\n| where LogicalServerName == '{LogicalServerName}'\r\n| summarize by ApplicationName", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "value": null, "typeSettings": { "additionalResourceOptions": [], "showDefault": false }, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "customWidth": "30", "name": "parameters - 1" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "add4bc9a-505f-4d22-9ba2-882be91adde0", "version": "KqlParameterItem/1.0", "name": "QueryTextSnippet", "type": 1, "timeContext": { "durationMs": 86400000 }, "value": "" }, { "id": "b78f8304-3dad-4b47-a624-380f6664dc35", "version": "KqlParameterItem/1.0", "name": "QueryTextSnippet2", "type": 1, "timeContext": { "durationMs": 86400000 }, "value": "" }, { "id": "516249a7-52fe-4ec4-9826-6f1b756405a8", "version": "KqlParameterItem/1.0", "name": "QueryTextSnippet3", "type": 1, "timeContext": { "durationMs": 86400000 } } ], "style": "formHorizontal", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 7" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SQLSecurityAuditEvents \r\n | where LogicalServerName == \"{LogicalServerName}\"\r\n | where DurationMs > 0\r\n | extend duration_seconds = DurationMs /1000.0\r\n | where Statement has '{QueryTextSnippet}' and Statement has '{QueryTextSnippet2}' and Statement has '{QueryTextSnippet3}'\r\n | where Statement != 'select @@version'\r\n | where Statement != 'SELECT @@SPID;'\r\n | where ServerPrincipalName has '{User}'\r\n | where ApplicationName has '{Application}'\r\n | project DatabaseName= DatabaseName, UserName= ServerPrincipalName, QueryEndTime= EventTime, Host= HostName, duration_seconds = round(duration_seconds), AffectedRows, Statement, QuerySource = ApplicationName \r\n | project-reorder DatabaseName, UserName, Host, QueryEndTime, duration_seconds, AffectedRows,Statement, QuerySource\r\n\r\n\r\n\r\n\r\n\r\n", "size": 2, "showAnalytics": true, "title": "Queries {User} {Application}", "noDataMessage": "Select a user to see query activity", "timeContextFromParameter": "TimeRange", "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Statement", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "96.4286ch" } } ], "sortBy": [ { "itemKey": "duration_seconds", "sortOrder": 2 } ] }, "sortBy": [ { "itemKey": "duration_seconds", "sortOrder": 2 } ] }, "showPin": true, "name": "query - 0 - Copy - Copy" } ] }, "conditionalVisibilities": [ { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "AuditSearch" }, { "parameterName": "AuditingState", "comparison": "isEqualTo", "value": "enabled" } ], "name": "AuditSearchGroup", "styleSettings": { "showBorder": true } }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "7fa3187e-9225-4faa-8f80-dc1bc40c5aab", "version": "KqlParameterItem/1.0", "name": "RequestId1", "type": 1, "value": "" } ], "style": "above", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "customWidth": "50", "name": "parameters - 3 - Copy" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "315fc476-469a-4d8d-b421-028d1113ab06", "version": "KqlParameterItem/1.0", "name": "RequestId2", "type": 1, "value": "", "timeContext": { "durationMs": 86400000 } } ], "style": "above", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "customWidth": "50", "name": "parameters - 2" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 9, "content": { "version": "KqlParameterItem/1.0", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "parameters": [ { "id": "1537c5b3-0b6c-4b1d-89be-946cd8268020", "version": "KqlParameterItem/1.0", "name": "QueryText1", "type": 1, "query": "SynapseSqlPoolExecRequests\r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where StatementType !in ('Batch','Execute') and RequestId == '{RequestId1}'\r\n| summarize max(Command)", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" } ], "style": "above", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 5" }, { "type": 1, "content": { "json": "#### {RequestId1} Query Text" }, "conditionalVisibility": { "parameterName": "RequestId1", "comparison": "isNotEqualTo" }, "name": "text - 5" }, { "type": 1, "content": { "json": "```{QueryText1}```" }, "conditionalVisibility": { "parameterName": "RequestId1", "comparison": "isNotEqualTo" }, "name": "text - 3" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolExecRequests\r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where StatementType !in ('Batch','Execute') and RequestId == '{RequestId1}'\r\n| summarize \r\n Request_ID=any(RequestId),\r\n Start_Time=max(StartTime),\r\n End_Time=max(EndTime),\r\n //Command=any(Command),\r\n Status=min(Status), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType),\r\n Resource_class=any(ResourceClass)\r\n by RequestId\r\n| summarize Start_Time=any(Start_Time), End_Time=any(End_Time),ElapsedTime_min=anyif((End_Time - Start_Time)/1m,Start_Time > ago(30d))\r\n//,Command=any(Command)\r\n,Status=any(Status),Statement_Type=any(Statement_Type),Resource_class=any(Resource_class) by Request_ID\r\n| project ElapsedTime_min\r\n//,Command\r\n,Resource_class,Start_Time\r\n//,End_Time\r\n,Statement_Type,Status\r\n", "size": 4, "title": "Exec Requests", "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "conditionalVisibility": { "parameterName": "RequestId1", "comparison": "isNotEqualTo" }, "name": "query - 2" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolRequestSteps \r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where RequestId == '{RequestId1}' and RequestId != ''\r\n| summarize StartTime=max(StartTime)\r\n ,EndTime=max(EndTime)\r\n ,RequestID=max(RequestId)\r\n ,Operation=max(OperationType)\r\n ,RowCount=max(RowCount)\r\n ,Command=max(Command)\r\n ,Status=min(Status)\r\n by StepIndex\r\n| order by StepIndex asc\r\n| project StartTime,EndTime,Operation,RowCount,Command,Status,StepIndex", "size": 3, "title": "Request Steps", "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "conditionalVisibility": { "parameterName": "RequestId1", "comparison": "isNotEqualTo" }, "name": "StepQueryRequest1", "styleSettings": { "margin": "0", "padding": "10px" } }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolExecRequests\r\n | where StatementType =='CreateStatistics'\r\n | where _ResourceId has '{DatabaseName}'\r\n | summarize \r\n Root_Query_Id=max(RootQueryId), \r\n Start_Time=max(StartTime),\r\n End_Compile_Time=max(EndCompileTime), \r\n End_Time=max(EndTime), \r\n Command=max(Command), \r\n Last_Status=min(Status),\r\n Statement_Type=max(StatementType),\r\n Resource_class=max(ResourceClass) \r\n by RequestId\r\n | where Root_Query_Id == '{RequestId1}'", "size": 0, "title": "Triggered Auto-Stats Statements", "noDataMessage": "No triggered autostats statements found", "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Submit_Time", "formatter": 0, "numberFormat": { "unit": 0, "options": { "style": "decimal" } } }, { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "100ch" } } ], "sortBy": [ { "itemKey": "End_Time", "sortOrder": 2 } ] }, "sortBy": [ { "itemKey": "End_Time", "sortOrder": 2 } ] }, "conditionalVisibility": { "parameterName": "RequestId1", "comparison": "isNotEqualTo" }, "name": "All triggered auto-stats statements" } ] }, "customWidth": "50", "name": "RequestId1Group", "styleSettings": { "showBorder": true } }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 9, "content": { "version": "KqlParameterItem/1.0", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "parameters": [ { "id": "1537c5b3-0b6c-4b1d-89be-946cd8268020", "version": "KqlParameterItem/1.0", "name": "QueryText2", "type": 1, "query": "SynapseSqlPoolExecRequests\r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where StatementType !in ('Batch','Execute') and RequestId == '{RequestId2}'\r\n| summarize max(Command)", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" } ], "style": "above", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 5" }, { "type": 1, "content": { "json": "#### {RequestId2} Query Text" }, "conditionalVisibility": { "parameterName": "RequestId2", "comparison": "isNotEqualTo" }, "name": "text - 5" }, { "type": 1, "content": { "json": "```{QueryText2}```" }, "conditionalVisibility": { "parameterName": "RequestId2", "comparison": "isNotEqualTo" }, "name": "text - 4" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolExecRequests\r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where StatementType !in ('Batch','Execute') and RequestId == '{RequestId2}'\r\n| summarize \r\n Request_ID=any(RequestId),\r\n Start_Time=max(StartTime),\r\n End_Time=max(EndTime),\r\n //Command=any(Command),\r\n Status=min(Status), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType),\r\n Resource_class=any(ResourceClass)\r\n by RequestId\r\n| summarize Start_Time=any(Start_Time), End_Time=any(End_Time),ElapsedTime_min=anyif((End_Time - Start_Time)/1m,Start_Time > ago(30d))\r\n//,Command=any(Command)\r\n,Status=any(Status),Statement_Type=any(Statement_Type),Resource_class=any(Resource_class) by Request_ID\r\n| project ElapsedTime_min\r\n//,Command\r\n,Resource_class,Start_Time\r\n//,End_Time\r\n,Statement_Type,Status\r\n", "size": 4, "title": "Exec Requests", "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "conditionalVisibility": { "parameterName": "RequestId2", "comparison": "isNotEqualTo" }, "name": "query - 2 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolRequestSteps \r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where RequestId == '{RequestId2}' and RequestId != ''\r\n| summarize StartTime=max(StartTime)\r\n ,EndTime=max(EndTime)\r\n ,RequestID=max(RequestId)\r\n ,Operation=max(OperationType)\r\n ,RowCount=max(RowCount)\r\n ,Command=max(Command)\r\n ,Status=min(Status)\r\n by StepIndex\r\n| order by StepIndex asc\r\n| project StartTime,EndTime,Operation,RowCount,Command,Status,StepIndex", "size": 3, "title": "Request Steps", "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "conditionalVisibility": { "parameterName": "RequestId2", "comparison": "isNotEqualTo" }, "name": "query - 4 - Copy", "styleSettings": { "padding": "10px" } }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolExecRequests\r\n | where StatementType =='CreateStatistics'\r\n | where _ResourceId has '{DatabaseName}'\r\n | summarize \r\n Root_Query_Id=max(RootQueryId), \r\n Start_Time=max(StartTime),\r\n End_Compile_Time=max(EndCompileTime), \r\n End_Time=max(EndTime), \r\n Command=max(Command), \r\n Last_Status=min(Status),\r\n Statement_Type=max(StatementType),\r\n Resource_class=max(ResourceClass) \r\n by RequestId\r\n | where Root_Query_Id == '{RequestId2}'", "size": 0, "title": "Triggered Auto-Stats Statements", "noDataMessage": "No triggered autostats statements found", "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Submit_Time", "formatter": 0, "numberFormat": { "unit": 0, "options": { "style": "decimal" } } }, { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "100ch" } } ] } }, "conditionalVisibility": { "parameterName": "RequestId2", "comparison": "isNotEqualTo" }, "name": "All triggered auto-stats statements" } ] }, "customWidth": "50", "name": "RequestId2Group", "styleSettings": { "showBorder": true } } ] }, "conditionalVisibilities": [ { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "QueryComparison" }, { "parameterName": "DiagnosticsState", "comparison": "isEqualTo", "value": "enabled" } ], "name": "QueryComparison" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 1, "content": { "json": "## This tab is used to determine what statements triggerred autostats creation jobs. \r\nThe flow of autostats creation is as follows\r\n1. Query Submit Time\r\n2. \tCreate Statistics submit Time\r\n3. \tCreate Statistics end Time\r\n4. Query end_compile_time\r\n5. Query Start_Time\r\n6. Query End_Time\r\n\r\nFurther, if multiple stats are created, then the creation of all stats for this query will fall between query submit_time and end_compile_time. \r\n\r\nThe charts on this page allow you to search for an autostats job by requestID or my snippet of the autostats statement text, which can just be the schema, table, or column name. Then it will show you all commands that include that request ID or text. It will then show you all statements in the create stat statement because the query we are trying to identify will wait for all of those stats creations to complete before proceeding. \r\n\r\nThe last chart will list the statement that triggered the stats creation. " }, "name": "text - 6" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "df5b9b85-4188-4f2c-88cb-1369e09f6742", "version": "KqlParameterItem/1.0", "name": "RootQueryId", "type": 1, "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 } }, { "id": "560c9ec5-6341-4fa1-9ce6-35ff010151b1", "version": "KqlParameterItem/1.0", "name": "RequestId", "type": 1, "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 } } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 5" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "0911bd4b-d471-480b-bdf4-1a2d4ba1ea6e", "version": "KqlParameterItem/1.0", "name": "RequestIdSearch", "type": 1, "value": "", "label": "RequestId for AutoStats Job" }, { "id": "c12e6495-4fd1-473c-8ffc-0bf502f54706", "version": "KqlParameterItem/1.0", "name": "QueryTextSnippet", "type": 1, "value": "", "timeContext": { "durationMs": 86400000 }, "label": "Snippet of autostats creation statement (Schema, table or column)" } ], "style": "formVertical", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "customWidth": "60", "name": "parameters - 3 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolExecRequests\r\n | where StatementType =='CreateStatistics'\r\n | where _ResourceId has '{DatabaseName}'\r\n| summarize \r\n Root_Query_Id=max(RootQueryId), \r\n Start_Time=max(StartTime),\r\n End_Time=max(EndTime), \r\n Command=max(Command), \r\n Last_Status=min(Status),\r\n Statement_Type=max(StatementType)\r\n by RequestId\r\n| where Command has 'CREATE STATISTICS _wa_sys'\r\n| where Command has '{QueryTextSnippet}' and RequestId has '{RequestIdSearch}'\r\n//| extend elapsedTime_sec = iif(End_Time > ago(365d),(End_Time - Submit_Time)/1s,real(null)) \r\n//| extend CompileTime_sec = (End_Compile_Time - Submit_Time)/1s\r\n//| order by elapsedTime_sec\r\n//| summarize \r\n // Executions = count(),\r\n // Max_Elapsed_Time_sec = bin(max(elapsedTime_sec),1),\r\n // Min_Elapsed_Time_sec = bin(min(elapsedTime_sec),1),\r\n // Variability_sec=bin((max(elapsedTime_sec)-min(elapsedTime_sec)),1),\r\n // SampleQID = any(RequestId),\r\n // SampleSessionID = any(Session_ID)\r\n // by Command\r\n//| order by Max_Elapsed_Time_sec\r\n\r\n\r\n", "size": 0, "showAnalytics": true, "title": "Matching Autostats Queries", "noDataMessageStyle": 4, "timeContextFromParameter": "TimeRange", "exportedParameters": [ { "fieldName": "RequestId", "parameterName": "RequestId", "parameterType": 1 }, { "fieldName": "Root_Query_Id", "parameterName": "RootQueryId", "parameterType": 1 } ], "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "50%" } } ], "sortBy": [ { "itemKey": "Command", "sortOrder": 1 } ] }, "sortBy": [ { "itemKey": "Command", "sortOrder": 1 } ] }, "name": "query - 0 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolExecRequests\r\n | where StatementType !='CreateStatistics'\r\n | where _ResourceId has '{DatabaseName}'\r\n | where RequestId == '{RootQueryId}'\r\n | summarize \r\n Start_Time=max(StartTime),\r\n End_Compile_Time=max(EndCompileTime), \r\n End_Time=max(EndTime), \r\n Command=max(Command), \r\n Last_Status=min(Status),\r\n Statement_Type=max(StatementType),\r\n Resource_class=max(ResourceClass) \r\n by RequestId", "size": 3, "showAnalytics": true, "title": "Statement that Triggered Selected Autostat", "noDataMessage": "Select an autostats query above to see what query triggered it", "noDataMessageStyle": 4, "timeContextFromParameter": "TimeRange", "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "150ch" } } ], "sortBy": [ { "itemKey": "Command", "sortOrder": 1 } ] }, "sortBy": [ { "itemKey": "Command", "sortOrder": 1 } ] }, "name": "query - 0 - Copy - Copy - Copy - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolExecRequests\r\n | where StatementType =='CreateStatistics'\r\n | where _ResourceId has '{DatabaseName}'\r\n| summarize \r\n Root_Query_Id=max(RootQueryId), \r\n Start_Time=max(StartTime),\r\n End_Time=max(EndTime), \r\n Command=max(Command), \r\n Last_Status=min(Status),\r\n Statement_Type=max(StatementType)\r\n by RequestId\r\n| where Command has 'CREATE STATISTICS _wa_sys'\r\n| where Root_Query_Id == '{RootQueryId}'", "size": 3, "showAnalytics": true, "title": "All Stats Statements Triggered by selected Query", "noDataMessageStyle": 4, "timeContextFromParameter": "TimeRange", "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 13" } ] }, "conditionalVisibilities": [ { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "Statistics" }, { "parameterName": "DiagnosticsState", "comparison": "isEqualTo", "value": "enabled" } ], "name": "statistics" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 1, "content": { "json": "" }, "customWidth": "60", "showPin": false, "name": "Image" }, { "type": 1, "content": { "json": "Enable SQL Auditing to get additional visibility into user activity against your SQL Pool\r\n\r\nThis section provides additional monitoring coverage that is based on SQL Audit logs.
\r\nIf you have not activated SQL Auditing for your dedeciated SQL Pool, you must enable them to go to the same Log Analytics workspace as the rest of your diagnostic settings for it to show up here. [Learn more](https://docs.microsoft.com/en-us/azure/azure-sql/database/auditing-overview)\r\n" }, "customWidth": "60", "name": "text - 2" }, { "type": 11, "content": { "version": "LinkItem/1.0", "style": "paragraph", "links": [ { "id": "f4df7a1e-2124-4620-9005-f9b66e47f550", "cellValue": "{DatabaseResourceName}", "linkTarget": "Resource", "linkLabel": "Configure Logs for Auditing >", "subTarget": "auditing", "preText": "", "postText": "", "style": "primary" } ] }, "customWidth": "70", "name": "links - 8" } ] }, "customWidth": "90", "name": "Onboarding Message - Not onboarded yet" } ] }, "conditionalVisibilities": [ { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "QueryAudit" }, { "parameterName": "AuditingState", "comparison": "isEqualTo", "value": "disabled" } ], "name": "AuditingDisabledGroup" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 1, "content": { "json": "" }, "customWidth": "60", "showPin": false, "name": "Image" }, { "type": 1, "content": { "json": "Get more visibility into the usage and performance of your Azure Synapse Dedicated SQL Pool\r\n\r\nThis section provides additional monitoring coverage that is based on diagnostic logs.
\r\n\r\nIf you have not activated monitoring in diagnostic settings, you must enable the **ExecRequests** and **RequestSteps** logs and send them to a Log Analytics workspace. You may choose to enable the **SQLSecurityAuditEvents** table at the same time to take full advantage of this monitoring workbook. [Learn more](https://docs.microsoft.com/en-us/azure/synapse-analytics/monitoring/how-to-monitor-using-azure-monitor#logs)" }, "customWidth": "60", "name": "text - 2" }, { "type": 11, "content": { "version": "LinkItem/1.0", "style": "paragraph", "links": [ { "id": "f4df7a1e-2124-4620-9005-f9b66e47f550", "cellValue": "{DatabaseResourceName}", "linkTarget": "Resource", "linkLabel": "Configure Logs for Monitoring >", "subTarget": "diagnostics", "preText": "", "postText": "", "style": "primary" } ] }, "customWidth": "70", "name": "links - 8" } ] }, "customWidth": "90", "name": "Onboarding Message - Not onboarded yet" } ] }, "conditionalVisibilities": [ { "parameterName": "GroupSelection", "comparison": "isNotEqualTo", "value": "QueryAudit" }, { "parameterName": "DiagnosticsState", "comparison": "isEqualTo", "value": "disabled" } ], "name": "DiagnosticsDisabledGroup" }, { "type": 1, "content": { "json": "Workbook version: v1.2", "style": "info" }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "Overview" }, "customWidth": "15", "name": "version", "styleSettings": { "showBorder": true } } ], "fallbackResourceIds": [ "azure monitor" ], "$schema": "https://github.com/Microsoft/Application-Insights-Workbooks/blob/master/schema/workbook.json" } ================================================ FILE: Monitor_Workbooks/DedicatedSqlPool_Non-Workspace_v1.4.workbook ================================================ { "version": "Notebook/1.0", "items": [ { "type": 9, "content": { "version": "KqlParameterItem/1.0", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "parameters": [ { "id": "28da10ec-a308-47f5-9819-92ebf810b292", "version": "KqlParameterItem/1.0", "name": "LogAnalyticsSubscription", "type": 6, "value": null, "typeSettings": { "additionalResourceOptions": [], "includeAll": true, "showDefault": false }, "timeContext": { "durationMs": 86400000 } }, { "id": "e383ed24-52ae-447b-9b80-51fd3ab6b919", "version": "KqlParameterItem/1.0", "name": "LogAnalyticsWorkspace", "type": 5, "query": "Resources\r\n| where type == 'microsoft.operationalinsights/workspaces'\r\n| project id\r\n", "crossComponentResources": [ "{LogAnalyticsSubscription}" ], "value": null, "typeSettings": { "additionalResourceOptions": [], "showDefault": false }, "timeContext": { "durationMs": 86400000 }, "queryType": 1, "resourceType": "microsoft.resourcegraph/resources" }, { "id": "9b9fe566-0f52-4a75-a35b-a79c50c6a6f0", "version": "KqlParameterItem/1.0", "name": "DatabaseResourceName", "type": 5, "query": "AzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| distinct ResourceId", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "value": null, "typeSettings": { "additionalResourceOptions": [], "showDefault": false }, "timeContext": { "durationMs": 2592000000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "id": "f5852627-70ca-4959-8d60-53b48864603f", "version": "KqlParameterItem/1.0", "name": "TimeRange", "type": 4, "isGlobal": true, "value": { "durationMs": 14400000 }, "typeSettings": { "selectableValues": [ { "durationMs": 300000 }, { "durationMs": 900000 }, { "durationMs": 1800000 }, { "durationMs": 3600000 }, { "durationMs": 14400000 }, { "durationMs": 43200000 }, { "durationMs": 86400000 }, { "durationMs": 172800000 }, { "durationMs": 259200000 }, { "durationMs": 604800000 }, { "durationMs": 1209600000 }, { "durationMs": 2419200000 }, { "durationMs": 2592000000 } ], "allowCustom": true }, "timeContext": { "durationMs": 86400000 } }, { "id": "6da2f63f-45a3-4b37-9108-5e8b7e358d85", "version": "KqlParameterItem/1.0", "name": "DatabaseName", "type": 1, "query": "AzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where ResourceId == '{DatabaseResourceName}'\r\n| distinct Resource ", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 604800000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "id": "8bba835b-f319-43b3-8ec6-4e051fc6d446", "version": "KqlParameterItem/1.0", "name": "LogicalServerName", "type": 1, "query": "AzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where ResourceId == '{DatabaseResourceName}'\r\n| distinct LogicalServerName_s", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 2" }, { "type": 11, "content": { "version": "LinkItem/1.0", "style": "tabs", "links": [ { "id": "202cbbc0-8d63-416d-89ed-451d6fe7c4b3", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Overview", "subTarget": "Workload", "preText": "Workload", "style": "link" }, { "id": "a7901bd0-a1f4-4491-b953-57555d764e00", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Workload Management", "subTarget": "WorkloadManagement", "style": "link" }, { "id": "45e12a14-8548-4477-aae3-c142b906dc9f", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "TempDB", "subTarget": "TempDB", "style": "link" }, { "id": "9ef8f730-d73d-432b-9b75-55095d1155f2", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Replicated Tables", "subTarget": "ReplicatedTables", "style": "link" }, { "id": "79d10d16-0696-4214-b306-c7a0e46cd64f", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Query Investigation", "subTarget": "QueryInvestigation", "style": "link" }, { "id": "31c1cf1c-74b5-44e2-ba9a-9497834ca3dc", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Query Comparison", "subTarget": "QueryComparison", "style": "link" }, { "id": "5ff681ee-e005-481f-b743-b66ab1b9d71d", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Session Investigation", "subTarget": "SessionInvestigation", "style": "link" }, { "id": "482ccc46-8a10-4ace-bfd6-63ac73b380af", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Query Audit", "subTarget": "QueryAudit", "style": "link" }, { "id": "db43bb45-1611-47ce-a2ad-517943f2aa1a", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "AutoStats", "subTarget": "Statistics", "style": "link" } ] }, "name": "links - 0" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "title": "Workload", "items": [ { "type": 10, "content": { "chartId": "workbook90867bfc-5c33-464f-ac31-2c2e006b97f4", "version": "MetricsItem/2.0", "size": 0, "chartType": 2, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 0 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-dwu_consumption_percent", "aggregation": 3, "splitBy": null, "columnName": "DWU Percentage" }, { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-cpu_percent", "aggregation": 3 }, { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-physical_data_read_percent", "aggregation": 3 } ], "title": "DWU Resource Utilization", "showCreateAlertRule": true, "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "showPin": true, "name": "metric - 1" }, { "type": 10, "content": { "chartId": "workbookb954d4a0-82ef-4409-88fb-837aaff80c8d", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 0 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-active_queries", "aggregation": 1, "splitBy": null }, { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-queued_queries", "aggregation": 1 } ], "title": "Active and Queued Queries", "showCreateAlertRule": true, "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "showPin": true, "name": "metric - 1" }, { "type": 10, "content": { "chartId": "workbookb954d4a0-82ef-4409-88fb-837aaff80c8d", "version": "MetricsItem/2.0", "size": 0, "chartType": 3, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 0 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-local_tempdb_usage_percent", "aggregation": 3, "splitBy": null, "columnName": "TempDB Utilization Percentage" } ], "title": "TempDB Utilization", "showCreateAlertRule": true, "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "showPin": true, "name": "metric - 1 - Copy" }, { "type": 10, "content": { "chartId": "workbookb954d4a0-82ef-4409-88fb-837aaff80c8d", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 0 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-WorkloadManagement-wlg_allocation_relative_to_system_percent", "aggregation": 3, "splitBy": null } ], "title": "Workload Group Utilization", "showCreateAlertRule": true, "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "showPin": true, "name": "Workload Group Utilization" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databaseName = '{DatabaseName}';\r\n//Long-Running Queries - Just Actual Queries\r\n//If 'Command' is empty - you need to set a bigger time window, the older record with the command is outside of your window\r\nAzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where Resource == databaseName\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize Session_ID=any(SessionId_s),\r\n Request_ID=any(RequestId_s),\r\n Submit_Time=max(SubmitTime_t),\r\n Start_Time=max(StartTime_t),\r\n End_Time=max(EndTime_t),\r\n Command=any(Command_s),\r\n Status=min(Status_s), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType_s),\r\n Resource_class=any(ResourceClass_s)\r\n by RequestId_s\r\n| summarize ElapsedTime_min=bin(anyif(((End_Time - Start_Time)/1m),Start_Time > ago(30d)),1),\r\n Session_ID=any(Session_ID), \r\n Submit_Time=any(Submit_Time) ,\r\n Start_Time=any(Start_Time), \r\n End_Time=any(End_Time),\r\n Command=any(Command),\r\n Status=any(Status),\r\n Statement_Type=any(Statement_Type)\r\n ,Resource_class=any(Resource_class) \r\n by Request_ID\r\n| where End_Time > ago(365d)\r\n| summarize count() by Status, bin(End_Time,5m)\r\n| render barchart \r\n", "size": 0, "title": "Query Completion Count by End Time - 5m buckets", "color": "redBright", "timeContextFromParameter": "TimeRange", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "chartSettings": { "seriesLabelSettings": [ { "seriesName": "Completed", "color": "green" }, { "seriesName": "Failed", "color": "red" }, { "seriesName": "Cancelled", "color": "yellow" } ] } }, "name": "query - 4" }, { "type": 1, "content": { "json": "Use the buttons below to filter the next chart for Success or Failed queries. In many cases a failed query may not have a 'Command' column populated depending on what stage the query failed in. ", "style": "info" }, "name": "text - 3" }, { "type": 11, "content": { "version": "LinkItem/1.0", "style": "nav", "links": [ { "id": "8e89112f-c67f-42c0-9622-02fa306fb7a5", "cellValue": "QueryCompletionType", "linkTarget": "parameter", "linkLabel": "All Queries", "subTarget": "''", "style": "primary" }, { "id": "6abe39c7-4d4e-4c45-aa54-dc9a4c5e876e", "cellValue": "QueryCompletionType", "linkTarget": "parameter", "linkLabel": "Success Only", "subTarget": "Completed", "preText": "", "style": "secondary" }, { "id": "e41b4a0b-8464-491e-92be-a57217d6dcac", "cellValue": "QueryCompletionType", "linkTarget": "parameter", "linkLabel": "Failures Only", "subTarget": "Failed", "preText": "", "style": "secondary" } ] }, "name": "links - 11" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databaseName = '{DatabaseName}';\r\n//Long-Running Queries - Just Actual Queries\r\n//If 'Command' is empty - you need to set a bigger time window, the older record with the command is outside of your window\r\nAzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where Resource == databaseName\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize Session_ID=any(SessionId_s),\r\n Request_ID=any(RequestId_s),\r\n Submit_Time=max(SubmitTime_t),\r\n Start_Time=max(StartTime_t),\r\n End_Time=max(EndTime_t),\r\n Command=max(Command_s),\r\n Status=min(Status_s), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType_s),\r\n Resource_class=any(ResourceClass_s)\r\n by RequestId_s\r\n| summarize ElapsedTime_min=bin(anyif(((End_Time - Start_Time)/1m),Start_Time > ago(30d)),1),\r\n Session_ID=any(Session_ID), \r\n Submit_Time=min(Submit_Time) ,\r\n Start_Time=any(Start_Time), \r\n End_Time=any(End_Time),\r\n Command=any(Command),\r\n Status=any(Status),\r\n Statement_Type=any(Statement_Type)\r\n ,Resource_class=any(Resource_class) \r\n by Request_ID\r\n//| where End_Time > ago(365d)\r\n| where Status has '{QueryCompletionType}'\r\n| order by Submit_Time\r\n\r\n", "size": 0, "showAnalytics": true, "title": "Query Completions - use above buttons to filter", "color": "redBright", "timeContextFromParameter": "TimeRange", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "rowLimit": 100 }, "chartSettings": { "seriesLabelSettings": [ { "seriesName": "Completed", "color": "green" }, { "seriesName": "Failed", "color": "red" }, { "seriesName": "Cancelled", "color": "yellow" } ] } }, "name": "query - 4 - Copy" } ] }, "name": "Query Completions", "styleSettings": { "showBorder": true } }, { "type": 10, "content": { "chartId": "workbook1afc57e6-0b32-4968-b299-db319bd21635", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 0 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-connection_successful", "aggregation": 1, "splitBy": null }, { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-connection_failed", "aggregation": 1 } ], "title": "Successful and Failed Connections", "showCreateAlertRule": true, "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "showPin": true, "name": "metric - 5" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 3, "content": { "version": "KqlItem/1.0", "query": " AzureDiagnostics\r\n | where Category == 'SQLSecurityAuditEvents' and LogicalServerName_s == 'lasr-sqldwdb-eastus2-prd'\r\n | where action_name_s in ('DATABASE AUTHENTICATION SUCCEEDED','DATABASE AUTHENTICATION FAILED')\r\n | project SourceSystem,client_tls_version_d,succeeded_s,session_id_d,client_ip_s,session_server_principal_name_s,server_principal_name_s,database_principal_name_s,application_name_s,host_name_s,TimeGenerated\r\n | summarize count() by succeeded_s,bin(TimeGenerated,1m)\r\n | render barchart\r\n\r\n\r\n\r\n", "size": 0, "title": "Database Authentication success/failure rate", "timeContextFromParameter": "TimeRange", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "chartSettings": { "xAxis": "TimeGenerated", "group": "succeeded_s", "createOtherGroup": null } }, "name": "query - 8" }, { "type": 11, "content": { "version": "LinkItem/1.0", "style": "nav", "links": [ { "id": "2ed22e0a-2b53-4ed0-8f65-d2c621f34dad", "cellValue": "AuthResult", "linkTarget": "parameter", "linkLabel": "All Authentications", "subTarget": "''", "style": "primary" }, { "id": "2789ab13-ae8a-472e-bad4-9c9bdc934d4d", "cellValue": "AuthResult", "linkTarget": "parameter", "linkLabel": "Success Only", "subTarget": "true", "style": "secondary" }, { "id": "5cf4ddd4-e189-4b71-b456-0d4f1572a0a3", "cellValue": "AuthResult", "linkTarget": "parameter", "linkLabel": "Failures Only", "subTarget": "false", "style": "secondary" } ] }, "name": "links - 10" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": " AzureDiagnostics\r\n | where Category == 'SQLSecurityAuditEvents' and LogicalServerName_s == 'lasr-sqldwdb-eastus2-prd'\r\n | where action_name_s in ('DATABASE AUTHENTICATION SUCCEEDED','DATABASE AUTHENTICATION FAILED')\r\n | where succeeded_s has '{AuthResult}'\r\n | project SourceSystem,client_tls_version_d,succeeded_s,session_id_d,client_ip_s,session_server_principal_name_s,server_principal_name_s,database_principal_name_s,application_name_s,host_name_s,TimeGenerated\r\n | order by TimeGenerated\r\n\r\n\r\n\r\n\r\n", "size": 0, "showAnalytics": true, "title": "Database Authentication success/failure rate", "noDataMessage": "Please select a button above", "timeContextFromParameter": "TimeRange", "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "rowLimit": 100 }, "chartSettings": { "xAxis": "TimeGenerated", "group": "succeeded_s", "createOtherGroup": null, "showLegend": true } }, "name": "query - 8 - Copy" } ] }, "name": "Database Authentication Group", "styleSettings": { "showBorder": true } }, { "type": 10, "content": { "chartId": "workbook993837ad-66d6-4cbc-ae1a-7c3f6623236b", "version": "MetricsItem/2.0", "size": 0, "chartType": 2, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 0 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-cache_used_percent", "aggregation": 3, "splitBy": null }, { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-cache_hit_percent", "aggregation": 3 } ], "title": "Adaptive Cache Used vs Hit Percentage", "showCreateAlertRule": true, "gridSettings": { "rowLimit": 10000 } }, "showPin": true, "name": "metric - 6" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "Workload" }, "name": "group - 1" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "title": "TempDB ", "items": [ { "type": 10, "content": { "chartId": "workbook4a9cf761-cce2-45b2-8947-8a9428ec7e1c", "version": "MetricsItem/2.0", "size": 0, "chartType": 3, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 0 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-local_tempdb_usage_percent", "aggregation": 3, "splitBy": null, "columnName": "TempDB Util" } ], "title": "TempDB Max and Avg Utilization", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "showPin": true, "name": "metric - 0" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "19ee48f5-8f4e-4939-a0ef-c6bf656a93f9", "version": "KqlParameterItem/1.0", "name": "WeightParameter", "type": 1, "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 } }, { "id": "00553ec8-1a41-4dd9-a024-d607639c9bbb", "version": "KqlParameterItem/1.0", "name": "RequestID", "type": 1, "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 } } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 3" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databaseName = '{DatabaseName}';\r\n//Weighted query steps\r\nAzureDiagnostics\r\n| where Category == 'RequestSteps'\r\n| where Resource == databaseName\r\n| where RowCount_d > 0\r\n| summarize sum(RowCount_d) by RequestId_s, OperationType_s\r\n| order by sum_RowCount_d desc\r\n| limit 20\r\n| render columnchart ", "size": 0, "title": "20 Largest Query Steps by Most Rows Moved", "timeContextFromParameter": "TimeRange", "exportFieldName": "Request_ID", "exportParameterName": "RequestID", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "chartSettings": { "xAxis": "RequestId_s", "group": "OperationType_s", "createOtherGroup": 20, "showLegend": true } }, "showPin": true, "name": "query - 1 - Copy" }, { "type": 11, "content": { "version": "LinkItem/1.0", "style": "nav", "links": [ { "id": "c98d3722-9907-43ab-9306-1957d6f7f858", "cellValue": "WeightParameter", "linkTarget": "parameter", "linkLabel": "Weighted Rowcounts", "subTarget": "Weighted", "preText": "", "postText": "", "style": "secondary" }, { "id": "a06ae99a-ad62-45e9-8c25-c219b81f59c0", "cellValue": "WeightParameter", "linkTarget": "parameter", "linkLabel": "Unweighted Rowcounts", "subTarget": "Unweighted", "preText": "", "postText": "", "style": "secondary" } ] }, "name": "links - 3" }, { "type": 1, "content": { "json": "Current Setting: {WeightParameter}", "style": "info" }, "name": "text - 4" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databaseName = '{DatabaseName}';\r\n//Weighted query steps\r\nlet RequestSteps = AzureDiagnostics\r\n| where Category == 'RequestSteps'\r\n| where Resource == databaseName\r\n| where RowCount_d > 100000000\r\n| extend Step_Elapsed_Min = round((EndTime_t - StartTime_t)/1m, 2)\r\n| extend Weighted_cnt = iff('{WeightParameter}'=='Weighted',(case(OperationType_s == 'BroadcastMoveOperation', (RowCount_d*20), RowCount_d)),RowCount_d)\r\n| project-rename StepStatus = Status_s, StepStart = StartTime_t, StepEnd = EndTime_t//, StepResource = Resource\r\n| top 100 by Weighted_cnt desc\r\n| order by Weighted_cnt desc\r\n| project Request_ID=RequestId_s,OperationType_s, RowCount_d,Weighted_cnt,Step_Elapsed_Min, StepStart, StepEnd, StepStatus, StepIndex_d,Resource;\r\nRequestSteps | join (AzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where Resource == databaseName\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize Session_ID=any(SessionId_s),\r\n Request_ID=any(RequestId_s),\r\n Submit_Time=max(SubmitTime_t),\r\n Start_Time=max(StartTime_t),\r\n End_Time=max(EndTime_t),\r\n Command=any(Command_s),\r\n Status=min(Status_s), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType_s),\r\n Resource_class=any(ResourceClass_s)\r\n by RequestId_s\r\n| summarize Session_ID=any(Session_ID), Submit_Time=any(Submit_Time) ,Start_Time=any(Start_Time), End_Time=any(End_Time),Command=any(Command),Status=any(Status),Statement_Type=any(Statement_Type),Resource_class=any(Resource_class) by Request_ID\r\n//| order by Step_Elapsed_Min desc\r\n| extend Request_Elapsed_Min = round((End_Time - Start_Time)/1m, 2)\r\n| project-rename ReqStatus = Status, ReqStart = Start_Time, ReqEnd = End_Time\r\n) on Request_ID\r\n| project-reorder Session_ID, Request_ID, Request_Elapsed_Min, ReqStart, ReqEnd, ReqStatus,StepIndex_d, OperationType_s, RowCount_d,Weighted_cnt,Step_Elapsed_Min, StepStart, StepEnd, StepStatus, Statement_Type, Command, Resource_class\r\n| order by Weighted_cnt desc\r\n| limit 20", "size": 3, "showAnalytics": true, "title": "20 Largest Query Steps by Most Rows Moved", "timeContextFromParameter": "TimeRange", "exportFieldName": "Request_ID1", "exportParameterName": "RequestID", "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "sortBy": [ { "itemKey": "Weighted_cnt", "sortOrder": 2 } ] }, "sortBy": [ { "itemKey": "Weighted_cnt", "sortOrder": 2 } ] }, "showPin": true, "name": "query - 1" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databaseName = '{DatabaseName}';\r\n//Long-Running Queries - Just Actual Queries\r\n//If 'Command' is empty - you need to set a bigger time window, the older record with the command is outside of your window\r\nAzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where Resource == databaseName\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize Session_ID=any(SessionId_s),\r\n Request_ID=any(RequestId_s),\r\n Submit_Time=max(SubmitTime_t),\r\n Start_Time=max(StartTime_t),\r\n End_Time=max(EndTime_t),\r\n Command=any(Command_s),\r\n Status=min(Status_s), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType_s),\r\n Resource_class=any(ResourceClass_s)\r\n by RequestId_s\r\n| summarize ElapsedTime_min=bin(anyif(((End_Time - Start_Time)/1m),Start_Time > ago(30d)),1),\r\n Session_ID=any(Session_ID), \r\n Submit_Time=any(Submit_Time) ,\r\n Start_Time=any(Start_Time), \r\n End_Time=any(End_Time),\r\n Command=any(Command),\r\n Status=any(Status),\r\n Statement_Type=any(Statement_Type)\r\n ,Resource_class=any(Resource_class) \r\n by Request_ID\r\n| where Request_ID == '{RequestID}'\r\n\r\n", "size": 4, "showAnalytics": true, "title": "Selected Query", "noDataMessage": "Select a query above to view details", "timeContextFromParameter": "TimeRange", "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "35%" } } ] } }, "name": "query - 6" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics\r\n| where Category == 'RequestSteps'\r\n| where Resource == '{DatabaseName}'\r\n| where RequestId_s == '{RequestID}' //Put your QueryID here\r\n| where Status_s != 'Running'\r\n| summarize max(StartTime_t),max(EndTime_t),max(RequestId_s),max(OperationType_s),max(RowCount_d),max(Command_s),max(Status_s) by StepIndex_d\r\n| order by StepIndex_d asc", "size": 3, "showAnalytics": true, "title": "Query Plan", "noDataMessage": "Select a query above to view the plan", "timeContextFromParameter": "TimeRange", "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 7" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "TempDB" }, "name": "group - 3" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "title": "Query Investigation", "items": [ { "type": 1, "content": { "json": "## Search Criteria\r\nUse the following fields to search either using a query text snippet or using a Request ID. If using a query text snippet, try to keep it as simple as possible becuase minor changes in formatting may cause your queries not to show up in the results. It's best to pick something like a table name, then choose the proper query from the list that will populate. " }, "customWidth": "50", "name": "text - 4" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "0c2128d0-d979-4562-a28c-e7ceb955f126", "version": "KqlParameterItem/1.0", "name": "RequestIdSearch", "type": 1, "value": "" }, { "id": "29880874-2d41-4bd5-bf22-3e47ae8b1145", "version": "KqlParameterItem/1.0", "name": "QueryTextSnippet", "type": 1, "value": "", "timeContext": { "durationMs": 86400000 } } ], "style": "formVertical", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "customWidth": "60", "name": "parameters - 3" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics \r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize \r\n Session_ID=max(SessionId_s), \r\n Request_ID=max(RequestId_s), \r\n Submit_Time=max(SubmitTime_t), \r\n Start_Time=max(StartTime_t),\r\n End_Compile_Time=max(EndCompileTime_t), \r\n End_Time=max(EndTime_t), \r\n Command=max(Command_s), \r\n Last_Status=min(Status_s),\r\n Statement_Type=max(StatementType_s),\r\n Resource_class=max(ResourceClass_s) \r\n by RequestId_s\r\n| where Command has '{QueryTextSnippet}'\r\nand RequestId_s has '{RequestIdSearch}'\r\n| extend elapsedTime_sec = iif(End_Time > ago(365d),(End_Time - Submit_Time)/1s,real(null)) \r\n| extend CompileTime_sec = (End_Compile_Time - Submit_Time)/1s\r\n| order by elapsedTime_sec\r\n| summarize \r\n Executions = count(),\r\n Max_Elapsed_Time_sec = bin(max(elapsedTime_sec),1),\r\n Min_Elapsed_Time_sec = bin(min(elapsedTime_sec),1),\r\n Variability_sec=bin((max(elapsedTime_sec)-min(elapsedTime_sec)),1),\r\n SampleQID = any(RequestId_s),\r\n SampleSessionID = any(Session_ID)\r\n by Command\r\n| order by Max_Elapsed_Time_sec\r\n\r\n\r\n", "size": 0, "showAnalytics": true, "title": "Matching Queries", "timeContextFromParameter": "TimeRange", "exportedParameters": [ { "fieldName": "SampleQID", "parameterName": "SampleQID" }, { "fieldName": "SampleSessionID", "parameterName": "Samp", "parameterType": 1 } ], "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "50%" } } ], "sortBy": [ { "itemKey": "Command", "sortOrder": 1 } ] }, "sortBy": [ { "itemKey": "Command", "sortOrder": 1 } ] }, "name": "query - 0" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics \r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s !in ('Batch','Execute')\r\n| where RequestId_s == '{SampleQID}'\r\n| summarize \r\n Session_ID=max(SessionId_s), \r\n Request_ID=max(RequestId_s), \r\n Submit_Time=min(SubmitTime_t), \r\n Start_Time=max(StartTime_t),\r\n End_Compile_Time=max(EndCompileTime_t), \r\n End_Time=max(EndTime_t), \r\n Command=max(Command_s), \r\n Last_Status=min(Status_s),\r\n Statement_Type=max(StatementType_s),\r\n Resource_class=max(ResourceClass_s) \r\n by RequestId_s\r\n| extend elapsedTime_sec = iif(End_Time > ago(365d),(End_Time - Submit_Time)/1s,real(null)) \r\n| extend CompileTime_sec = (End_Compile_Time - Submit_Time)/1s\r\n| join kind=inner\r\n (AzureDiagnostics \r\n | where Category == 'ExecRequests'\r\n | where Resource == '{DatabaseName}'\r\n | where StatementType_s !in ('Batch','Execute')\r\n | summarize \r\n Session_ID=max(SessionId_s), \r\n Request_ID=max(RequestId_s), \r\n Submit_Time=min(SubmitTime_t), \r\n Start_Time=max(StartTime_t),\r\n End_Compile_Time=max(EndCompileTime_t), \r\n End_Time=max(EndTime_t), \r\n Command=max(Command_s), \r\n Last_Status=min(Status_s),\r\n Statement_Type=max(StatementType_s),\r\n Resource_class=max(ResourceClass_s) \r\n by RequestId_s\r\n | extend elapsedTime_sec = (End_Time - Submit_Time)/1s\r\n | extend elapsedTime_sec = iif(End_Time > ago(365d),(End_Time - Submit_Time)/1s,real(null)) \r\n | extend CompileTime_sec = (End_Compile_Time - Submit_Time)/1s\r\n )\r\non Command \r\n| project Request_ID1,Session_ID1,Submit_Time1,Start_Time1,End_Compile_Time1,End_Time1,Last_Status1,Statement_Type1,Resource_class1,elapsedTime_sec1,CompileTime_sec1\r\n", "size": 0, "showAnalytics": true, "title": "All Executions of Selected Query", "noDataMessage": "Select a query above to see individual executions", "timeContextFromParameter": "TimeRange", "exportFieldName": "Request_ID1", "exportParameterName": "RequestId", "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "sortBy": [] }, "name": "query - 0 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics\r\n| where Category == 'RequestSteps'\r\n| where Resource == '{DatabaseName}'\r\n| where RequestId_s == '{RequestId}'\r\n//| where Status_s != 'Running'\r\n| summarize max(StartTime_t),max(EndTime_t),max(RequestId_s),max(OperationType_s),max(RowCount_d),max(Command_s),min(Status_s) by StepIndex_d\r\n| order by StepIndex_d asc", "size": 3, "showAnalytics": true, "title": "Query Plan for Selected Query", "noDataMessage": "Select a Query Above to See the Query Plan", "timeContextFromParameter": "TimeRange", "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 0 - Copy - Copy" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "parameters": [ { "id": "1191e58a-c1f9-4853-b36b-4be8eecbb48f", "version": "KqlParameterItem/1.0", "name": "Query_Submit_Time", "type": 1, "query": " AzureDiagnostics \r\n | where Category == 'ExecRequests'\r\n | where Resource == '{DatabaseName}'\r\n | where StatementType_s !in ('Batch','Execute')\r\n | where RequestId_s =='{RequestId}'\r\n | summarize \r\n Submit_Time=min(SubmitTime_t)\r\n by RequestId_s\r\n | project Submit_Time", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "id": "f6bcb2a4-3356-4110-ba13-99c7d13a26f0", "version": "KqlParameterItem/1.0", "name": "Query_End_Compile_Time", "type": 1, "query": " AzureDiagnostics \r\n | where Category == 'ExecRequests'\r\n | where Resource == '{DatabaseName}'\r\n | where StatementType_s !in ('Batch','Execute')\r\n | where RequestId_s =='{RequestId}'\r\n | summarize \r\n End_Compile_Time=max(EndCompileTime_t) \r\n by RequestId_s\r\n | project End_Compile_Time", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 6" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": " AzureDiagnostics \r\n | where Category == 'ExecRequests'\r\n | where Resource == 'LASR-SQLDWDB-PRD'\r\n | where StatementType_s =='CreateStatistics'\r\n | summarize \r\n Session_ID=max(SessionId_s), \r\n Request_ID=max(RequestId_s), \r\n Submit_Time=min(SubmitTime_t), \r\n Start_Time=max(StartTime_t),\r\n End_Compile_Time=max(EndCompileTime_t), \r\n End_Time=max(EndTime_t), \r\n Command=max(Command_s), \r\n Last_Status=min(Status_s),\r\n Statement_Type=max(StatementType_s),\r\n Resource_class=max(ResourceClass_s) \r\n by RequestId_s\r\n | where Submit_Time > datetime('{Query_Submit_Time}') and End_Time < datetime('{Query_End_Compile_Time}')// or RequestId_s == '{RequestId}'\r\n", "size": 0, "showAnalytics": true, "title": "All possibly related auto-stats statements based on time", "noDataMessage": "no auto stats statements found that could be related", "timeContextFromParameter": "TimeRange", "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Submit_Time", "formatter": 0, "numberFormat": { "unit": 0, "options": { "style": "decimal" } } }, { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "100ch" } } ] } }, "name": "All possibly related auto-stats statements" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "QueryInvestigation" }, "name": "group - 4", "styleSettings": { "showBorder": true } }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "title": "Replicated Tables", "items": [ { "type": 1, "content": { "json": "All Charts on this page are based on the last 7 days of data", "style": "info" }, "name": "text - 5" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Build cache count by day\r\nAzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s == 'BuildReplicatedTableCache'\r\n| where Command_s != \"\"\r\n| where ResourceClass_s != \"\"\r\n| project Command_s,TimeGenerated,RequestId_s\r\n| summarize LastRebuild=max(TimeGenerated),RebuildCount=count(RequestId_s) by Command_s\r\n| order by RebuildCount desc\r\n| limit 15\r\n", "size": 3, "showAnalytics": true, "title": "Top 15 Most Rebuilds by Table", "timeContext": { "durationMs": 604800000 }, "exportFieldName": "Command_s", "exportParameterName": "QueryText", "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command_s", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "40%" } } ] } }, "showPin": true, "name": "query - 0" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Build cache count by day\r\nAzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s == 'BuildReplicatedTableCache'\r\n| where Command_s == \"{QueryText}\"\r\n| where ResourceClass_s != \"\"\r\n| project Command_s,TimeGenerated,RequestId_s\r\n| summarize count() by Command_s,bin(TimeGenerated,24h)\r\n| limit 20\r\n| render timechart", "size": 0, "showAnalytics": true, "title": "Rebuilds per Day for Selected Table", "noDataMessage": "Select a query above to see runs by day", "timeContext": { "durationMs": 604800000 }, "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "chartSettings": { "group": "Command_s", "createOtherGroup": 20, "ySettings": { "min": 0 } } }, "name": "query - 0 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Build cache count by day\r\nAzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s == 'BuildReplicatedTableCache'\r\n| where Command_s != \"\"\r\n| where ResourceClass_s != \"\"\r\n| project Command_s,TimeGenerated,RequestId_s\r\n| summarize count() by Command_s, bin(TimeGenerated,24h)\r\n| where count_ > 7\r\n| order by count_ desc\r\n\r\n", "size": 2, "title": "Rebuild Count by Table by Day", "noDataMessage": " Only tables with more than 7 total rebuilds will show up. If no talbes with that many rebuilds are found this chart will be empty", "timeContext": { "durationMs": 604800000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "categoricalbar", "gridSettings": { "sortBy": [ { "itemKey": "count_", "sortOrder": 1 } ] }, "sortBy": [ { "itemKey": "count_", "sortOrder": 1 } ], "tileSettings": { "showBorder": false, "titleContent": { "columnMatch": "Command_s", "formatter": 1 }, "leftContent": { "columnMatch": "count_", "formatter": 12, "formatOptions": { "palette": "auto" }, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "graphSettings": { "type": 0, "topContent": { "columnMatch": "Command_s", "formatter": 1 }, "centerContent": { "columnMatch": "count_", "formatter": 1, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "chartSettings": { "group": "Command_s", "createOtherGroup": 99, "showDataPoints": true } }, "name": "query - 0 - Copy - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Long-Running Queries - Just Actual Queries\r\nAzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize Session_ID=max(SessionId_s), Request_ID=max(RequestId_s), Submit_Time=max(SubmitTime_t), Start_Time=max(StartTime_t), End_Time=max(EndTime_t), Command=max(Command_s), Statement_Type=max(StatementType_s), Resource_class=max(ResourceClass_s) by RequestId_s\r\n| join kind= inner\r\n(\r\n AzureDiagnostics\r\n | where Category == 'ExecRequests'\r\n | where Resource == '{DatabaseName}'\r\n //| where StatementType_s !in ('Batch','Execute')\r\n | where StatementType_s == 'BuildReplicatedTableCache'\r\n | where EndTime_t > ago(7d)\r\n | where StartTime_t > ago(7d)\r\n | extend elapsedTime_min = (EndTime_t - StartTime_t)/1m\r\n //| extend elapsedTime_min = elapsedTime/1m\r\n | order by elapsedTime_min desc\r\n | project Request_ID=RequestId_s,elapsedTime_min \r\n)\r\non Request_ID\r\n| order by elapsedTime_min desc\r\n| project Request_ID,Submit_Time,Start_Time,End_Time,Elapsed_Time=round(elapsedTime_min,1) ,Command\r\n| limit 15\r\n", "size": 3, "showAnalytics": true, "title": "Top 15 Elapsed Time per Rebuild", "timeContext": { "durationMs": 604800000 }, "exportFieldName": "Request_ID", "exportParameterName": "RequestId", "exportDefaultValue": "999999", "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "40%" } } ] } }, "showPin": true, "name": "query - 3" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics\r\n| where Category == 'RequestSteps'\r\n| where Resource == '{DatabaseName}'\r\n| where RequestId_s == '{RequestId}'\r\n| where Status_s != 'Running'\r\n| summarize max(StartTime_t),max(EndTime_t),max(RequestId_s),max(OperationType_s),max(RowCount_d),max(Command_s),max(Status_s) by StepIndex_d\r\n| order by StepIndex_d asc", "size": 3, "showAnalytics": true, "title": "Query Plan for Selected Query", "noDataMessage": "Select a query above to view plan", "timeContext": { "durationMs": 604800000 }, "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 4" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "ReplicatedTables" }, "name": "ReplicatedTablesGroup" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "title": "Workload Management", "items": [ { "type": 10, "content": { "chartId": "workbook72446028-6edb-4cb0-8952-e0c13bda488f", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 0 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-WorkloadManagement-wlg_allocation_relative_to_system_percent", "aggregation": 3, "splitBy": null } ], "title": "Workload Group Allocation By System Percent", "showCreateAlertRule": true, "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "showPin": true, "name": "metric - 0" }, { "type": 10, "content": { "chartId": "workbookc898119a-7381-469d-b51a-d505b4f80e73", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 0 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-WorkloadManagement-wlg_active_queries", "aggregation": 1, "splitBy": null } ], "title": "Query Count by Workload Group", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "showPin": true, "name": "metric - 1" }, { "type": 10, "content": { "chartId": "workbook8d175f6c-427b-47fc-85ea-37edd0be707c", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 0 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-WorkloadManagement-wlg_queued_queries", "aggregation": 1, "splitBy": null } ], "title": "Queued Queries by Workload Group", "showCreateAlertRule": true, "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "showPin": true, "name": "Queued Queries by Workload Group" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "parameters": [ { "id": "6f50577d-7b00-4e4a-acf9-d45c7a5ee813", "version": "KqlParameterItem/1.0", "name": "WorkloadGroupName", "type": 2, "query": "AzureDiagnostics\r\n| where Category == 'ExecRequests'\r\nand Resource == '{DatabaseName}'\r\n and ResourceClass_s != \"\"\r\n| distinct ResourceClass_s", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "value": null, "typeSettings": { "additionalResourceOptions": [], "showDefault": false }, "timeContext": { "durationMs": 604800000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 2" }, { "type": 10, "content": { "chartId": "workbook3da1d18a-1bf5-46c5-b3b7-211f71d329cc", "version": "MetricsItem/2.0", "size": 0, "chartType": 2, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 0 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-WorkloadManagement-wlg_active_queries", "aggregation": 1, "splitBy": null }, { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-WorkloadManagement-wlg_queued_queries", "aggregation": 1 }, { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-WorkloadManagement-wlg_allocation_relative_to_system_percent", "aggregation": 3 }, { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-WorkloadManagement-wlg_effective_min_resource_percent", "aggregation": 3 }, { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-WorkloadManagement-wlg_effective_cap_resource_percent", "aggregation": 3 } ], "filters": [ { "id": "3", "key": "WorkloadGroupName", "operator": 0, "valueParam": "WorkloadGroupName" } ], "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "name": "metric - 3" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "WorkloadManagement" }, "name": "group - 6" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "title": "Query Audit", "items": [ { "type": 1, "content": { "json": "## Select a Principal or Application name to filter results - leave to 'unset' to view all results\r\nSQL Auditing must be enabled and sending to the same Log Analytics Workspace for this page to work. " }, "name": "text - 5" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "parameters": [ { "id": "8d25c043-d1ff-4546-a1fa-f4bcbfdab8af", "version": "KqlParameterItem/1.0", "name": "User", "type": 2, "description": "User to filter subsequent queries - leave to 'unset' for all users", "query": "AzureDiagnostics\r\n| where Category == 'SQLSecurityAuditEvents' and LogicalServerName_s == '{LogicalServerName}'\r\n| summarize by server_principal_name_s", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "value": null, "typeSettings": { "additionalResourceOptions": [], "showDefault": false }, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "id": "aa766d64-693f-4024-b4a4-b5b56b28376b", "version": "KqlParameterItem/1.0", "name": "Application", "type": 2, "query": "AzureDiagnostics\r\n| where Category == 'SQLSecurityAuditEvents' and LogicalServerName_s == '{LogicalServerName}'\r\n| summarize by application_name_s", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "value": null, "typeSettings": { "additionalResourceOptions": [], "showDefault": false }, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "customWidth": "30", "name": "parameters - 1" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics\r\n| where Category == 'SQLSecurityAuditEvents' and LogicalServerName_s == \"{LogicalServerName}\"\r\n| where duration_milliseconds_d > 0\r\n| extend duration_seconds = duration_milliseconds_d /1000.0\r\n| where statement_s != 'select @@version'\r\n| where statement_s != 'SELECT @@SPID;'\r\n| where server_principal_name_s has '{User}'\r\n| where application_name_s has '{Application}'\r\n| project server_principal_name_s, succeeded_s, event_time_t, LogicalServerName_s, duration_milliseconds_d, duration_seconds, affected_rows_d, statement_s, application_name_s\r\n| summarize duration_seconds = round(sum(duration_seconds)) , query_count = count(statement_s) by EventDay = bin(event_time_t,1d), UserName = server_principal_name_s, Application = application_name_s \r\n| order by EventDay, duration_seconds desc", "size": 0, "showAnalytics": true, "title": "Query Summary for Selected User {User} {Application}", "noDataMessage": "Select a user to see query activity", "timeContextFromParameter": "TimeRange", "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 0 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics\r\n| where Category == 'SQLSecurityAuditEvents' and LogicalServerName_s == \"{LogicalServerName}\"\r\n| where duration_milliseconds_d > 0\r\n| extend duration_seconds = duration_milliseconds_d /1000.0\r\n| where statement_s != 'select @@version'\r\n| where statement_s != 'SELECT @@SPID;'\r\n| where server_principal_name_s has '{User}'\r\n| where application_name_s has '{Application}'\r\n| project server_principal_name_s, succeeded_s, event_time_t, LogicalServerName_s, duration_milliseconds_d, duration_seconds, affected_rows_d, statement_s, application_name_s\r\n| summarize duration_seconds = round(sum(duration_seconds)) , query_count = count(statement_s) by EventDay = bin(event_time_t,1d), UserName = server_principal_name_s, Application = application_name_s \r\n| order by EventDay, duration_seconds desc", "size": 0, "title": "Query Summary for Selected User {User} {Application}", "noDataMessage": "Select a user to see query activity", "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "unstackedbar", "tileSettings": { "showBorder": false, "titleContent": { "columnMatch": "UserName", "formatter": 1 }, "leftContent": { "columnMatch": "duration_seconds", "formatter": 12, "formatOptions": { "palette": "auto" }, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "graphSettings": { "type": 0, "topContent": { "columnMatch": "UserName", "formatter": 1 }, "centerContent": { "columnMatch": "duration_seconds", "formatter": 1, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "chartSettings": { "xAxis": "UserName" }, "mapSettings": { "locInfo": "LatLong", "sizeSettings": "duration_seconds", "sizeAggregation": "Sum", "legendMetric": "duration_seconds", "legendAggregation": "Sum", "itemColorSettings": { "type": "heatmap", "colorAggregation": "Sum", "nodeColorField": "duration_seconds", "heatmapPalette": "greenRed" } } }, "name": "query - 0 - Copy - Copy" }, { "type": 1, "content": { "json": "## This next chart is approximate\r\nThe next chart uses an approximate join based on end time. If the Exec Requests Query Text and the Audit Log Query text don't match up, then it is likely not a real match and the data in the row shoudl not be trusted. You will most likely get false matches for very short queries.", "style": "warning" }, "name": "text - 7" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databasename='{DatabaseName}';\r\nAzureDiagnostics \r\n| where Category == 'ExecRequests'\r\n| where Resource == databasename\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize Session_ID=max(SessionId_s), \r\n Query_Submit_Time=max(SubmitTime_t), \r\n Query_Start_Time=max(StartTime_t), \r\n Query_End_Time=max(EndTime_t), \r\n Query_Text=max(Command_s), \r\n Status=min(Status_s),\r\n Resource_class=max(ResourceClass_s) ,\r\n Query_ElapsedTime_s=round((max(EndTime_t) - max(StartTime_t))/1s)\r\n by RequestId_s\r\n| join kind = leftouter \r\n(\r\n AzureDiagnostics\r\n | where Category == 'RequestSteps'\r\n | where Resource == databasename\r\n | summarize num_steps=max(StepIndex_d), \r\n max_step_rows=max(RowCount_d), \r\n max_step_sec=max(EndTime_t-StartTime_t)/1s\r\n by RequestId_s\r\n ) on RequestId_s\r\n| order by Query_Submit_Time\r\n| project Session_ID,RequestId_s,Query_Submit_Time,Query_Start_Time,EventTime = Query_End_Time,num_steps,max_step_rows,max_step_sec,Query_ElapsedTime_s,Status,Query = Query_Text,Resource_class\r\n| join kind = rightouter \r\n(\r\n AzureDiagnostics\r\n | where Category == 'SQLSecurityAuditEvents' and LogicalServerName_s == \"{LogicalServerName}\"\r\n | where duration_milliseconds_d > 0\r\n | extend duration_seconds = duration_milliseconds_d /1000.0\r\n | where statement_s != 'select @@version'\r\n | where statement_s != 'SELECT @@SPID;'\r\n | where server_principal_name_s has '{User}'\r\n // | where application_name_s has '{Application}'\r\n | project DatabaseName= database_name_s, UserName= server_principal_name_s, EventTime= event_time_t, Host= host_name_s, duration_seconds = round(duration_seconds), statement_s, QuerySource = application_name_s , affected_rows_d\r\n | project-reorder DatabaseName, UserName, Host, EventTime, duration_seconds, statement_s, QuerySource\r\n) on EventTime\r\n | order by affected_rows_d desc\r\n| project Session_ID,RequestID=RequestId_s,Submit_time=Query_Submit_Time,Start_Time=Query_Start_Time,End_Time=EventTime,Status,Resource_class,UserName,Exec_request_text=Query,Audit_Query_text=statement_s,Host,QuerySource,Affected_rows=affected_rows_d,num_steps,max_step_rows,max_step_sec,Total_Duration_s=duration_seconds\r\n\r\n\r\n\r\n\r\n", "size": 0, "showAnalytics": true, "title": "Queries {User} {Application}", "noDataMessage": "Select a user to see query activity", "timeContextFromParameter": "TimeRange", "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "showPin": true, "name": "query - 0 - Copy - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": " AzureDiagnostics\r\n | where Category == 'SQLSecurityAuditEvents' and LogicalServerName_s == \"{LogicalServerName}\"\r\n | where duration_milliseconds_d > 0\r\n| extend Duration = round(duration_milliseconds_d /1000.0)\r\n| extend TimeBin = case (datetime_part(\"Hour\",TimeGenerated) in (6,7,8,9,10,11,12), \"Morning_6-12\", datetime_part(\"Hour\",TimeGenerated) in (13,14,15,16,17,18), \"Afternoon_12-18\", \"Overnight_18-6\")\r\n| where server_principal_name_s has '{User}'\r\n| where application_name_s has '{Application}'\r\n| summarize QueryDuration = sum(Duration) by EventTime = bin(event_time_t, 1d), TimeBin", "size": 0, "title": "Query Activity by time - sum(Duration) {User} {Application}", "noDataMessage": "Select a user to see query activity", "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "barchart" }, "name": "query - 0 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databasename='{DatabaseName}';\r\nAzureDiagnostics \r\n| where Category == 'ExecRequests'\r\n| where Resource == databasename\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize Session_ID=max(SessionId_s), \r\n Query_Submit_Time=max(SubmitTime_t), \r\n Query_Start_Time=max(StartTime_t), \r\n Query_End_Time=max(EndTime_t), \r\n Query_Text=max(Command_s), \r\n Status=min(Status_s),\r\n Resource_class=max(ResourceClass_s) ,\r\n Query_ElapsedTime_s=round((max(EndTime_t) - max(StartTime_t))/1s)\r\n by RequestId_s\r\n| join kind = leftouter \r\n(\r\n AzureDiagnostics\r\n | where Category == 'RequestSteps'\r\n | where Resource == databasename\r\n | summarize num_steps=max(StepIndex_d), \r\n max_step_rows=max(RowCount_d), \r\n max_step_sec=max(EndTime_t-StartTime_t)/1s\r\n by RequestId_s\r\n ) on RequestId_s\r\n| order by Query_Submit_Time\r\n| project Session_ID,RequestId_s,Query_Submit_Time,Query_Start_Time,EventTime = Query_End_Time,num_steps,max_step_rows,max_step_sec,Query_ElapsedTime_s,Status,Query = Query_Text,Resource_class\r\n| join kind = rightouter \r\n(\r\n AzureDiagnostics\r\n | where Category == 'SQLSecurityAuditEvents' and LogicalServerName_s == \"{LogicalServerName}\"\r\n | where duration_milliseconds_d > 0\r\n | extend duration_seconds = duration_milliseconds_d /1000.0\r\n | where statement_s != 'select @@version'\r\n | where statement_s != 'SELECT @@SPID;'\r\n | where server_principal_name_s has '{User}'\r\n // | where application_name_s has '{Application}'\r\n | project DatabaseName= database_name_s, UserName= server_principal_name_s, EventTime= event_time_t, Host= host_name_s, duration_seconds = round(duration_seconds), statement_s, QuerySource = application_name_s , affected_rows_d\r\n | project-reorder DatabaseName, UserName, Host, EventTime, duration_seconds, statement_s, QuerySource\r\n) on EventTime\r\n | order by affected_rows_d desc\r\n| project Session_ID,RequestID=RequestId_s,Submit_time=Query_Submit_Time,Start_Time=Query_Start_Time,End_Time=EventTime,Status,Resource_class,UserName,Query_text=statement_s,Host,QuerySource,Affected_rows=affected_rows_d,num_steps,max_step_rows,max_step_sec,Total_Duration_s=duration_seconds\r\n\r\n\r\n\r\n\r\n", "size": 0, "showAnalytics": true, "title": "Affected Rows By Session ID", "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "linechart", "chartSettings": { "xAxis": "RequestID", "yAxis": [ "Affected_rows" ] } }, "showPin": true, "name": "query - 6" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "QueryAudit" }, "name": "QueryAuditGroup", "styleSettings": { "showBorder": true } }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "title": "Query Comparison", "items": [ { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "7fa3187e-9225-4faa-8f80-dc1bc40c5aab", "version": "KqlParameterItem/1.0", "name": "RequestId1", "type": 1, "value": "" } ], "style": "above", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "customWidth": "50", "name": "parameters - 3 - Copy" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "315fc476-469a-4d8d-b421-028d1113ab06", "version": "KqlParameterItem/1.0", "name": "RequestId2", "type": 1, "value": "", "timeContext": { "durationMs": 86400000 } } ], "style": "above", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "customWidth": "50", "name": "parameters - 2" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s !in ('Batch','Execute') and RequestId_s == '{RequestId1}'\r\n| summarize Session_ID=any(SessionId_s),\r\n Request_ID=any(RequestId_s),\r\n Submit_Time=min(SubmitTime_t),\r\n Start_Time=max(StartTime_t),\r\n End_Time=max(EndTime_t),\r\n Command=any(Command_s),\r\n Status=min(Status_s), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType_s),\r\n Resource_class=any(ResourceClass_s)\r\n by RequestId_s\r\n| summarize Session_ID=any(Session_ID), Submit_Time=any(Submit_Time) ,Start_Time=any(Start_Time), End_Time=any(End_Time),ElapsedTime_min=anyif((End_Time - Start_Time)/1m,Start_Time > ago(30d)),Command=any(Command),Status=any(Status),Statement_Type=any(Statement_Type),Resource_class=any(Resource_class) by Request_ID\r\n| project Session_ID,Request_ID,ElapsedTime_min,Command,Resource_class,Submit_Time,Start_Time,End_Time,Statement_Type,Status\r\n", "size": 4, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "customWidth": "50", "name": "query - 2" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s !in ('Batch','Execute') and RequestId_s == '{RequestId2}'\r\n| summarize Session_ID=any(SessionId_s),\r\n Request_ID=any(RequestId_s),\r\n Submit_Time=min(SubmitTime_t),\r\n Start_Time=max(StartTime_t),\r\n End_Time=max(EndTime_t),\r\n Command=any(Command_s),\r\n Status=min(Status_s), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType_s),\r\n Resource_class=any(ResourceClass_s)\r\n by RequestId_s\r\n| summarize Session_ID=any(Session_ID), Submit_Time=any(Submit_Time) ,Start_Time=any(Start_Time), End_Time=any(End_Time),ElapsedTime_min=anyif((End_Time - Start_Time)/1m,Start_Time > ago(30d)),Command=any(Command),Status=any(Status),Statement_Type=any(Statement_Type),Resource_class=any(Resource_class) by Request_ID\r\n| project Session_ID,Request_ID,ElapsedTime_min,Command,Resource_class,Submit_Time,Start_Time,End_Time,Statement_Type,Status\r\n", "size": 4, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "customWidth": "50", "name": "query - 2 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics\r\n| where Category == 'RequestSteps'\r\n| where Resource == '{DatabaseName}'\r\n| where RequestId_s == '{RequestId1}'\r\n| summarize StartTime=max(StartTime_t)\r\n ,EndTime=max(EndTime_t)\r\n ,RequestID=max(RequestId_s)\r\n ,Operation=max(OperationType_s)\r\n ,RowCount=max(RowCount_d)\r\n ,Command=max(Command_s)\r\n ,Status=max(Status_s)\r\n by StepIndex_d\r\n| order by StepIndex_d asc\r\n| project StartTime,EndTime,RequestID,Operation,RowCount,Command,Status,StepIndex_d", "size": 3, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "customWidth": "50", "name": "query - 4", "styleSettings": { "margin": "0", "padding": "10px" } }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics\r\n| where Category == 'RequestSteps'\r\n| where Resource == '{DatabaseName}'\r\n| where RequestId_s == '{RequestId2}'\r\n| summarize StartTime=max(StartTime_t)\r\n ,EndTime=max(EndTime_t)\r\n ,RequestID=max(RequestId_s)\r\n ,Operation=max(OperationType_s)\r\n ,RowCount=max(RowCount_d)\r\n ,Command=max(Command_s)\r\n ,Status=max(Status_s)\r\n by StepIndex_d\r\n| order by StepIndex_d asc\r\n| project StartTime,EndTime,RequestID,Operation,RowCount,Command,Status,StepIndex_d", "size": 3, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "customWidth": "50", "name": "query - 4 - Copy", "styleSettings": { "padding": "10px" } }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "parameters": [ { "id": "03d1c3ba-0d28-4584-bb63-388f8477034a", "version": "KqlParameterItem/1.0", "name": "Query_Submit_Time1", "type": 1, "query": " AzureDiagnostics \r\n | where Category == 'ExecRequests'\r\n | where Resource == '{DatabaseName}'\r\n | where StatementType_s !in ('Batch','Execute')\r\n | where RequestId_s =='{RequestId1}'\r\n | summarize \r\n Submit_Time=min(SubmitTime_t)\r\n by RequestId_s\r\n | project Submit_Time", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "id": "af36efd7-c5a0-429e-8908-a24e22ee6087", "version": "KqlParameterItem/1.0", "name": "Query_End_Compile_Time1", "type": 1, "query": " AzureDiagnostics \r\n | where Category == 'ExecRequests'\r\n | where Resource == '{DatabaseName}'\r\n | where StatementType_s !in ('Batch','Execute')\r\n | where RequestId_s =='{RequestId1}'\r\n | summarize \r\n End_Compile_Time=max(EndCompileTime_t) \r\n by RequestId_s\r\n | project End_Compile_Time", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "version": "KqlParameterItem/1.0", "name": "Query_Submit_Time2", "type": 1, "query": " AzureDiagnostics \r\n | where Category == 'ExecRequests'\r\n | where Resource == '{DatabaseName}'\r\n | where StatementType_s !in ('Batch','Execute')\r\n | where RequestId_s =='{RequestId2}'\r\n | summarize \r\n Submit_Time=min(SubmitTime_t)\r\n by RequestId_s\r\n | project Submit_Time", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "id": "3e691c5e-2c25-4b1a-b845-032901fb08b6" }, { "version": "KqlParameterItem/1.0", "name": "Query_End_Compile_Time2", "type": 1, "query": " AzureDiagnostics \r\n | where Category == 'ExecRequests'\r\n | where Resource == '{DatabaseName}'\r\n | where StatementType_s !in ('Batch','Execute')\r\n | where RequestId_s =='{RequestId2}'\r\n | summarize \r\n End_Compile_Time=max(EndCompileTime_t) \r\n by RequestId_s\r\n | project End_Compile_Time", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "id": "6dd3ddbe-09bd-485f-b202-296f391ede6d" } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 6 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": " AzureDiagnostics \r\n | where Category == 'ExecRequests'\r\n | where Resource == '{DatabaseName}'\r\n | where StatementType_s =='CreateStatistics'\r\n | summarize \r\n Session_ID=max(SessionId_s), \r\n //Request_ID=max(RequestId_s), \r\n Submit_Time=min(SubmitTime_t), \r\n //Start_Time=max(StartTime_t),\r\n //End_Compile_Time=max(EndCompileTime_t), \r\n End_Time=max(EndTime_t), \r\n Command=max(Command_s), \r\n Last_Status=min(Status_s),\r\n Statement_Type=max(StatementType_s),\r\n Resource_class=max(ResourceClass_s) \r\n by RequestId_s\r\n | where Submit_Time > datetime('{Query_Submit_Time1}') and End_Time < datetime('{Query_End_Compile_Time1}') and End_Time > ago(30d)\r\n| project Command, Status=Last_Status ,Submit_Time,End_Time,Session_ID,Request_ID=RequestId_s,Statement_Type\r\n", "size": 0, "title": "All possibly related auto-stats statements based on time", "noDataMessage": "no auto stats statements found that could be related", "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Submit_Time", "formatter": 0, "numberFormat": { "unit": 0, "options": { "style": "decimal" } } }, { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "100ch" } } ], "sortBy": [ { "itemKey": "End_Time", "sortOrder": 2 } ] }, "sortBy": [ { "itemKey": "End_Time", "sortOrder": 2 } ] }, "customWidth": "50", "name": "All possibly related auto-stats statements - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": " AzureDiagnostics \r\n | where Category == 'ExecRequests'\r\n | where Resource == '{DatabaseName}'\r\n | where StatementType_s =='CreateStatistics'\r\n | summarize \r\n Session_ID=max(SessionId_s), \r\n //Request_ID=max(RequestId_s), \r\n Submit_Time=min(SubmitTime_t), \r\n //Start_Time=max(StartTime_t),\r\n //End_Compile_Time=max(EndCompileTime_t), \r\n End_Time=max(EndTime_t), \r\n Command=max(Command_s), \r\n Last_Status=min(Status_s),\r\n Statement_Type=max(StatementType_s),\r\n Resource_class=max(ResourceClass_s) \r\n by RequestId_s\r\n | where Submit_Time > datetime('{Query_Submit_Time2}') and End_Time < datetime('{Query_End_Compile_Time2}') and End_Time > ago(30d)\r\n| project Command, Status=Last_Status ,Submit_Time,End_Time,Session_ID,Request_ID=RequestId_s,Statement_Type\r\n", "size": 0, "title": "All possibly related auto-stats statements based on time", "noDataMessage": "no auto stats statements found that could be related", "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Submit_Time", "formatter": 0, "numberFormat": { "unit": 0, "options": { "style": "decimal" } } }, { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "100ch" } } ] } }, "customWidth": "50", "name": "All possibly related auto-stats statements - Copy - Copy" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "QueryComparison" }, "name": "QueryComparison" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "title": "Session Investigation", "items": [ { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "feb2ac70-2555-456e-bfa6-6ad4a2dcad0f", "version": "KqlParameterItem/1.0", "name": "SessionID", "type": 1, "value": "", "timeContext": { "durationMs": 86400000 } } ], "style": "above", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 0" }, { "type": 1, "content": { "json": "The matching of the user information in the next chart is approximate. This information is a work in progress", "style": "warning" }, "name": "text - 4" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databasename='{DatabaseName}';\r\nAzureDiagnostics \r\n| where Category == 'ExecRequests'\r\n| where Resource == databasename\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize Query_End_Time = max(EndTime_t ) by SessionId_s\r\n| where SessionId_s == '{SessionID}'\r\n| join kind = rightouter \r\n( \r\n AzureDiagnostics\r\n | where Category == 'SQLSecurityAuditEvents' \r\n | where duration_milliseconds_d > 0\r\n | extend duration_seconds = duration_milliseconds_d /1000.0\r\n | where statement_s != 'select @@version' and statement_s != 'SELECT @@SPID;' and server_principal_name_s != '##MS_InstanceCertificate##'\r\n) on $left.Query_End_Time==$right.event_time_t \r\n| summarize DatabaseName= max(database_name_s)\r\n , UserName= any(server_principal_name_s)\r\n , Host= max(host_name_s)\r\n , Application=max(application_name_s)\r\n by SessionId_s\r\n\r\n\r\n\r\n", "size": 4, "showAnalytics": true, "timeContextFromParameter": "TimeRange", "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "table", "tileSettings": { "titleContent": { "columnMatch": "UserName" }, "subtitleContent": { "columnMatch": "SessionId_s" }, "leftContent": { "columnMatch": "Application" }, "rightContent": { "columnMatch": "Host" }, "secondaryContent": { "columnMatch": "DatabaseName" }, "showBorder": false, "size": "full" }, "graphSettings": { "type": 0 } }, "name": "query - 3" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics \r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize \r\n Session_ID=max(SessionId_s), \r\n Submit_Time=max(SubmitTime_t), \r\n Start_Time=max(StartTime_t),\r\n End_Compile_Time=max(EndCompileTime_t), \r\n End_Time=max(EndTime_t), \r\n Command=max(Command_s), \r\n Last_Status=min(Status_s),\r\n Statement_Type=max(StatementType_s),\r\n Resource_class=max(ResourceClass_s) \r\n by RequestId_s\r\n| where Session_ID has '{SessionID}'\r\n| extend elapsedTime_sec = iif(End_Time > ago(365d),(End_Time - Submit_Time)/1s,real(null)) \r\n| order by Submit_Time asc\r\n\r\n\r\n\r\n\r\n", "size": 0, "showAnalytics": true, "timeContextFromParameter": "TimeRange", "exportFieldName": "RequestId_s", "exportParameterName": "RequestID", "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 1" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics\r\n| where Category == 'RequestSteps'\r\n| where Resource == '{DatabaseName}'\r\n| where RequestId_s == '{RequestID}'\r\n//| where Status_s != 'Running'\r\n| summarize Start_Time=max(StartTime_t),End_Time=max(EndTime_t),Request_ID=max(RequestId_s),Operation_Type=max(OperationType_s),Row_Count=max(RowCount_d),Statement=max(Command_s),Status=min(Status_s) by StepIndex_d\r\n| order by StepIndex_d asc", "size": 3, "showAnalytics": true, "timeContextFromParameter": "TimeRange", "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 2" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "SessionInvestigation" }, "name": "group - 9" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 1, "content": { "json": "## This tab is used to determine what statements triggerred autostats creation jobs. \r\nThe flow of autostats creation is as follows\r\n1. Query Submit Time\r\n2. \tCreate Statistics submit Time\r\n3. \tCreate Statistics end Time\r\n4. Query end_compile_time\r\n5. Query Start_Time\r\n6. Query End_Time\r\n\r\nFurther, if multiple stats are created, then the creation of all stats for this query will fall between query submit_time and end_compile_time. \r\n\r\nThe charts on this page allow you to search for an autostats job by requestID or my snippet of the autostats statement text, which can just be the schema, table, or column name. Then it will show you all commands that include that request ID or text. It will then show you all statements in the create stat statement because the query we are trying to identify will wait for all of those stats creations to complete before proceeding. \r\n\r\nThe last chart will list out all statements that could possibly have triggerred the stats creation job based on their submite/end_compile_time. " }, "name": "text - 6" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "0911bd4b-d471-480b-bdf4-1a2d4ba1ea6e", "version": "KqlParameterItem/1.0", "name": "RequestIdSearch", "type": 1, "value": "", "label": "RequestId for AutoStats Job" }, { "id": "c12e6495-4fd1-473c-8ffc-0bf502f54706", "version": "KqlParameterItem/1.0", "name": "QueryTextSnippet", "type": 1, "value": "", "timeContext": { "durationMs": 86400000 }, "label": "Snippet of autostats creation statement (Schema, table or column)" } ], "style": "formVertical", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "customWidth": "60", "name": "parameters - 3 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics \r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize \r\n Session_ID=max(SessionId_s), \r\n Request_ID=max(RequestId_s), \r\n Submit_Time=max(SubmitTime_t), \r\n Start_Time=max(StartTime_t),\r\n End_Compile_Time=max(EndCompileTime_t), \r\n End_Time=max(EndTime_t), \r\n Command=max(Command_s), \r\n Last_Status=min(Status_s),\r\n Statement_Type=max(StatementType_s),\r\n Resource_class=max(ResourceClass_s) \r\n by RequestId_s\r\n| where Command has 'CREATE STATISTICS _wa_sys'\r\n| where Command has '{QueryTextSnippet}'\r\nand RequestId_s has '{RequestIdSearch}'\r\n| extend elapsedTime_sec = iif(End_Time > ago(365d),(End_Time - Submit_Time)/1s,real(null)) \r\n| extend CompileTime_sec = (End_Compile_Time - Submit_Time)/1s\r\n| order by elapsedTime_sec\r\n| summarize \r\n Executions = count(),\r\n Max_Elapsed_Time_sec = bin(max(elapsedTime_sec),1),\r\n Min_Elapsed_Time_sec = bin(min(elapsedTime_sec),1),\r\n Variability_sec=bin((max(elapsedTime_sec)-min(elapsedTime_sec)),1),\r\n SampleQID = any(RequestId_s),\r\n SampleSessionID = any(Session_ID)\r\n by Command\r\n| order by Max_Elapsed_Time_sec\r\n\r\n\r\n", "size": 0, "title": "Matching Queries", "timeContextFromParameter": "TimeRange", "exportedParameters": [ { "fieldName": "SampleQID", "parameterName": "SampleQID" }, { "fieldName": "SampleSessionID", "parameterName": "Samp", "parameterType": 1 } ], "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "50%" } } ], "sortBy": [ { "itemKey": "Command", "sortOrder": 1 } ] }, "sortBy": [ { "itemKey": "Command", "sortOrder": 1 } ] }, "name": "query - 0 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics \r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s !in ('Batch','Execute')\r\n| where RequestId_s == '{SampleQID}'\r\n| summarize \r\n Session_ID=max(SessionId_s), \r\n Request_ID=max(RequestId_s), \r\n Submit_Time=min(SubmitTime_t), \r\n Start_Time=max(StartTime_t),\r\n End_Compile_Time=max(EndCompileTime_t), \r\n End_Time=max(EndTime_t), \r\n Command=max(Command_s), \r\n Last_Status=min(Status_s),\r\n Statement_Type=max(StatementType_s),\r\n Resource_class=max(ResourceClass_s) \r\n by RequestId_s\r\n| extend elapsedTime_sec = iif(End_Time > ago(365d),(End_Time - Submit_Time)/1s,real(null)) \r\n| extend CompileTime_sec = (End_Compile_Time - Submit_Time)/1s\r\n| join kind=inner\r\n (AzureDiagnostics \r\n | where Category == 'ExecRequests'\r\n | where Resource == '{DatabaseName}'\r\n | where StatementType_s !in ('Batch','Execute')\r\n | summarize \r\n Session_ID=max(SessionId_s), \r\n Request_ID=max(RequestId_s), \r\n Submit_Time=min(SubmitTime_t), \r\n Start_Time=max(StartTime_t),\r\n End_Compile_Time=max(EndCompileTime_t), \r\n End_Time=max(EndTime_t), \r\n Command=max(Command_s), \r\n Last_Status=min(Status_s),\r\n Statement_Type=max(StatementType_s),\r\n Resource_class=max(ResourceClass_s) \r\n by RequestId_s\r\n | extend elapsedTime_sec = (End_Time - Submit_Time)/1s\r\n | extend elapsedTime_sec = iif(End_Time > ago(365d),(End_Time - Submit_Time)/1s,real(null)) \r\n | extend CompileTime_sec = (End_Compile_Time - Submit_Time)/1s\r\n )\r\non Command \r\n| project Request_ID1,Session_ID1,Submit_Time1,Start_Time1,End_Compile_Time1,End_Time1,Last_Status1,Statement_Type1,elapsedTime_sec1,CompileTime_sec1\r\n", "size": 0, "title": "All Executions of Selected Query", "noDataMessage": "Select a query above to see individual executions", "timeContextFromParameter": "TimeRange", "exportedParameters": [ { "fieldName": "Request_ID1", "parameterName": "RequestId" }, { "fieldName": "End_Time1", "parameterName": "StatEndTime", "parameterType": 1 }, { "fieldName": "Submit_Time1", "parameterName": "StatSubmitTime", "parameterType": 1 }, { "fieldName": "Session_ID1", "parameterName": "SessionId", "parameterType": 1 } ], "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "sortBy": [ { "itemKey": "End_Time1", "sortOrder": 1 } ] }, "sortBy": [ { "itemKey": "End_Time1", "sortOrder": 1 } ] }, "name": "query - 0 - Copy - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": " AzureDiagnostics \r\n | where Category == 'ExecRequests'\r\n | where Resource == '{DatabaseName}'\r\n | where StatementType_s !in ('Batch','Execute')\r\n | where SessionId_s == '{SessionId}'\r\n | summarize \r\n Session_ID=max(SessionId_s), \r\n Request_ID=max(RequestId_s), \r\n Submit_Time=min(SubmitTime_t), \r\n Start_Time=max(StartTime_t),\r\n End_Compile_Time=max(EndCompileTime_t), \r\n End_Time=max(EndTime_t), \r\n Command=max(Command_s), \r\n Last_Status=min(Status_s),\r\n Statement_Type=max(StatementType_s),\r\n Resource_class=max(ResourceClass_s) \r\n by RequestId_s\r\n| project Session_ID,Request_ID,Submit_Time,End_Compile_Time,Start_Time,End_Time,Last_Status,Statement_Type,Command\r\n\r\n\r\n", "size": 0, "title": "All Statements in Stats Statement Session", "noDataMessage": "Select a query above to see individual executions", "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "150ch" } } ], "sortBy": [ { "itemKey": "Command", "sortOrder": 1 } ] }, "sortBy": [ { "itemKey": "Command", "sortOrder": 1 } ] }, "name": "query - 0 - Copy - Copy - Copy - Copy" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "parameters": [ { "id": "4e005821-785a-4246-aae8-de00987cba18", "version": "KqlParameterItem/1.0", "name": "Session_Submit_Time", "type": 1, "query": "AzureDiagnostics \r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s !in ('Batch','Execute')\r\n| where SessionId_s == '{SessionId}'\r\n| summarize \r\n Session_Submit_Time=min(SubmitTime_t) \r\n by SessionId_s\r\n| project Session_Submit_Time\r\n\r\n\r\n", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 259200000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "id": "b046db56-e6b3-4f3d-afb3-9687240c21f1", "version": "KqlParameterItem/1.0", "name": "Session_End_Time", "type": 1, "query": "AzureDiagnostics \r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s !in ('Batch','Execute')\r\n| where SessionId_s == '{SessionId}'\r\n| summarize \r\n Session_End_Time=max(EndTime_t) \r\n by SessionId_s\r\n| project Session_End_Time", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 259200000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 7" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics \r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s !in ('Batch','Execute')\r\n| where SubmitTime_t < datetime('{Session_Submit_Time}') and EndCompileTime_t > datetime('{Session_End_Time}') or RequestId_s == '{RequestId}'\r\n| summarize by RequestId_s\r\n| join kind=inner\r\n (\r\n AzureDiagnostics \r\n | where Category == 'ExecRequests'\r\n | where Resource == '{DatabaseName}'\r\n | where StatementType_s !in ('Batch','Execute')\r\n | summarize \r\n Session_ID=max(SessionId_s), \r\n Request_ID=max(RequestId_s), \r\n Submit_Time=min(SubmitTime_t), \r\n Start_Time=max(StartTime_t),\r\n End_Compile_Time=max(EndCompileTime_t), \r\n End_Time=max(EndTime_t), \r\n Command=max(Command_s), \r\n Last_Status=min(Status_s),\r\n Statement_Type=max(StatementType_s),\r\n Resource_class=max(ResourceClass_s) \r\n by RequestId_s\r\n ) on RequestId_s\r\n| order by End_Compile_Time\r\n| project Session_ID,Request_ID,Submit_Time,End_Compile_Time,Start_Time,End_Time,Last_Status,Statement_Type,Command\r\n\r\n", "size": 0, "title": "Query Executions that could have triggered Stats Statement based on Time of total session", "noDataMessage": "Select a query above to see individual executions", "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "150ch" } } ], "sortBy": [ { "itemKey": "Command", "sortOrder": 1 } ] }, "sortBy": [ { "itemKey": "Command", "sortOrder": 1 } ] }, "name": "query - 0 - Copy - Copy - Copy - Copy" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "Statistics" }, "name": "statistics" }, { "type": 1, "content": { "json": "Workbook Version: 1.4" }, "name": "text - 11" } ], "fallbackResourceIds": [ "Azure Monitor" ], "$schema": "https://github.com/Microsoft/Application-Insights-Workbooks/blob/master/schema/workbook.json" } ================================================ FILE: Monitor_Workbooks/README.md ================================================ # Monitor Synapse Use this template to monitor your dedicated SQL Pools. If you have an instance that was created withint a Synapse workspace, then you will use the workspaces sql pool template. If the instance was deployed standalone and was not originally part of a workspace, you will use the standalone template. ![DedicatedPoolWB1](/Collateral/Screenshots/DedicatedPoolWB1.png) ## Pre-Requisites 1. Log Analytics workspace created 2. Diagnostic settings enabled to send all diagnostics except DMS Workers and SQL Requests to log analytics 3. Auditing enabled for the database or server and sent to Log Analytics (without this the 'Query Activity' tab will not have any data) ## To use the template: 1. Create a new workbook in Azure Monitor (accessing directly from Azure Workbooks does not have a 'new workbook' button) 2. Click edit if you are not already in edit mode 3. Click the advanced editor button - "" 4. Paste in the contents of this JSON into the Gallery Template and Save 5. Fill in the radio parameters at the top to populate your dashboards. # To configure additional components to be monitored: ## Spark Pools Follow these instructions to configure diagnostic settings and download the workbook https://docs.microsoft.com/en-us/azure/synapse-analytics/spark/apache-spark-azure-log-analytics ![SparkWB1](/Collateral/Screenshots/SparkWB1.png) ## Storage accounts When creating a workbook, search public templates for storage account and you will see storage account workbooks. You can filter it just to be the storage accounts for your synapse instance or look at all at once. Clicking one of the storage accounts will take you to a separate workbook just for investigating that storage account. ![StorageWB1](/Collateral/Screenshots/StorageAccountOverviewScreenshot_WB2.png) ## Pipeline/trigger runs The pipeline workbook is an adaptation of an existing Azure Data Factory and serves both services. ![PipelineWB1](/Collateral/Screenshots/SynapsePipelineWorkbook1.png) ## Serverless Early version of the serverless workbook has been posted. This includes query execution information including costing. You must have 'diagnostic settings' enabled at the workspace level to send 'BuiltinSqlReqsEnded' to Log Analytics. ![ServerlessWB1](/Collateral/Screenshots/ServerlessWB2.png) ================================================ FILE: Monitor_Workbooks/SynapsePipelines_v1.1.workbook ================================================ { "version": "Notebook/1.0", "items": [ { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "d49554d4-694d-4606-89aa-510d92eb95cd", "version": "KqlParameterItem/1.0", "name": "TimeRange", "type": 4, "value": { "durationMs": 86400000 }, "typeSettings": { "selectableValues": [ { "durationMs": 300000 }, { "durationMs": 900000 }, { "durationMs": 1800000 }, { "durationMs": 3600000 }, { "durationMs": 14400000 }, { "durationMs": 43200000 }, { "durationMs": 86400000 }, { "durationMs": 172800000 }, { "durationMs": 259200000 }, { "durationMs": 604800000 }, { "durationMs": 1209600000 }, { "durationMs": 2419200000 }, { "durationMs": 2592000000 }, { "durationMs": 5184000000 }, { "durationMs": 7776000000 } ] }, "label": "Time Range" }, { "id": "d0ad178a-e2af-4157-a902-86c94e4dad29", "version": "KqlParameterItem/1.0", "name": "LogAnalyticsSubscription", "label": "Log Analytics Subsciption", "type": 6, "multiSelect": true, "quote": "'", "delimiter": ",", "typeSettings": { "additionalResourceOptions": [ "value::all" ], "includeAll": true, "showDefault": false }, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "value": [] }, { "id": "fe0740a1-545a-47d0-9b91-acbd7034a551", "version": "KqlParameterItem/1.0", "name": "LogAnalyticsWorkspace", "label": "Log Analytics Workspace", "type": 5, "multiSelect": true, "quote": "'", "delimiter": ",", "query": "Resources\r\n| where type == 'microsoft.operationalinsights/workspaces'\r\n| project id\r\n", "crossComponentResources": [ "{LogAnalyticsSubscription}" ], "typeSettings": { "additionalResourceOptions": [ "value::all" ], "showDefault": false }, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 1, "resourceType": "microsoft.resourcegraph/resources", "value": [] }, { "id": "fd3f9b36-6e8f-4396-8478-1c9c46174057", "version": "KqlParameterItem/1.0", "name": "DataFactory", "label": "Synapse/Data Factory", "type": 5, "isGlobal": true, "query": "let synape = SynapseIntegrationPipelineRuns\r\n| extend ResourceId = _ResourceId;\r\n\r\nlet df = ADFPipelineRun;\r\n\r\nlet allPipelines = df \r\n| union synape;\r\n\r\nallPipelines\r\n| distinct ResourceId", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "typeSettings": { "resourceTypeFilter": { "microsoft.datafactory/factories": true, "microsoft.datafactory/datafactories": true, "microsoft.synapse/workspaces": true, "Microsoft.Synapse/workspaces": true, "Microsoft.Synapse/workspaces/bigDataPools": true, "Microsoft.Synapse/workspaces/kustopools": true, "Microsoft.Synapse/workspaces/kustopools/databases": true, "Microsoft.Synapse/workspaces/scopePools": true, "Microsoft.Synapse/workspaces/sqlPools": true }, "additionalResourceOptions": [], "showDefault": false }, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "value": null }, { "id": "8dd2023d-6684-44e2-b910-82a0c0fbf879", "version": "KqlParameterItem/1.0", "name": "pipeline", "label": "Pipeline", "type": 2, "isGlobal": true, "multiSelect": true, "quote": "'", "delimiter": ",", "query": "let synape = SynapseIntegrationPipelineRuns\r\n| extend ResourceId = _ResourceId;\r\n\r\nlet df = ADFPipelineRun;\r\n\r\nlet allPipelines = df \r\n| union synape;\r\n\r\nallPipelines\r\n| where ResourceId in (\"{DataFactory}\")\r\n| project pipeId= strcat(ResourceId , PipelineName) , PipelineName\r\n//| distinct pipeId, PipelineName\r\n| distinct PipelineName", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "typeSettings": { "additionalResourceOptions": [ "value::all" ], "showDefault": false }, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "defaultValue": "value::all", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.resourcegraph/resources" }, "name": "parameters - 2" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 11, "content": { "version": "LinkItem/1.0", "style": "tabs", "links": [ { "id": "e870a3f7-acab-4aac-93b8-35b8bab51c1c", "cellValue": "selectedTab", "linkTarget": "parameter", "linkLabel": "Overview Dashboard", "subTarget": "overview", "preText": "Overview Dashboard", "style": "link" }, { "id": "a773b8fc-30b4-480a-b1b2-a73653aa1fe5", "cellValue": "selectedTab", "linkTarget": "parameter", "linkLabel": "Pipeline Details", "subTarget": "pipeline", "preText": "Pipeline Details ", "style": "link" } ] }, "name": "links - 7" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let synape = SynapseIntegrationPipelineRuns\r\n| extend ResourceId = _ResourceId;\r\n\r\nlet df = ADFPipelineRun;\r\n\r\nlet allPipelines = df \r\n| union synape;\r\n\r\nallPipelines\r\n| where ResourceId in (\"{DataFactory}\") \r\n| where PipelineName in ({pipeline}) \r\n| extend Resource = tostring(split(ResourceId, \"/\")[8])\r\n| summarize dcount(RunId) by Resource, ResourceId\r\n", "size": 1, "title": "⚙ Runs per Synapse/Datafactory", "timeContextFromParameter": "TimeRange", "exportFieldName": "ResourceId", "exportParameterName": "DataFactory", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "piechart", "tileSettings": { "showBorder": false, "titleContent": { "columnMatch": "ResourceId", "formatter": 1 }, "leftContent": { "columnMatch": "dcount_RunId", "formatter": 12, "formatOptions": { "palette": "auto" }, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "chartSettings": { "ySettings": {} } }, "customWidth": "33", "name": "query - 2", "styleSettings": { "showBorder": true } }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let synape = SynapseIntegrationPipelineRuns\r\n| extend ResourceId = _ResourceId;\r\n\r\nlet df = ADFPipelineRun;\r\n\r\nlet allPipelines = df \r\n| union synape;\r\n\r\nlet T= allPipelines\r\n| where ResourceId in (\"{DataFactory}\")\r\n| where PipelineName in ({pipeline}) \r\n|summarize arg_max(TimeGenerated,* ) by RunId;\r\n\r\nT\r\n| summarize Succeeded=dcountif(RunId, Status startswith \"Succeeded\"),Failed=dcountif(RunId, Status startswith \"Failed\"), Cancelled = dcountif(RunId, Status startswith \"Cancelled\") by PipelineName\r\n|render barchart with (series = PipelineName)\r\n", "size": 1, "title": "🎯 Runs per pipeline grouped by status", "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Succeeded", "formatter": 3, "formatOptions": { "palette": "green" } }, { "columnMatch": "Failed", "formatter": 3, "formatOptions": { "palette": "red" } }, { "columnMatch": "Cancelled", "formatter": 3, "formatOptions": { "palette": "orange" }, "numberFormat": { "unit": 17, "options": { "style": "decimal" } } } ] }, "tileSettings": { "showBorder": false, "titleContent": { "columnMatch": "PipelineName", "formatter": 1 }, "leftContent": { "columnMatch": "dcount_RunId", "formatter": 12, "formatOptions": { "palette": "auto" }, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "graphSettings": { "type": 0, "topContent": { "columnMatch": "PipelineName", "formatter": 1 }, "centerContent": { "columnMatch": "dcount_RunId", "formatter": 1, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "chartSettings": { "xAxis": "PipelineName", "seriesLabelSettings": [ { "seriesName": "Succeeded", "color": "green" }, { "seriesName": "Failed", "color": "red" }, { "seriesName": "Cancelled", "color": "orange" }, { "seriesName": "Total", "color": "blue" } ], "xSettings": {}, "ySettings": {} } }, "customWidth": "33", "name": "query - 4 - Copy", "styleSettings": { "showBorder": true } }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let synape = SynapseIntegrationPipelineRuns\r\n| extend ResourceId = _ResourceId;\r\n\r\nlet df = ADFPipelineRun;\r\n\r\nlet allPipelines = df \r\n| union synape;\r\n\r\nallPipelines\r\n| where ResourceId in (\"{DataFactory}\") \r\n| where PipelineName in ({pipeline}) \r\n| where Status in ('Failed', 'Succeeded')\r\n| summarize arg_max(TimeGenerated,* ) by RunId\r\n| extend endd = iff(End == todatetime('1601-01-01T00:00:00Z'),now(),End)\r\n| extend Duration = datetime_diff('Second',endd, Start) \r\n| summarize avg(Duration) by PipelineName", "size": 1, "aggregation": 3, "title": "⏲ Average duration per pipeline", "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "barchart", "tileSettings": { "showBorder": false, "titleContent": { "columnMatch": "PipelineName", "formatter": 1 }, "leftContent": { "columnMatch": "Duration", "formatter": 12, "formatOptions": { "palette": "auto" }, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "graphSettings": { "type": 0 }, "chartSettings": { "showMetrics": false, "showLegend": true } }, "customWidth": "34", "name": "query - 5", "styleSettings": { "showBorder": true } }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let synape = SynapseIntegrationPipelineRuns\r\n| extend ResourceId = _ResourceId, Link1 = \"https://web.azuresynapse.net/en-us/monitoring/pipelineruns?workspace=\" , Link2 = \"https://web.azuresynapse.net/en-us/monitoring/pipelineruns/\";\r\n\r\nlet df = ADFPipelineRun\r\n|extend Link1 = \"https://ms-adf.azure.com/monitoring/pipelineruns?factory=\", Link2 = \"https://ms-adf.azure.com/en-us/monitoring/pipelineruns/\", Link3= \"?factory=\";\r\n\r\nlet allPipelines = df \r\n| union synape;\r\n\r\nlet allActivites = ADFActivityRun\r\n| union (SynapseIntegrationActivityRuns | extend ResourceId = _ResourceId) ;\r\n\r\n\r\nlet T = allPipelines\r\n| where ResourceId in (\"{DataFactory}\") \r\n| where PipelineName in ({pipeline}) \r\n| summarize arg_max(TimeGenerated,* ) by RunId\r\n| extend StatusIcon = case(Status == \"Succeeded\", '🟢', \r\n Status == \"InProgress\", '🟡', \r\n Status == \"Queued\", '🔵',\r\n Status == \"Cancelled\",'🟠', \r\n Status == \"Failed\", '🔴', \r\n '0')\r\n|order by TimeGenerated;\r\n\r\n\r\n\r\n\r\nlet T2 = T\r\n| summarize commands_details = make_list(pack('status', StatusIcon, 'TimeGenerated', TimeGenerated)) by PipelineName\r\n| mv-apply command_details = commands_details on\r\n(\r\n order by todatetime(command_details['TimeGenerated']) asc\r\n | summarize make_list(command_details['status'])\r\n)\r\n| project-away commands_details \r\n| extend ['Last runs'] = strcat_array(list_command_details_status,'');\r\n\r\n\r\n\r\n\r\nallPipelines\r\n| where ResourceId in (\"{DataFactory}\") \r\n| where PipelineName in ({pipeline}) \r\n| summarize arg_max(TimeGenerated,* ) by PipelineName\r\n| extend ParentId = ''\r\n , Id = PipelineName\r\n ,Link = strcat(Link1, ResourceId)\r\n , Resource = ResourceId\r\n , endd = iff(End == todatetime('1601-01-01T00:00:00Z'),now(),End)\r\n| extend Duration = format_timespan(endd- Start,'hh:mm:ss') ,Pipeline = strcat('🗜️ ', PipelineName) \r\n| join T2 on PipelineName\r\n|project ParentId, Id , Resource, Pipeline, Status, Start, Duration, ['Last runs'], Link,TimeGenerated\r\n\r\n|union (T\r\n| extend ParentId = PipelineName\r\n ,Id = RunId\r\n ,Link = strcat(Link2,CorrelationId,\"?factory=\",ResourceId)\r\n , endd = iff(End == todatetime('1601-01-01T00:00:00Z'),now(),End)\r\n|extend Duration = format_timespan(endd- Start,'hh:mm:ss') \r\n|project ParentId,Id, Status,Start,Duration,Link,TimeGenerated)\r\n|union (allActivites \r\n| where ResourceId in (\"{DataFactory}\") \r\n| where PipelineName in ({pipeline}) \r\n| summarize arg_max(TimeGenerated,* ) by ActivityRunId\r\n| extend endd = iff(End == todatetime('1601-01-01T00:00:00Z'),now(),End)\r\n| extend ParentId = PipelineRunId,Id = ActivityRunId,Link=\"\",Duration = format_timespan(endd- Start,'hh:mm:ss') , Resource = ActivityName\r\n| order by TimeGenerated desc \r\n| project ParentId,Id, Status,Start,Duration,Link,TimeGenerated, Resource)\r\n| union (allActivites \r\n| where ResourceId in (\"{DataFactory}\") \r\n| where PipelineName in ({pipeline}) \r\n| summarize arg_max(TimeGenerated,* ) by ActivityRunId\r\n| where Status ==\"Failed\"\r\n| extend ParentId = ActivityRunId, Id = \"*\", ['Last runs'] = ErrorMessage\r\n| project ParentId, Id, ['Last runs']);\r\n", "size": 0, "title": "📑 Last runs", "timeContextFromParameter": "TimeRange", "exportedParameters": [ { "fieldName": "PipelineName", "parameterName": "pipeline", "parameterType": 5 } ], "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "ParentId", "formatter": 5, "formatOptions": {} }, { "columnMatch": "Id", "formatter": 5, "formatOptions": {} }, { "columnMatch": "Resource", "formatter": 13, "formatOptions": { "linkTarget": null, "showIcon": true } }, { "columnMatch": "Status", "formatter": 18, "formatOptions": { "thresholdsOptions": "icons", "thresholdsGrid": [ { "operator": "==", "thresholdValue": "Failed", "representation": "critical", "text": "{0}{1}" }, { "operator": "==", "thresholdValue": "Succeeded", "representation": "success", "text": "{0}{1}" }, { "operator": "==", "thresholdValue": "InProgress", "representation": "pending" }, { "operator": "==", "thresholdValue": "Queued", "representation": "1", "text": "{0}{1}" }, { "operator": "==", "thresholdValue": "Cancelled", "representation": "2", "text": "{0}{1}" }, { "operator": "Default", "thresholdValue": null, "representation": "more", "text": "{0}{1}" } ] } }, { "columnMatch": "Start", "formatter": 6, "formatOptions": {} }, { "columnMatch": "Link", "formatter": 7, "formatOptions": { "linkTarget": "Url", "linkLabel": "🌐 (url)" } }, { "columnMatch": "TimeGenerated", "formatter": 5, "formatOptions": {} } ], "hierarchySettings": { "idColumn": "Id", "parentColumn": "ParentId", "treeType": 0, "expanderColumn": "Pipeline" }, "sortBy": [ { "itemKey": "Last runs", "sortOrder": 1 } ] }, "sortBy": [ { "itemKey": "Last runs", "sortOrder": 1 } ] }, "name": "query - 3", "styleSettings": { "showBorder": true } }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let synape = SynapseIntegrationPipelineRuns\r\n| extend ResourceId = _ResourceId;\r\n\r\nlet df = ADFPipelineRun;\r\n\r\nlet allPipelines = df \r\n| union synape;\r\n\r\nallPipelines\r\n| where ResourceId in (\"{DataFactory}\") \r\n| where PipelineName in ({pipeline}) \r\n| where Status in ('Failed', 'Succeeded')\r\n| summarize arg_max(TimeGenerated,* ) by RunId\r\n| summarize count() by ResourceId, PipelineName, format_datetime(bin(TimeGenerated, 1d),'yyyy-MM-dd')", "size": 1, "aggregation": 3, "showAnnotations": true, "title": "🗓 Number of runs by date", "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "barchart", "graphSettings": { "type": 0 }, "chartSettings": { "xAxis": "TimeGenerated", "group": "PipelineName", "createOtherGroup": null, "showMetrics": false, "showLegend": true, "xSettings": { "numberFormatSettings": { "unit": 0, "options": { "style": "decimal", "useGrouping": false } } } } }, "customWidth": "50", "name": "query - 5 - Copy - Copy", "styleSettings": { "showBorder": true } }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let synape = SynapseIntegrationPipelineRuns\r\n| extend ResourceId = _ResourceId;\r\n\r\nlet df = ADFPipelineRun;\r\n\r\nlet allPipelines = df \r\n| union synape;\r\n\r\nallPipelines\r\n| where ResourceId in (\"{DataFactory}\") \r\n| where PipelineName in ({pipeline}) \r\n| where Status in ('Failed', 'Succeeded')\r\n| summarize arg_max(TimeGenerated,* ) by RunId\r\n| summarize count() by ResourceId, PipelineName, format_datetime(bin(TimeGenerated, 1h),'HH:mm')\r\n|order by TimeGenerated asc", "size": 1, "aggregation": 3, "showAnnotations": true, "title": "🕓 Number of runs over time", "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "barchart", "graphSettings": { "type": 0 }, "chartSettings": { "xAxis": "TimeGenerated", "group": "PipelineName", "createOtherGroup": null, "showMetrics": false, "showLegend": true, "xSettings": { "numberFormatSettings": { "unit": 0, "options": { "style": "decimal", "useGrouping": false } } } } }, "customWidth": "50", "name": "query - 5 - Copy - Copy - Copy", "styleSettings": { "showBorder": true } } ] }, "conditionalVisibility": { "parameterName": "selectedTab", "comparison": "isEqualTo", "value": "overview" }, "name": "group - 8", "styleSettings": { "showBorder": true } }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let synape = SynapseIntegrationPipelineRuns\r\n| extend ResourceId = _ResourceId;\r\n\r\nlet df = ADFPipelineRun;\r\n\r\nlet allPipelines = df \r\n| union synape;\r\n\r\nallPipelines\r\n| where ResourceId in (\"{DataFactory}\") \r\n| where PipelineName in ({pipeline}) \r\n| where Status in ('Failed', 'Succeeded')\r\n| summarize arg_max(TimeGenerated,* ) by RunId\r\n| extend endd = iff(End == todatetime('1601-01-01T00:00:00Z'),now(),End)\r\n| extend Duration = datetime_diff('Second',endd, Start) \r\n| summarize avg(Duration) by PipelineName, Start", "size": 1, "aggregation": 3, "title": "⏱ Duration over time ", "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "linechart", "tileSettings": { "showBorder": false, "titleContent": { "columnMatch": "PipelineName", "formatter": 1 }, "leftContent": { "columnMatch": "Duration", "formatter": 12, "formatOptions": { "palette": "auto" }, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "graphSettings": { "type": 0 }, "chartSettings": { "showMetrics": false, "showLegend": true, "ySettings": { "numberFormatSettings": { "unit": 24, "options": { "style": "decimal", "useGrouping": true } } } } }, "name": "query - 5 - Copy", "styleSettings": { "showBorder": true } }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let allActivites = ADFActivityRun\r\n| union (SynapseIntegrationActivityRuns | extend ResourceId = _ResourceId) ;\r\n\r\nlet Activites = allActivites\r\n| extend a = todynamic(Output)\r\n| summarize Rows= sum(toint(a.rowsCopied)) by CorrelationId ;\r\n//, sum(toint(a.dataWritten)), sum(toint(a.filesRead)), sum(toint(a.rowsCopied))\r\n\r\n\r\nlet synape = SynapseIntegrationPipelineRuns\r\n| extend ResourceId = _ResourceId;\r\n\r\nlet df = ADFPipelineRun;\r\n\r\nlet allPipelines = df \r\n| union synape;\r\n\r\nallPipelines\r\n| where ResourceId in (\"{DataFactory}\") \r\n| where PipelineName in ({pipeline}) \r\n| summarize arg_max(TimeGenerated,* ) by RunId\r\n| join Activites on CorrelationId\r\n| project PipelineName, TimeGenerated, Rows", "size": 1, "title": "💾 Rows copied over time", "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "areachart" }, "customWidth": "32", "name": "query - 1 - Copy - Copy - Copy", "styleSettings": { "showBorder": true } }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let allActivites = ADFActivityRun\r\n| union (SynapseIntegrationActivityRuns | extend ResourceId = _ResourceId) ;\r\n\r\nlet Activites = allActivites\r\n| extend a = todynamic(Output)\r\n| summarize Read= sum(toint(a.dataRead)),Written = sum(toint(a.dataWritten)) by CorrelationId ;\r\n//, sum(toint(a.dataWritten)), sum(toint(a.filesRead)), sum(toint(a.rowsCopied))\r\n\r\n\r\nlet synape = SynapseIntegrationPipelineRuns\r\n| extend ResourceId = _ResourceId;\r\n\r\nlet df = ADFPipelineRun;\r\n\r\nlet allPipelines = df \r\n| union synape;\r\n\r\nallPipelines\r\n| where ResourceId in (\"{DataFactory}\") \r\n| where PipelineName in ({pipeline}) \r\n| summarize arg_max(TimeGenerated,* ) by RunId\r\n| join Activites on CorrelationId\r\n| project PipelineName, TimeGenerated, Read, Written", "size": 1, "title": "💻 Data read/written over time", "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "areachart" }, "customWidth": "33", "name": "query - 1 - Copy", "styleSettings": { "showBorder": true } }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let allActivites = ADFActivityRun\r\n| union (SynapseIntegrationActivityRuns | extend ResourceId = _ResourceId) ;\r\n\r\nlet Activites = allActivites\r\n| extend a = todynamic(Output)\r\n| summarize Read= sum(toint(a.filesRead)),Written = sum(toint(a.filesWritten)) by CorrelationId ;\r\n//, sum(toint(a.dataWritten)), sum(toint(a.filesRead)), sum(toint(a.rowsCopied))\r\n\r\n\r\nlet synape = SynapseIntegrationPipelineRuns\r\n| extend ResourceId = _ResourceId;\r\n\r\nlet df = ADFPipelineRun;\r\n\r\nlet allPipelines = df \r\n| union synape;\r\n\r\nallPipelines\r\n| where ResourceId in (\"{DataFactory}\") \r\n| where PipelineName in ({pipeline}) \r\n| summarize arg_max(TimeGenerated,* ) by RunId\r\n| join Activites on CorrelationId\r\n| project PipelineName, TimeGenerated, Read, Written", "size": 1, "title": "📄 Files read / written over time", "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "areachart" }, "customWidth": "33", "name": "query - 1 - Copy - Copy", "styleSettings": { "showBorder": true } }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let allActivites = ADFActivityRun\r\n| union (SynapseIntegrationActivityRuns | extend ResourceId = _ResourceId) ;\r\n\r\nallActivites\r\n| where ResourceId in (\"{DataFactory}\") \r\n| where PipelineName in ({pipeline}) \r\n| where Status == \"Failed\"\r\n| extend a = todynamic(Output)\r\n| summarize count() by TimeGenerated; //, ErrorMessage, FailureType, ActivityName, ActivityType;\r\n", "size": 1, "title": "🛑 Errors over time", "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "categoricalbar", "tileSettings": { "showBorder": false, "titleContent": { "columnMatch": "PipelineName", "formatter": 1 }, "leftContent": { "columnMatch": "ErrorCode", "formatter": 12, "formatOptions": { "palette": "auto" }, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "graphSettings": { "type": 0, "topContent": { "columnMatch": "PipelineName", "formatter": 1 }, "centerContent": { "columnMatch": "ErrorCode", "formatter": 1, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "chartSettings": { "showMetrics": false, "seriesLabelSettings": [ { "seriesName": "count_", "color": "redBright" } ] } }, "name": "query - 1 - Copy - Copy - Copy - Copy", "styleSettings": { "showBorder": true } }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let allActivites = ADFActivityRun\r\n| union (SynapseIntegrationActivityRuns | extend ResourceId = _ResourceId) ;\r\n\r\nallActivites\r\n| where ResourceId in (\"{DataFactory}\") \r\n| where PipelineName in ({pipeline}) \r\n| where Status == \"Failed\"\r\n| extend a = todynamic(Output)\r\n| summarize count() by ActivityType; //, ErrorMessage, FailureType, ActivityName, ActivityType;\r\n", "size": 1, "title": "🛑 Errors per Activity type", "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "categoricalbar", "tileSettings": { "showBorder": false, "titleContent": { "columnMatch": "PipelineName", "formatter": 1 }, "leftContent": { "columnMatch": "ErrorCode", "formatter": 12, "formatOptions": { "palette": "auto" }, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "graphSettings": { "type": 0, "topContent": { "columnMatch": "PipelineName", "formatter": 1 }, "centerContent": { "columnMatch": "ErrorCode", "formatter": 1, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } } }, "customWidth": "33", "name": "query - 1 - Copy - Copy - Copy", "styleSettings": { "showBorder": true } }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let allActivites = ADFActivityRun\r\n| union (SynapseIntegrationActivityRuns | extend ResourceId = _ResourceId) ;\r\n\r\nallActivites\r\n| where ResourceId in (\"{DataFactory}\") \r\n| where PipelineName in ({pipeline}) \r\n| where Status == \"Failed\"\r\n| extend a = todynamic(Output)\r\n| summarize count() by FailureType; //, ErrorMessage, FailureType, ActivityName, ActivityType;\r\n", "size": 1, "title": "🛑 Errors per failure type", "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "categoricalbar", "tileSettings": { "showBorder": false, "titleContent": { "columnMatch": "PipelineName", "formatter": 1 }, "leftContent": { "columnMatch": "ErrorCode", "formatter": 12, "formatOptions": { "palette": "auto" }, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "graphSettings": { "type": 0, "topContent": { "columnMatch": "PipelineName", "formatter": 1 }, "centerContent": { "columnMatch": "ErrorCode", "formatter": 1, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } } }, "customWidth": "33", "name": "query - 1 - Copy - Copy - Copy - Copy", "styleSettings": { "showBorder": true } }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let allActivites = ADFActivityRun\r\n| union (SynapseIntegrationActivityRuns | extend ResourceId = _ResourceId) ;\r\n\r\nallActivites\r\n| where ResourceId in (\"{DataFactory}\") \r\n| where PipelineName in ({pipeline}) \r\n| where Status == \"Failed\"\r\n| extend a = todynamic(Output)\r\n| summarize count() by ActivityName; //, ErrorMessage, FailureType, ActivityName, ActivityType;\r\n", "size": 1, "title": "🛑 Errors per activity name", "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "categoricalbar", "tileSettings": { "showBorder": false, "titleContent": { "columnMatch": "PipelineName", "formatter": 1 }, "leftContent": { "columnMatch": "ErrorCode", "formatter": 12, "formatOptions": { "palette": "auto" }, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "graphSettings": { "type": 0, "topContent": { "columnMatch": "PipelineName", "formatter": 1 }, "centerContent": { "columnMatch": "ErrorCode", "formatter": 1, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } } }, "customWidth": "33", "name": "query - 1 - Copy - Copy - Copy - Copy - Copy", "styleSettings": { "showBorder": true } }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let allActivites = ADFActivityRun\r\n| union (SynapseIntegrationActivityRuns | extend ResourceId = _ResourceId) ;\r\n\r\nallActivites\r\n| where ResourceId in (\"{DataFactory}\") \r\n| where PipelineName in ({pipeline}) \r\n| where Status == \"Failed\"\r\n| extend a = todynamic(Output)\r\n| project TimeGenerated, PipelineName, ErrorCode, ErrorMessage, FailureType, ActivityName, ActivityType\r\n| order by TimeGenerated desc;", "size": 0, "title": "❗ Last failing activites", "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "rowLimit": 1000 } }, "name": "query - 7", "styleSettings": { "showBorder": true } } ] }, "conditionalVisibility": { "parameterName": "selectedTab", "comparison": "isEqualTo", "value": "pipeline" }, "name": "PipelineGroup", "styleSettings": { "showBorder": true } } ] }, "conditionalVisibility": { "parameterName": "DataFactory", "comparison": "isNotEqualTo" }, "name": "VariablesSetMainGroup" }, { "type": 1, "content": { "json": "Please set the variables above to view the Pipeline/Data Factory Details", "style": "warning" }, "conditionalVisibility": { "parameterName": "DataFactory", "comparison": "isEqualTo" }, "name": "text - 2", "styleSettings": { "showBorder": true } } ], "fallbackResourceIds": [ "Azure Monitor" ], "$schema": "https://github.com/Microsoft/Application-Insights-Workbooks/blob/master/schema/workbook.json" } ================================================ FILE: Monitor_Workbooks/SynapseServerlessWorkbook.workbook ================================================ { "version": "Notebook/1.0", "items": [ { "type": 9, "content": { "version": "KqlParameterItem/1.0", "crossComponentResources": [ "value::all" ], "parameters": [ { "id": "c4475a86-95ea-46b8-a5c0-3ee1c3f528bc", "version": "KqlParameterItem/1.0", "name": "TimeRange", "type": 4, "value": { "durationMs": 43200000 }, "typeSettings": { "selectableValues": [ { "durationMs": 300000 }, { "durationMs": 900000 }, { "durationMs": 1800000 }, { "durationMs": 3600000 }, { "durationMs": 14400000 }, { "durationMs": 43200000 }, { "durationMs": 86400000 }, { "durationMs": 172800000 }, { "durationMs": 259200000 }, { "durationMs": 604800000 }, { "durationMs": 1209600000 }, { "durationMs": 2419200000 }, { "durationMs": 2592000000 }, { "durationMs": 5184000000 }, { "durationMs": 7776000000 } ] }, "timeContext": { "durationMs": 86400000 } }, { "id": "94b22c78-91c8-47e6-8833-70d458e199c3", "version": "KqlParameterItem/1.0", "name": "Subscriptions", "type": 6, "isRequired": true, "multiSelect": true, "quote": "'", "delimiter": ",", "typeSettings": { "additionalResourceOptions": [ "value::1", "value::all" ], "includeAll": false, "showDefault": false }, "defaultValue": "value::all", "value": [ "value::all" ] }, { "id": "3dbc1029-1a17-4a4d-a133-2d47c1e7844e", "version": "KqlParameterItem/1.0", "name": "Synapse", "type": 5, "multiSelect": true, "quote": "'", "delimiter": ",", "query": "Resources\r\n| where type == 'microsoft.synapse/workspaces'\r\n| project id\r\n", "crossComponentResources": [ "{Subscriptions}" ], "typeSettings": { "additionalResourceOptions": [ "value::1", "value::all" ], "showDefault": false }, "timeContext": { "durationMs": 86400000 }, "defaultValue": "value::all", "queryType": 1, "resourceType": "microsoft.resourcegraph/resources", "value": [ "value::all" ] }, { "id": "4d1459db-354e-4019-8e86-015d946ce892", "version": "KqlParameterItem/1.0", "name": "LogAnalyticsWorkspace", "type": 5, "multiSelect": true, "quote": "'", "delimiter": ",", "query": "Resources\r\n| where type == 'microsoft.operationalinsights/workspaces'\r\n| project id\r\n", "crossComponentResources": [ "value::all" ], "value": [ "value::all" ], "typeSettings": { "additionalResourceOptions": [ "value::1", "value::all" ], "showDefault": false }, "defaultValue": "value::all", "queryType": 1, "resourceType": "microsoft.resourcegraph/resources" } ], "style": "pills", "queryType": 1, "resourceType": "microsoft.resourcegraph/resources" }, "name": "parameters - 1" }, { "type": 1, "content": { "json": "All costs listed in this workbook are approximate based on $5/TB and data processed is set to a minimum of 10MB. All calculations in the query results are using the charged data processed as opposed to the actual data processed. ", "style": "warning" }, "name": "text - 4" }, { "type": 11, "content": { "version": "LinkItem/1.0", "style": "tabs", "links": [ { "id": "4ee15681-1a46-4207-ac59-efab22cd6d9b", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Summary", "subTarget": "Summary", "style": "link" }, { "id": "82d489b0-87d6-4875-a5de-c7eb2d1c8c4f", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Data Processed", "subTarget": "DataProcessed", "style": "link" }, { "id": "7c0e9efd-a60a-40d7-a290-12133a09a440", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Query Performance", "subTarget": "QueryPerformance", "style": "link" } ] }, "name": "links - 4" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 10, "content": { "chartId": "workbook9cfd0268-d682-40bb-870c-61e05013f973", "version": "MetricsItem/2.0", "size": 4, "chartType": -1, "resourceType": "microsoft.synapse/workspaces", "metricScope": 0, "resourceParameter": "Synapse", "resourceIds": [ "{Synapse}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 86400000 }, "metrics": [ { "namespace": "microsoft.synapse/workspaces", "metric": "microsoft.synapse/workspaces-Builtin SQL Pool-BuiltinSqlPoolLoginAttempts", "aggregation": 1 } ], "title": "Login Attempts", "gridFormatType": 1, "tileSettings": { "showBorder": false, "titleContent": { "columnMatch": "Name", "formatter": 13 }, "leftContent": { "columnMatch": "Value", "formatter": 12, "formatOptions": { "palette": "auto" }, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "timeBrushParameterName": "TimeRange", "gridSettings": { "rowLimit": 10000 } }, "customWidth": "33", "showPin": true, "name": "LoginAttemptsChart - Copy" }, { "type": 10, "content": { "chartId": "workbookdc90b0c5-4f40-4242-89b8-87eac7b9acaf", "version": "MetricsItem/2.0", "size": 4, "chartType": -1, "resourceType": "microsoft.synapse/workspaces", "metricScope": 0, "resourceParameter": "Synapse", "resourceIds": [ "{Synapse}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 86400000 }, "metrics": [ { "namespace": "microsoft.synapse/workspaces", "metric": "microsoft.synapse/workspaces-Builtin SQL Pool-BuiltinSqlPoolRequestsEnded", "aggregation": 1, "columnName": "Requests Completed" } ], "title": "Completed Requests", "gridFormatType": 1, "tileSettings": { "showBorder": false, "titleContent": { "columnMatch": "Name", "formatter": 13 }, "leftContent": { "columnMatch": "Value", "formatter": 12, "formatOptions": { "palette": "auto" }, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "33", "showPin": true, "name": "CompletedRequestCountTile" }, { "type": 10, "content": { "chartId": "workbook1f0054e6-9715-47bb-a7fc-e92812c07403", "version": "MetricsItem/2.0", "size": 4, "chartType": -1, "resourceType": "microsoft.synapse/workspaces", "metricScope": 0, "resourceParameter": "Synapse", "resourceIds": [ "{Synapse}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 86400000 }, "metrics": [ { "namespace": "microsoft.synapse/workspaces", "metric": "microsoft.synapse/workspaces-Builtin SQL Pool-BuiltinSqlPoolDataProcessedBytes", "aggregation": 1 } ], "title": "Data Processed", "gridFormatType": 1, "tileSettings": { "showBorder": false, "titleContent": { "columnMatch": "Name", "formatter": 13 }, "leftContent": { "columnMatch": "Value", "formatter": 12, "formatOptions": { "palette": "auto" }, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "33", "showPin": true, "name": "DataProcessed - Copy" }, { "type": 10, "content": { "chartId": "workbookdc90b0c5-4f40-4242-89b8-87eac7b9acaf", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.synapse/workspaces", "metricScope": 0, "resourceParameter": "Synapse", "resourceIds": [ "{Synapse}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 86400000 }, "metrics": [ { "namespace": "microsoft.synapse/workspaces", "metric": "microsoft.synapse/workspaces-Builtin SQL Pool-BuiltinSqlPoolRequestsEnded", "aggregation": 1, "splitBy": null, "columnName": "Requests Completed" } ], "title": "Completed Requests", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "showPin": true, "name": "CompletedRequestCount" }, { "type": 10, "content": { "chartId": "workbook1f0054e6-9715-47bb-a7fc-e92812c07403", "version": "MetricsItem/2.0", "size": 0, "chartType": 2, "resourceType": "microsoft.synapse/workspaces", "metricScope": 0, "resourceParameter": "Synapse", "resourceIds": [ "{Synapse}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 86400000 }, "metrics": [ { "namespace": "microsoft.synapse/workspaces", "metric": "microsoft.synapse/workspaces-Builtin SQL Pool-BuiltinSqlPoolDataProcessedBytes", "aggregation": 1, "splitBy": null } ], "title": "Data Processed", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "showPin": true, "name": "DataProcessed" }, { "type": 10, "content": { "chartId": "workbook9cfd0268-d682-40bb-870c-61e05013f973", "version": "MetricsItem/2.0", "size": 0, "chartType": 2, "resourceType": "microsoft.synapse/workspaces", "metricScope": 0, "resourceParameter": "Synapse", "resourceIds": [ "{Synapse}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 86400000 }, "metrics": [ { "namespace": "microsoft.synapse/workspaces", "metric": "microsoft.synapse/workspaces-Builtin SQL Pool-BuiltinSqlPoolLoginAttempts", "aggregation": 1, "splitBy": null } ], "title": "Login Attempts", "timeBrushParameterName": "TimeRange", "gridSettings": { "rowLimit": 10000 } }, "showPin": true, "name": "LoginAttemptsChart" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Queries by completion type\r\nSynapseBuiltinSqlPoolRequestsEnded\r\n| where _ResourceId in~ ({Synapse})\r\n| summarize count() by ResultType\r\n| render piechart ", "size": 3, "showAnalytics": true, "title": "Queries by Result Type", "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "sortBy": [ { "itemKey": "$gen_link_Properties_9", "sortOrder": 1 } ] }, "sortBy": [ { "itemKey": "$gen_link_Properties_9", "sortOrder": 1 } ] }, "customWidth": "33", "showPin": true, "name": "QueriesByResultType" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Queries by query type\r\nSynapseBuiltinSqlPoolRequestsEnded\r\n| where _ResourceId in~ ({Synapse})\r\n| project CommandType=tostring(Properties.command)\r\n| summarize count() by CommandType\r\n| render piechart \r\n\r\n", "size": 3, "showAnalytics": true, "title": "Queries by Query Type", "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "customWidth": "33", "showPin": true, "name": "Queries by Query Type" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Queries by completion type\r\nSynapseBuiltinSqlPoolRequestsEnded\r\n| where _ResourceId in~ ({Synapse})\r\n| project BytesProcessed=Properties.dataProcessedBytes,tostring(Identity)\r\n| summarize sum(toint(BytesProcessed)) by Identity\r\n| render piechart \r\n\r\n", "size": 3, "showAnalytics": true, "title": "Data Processed By User", "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "customWidth": "33", "showPin": true, "name": "Data Processed By User" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Most Recent Query Runs\r\nSynapseBuiltinSqlPoolRequestsEnded\r\n| order by TimeGenerated\r\n| where _ResourceId in~ ({Synapse})\r\n| project \r\n StartTime=Properties.startTime,\r\n EndTime=Properties.endTime, \r\n Identity,\r\n CommandType=Properties.command,\r\n Result=ResultType,\r\n MbProcessed=(Properties.dataProcessedBytes/1000/1000),\r\n QueryText=Properties.queryText,\r\n _ResourceId\r\n| extend elapsedTime_sec =(todatetime(EndTime) - StartTime)/1s\r\n| extend Approx_Cost=((MbProcessed)*5.0/100000.0)/100 //multiply by price per mb ($5 per TB from Microsoft Docs: https://azure.microsoft.com/en-us/pricing/details/synapse-analytics/)\r\n| project-reorder StartTime,EndTime,elapsedTime_sec,Identity,CommandType,Result,MbProcessed,Approx_Cost\r\n", "size": 2, "showAnalytics": true, "title": "Recent Queries", "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "StartTime", "formatter": 6 }, { "columnMatch": "EndTime", "formatter": 6 }, { "columnMatch": "elapsedTime_sec", "formatter": 8, "formatOptions": { "palette": "blue" } }, { "columnMatch": "Result", "formatter": 18, "formatOptions": { "thresholdsOptions": "icons", "thresholdsGrid": [ { "operator": "Default", "thresholdValue": null, "representation": "success", "text": "{0}{1}" } ] } }, { "columnMatch": "MbProcessed", "formatter": 3, "formatOptions": { "palette": "blue" } }, { "columnMatch": "Approx_Cost", "formatter": 8, "formatOptions": { "palette": "yellow" }, "numberFormat": { "unit": 0, "options": { "style": "decimal", "minimumFractionDigits": 2, "maximumFractionDigits": 6 } } }, { "columnMatch": "QueryText", "formatter": 7, "formatOptions": { "linkTarget": "CellDetails", "linkIsContextBlade": true, "customColumnWidthSetting": "100ch" } }, { "columnMatch": "BytesProcessed", "formatter": 8, "formatOptions": { "palette": "red" } } ] } }, "showPin": true, "name": "Recent Queries" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Overall concurrency\r\nlet snapshotTelemetryInterval = 1m;//1m;//1h;//30m;//Do not change\r\nlet minTelemetryDate = toscalar(SynapseSqlPoolExecRequests | summarize min(StartTime));\r\nlet maxTelemetryDate = toscalar(SynapseSqlPoolExecRequests | summarize max(EndTime));\r\nlet timeIntervals = range SnapshotTimeStamp from bin(minTelemetryDate, snapshotTelemetryInterval) to bin(maxTelemetryDate, snapshotTelemetryInterval) step snapshotTelemetryInterval;\r\nSynapseBuiltinSqlPoolRequestsEnded\r\n| order by TimeGenerated\r\n| where _ResourceId in~ ({Synapse})\r\n| project \r\n StartTime=todatetime(Properties.startTime),\r\n EndTime=todatetime(Properties.endTime), \r\n MbProcessed=(Properties.dataProcessedBytes/1000/1000)\r\n| extend elapsedTime_sec =(EndTime - StartTime)/1s\r\n| mv-expand TimeInterval=range(bin(StartTime, snapshotTelemetryInterval), bin(EndTime, snapshotTelemetryInterval) , snapshotTelemetryInterval) limit 100000\r\n| summarize ActiveQueryCount=count(),sum(MbProcessed),avg(elapsedTime_sec) by todatetime(TimeInterval)\r\n", "size": 2, "showAnalytics": true, "title": "Concurrency", "timeContextFromParameter": "TimeRange", "timeBrushParameterName": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "linechart", "gridSettings": { "formatters": [ { "columnMatch": "StartTime", "formatter": 6 }, { "columnMatch": "EndTime", "formatter": 6 }, { "columnMatch": "elapsedTime_sec", "formatter": 8, "formatOptions": { "palette": "blue" } }, { "columnMatch": "Result", "formatter": 18, "formatOptions": { "thresholdsOptions": "icons", "thresholdsGrid": [ { "operator": "Default", "thresholdValue": null, "representation": "success", "text": "{0}{1}" } ] } }, { "columnMatch": "MbProcessed", "formatter": 3, "formatOptions": { "palette": "blue" } }, { "columnMatch": "Approx_Cost", "formatter": 8, "formatOptions": { "palette": "yellow" }, "numberFormat": { "unit": 0, "options": { "style": "decimal", "minimumFractionDigits": 2, "maximumFractionDigits": 6 } } }, { "columnMatch": "QueryText", "formatter": 7, "formatOptions": { "linkTarget": "CellDetails", "linkIsContextBlade": true, "customColumnWidthSetting": "100ch" } }, { "columnMatch": "BytesProcessed", "formatter": 8, "formatOptions": { "palette": "red" } } ] }, "graphSettings": { "type": 0 } }, "showPin": true, "name": "Concurrency" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "Summary" }, "name": "SummaryGroup" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 10, "content": { "chartId": "workbook1f0054e6-9715-47bb-a7fc-e92812c07403", "version": "MetricsItem/2.0", "size": 4, "chartType": -1, "resourceType": "microsoft.synapse/workspaces", "metricScope": 0, "resourceParameter": "Synapse", "resourceIds": [ "{Synapse}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 0 }, "metrics": [ { "namespace": "microsoft.synapse/workspaces", "metric": "microsoft.synapse/workspaces-Builtin SQL Pool-BuiltinSqlPoolDataProcessedBytes", "aggregation": 1 } ], "title": "Total Data Processed", "gridFormatType": 1, "tileSettings": { "showBorder": false, "titleContent": { "columnMatch": "Name", "formatter": 13 }, "leftContent": { "columnMatch": "Value", "formatter": 12, "formatOptions": { "palette": "auto" }, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "showPin": true, "name": "DataProcessed" }, { "type": 10, "content": { "chartId": "workbook1f0054e6-9715-47bb-a7fc-e92812c07403", "version": "MetricsItem/2.0", "size": 0, "chartType": 2, "resourceType": "microsoft.synapse/workspaces", "metricScope": 0, "resourceParameter": "Synapse", "resourceIds": [ "{Synapse}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 86400000 }, "metrics": [ { "namespace": "microsoft.synapse/workspaces", "metric": "microsoft.synapse/workspaces-Builtin SQL Pool-BuiltinSqlPoolDataProcessedBytes", "aggregation": 1, "splitBy": null } ], "title": "Data Processed and Request Completed Count", "showOpenInMe": true, "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "showPin": true, "name": "DataProcessed - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Queries by completion type\r\nSynapseBuiltinSqlPoolRequestsEnded\r\n| where _ResourceId in~ ({Synapse})\r\n| project \r\n BytesProcessed=Properties.dataProcessedBytes,\r\n tostring(Identity),\r\n QueryHash=tostring(Properties.queryHash),\r\n QueryText=tostring(Properties.queryText),\r\n _ResourceId\r\n| extend MbProcessed = case (BytesProcessed < 10000000,10000000,\r\n\t\t\t\t\t\t\tBytesProcessed)/1000/1000\r\n| summarize \r\n MaxSingleQueryMBProcessed=max(toint(MbProcessed)),\r\n TotalMBProcessed=sum(toint(MbProcessed)),\r\n QueryCount=count(),\r\n QueryHash=any(QueryHash) ,\r\n Resource=any(_ResourceId)\r\n by QueryText //using queryText because queryHash doesn’t change if only literals are different\r\n| extend Approx_Accumulated_Cost=((TotalMBProcessed)*5.0/100000.0)/100 \r\n| extend Approx_Cost_Per_Execution=((TotalMBProcessed)*5.0/100000.0)/100/QueryCount\r\n| order by TotalMBProcessed\r\n", "size": 0, "showAnalytics": true, "title": "Data Processed By Query", "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "table", "gridSettings": { "formatters": [ { "columnMatch": "QueryText", "formatter": 7, "formatOptions": { "linkTarget": "CellDetails", "linkIsContextBlade": true } }, { "columnMatch": "MaxSingleQueryMBProcessed", "formatter": 8, "formatOptions": { "palette": "orange" } }, { "columnMatch": "TotalMBProcessed", "formatter": 3, "formatOptions": { "palette": "blue" } }, { "columnMatch": "QueryCount", "formatter": 8, "formatOptions": { "min": 0, "palette": "turquoise" } }, { "columnMatch": "Approx_Accumulated_Cost", "formatter": 8, "formatOptions": { "palette": "yellow" }, "numberFormat": { "unit": 0, "options": { "style": "decimal", "minimumFractionDigits": 2, "maximumFractionDigits": 4 } } }, { "columnMatch": "Approx_Cost_Per_Execution", "formatter": 0, "numberFormat": { "unit": 0, "options": { "style": "decimal", "minimumFractionDigits": 2, "maximumFractionDigits": 6 } } }, { "columnMatch": "MaxSingleQueryBytesProcessed", "formatter": 8, "formatOptions": { "palette": "orange" } }, { "columnMatch": "TotalBytesProcessed", "formatter": 3, "formatOptions": { "palette": "blue", "compositeBarSettings": { "labelText": "", "columnSettings": [] }, "customColumnWidthSetting": "866.007px" } }, { "columnMatch": "I", "formatter": 3, "formatOptions": { "palette": "blue" } }, { "columnMatch": "any_QueryText", "formatter": 7, "formatOptions": { "linkTarget": "CellDetails", "linkIsContextBlade": true } } ] }, "sortBy": [] }, "showPin": true, "name": "Data Processed By Query", "styleSettings": { "showBorder": true } }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Queries by completion type\r\nSynapseBuiltinSqlPoolRequestsEnded\r\n| where _ResourceId in~ ({Synapse})\r\n| project BytesProcessed=Properties.dataProcessedBytes\r\n\t\t, tostring(Identity)\r\n| extend MbProcessed = case (BytesProcessed < 10000000,10000000,\r\n BytesProcessed)/1000/1000\r\n| summarize\r\n TotalMBProcessed=sum(toint(MbProcessed)),\r\n QueryCount=count(),\r\n MaxSingleQueryMBProcessed=max(toint(MbProcessed) )\r\n by Identity\r\n| extend Approx_Cost=((TotalMBProcessed) *5.0/100000.0) / 100 \r\n| order by TotalMBProcessed", "size": 0, "showAnalytics": true, "title": "Data Processed By User with $5 per TB cost", "timeContextFromParameter": "TimeRange", "exportFieldName": "Identity", "exportParameterName": "Identity", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "table", "gridSettings": { "formatters": [ { "columnMatch": "TotalMBProcessed", "formatter": 3, "formatOptions": { "palette": "blue" } }, { "columnMatch": "QueryCount", "formatter": 8, "formatOptions": { "min": 0, "palette": "turquoise" } }, { "columnMatch": "MaxSingleQueryMBProcessed", "formatter": 8, "formatOptions": { "palette": "orange" } }, { "columnMatch": "Approx_Cost", "formatter": 0, "numberFormat": { "unit": 0, "options": { "style": "decimal", "useGrouping": true, "minimumFractionDigits": 2, "maximumFractionDigits": 4 } } }, { "columnMatch": "TotalBytesProcessed", "formatter": 3, "formatOptions": { "min": 0, "palette": "blue", "compositeBarSettings": { "labelText": "", "columnSettings": [] }, "customColumnWidthSetting": "866.007px" } }, { "columnMatch": "MaxSingleQueryBytesProcessed", "formatter": 8, "formatOptions": { "min": 0, "palette": "orange" } } ] } }, "showPin": true, "name": "Data Processed By User - With Cost", "styleSettings": { "showBorder": true } }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Query runs by user sorted by bytes processed\r\nSynapseBuiltinSqlPoolRequestsEnded\r\n| where _ResourceId in~ ({Synapse})\r\n| where Identity == '{Identity}'\r\n| project \r\n StartTime=Properties.startTime,\r\n EndTime=Properties.endTime, \r\n Identity,\r\n CommandType=Properties.command,\r\n Result=ResultType,\r\n BytesProcessed=Properties.dataProcessedBytes,\r\n QueryText=Properties.queryText\r\n| order by toint(BytesProcessed)\r\n", "size": 2, "title": "Query Summary for User by Data Processed", "noDataMessage": "Select a user to see their query history", "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "StartTime", "formatter": 6 }, { "columnMatch": "EndTime", "formatter": 6 }, { "columnMatch": "Result", "formatter": 18, "formatOptions": { "thresholdsOptions": "icons", "thresholdsGrid": [ { "operator": "Default", "thresholdValue": null, "representation": "success", "text": "{0}{1}" } ] } }, { "columnMatch": "BytesProcessed", "formatter": 8, "formatOptions": { "min": 0, "palette": "blue" } }, { "columnMatch": "QueryText", "formatter": 7, "formatOptions": { "linkTarget": "CellDetails", "linkIsContextBlade": true, "customColumnWidthSetting": "100ch" } } ] } }, "conditionalVisibility": { "parameterName": "Identity", "comparison": "isNotEqualTo" }, "name": "Query Summary for User by Data Processed" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "DataProcessed" }, "name": "DataProcessed" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "title": "Query Performance", "items": [ { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Most Recent Query Runs\r\nSynapseBuiltinSqlPoolRequestsEnded\r\n| order by TimeGenerated\r\n| where _ResourceId in~ ({Synapse})\r\n| project \r\n StartTime=Properties.startTime,\r\n EndTime=Properties.endTime, \r\n Identity,\r\n CommandType=Properties.command,\r\n Result=ResultType,\r\n MbProcessed=(Properties.dataProcessedBytes/1000/1000),\r\n QueryText=Properties.queryText,\r\n QueryHash=Properties.queryHash,\r\n _ResourceId\r\n| extend elapsedTime_sec =(todatetime(EndTime) - StartTime)/1s\r\n| extend Approx_Cost=((MbProcessed)*5.0/100000.0)/100 //multiply by price per mb ($5 per TB from Microsoft Docs: https://azure.microsoft.com/en-us/pricing/details/synapse-analytics/)\r\n| project-reorder StartTime,EndTime,elapsedTime_sec,Identity,CommandType,Result,MbProcessed,Approx_Cost\r\n", "size": 2, "showAnalytics": true, "title": "Recent Queries", "exportFieldName": "QueryHash", "exportParameterName": "QueryHash", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "StartTime", "formatter": 6 }, { "columnMatch": "EndTime", "formatter": 6 }, { "columnMatch": "elapsedTime_sec", "formatter": 8, "formatOptions": { "palette": "blue" } }, { "columnMatch": "Result", "formatter": 18, "formatOptions": { "thresholdsOptions": "icons", "thresholdsGrid": [ { "operator": "Default", "thresholdValue": null, "representation": "success", "text": "{0}{1}" } ] } }, { "columnMatch": "MbProcessed", "formatter": 3, "formatOptions": { "palette": "blue" } }, { "columnMatch": "Approx_Cost", "formatter": 8, "formatOptions": { "palette": "yellow" }, "numberFormat": { "unit": 0, "options": { "style": "decimal", "minimumFractionDigits": 2, "maximumFractionDigits": 6 } } }, { "columnMatch": "QueryText", "formatter": 7, "formatOptions": { "linkTarget": "CellDetails", "linkIsContextBlade": true, "customColumnWidthSetting": "100ch" } }, { "columnMatch": "BytesProcessed", "formatter": 8, "formatOptions": { "palette": "red" } } ] } }, "showPin": true, "name": "Recent Queries - Copy" }, { "type": 1, "content": { "json": "Select a query to view graphical history of each run" }, "name": "text - 2" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Most Recent Query Runs\r\nSynapseBuiltinSqlPoolRequestsEnded\r\n| order by TimeGenerated\r\n| where _ResourceId in~ ({Synapse})\r\n| where Properties.queryHash == {QueryHash}\r\n| project \r\n StartTime=Properties.startTime,\r\n EndTime=Properties.endTime, \r\n Identity,\r\n RequestId=Properties.clientRequestId,\r\n StatementId = Properties.distributedStatementId,\r\n CommandType=Properties.command,\r\n Result=ResultType,\r\n MbProcessed=(Properties.dataProcessedBytes/1000/1000),\r\n QueryText=Properties.queryText,\r\n QueryHash=Properties.queryHash,\r\n _ResourceId\r\n| extend elapsedTime_sec =(todatetime(EndTime) - StartTime)/1s\r\n| extend Approx_Cost=((MbProcessed)*5.0/100000.0)/100 \r\n| project-reorder StartTime,EndTime,elapsedTime_sec,Identity,RequestId,StatementId,CommandType,Result,MbProcessed,Approx_Cost\r\n", "size": 2, "showAnalytics": true, "title": "Selected Query History", "noDataMessage": "Please select a query to view run history", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "linechart", "gridSettings": { "formatters": [ { "columnMatch": "StartTime", "formatter": 6 }, { "columnMatch": "EndTime", "formatter": 6 }, { "columnMatch": "elapsedTime_sec", "formatter": 8, "formatOptions": { "palette": "blue" } }, { "columnMatch": "Result", "formatter": 18, "formatOptions": { "thresholdsOptions": "icons", "thresholdsGrid": [ { "operator": "Default", "thresholdValue": null, "representation": "success", "text": "{0}{1}" } ] } }, { "columnMatch": "MbProcessed", "formatter": 3, "formatOptions": { "palette": "blue" } }, { "columnMatch": "Approx_Cost", "formatter": 8, "formatOptions": { "palette": "yellow" }, "numberFormat": { "unit": 0, "options": { "style": "decimal", "minimumFractionDigits": 2, "maximumFractionDigits": 6 } } }, { "columnMatch": "QueryText", "formatter": 7, "formatOptions": { "linkTarget": "CellDetails", "linkIsContextBlade": true, "customColumnWidthSetting": "100ch" } }, { "columnMatch": "BytesProcessed", "formatter": 8, "formatOptions": { "palette": "red" } } ] }, "chartSettings": { "xAxis": "EndTime", "yAxis": [ "elapsedTime_sec", "MbProcessed" ], "showDataPoints": true } }, "conditionalVisibility": { "parameterName": "QueryHash", "comparison": "isNotEqualTo", "value": "" }, "showPin": true, "name": "SelectedQueryHistory" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "QueryPerformance" }, "name": "QueryPerformance" } ], "fallbackResourceIds": [ "Azure Monitor" ], "$schema": "https://github.com/Microsoft/Application-Insights-Workbooks/blob/master/schema/workbook.json" } ================================================ FILE: Monitor_Workbooks/archive/DW_Summary.workbook.bak ================================================ { "version": "Notebook/1.0", "items": [ { "type": 9, "content": { "version": "KqlParameterItem/1.0", "crossComponentResources": [ "{Subscriptions}" ], "parameters": [ { "id": "15a2c4b1-1223-428f-80a0-53ec8e8e86a5", "version": "KqlParameterItem/1.0", "name": "TimeRange", "type": 4, "isRequired": true, "value": { "durationMs": 259200000 }, "typeSettings": { "selectableValues": [ { "durationMs": 300000 }, { "durationMs": 900000 }, { "durationMs": 1800000 }, { "durationMs": 3600000 }, { "durationMs": 14400000 }, { "durationMs": 43200000 }, { "durationMs": 86400000 }, { "durationMs": 172800000 }, { "durationMs": 259200000 }, { "durationMs": 604800000 }, { "durationMs": 1209600000 }, { "durationMs": 2419200000 }, { "durationMs": 2592000000 }, { "durationMs": 5184000000 }, { "durationMs": 7776000000 } ], "allowCustom": true } }, { "id": "bc3b3200-d39a-4d72-adc3-8473457d9b30", "version": "KqlParameterItem/1.0", "name": "Subscriptions", "type": 6, "isRequired": true, "multiSelect": true, "quote": "'", "delimiter": ",", "value": [ "value::all" ], "typeSettings": { "additionalResourceOptions": [ "value::1", "value::all" ], "includeAll": false } } ], "style": "pills", "queryType": 1, "resourceType": "microsoft.resourcegraph/resources" }, "name": "parameters - 1" }, { "type": 11, "content": { "version": "LinkItem/1.0", "style": "tabs", "links": [ { "id": "d29d564f-9326-433b-8b87-678461724323", "cellValue": "objectType", "linkTarget": "parameter", "linkLabel": "Dedicated Pools", "subTarget": "dedicated", "style": "link" } ] }, "name": "links - 6" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 9, "content": { "version": "KqlParameterItem/1.0", "crossComponentResources": [ "{Subscriptions}" ], "parameters": [ { "id": "8998a008-ea1b-4f4b-bcc2-44e15deba715", "version": "KqlParameterItem/1.0", "name": "SQLDWDBs", "type": 5, "isRequired": true, "multiSelect": true, "quote": "'", "delimiter": ",", "query": "where type =~ 'microsoft.sql/servers/databases'\r\n| where sku has \"DataWarehouse\"\r\n| project id", "crossComponentResources": [ "{Subscriptions}" ], "value": [ "value::all" ], "typeSettings": { "additionalResourceOptions": [ "value::1", "value::all" ] }, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 1, "resourceType": "microsoft.resourcegraph/resources" } ], "style": "pills", "queryType": 1, "resourceType": "microsoft.resourcegraph/resources" }, "name": "Parameters - SQL DW" }, { "type": 11, "content": { "version": "LinkItem/1.0", "style": "tabs", "links": [ { "id": "933d2413-fcd3-4a62-827d-de0aeefd2632", "cellValue": "selectedTab", "linkTarget": "parameter", "linkLabel": "Metrics", "subTarget": "metrics", "preText": "selec", "style": "link" } ] }, "name": "links - 3" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 10, "content": { "chartId": "workbookf1358ff0-0e10-4ac2-ab2d-2fdfdb74dc2f", "version": "MetricsItem/2.0", "size": 2, "chartType": 0, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "SQLDWDBs", "resourceIds": [ "{SQLDWDBs}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 604800000 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-dwu_limit", "aggregation": 3, "columnName": "DWU" }, { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-dwu_consumption_percent", "aggregation": 3 }, { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-cpu_percent", "aggregation": 3 }, { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-physical_data_read_percent", "aggregation": 3 }, { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-local_tempdb_usage_percent", "aggregation": 3, "columnName": "TempDB Usage" }, { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-queued_queries", "aggregation": 1 } ], "gridSettings": { "formatters": [ { "columnMatch": "$gen_group", "formatter": 13, "formatOptions": { "linkTarget": "Resource", "showIcon": true } }, { "columnMatch": "Group", "formatter": 13, "formatOptions": { "linkTarget": "Resource", "showIcon": true } }, { "columnMatch": "Subscription", "formatter": 13, "formatOptions": { "linkTarget": "Resource", "showIcon": true } }, { "columnMatch": "Name", "formatter": 5 }, { "columnMatch": "DWU", "formatter": 8, "formatOptions": { "palette": "magenta" } }, { "columnMatch": "DWU Timeline", "formatter": 5 }, { "columnMatch": "microsoft.sql/servers/databases-Basic-dwu_consumption_percent", "formatter": 8, "formatOptions": { "min": 0, "max": 100, "palette": "greenRed" }, "numberFormat": { "unit": 1, "options": { "style": "decimal", "useGrouping": false } } }, { "columnMatch": "microsoft.sql/servers/databases-Basic-dwu_consumption_percent Timeline", "formatter": 21, "formatOptions": { "palette": "blue" } }, { "columnMatch": "microsoft.sql/servers/databases-Basic-cpu_percent", "formatter": 8, "formatOptions": { "min": 0, "max": 100, "palette": "greenRed" }, "numberFormat": { "unit": 1, "options": { "style": "decimal" } } }, { "columnMatch": "microsoft.sql/servers/databases-Basic-cpu_percent Timeline", "formatter": 5 }, { "columnMatch": "microsoft.sql/servers/databases-Basic-physical_data_read_percent", "formatter": 8, "formatOptions": { "min": 0, "max": 100, "palette": "greenRed" }, "numberFormat": { "unit": 1, "options": { "style": "decimal" } } }, { "columnMatch": "microsoft.sql/servers/databases-Basic-physical_data_read_percent Timeline", "formatter": 5 }, { "columnMatch": "TempDB Usage", "formatter": 8, "formatOptions": { "min": 0, "max": 100, "palette": "greenRed" } }, { "columnMatch": "TempDB Usage Timeline", "formatter": 21, "formatOptions": { "palette": "red" } }, { "columnMatch": "microsoft.sql/servers/databases-Basic-queued_queries", "formatter": 8, "formatOptions": { "min": 0, "max": 1024, "palette": "yellowOrangeRed" }, "numberFormat": { "unit": 0, "options": { "style": "decimal" } } }, { "columnMatch": "microsoft.sql/servers/databases-Basic-queued_queries Timeline", "formatter": 21, "formatOptions": { "palette": "yellow" } }, { "columnMatch": "microsoft.sql/servers/databases-Basic-local_tempdb_usage_percent", "formatter": 21, "formatOptions": { "palette": "blue" }, "numberFormat": { "unit": 1, "options": { "style": "decimal" } } }, { "columnMatch": "microsoft.sql/servers/databases-Basic-local_tempdb_usage_percent Timeline", "formatter": 8, "formatOptions": { "palette": "blue" } }, { "columnMatch": "microsoft.sql/servers/databases-Basic-dwu_limit", "formatter": 21, "formatOptions": { "palette": "yellow" }, "numberFormat": { "unit": 0, "options": { "style": "decimal" } } } ], "rowLimit": 10000, "hierarchySettings": { "treeType": 1, "groupBy": [ "Subscription" ], "expandTopLevel": true, "finalBy": "Name" }, "sortBy": [ { "itemKey": "$gen_heatmap_DWU_3", "sortOrder": 1 } ], "labelSettings": [ { "columnId": "DWU", "label": "DWU" }, { "columnId": "DWU Timeline", "label": "DWU Timeline" }, { "columnId": "microsoft.sql/servers/databases-Basic-dwu_consumption_percent", "label": "DWU (Max)" }, { "columnId": "microsoft.sql/servers/databases-Basic-dwu_consumption_percent Timeline", "label": "DWU percentage Timeline" }, { "columnId": "microsoft.sql/servers/databases-Basic-cpu_percent", "label": "CPU (Max)" }, { "columnId": "microsoft.sql/servers/databases-Basic-cpu_percent Timeline", "label": "CPU percentage Timeline" }, { "columnId": "microsoft.sql/servers/databases-Basic-physical_data_read_percent", "label": "Data IO (Max)" }, { "columnId": "microsoft.sql/servers/databases-Basic-physical_data_read_percent Timeline", "label": "Data IO percentage Timeline" }, { "columnId": "TempDB Usage", "label": "TempDB (Max)" }, { "columnId": "TempDB Usage Timeline", "label": "TempDB Usage Timeline" }, { "columnId": "microsoft.sql/servers/databases-Basic-queued_queries", "label": "Queued queries (Sum)" }, { "columnId": "microsoft.sql/servers/databases-Basic-queued_queries Timeline", "label": "Queued queries Timeline" } ] }, "sortBy": [ { "itemKey": "$gen_heatmap_DWU_3", "sortOrder": 1 } ] }, "showPin": true, "name": "Metrics - SQL DW DTU/CPU" } ] }, "conditionalVisibility": { "parameterName": "selectedTab", "comparison": "isEqualTo", "value": "metrics" }, "name": "dedicatedMetricsGroup" } ] }, "conditionalVisibility": { "parameterName": "objectType", "comparison": "isEqualTo", "value": "dedicated" }, "name": "Dedicated Pool Group" } ], "fallbackResourceIds": [ "Azure Monitor" ], "$schema": "https://github.com/Microsoft/Application-Insights-Workbooks/blob/master/schema/workbook.json" } ================================================ FILE: Monitor_Workbooks/archive/DedicatedSQLPool_workspace_v1.0.workbook ================================================ { "version": "Notebook/1.0", "items": [ { "type": 9, "content": { "version": "KqlParameterItem/1.0", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "parameters": [ { "id": "f5852627-70ca-4959-8d60-53b48864603f", "version": "KqlParameterItem/1.0", "name": "TimeRange", "type": 4, "isGlobal": true, "value": { "durationMs": 86400000 }, "typeSettings": { "selectableValues": [ { "durationMs": 300000 }, { "durationMs": 900000 }, { "durationMs": 1800000 }, { "durationMs": 3600000 }, { "durationMs": 14400000 }, { "durationMs": 43200000 }, { "durationMs": 86400000 }, { "durationMs": 172800000 }, { "durationMs": 259200000 }, { "durationMs": 604800000 }, { "durationMs": 1209600000 }, { "durationMs": 2419200000 }, { "durationMs": 2592000000 } ], "allowCustom": true }, "timeContext": { "durationMs": 86400000 } }, { "id": "28da10ec-a308-47f5-9819-92ebf810b292", "version": "KqlParameterItem/1.0", "name": "LogAnalyticsSubscription", "type": 6, "value": null, "typeSettings": { "additionalResourceOptions": [], "includeAll": true, "showDefault": false }, "timeContext": { "durationMs": 86400000 } }, { "id": "e383ed24-52ae-447b-9b80-51fd3ab6b919", "version": "KqlParameterItem/1.0", "name": "LogAnalyticsWorkspace", "type": 5, "query": "Resources\r\n| where type == 'microsoft.operationalinsights/workspaces'\r\n| project id\r\n", "crossComponentResources": [ "{LogAnalyticsSubscription}" ], "value": null, "typeSettings": { "additionalResourceOptions": [], "showDefault": false }, "timeContext": { "durationMs": 86400000 }, "queryType": 1, "resourceType": "microsoft.resourcegraph/resources" }, { "id": "9b9fe566-0f52-4a75-a35b-a79c50c6a6f0", "version": "KqlParameterItem/1.0", "name": "DatabaseResourceName", "type": 5, "query": "SynapseSqlPoolExecRequests \r\n| distinct _ResourceId", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "value": null, "typeSettings": { "additionalResourceOptions": [], "showDefault": false }, "timeContext": { "durationMs": 2592000000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "id": "6da2f63f-45a3-4b37-9108-5e8b7e358d85", "version": "KqlParameterItem/1.0", "name": "DatabaseName", "type": 1, "query": "print split (\"{DatabaseResourceName}\",\"/\")[-1]", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "id": "8bba835b-f319-43b3-8ec6-4e051fc6d446", "version": "KqlParameterItem/1.0", "name": "LogicalServerName", "type": 1, "query": "SynapseSqlPoolExecRequests\r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| distinct LogicalServerName", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "id": "b86cd4a2-2303-4288-b48c-1c119cb420ba", "version": "KqlParameterItem/1.0", "name": "AuditingState", "type": 1, "query": "let hasNonEmptyTable = (T:string) \r\n{ \r\n toscalar( \r\n union isfuzzy=true \r\n ( table(T) \r\n | where DatabaseName has '{DatabaseName}'\r\n | where TimeGenerated > ago(30d)| take 1 | count as Count ),\r\n (print Count=0) \r\n | summarize sum(Count) \r\n ) > 0\r\n};\r\nlet TableName = 'SQLSecurityAuditEvents';\r\nprint IsPresent=iif(hasNonEmptyTable(TableName ), \"enabled\", \"disabled\")", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 604800000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "id": "4025bcb8-f6d7-4e81-b805-84253835f8fb", "version": "KqlParameterItem/1.0", "name": "DiagnosticsState", "type": 1, "query": "let hasNonEmptyTable = (T:string, T2:string) \r\n{ \r\n toscalar( \r\n union isfuzzy=true \r\n ( table(T) | where TimeGenerated > ago(30d) | where _ResourceId endswith '/sqlpools/{DatabaseName}'| take 1 | count as Count ),\r\n ( table(T2) | where TimeGenerated > ago(30d) | where _ResourceId endswith '/sqlpools/{DatabaseName}'| take 1 | count as Count),\r\n (print Count=0) \r\n | summarize sum(Count) \r\n ) > 1\r\n};\r\nlet TableName = 'SynapseSqlPoolExecRequests';\r\nlet TableName2 = 'SynapseSqlPoolRequestSteps';\r\nprint IsPresent=iif(hasNonEmptyTable(TableName,TableName2 ), \"enabled\", \"disabled\")", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 2592000000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "customWidth": "90", "name": "parameters - 2" }, { "type": 1, "content": { "json": "Select your Log Analytics Workspace by setting the parameters above from left to right. ", "style": "warning" }, "conditionalVisibility": { "parameterName": "DatabaseResourceName", "comparison": "isEqualTo" }, "customWidth": "30", "name": "text - 14" }, { "type": 11, "content": { "version": "LinkItem/1.0", "style": "tabs", "links": [ { "id": "202cbbc0-8d63-416d-89ed-451d6fe7c4b3", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Overview", "subTarget": "Overview", "preText": "Workload", "style": "link" }, { "id": "a7901bd0-a1f4-4491-b953-57555d764e00", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Workload Management", "subTarget": "WorkloadManagement", "style": "link" }, { "id": "45e12a14-8548-4477-aae3-c142b906dc9f", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "TempDB", "subTarget": "TempDB", "style": "link" }, { "id": "9ef8f730-d73d-432b-9b75-55095d1155f2", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Replicated Tables", "subTarget": "ReplicatedTables", "style": "link" }, { "id": "79d10d16-0696-4214-b306-c7a0e46cd64f", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Query Investigation", "subTarget": "QueryInvestigation", "style": "link" }, { "id": "31c1cf1c-74b5-44e2-ba9a-9497834ca3dc", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Query Comparison", "subTarget": "QueryComparison", "style": "link" }, { "id": "482ccc46-8a10-4ace-bfd6-63ac73b380af", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Query Audit", "subTarget": "QueryAudit", "style": "link" }, { "id": "db43bb45-1611-47ce-a2ad-517943f2aa1a", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "AutoStats", "subTarget": "Statistics", "style": "link" } ] }, "name": "links - 0" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 10, "content": { "chartId": "workbook90867bfc-5c33-464f-ac31-2c2e006b97f4", "version": "MetricsItem/2.0", "size": 0, "chartType": 2, "resourceType": "microsoft.synapse/workspaces/sqlpools", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 31597002, "endTime": "2022-01-21T03:06:58.357Z" }, "metrics": [ { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-DWUUsedPercent", "aggregation": 3, "splitBy": null, "columnName": "DWU Usaed %" }, { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-CPUPercent", "aggregation": 3, "columnName": "CPU Used %" } ], "title": "DWU Resource Utilization", "showOpenInMe": true, "showCreateAlertRule": true, "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "showPin": true, "name": "metric - 1" }, { "type": 10, "content": { "chartId": "workbookb954d4a0-82ef-4409-88fb-837aaff80c8d", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.synapse/workspaces/sqlpools", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 31597002, "endTime": "2022-01-21T03:06:58.357Z" }, "metrics": [ { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-ActiveQueries", "aggregation": 1, "splitBy": null }, { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-QueuedQueries", "aggregation": 1 } ], "title": "Active and Queued Queries", "showOpenInMe": true, "showCreateAlertRule": true, "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "showPin": true, "name": "metric - 1" }, { "type": 10, "content": { "chartId": "workbookb954d4a0-82ef-4409-88fb-837aaff80c8d", "version": "MetricsItem/2.0", "size": 0, "chartType": 3, "resourceType": "microsoft.synapse/workspaces/sqlpools", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 31597002, "endTime": "2022-01-21T03:06:58.357Z" }, "metrics": [ { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-LocalTempDBUsedPercent", "aggregation": 3, "splitBy": null, "columnName": "TempDB Utilization Percentage" } ], "title": "TempDB Utilization", "showOpenInMe": true, "showCreateAlertRule": true, "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "showPin": true, "name": "metric - 1 - Copy" }, { "type": 10, "content": { "chartId": "workbookb954d4a0-82ef-4409-88fb-837aaff80c8d", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.synapse/workspaces/sqlpools", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 31597002, "endTime": "2022-01-21T03:06:58.357Z" }, "metrics": [ { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool Workload management-WLGAllocationBySystemPercent", "aggregation": 3, "splitBy": null, "columnName": "Workload Group Allocation by System %" } ], "title": "Workload Group Utilization", "showOpenInMe": true, "showCreateAlertRule": true, "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "showPin": true, "name": "Workload Group Utilization" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Long-Running Queries - Just Actual Queries\r\n//If 'Command' is empty - you need to set a bigger time window, the older record with the command is outside of your window\r\nSynapseSqlPoolExecRequests \r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where StatementType !in ('Batch','Execute')\r\n| summarize //Session_ID=any(SessionId),\r\n Request_ID=any(RequestId),\r\n //Submit_Time=max(SubmitTime),\r\n Start_Time=max(StartTime),\r\n End_Time=max(EndTime),\r\n Command=any(Command),\r\n Status=min(Status), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType),\r\n Resource_class=any(ResourceClass)\r\n by RequestId\r\n| summarize ElapsedTime_min=bin(anyif(((End_Time - Start_Time)/1m),Start_Time > ago(30d)),1),\r\n //Session_ID=any(Session_ID), \r\n // Submit_Time=any(Submit_Time) ,\r\n Start_Time=any(Start_Time), \r\n End_Time=any(End_Time),\r\n Command=any(Command),\r\n Status=any(Status),\r\n Statement_Type=any(Statement_Type)\r\n ,Resource_class=any(Resource_class) \r\n by Request_ID\r\n| where End_Time > ago(365d)\r\n| summarize count() by Status, bin(End_Time,5m)\r\n| render barchart \r\n", "size": 0, "showAnalytics": true, "title": "Query Completion Count by End Time - 5m buckets", "color": "redBright", "timeContextFromParameter": "TimeRange", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "chartSettings": { "seriesLabelSettings": [ { "seriesName": "Completed", "color": "green" }, { "seriesName": "Failed", "color": "red" }, { "seriesName": "Cancelled", "color": "yellow" } ] } }, "showPin": true, "name": "query - 4" }, { "type": 1, "content": { "json": "Use the buttons below to filter the next chart for Success or Failed queries. In many cases a failed query may not have a 'Command' column populated depending on what stage the query failed in. ", "style": "info" }, "customWidth": "25", "name": "text - 3" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "e2a833ac-48b4-4ccd-bbcd-33fccf1dbd75", "version": "KqlParameterItem/1.0", "name": "QueryCompletionType", "type": 1, "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 } } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 4" }, { "type": 11, "content": { "version": "LinkItem/1.0", "style": "nav", "links": [ { "id": "8e89112f-c67f-42c0-9622-02fa306fb7a5", "cellValue": "QueryCompletionType", "linkTarget": "parameter", "linkLabel": "All Queries", "subTarget": "''", "style": "primary" }, { "id": "6abe39c7-4d4e-4c45-aa54-dc9a4c5e876e", "cellValue": "QueryCompletionType", "linkTarget": "parameter", "linkLabel": "Success Only", "subTarget": "Completed", "preText": "", "style": "secondary" }, { "id": "e41b4a0b-8464-491e-92be-a57217d6dcac", "cellValue": "QueryCompletionType", "linkTarget": "parameter", "linkLabel": "Failures Only", "subTarget": "Failed", "preText": "", "style": "secondary" } ] }, "name": "links - 11" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Long-Running Queries - Just Actual Queries\r\n//If 'Command' is empty - you need to set a bigger time window, the older record with the command is outside of your window\r\nSynapseSqlPoolExecRequests \r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where StatementType !in ('Batch','Execute')\r\n| summarize //Session_ID=any(SessionId),\r\n Request_ID=any(RequestId),\r\n Start_Time=max(StartTime),\r\n End_Time=max(EndTime),\r\n Command=any(Command),\r\n Status=min(Status), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType),\r\n Resource_class=any(ResourceClass)\r\n by RequestId\r\n| summarize ElapsedTime_min=bin(anyif(((End_Time - Start_Time)/1m),Start_Time > ago(30d)),1),\r\n Start_Time=any(Start_Time), \r\n End_Time=any(End_Time),\r\n Command=any(Command),\r\n Status=any(Status),\r\n Statement_Type=any(Statement_Type)\r\n ,Resource_class=any(Resource_class) \r\n by Request_ID\r\n| where Status has '{QueryCompletionType}'\r\n| order by Start_Time\r\n\r\n", "size": 0, "showAnalytics": true, "title": "Query Completions - use above buttons to filter", "color": "redBright", "timeContextFromParameter": "TimeRange", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "rowLimit": 100 }, "chartSettings": { "seriesLabelSettings": [ { "seriesName": "Completed", "color": "green" }, { "seriesName": "Failed", "color": "red" }, { "seriesName": "Cancelled", "color": "yellow" } ] } }, "showPin": true, "name": "query - 4 - Copy" } ] }, "name": "Query Completions", "styleSettings": { "showBorder": true } }, { "type": 10, "content": { "chartId": "workbook1afc57e6-0b32-4968-b299-db319bd21635", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.synapse/workspaces/sqlpools", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 31597002, "endTime": "2022-01-21T03:06:58.357Z" }, "metrics": [ { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-Connections", "aggregation": 1, "splitBy": null }, { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-ConnectionsBlockedByFirewall", "aggregation": 1 } ], "title": "Successful and Failed Connections", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "name": "metric - 5" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 3, "content": { "version": "KqlItem/1.0", "query": " SQLSecurityAuditEvents\r\n | where LogicalServerName == '{LogicalServerName}'\r\n | where ActionName in ('DATABASE AUTHENTICATION SUCCEEDED','DATABASE AUTHENTICATION FAILED')\r\n | project SourceSystem,ClientTlsVersion ,Succeeded,SessionId,ClientIp,SessionServerPrincipalName,ServerPrincipalName,DatabasePrincipalName,ApplicationName,HostName,TimeGenerated\r\n | summarize count() by Succeeded,bin(TimeGenerated,1m)\r\n | render barchart\r\n\r\n\r\n\r\n", "size": 0, "showAnalytics": true, "title": "Database Authentication success/failure rate", "timeContextFromParameter": "TimeRange", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "chartSettings": { "xAxis": "TimeGenerated", "group": "succeeded_s", "createOtherGroup": null } }, "showPin": true, "name": "query - 8" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "f7485a11-48df-4b61-a70e-9f56d6a00ec6", "version": "KqlParameterItem/1.0", "name": "AuthResult", "type": 1, "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 } } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 3" }, { "type": 11, "content": { "version": "LinkItem/1.0", "style": "nav", "links": [ { "id": "2ed22e0a-2b53-4ed0-8f65-d2c621f34dad", "cellValue": "AuthResult", "linkTarget": "parameter", "linkLabel": "All Authentications", "subTarget": "''", "style": "primary" }, { "id": "2789ab13-ae8a-472e-bad4-9c9bdc934d4d", "cellValue": "AuthResult", "linkTarget": "parameter", "linkLabel": "Success Only", "subTarget": "true", "style": "secondary" }, { "id": "5cf4ddd4-e189-4b71-b456-0d4f1572a0a3", "cellValue": "AuthResult", "linkTarget": "parameter", "linkLabel": "Failures Only", "subTarget": "false", "style": "secondary" } ] }, "name": "links - 10" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": " SQLSecurityAuditEvents\r\n | where LogicalServerName == '{LogicalServerName}'\r\n | where ActionName in ('DATABASE AUTHENTICATION SUCCEEDED','DATABASE AUTHENTICATION FAILED')\r\n | where Succeeded == '{AuthResult}'\r\n | project SourceSystem,ClientTlsVersion ,Succeeded,SessionId,ClientIp,SessionServerPrincipalName,ServerPrincipalName,DatabasePrincipalName,ApplicationName,HostName,TimeGenerated\r\n //| summarize count() by Succeeded,bin(TimeGenerated,1m)\r\n\r\n\r\n\r\n\r\n\r\n", "size": 0, "showAnalytics": true, "title": "Database Authentication success/failure rate", "noDataMessage": "No Results", "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "rowLimit": 100 }, "chartSettings": { "xAxis": "TimeGenerated", "group": "succeeded_s", "createOtherGroup": null, "showLegend": true } }, "showPin": true, "name": "query - 8 - Copy" } ] }, "conditionalVisibility": { "parameterName": "AuditingState", "comparison": "isEqualTo", "value": "enabled" }, "name": "Database Authentication Group", "styleSettings": { "showBorder": true } }, { "type": 10, "content": { "chartId": "workbook993837ad-66d6-4cbc-ae1a-7c3f6623236b", "version": "MetricsItem/2.0", "size": 0, "chartType": 2, "resourceType": "microsoft.synapse/workspaces/sqlpools", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 31597002, "endTime": "2022-01-21T03:06:58.357Z" }, "metrics": [ { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-AdaptiveCacheUsedPercent", "aggregation": 3, "splitBy": null }, { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-AdaptiveCacheHitPercent", "aggregation": 3 } ], "title": "Adaptive Cache Used vs Hit Percentage", "showCreateAlertRule": true, "gridSettings": { "rowLimit": 10000 } }, "showPin": true, "name": "metric - 6" } ] }, "conditionalVisibilities": [ { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "Overview" }, { "parameterName": "DiagnosticsState", "comparison": "isEqualTo", "value": "enabled" } ], "name": "overviewGroup" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 10, "content": { "chartId": "workbook4a9cf761-cce2-45b2-8947-8a9428ec7e1c", "version": "MetricsItem/2.0", "size": 0, "chartType": 3, "resourceType": "microsoft.synapse/workspaces/sqlpools", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 31597002, "endTime": "2022-01-21T03:06:58.357Z" }, "metrics": [ { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-LocalTempDBUsedPercent", "aggregation": 3, "splitBy": null, "columnName": "TempDB Util" } ], "title": "TempDB Max and Avg Utilization", "showOpenInMe": true, "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "showPin": true, "name": "metric - 0" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "19ee48f5-8f4e-4939-a0ef-c6bf656a93f9", "version": "KqlParameterItem/1.0", "name": "WeightParameter", "type": 1, "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 } }, { "id": "00553ec8-1a41-4dd9-a024-d607639c9bbb", "version": "KqlParameterItem/1.0", "name": "RequestID", "type": 1, "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 }, "value": "" } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 3" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databaseResourceName = '{DatabaseResourceName}';\r\n//Weighted query steps\r\nSynapseSqlPoolRequestSteps \r\n| where _ResourceId == databaseResourceName\r\n| where RowCount > 0\r\n| summarize sum(RowCount) by RequestId, OperationType\r\n| order by sum_RowCount desc\r\n| limit 20\r\n| render columnchart ", "size": 0, "showAnalytics": true, "title": "20 Largest Query Steps by Most Rows Moved", "timeContextFromParameter": "TimeRange", "exportFieldName": "Request_ID", "exportParameterName": "RequestID", "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "chartSettings": { "xAxis": "RequestId", "group": "OperationType", "createOtherGroup": 20, "showLegend": true } }, "showPin": true, "name": "query - 1 - Copy" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "8afacdd5-2690-48d0-b125-fb118378e90c", "version": "KqlParameterItem/1.0", "name": "WeightParameter", "type": 1, "value": "Unweighted", "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 } } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 8" }, { "type": 11, "content": { "version": "LinkItem/1.0", "style": "nav", "links": [ { "id": "c98d3722-9907-43ab-9306-1957d6f7f858", "cellValue": "WeightParameter", "linkTarget": "parameter", "linkLabel": "Weighted Rowcounts", "subTarget": "Weighted", "preText": "", "postText": "", "style": "secondary" }, { "id": "a06ae99a-ad62-45e9-8c25-c219b81f59c0", "cellValue": "WeightParameter", "linkTarget": "parameter", "linkLabel": "Unweighted Rowcounts", "subTarget": "Unweighted", "preText": "", "postText": "", "style": "secondary" } ] }, "name": "links - 3" }, { "type": 1, "content": { "json": "Current Setting: {WeightParameter}", "style": "info" }, "customWidth": "25", "name": "text - 4" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databaseResourceName = '{DatabaseResourceName}';\r\n//Weighted query steps\r\nlet RequestSteps = SynapseSqlPoolRequestSteps\r\n| where _ResourceId == databaseResourceName\r\n//| where RowCount > 10000000\r\n| extend Step_Elapsed_Min = round((EndTime - StartTime) /1m, 2)\r\n| extend Weighted_cnt = iff('{WeightParameter}'=='Weighted',(case(OperationType == 'BroadcastMoveOperation', (RowCount*10), RowCount)),RowCount)\r\n| project-rename StepStatus = Status, StepStart = StartTime, StepEnd = EndTime//, StepResource = Resource\r\n| top 100 by Weighted_cnt desc\r\n| order by Weighted_cnt desc\r\n| project Request_ID=RequestId,OperationType, RowCount,Weighted_cnt,Step_Elapsed_Min, StepStart, StepEnd, StepStatus, StepIndex;\r\nRequestSteps | join (\r\nSynapseSqlPoolExecRequests\r\n| where _ResourceId == databaseResourceName\r\n| where StatementType !in ('Batch','Execute')\r\n| summarize //Session_ID=any(SessionId),\r\n Request_ID=any(RequestId),\r\n //Submit_Time=max(SubmitTime),\r\n Start_Time=max(StartTime),\r\n End_Time=max(EndTime),\r\n Command=any(Command),\r\n Status=min(Status), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType),\r\n Resource_class=any(ResourceClass)\r\n by RequestId\r\n| summarize //Session_ID=any(Session_ID), \r\n//Submit_Time=any(Submit_Time) ,\r\nStart_Time=any(Start_Time), End_Time=any(End_Time),Command=any(Command),Status=any(Status),Statement_Type=any(Statement_Type),Resource_class=any(Resource_class) by Request_ID\r\n//| order by Step_Elapsed_Min desc\r\n| extend Request_Elapsed_Min = round((End_Time - Start_Time)/1m, 2)\r\n| project-rename ReqStatus = Status, ReqStart = Start_Time, ReqEnd = End_Time\r\n) on Request_ID\r\n| project-reorder //Session_ID, \r\nRequest_ID, Request_Elapsed_Min, ReqStart, ReqEnd, ReqStatus,StepIndex, OperationType, RowCount,Weighted_cnt,Step_Elapsed_Min, StepStart, StepEnd, StepStatus, Statement_Type, Command, Resource_class\r\n| order by Weighted_cnt desc\r\n| limit 20", "size": 3, "showAnalytics": true, "title": "20 Largest Query Steps by Most Rows Moved", "timeContextFromParameter": "TimeRange", "exportFieldName": "Request_ID1", "exportParameterName": "RequestID", "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "sortBy": [ { "itemKey": "Weighted_cnt", "sortOrder": 2 } ] }, "sortBy": [ { "itemKey": "Weighted_cnt", "sortOrder": 2 } ] }, "showPin": true, "name": "query - 1" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databaseResourceName = '{DatabaseResourceName}';\r\n//Long-Running Queries - Just Actual Queries\r\n//If 'Command' is empty - you need to set a bigger time window, the older record with the command is outside of your window\r\nSynapseSqlPoolExecRequests\r\n| where _ResourceId == databaseResourceName\r\n| where StatementType !in ('Batch','Execute')\r\n| summarize //Session_ID=any(SessionId),\r\n Request_ID=any(RequestId),\r\n Start_Time=max(StartTime),\r\n End_Time=max(EndTime),\r\n Command=any(Command),\r\n Status=min(Status), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType),\r\n Resource_class=any(ResourceClass)\r\n by RequestId\r\n| summarize ElapsedTime_min=bin(anyif(((End_Time - Start_Time)/1m),Start_Time > ago(30d)),1),\r\n Start_Time=any(Start_Time), \r\n End_Time=any(End_Time),\r\n Command=any(Command),\r\n Status=any(Status),\r\n Statement_Type=any(Statement_Type)\r\n ,Resource_class=any(Resource_class) \r\n by Request_ID\r\n| where Request_ID == '{RequestID}' and Request_ID != ''\r\n\r\n", "size": 4, "showAnalytics": true, "title": "Selected Query", "noDataMessage": "Select a query above to view details", "noDataMessageStyle": 4, "timeContextFromParameter": "TimeRange", "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "35%" } } ] } }, "showPin": true, "name": "query - 6" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolRequestSteps \r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where RequestId == '{RequestID}' and RequestId != '' //Put your QueryID here\r\n| where Status != 'Running'\r\n| summarize max(StartTime),max(EndTime),max(RequestId),max(OperationType),max(RowCount),max(Command),max(Status) by StepIndex\r\n| order by StepIndex asc", "size": 3, "showAnalytics": true, "title": "Query Plan", "noDataMessage": "Select a query above to view the plan", "noDataMessageStyle": 4, "timeContextFromParameter": "TimeRange", "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "showPin": true, "name": "query - 7" } ] }, "conditionalVisibilities": [ { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "TempDB" }, { "parameterName": "DiagnosticsState", "comparison": "isEqualTo", "value": "enabled" } ], "name": "TempDBGroup" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 1, "content": { "json": "## Search Criteria\r\nUse the following fields to search either using a query text snippet or using a Request ID. If using a query text snippet, try to keep it as simple as possible becuase minor changes in formatting may cause your queries not to show up in the results. It's best to pick something like a table name, then choose the proper query from the list that will populate. " }, "customWidth": "50", "name": "text - 4" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "4b98dd26-4ccf-420e-a990-8d015f27fb76", "version": "KqlParameterItem/1.0", "name": "SampleQID", "type": 1, "value": "999", "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 } }, { "id": "d5524dd5-cf7e-41cf-beb3-474b3290289e", "version": "KqlParameterItem/1.0", "name": "RequestId", "type": 1, "value": "", "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 } } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "initializeQueryInvestigationParameters" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "0c2128d0-d979-4562-a28c-e7ceb955f126", "version": "KqlParameterItem/1.0", "name": "RequestId", "type": 1, "value": "", "label": "Request Id Search" }, { "id": "29880874-2d41-4bd5-bf22-3e47ae8b1145", "version": "KqlParameterItem/1.0", "name": "QueryTextSnippet", "type": 1, "value": "", "timeContext": { "durationMs": 86400000 } } ], "style": "formVertical", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "customWidth": "60", "name": "parameters - 3" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolExecRequests\r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where StatementType !in ('Batch','Execute')\r\n| summarize \r\n Request_ID=max(RequestId), \r\n Start_Time=max(StartTime),\r\n End_Compile_Time=max(EndCompileTime), \r\n End_Time=max(EndTime), \r\n QueryText = any(Command), \r\n Last_Status=min(Status),\r\n Statement_Type=max(StatementType),\r\n Resource_class=max(ResourceClass) \r\n by RequestId\r\n| extend Elapsed_Time_s=(End_Time - Start_Time)/1s\r\n| where QueryText has '{QueryTextSnippet}'\r\nand RequestId has '{RequestId}'\r\n| summarize \r\n Executions = count(),\r\n SampleQID = any(RequestId),\r\n Elapsed_Time_s=max(Elapsed_Time_s)\r\n by QueryText\r\n| order by Elapsed_Time_s\r\n\r\n\r\n\r\n", "size": 0, "showAnalytics": true, "title": "Matching Queries", "timeContextFromParameter": "TimeRange", "exportedParameters": [ { "fieldName": "SampleQID", "parameterName": "SampleQID" }, { "fieldName": "SampleQID", "parameterName": "RequestId", "parameterType": 1 }, { "fieldName": "QueryText", "parameterName": "QueryText", "parameterType": 1 } ], "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "50%" } } ], "sortBy": [ { "itemKey": "Elapsed_Time_s", "sortOrder": 2 } ] }, "sortBy": [ { "itemKey": "Elapsed_Time_s", "sortOrder": 2 } ] }, "showPin": true, "name": "query - 0" }, { "type": 1, "content": { "json": "## DSQL Command " }, "conditionalVisibility": { "parameterName": "QueryText", "comparison": "isNotEqualTo" }, "name": "text - 8" }, { "type": 1, "content": { "json": "```{QueryText}```\r\n" }, "conditionalVisibility": { "parameterName": "QueryText", "comparison": "isNotEqualTo" }, "name": "ShowQueryText", "styleSettings": { "showBorder": true } }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolExecRequests\r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where StatementType !in ('Batch','Execute')\r\n| where RequestId == '{SampleQID}'\r\n| summarize \r\n Request_ID=max(RequestId), \r\n Start_Time=max(StartTime),\r\n End_Compile_Time=max(EndCompileTime), \r\n End_Time=max(EndTime), \r\n Command=max(Command), \r\n Last_Status=min(Status),\r\n Statement_Type=max(StatementType),\r\n Resource_class=max(ResourceClass) \r\n by RequestId\r\n| extend elapsedTime_sec = iif(End_Time > ago(365d),(End_Time - Start_Time)/1s,real(null)) \r\n| join kind=inner\r\n (SynapseSqlPoolExecRequests\r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where StatementType !in ('Batch','Execute')\r\n | summarize \r\n Request_ID=max(RequestId), \r\n Start_Time=max(StartTime),\r\n End_Compile_Time=max(EndCompileTime), \r\n End_Time=max(EndTime), \r\n Command=max(Command), \r\n Last_Status=min(Status),\r\n Statement_Type=max(StatementType),\r\n Resource_class=max(ResourceClass) \r\n by RequestId\r\n //| extend elapsedTime_sec = (End_Time - Start_Time)/1s\r\n | extend elapsedTime_sec = iif(End_Time > ago(365d),(End_Time - Start_Time)/1s,real(null)) \r\n )\r\non Command \r\n| project Request_ID1,Start_Time1,End_Compile_Time1,End_Time1,Last_Status1,Statement_Type1,Resource_class1,elapsedTime_sec1\r\n", "size": 0, "showAnalytics": true, "title": "All Executions of Selected Query Text", "noDataMessage": "Select a query above to see individual executions", "noDataMessageStyle": 4, "timeContextFromParameter": "TimeRange", "exportFieldName": "Request_ID1", "exportParameterName": "RequestId", "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "sortBy": [] }, "showPin": true, "name": "query - 0 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolRequestSteps \r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where RequestId == '{RequestId}' and RequestId != ''\r\n| where Status != 'Running'\r\n| summarize max(StartTime),max(EndTime),max(RequestId),max(OperationType),max(RowCount),max(Command),max(Status) by StepIndex\r\n| order by StepIndex asc", "size": 3, "showAnalytics": true, "title": "Query Plan for Selected Query", "noDataMessage": "Select a Query Above to See the Query Plan", "noDataMessageStyle": 4, "timeContextFromParameter": "TimeRange", "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 0 - Copy - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolExecRequests\r\n | where StatementType =='CreateStatistics'\r\n | where _ResourceId has '{DatabaseName}'\r\n | summarize \r\n Root_Query_Id=max(RootQueryId), \r\n Start_Time=max(StartTime),\r\n End_Compile_Time=max(EndCompileTime), \r\n End_Time=max(EndTime), \r\n Command=max(Command), \r\n Last_Status=min(Status),\r\n Statement_Type=max(StatementType),\r\n Resource_class=max(ResourceClass) \r\n by RequestId\r\n | where Root_Query_Id == '{RequestId}'", "size": 0, "showAnalytics": true, "title": "Triggered Auto-Stats Statements", "noDataMessage": "No triggered autostats statements found", "timeContextFromParameter": "TimeRange", "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Submit_Time", "formatter": 0, "numberFormat": { "unit": 0, "options": { "style": "decimal" } } }, { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "100ch" } } ] } }, "name": "All triggered auto-stats statements" } ] }, "conditionalVisibilities": [ { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "QueryInvestigation" }, { "parameterName": "DiagnosticsState", "comparison": "isEqualTo", "value": "enabled" } ], "name": "QueryInvestigationGroup", "styleSettings": { "showBorder": true } }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 1, "content": { "json": "All Charts on this page are based on the last 7 days of data", "style": "info" }, "customWidth": "25", "name": "text - 5" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "533ff6bb-97cd-4aaa-9372-171cad378bcd", "version": "KqlParameterItem/1.0", "name": "QueryText", "type": 1, "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 } }, { "id": "99de0056-d4f3-465e-a27e-599d69b23c77", "version": "KqlParameterItem/1.0", "name": "RequestId", "type": 1, "value": "999", "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 } } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "initializeTempDBVariables" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Build cache count by day\r\nlet databaseResourceName = '{DatabaseResourceName}';\r\n//Long-Running Queries - Just Actual Queries\r\n//If 'Command' is empty - you need to set a bigger time window, the older record with the command is outside of your window\r\nSynapseSqlPoolExecRequests\r\n| where _ResourceId == databaseResourceName\r\n| where StatementType == 'BuildReplicatedTableCache'\r\n| where Command != \"\"\r\n| where ResourceClass != \"\"\r\n| project Command,TimeGenerated,RequestId\r\n| summarize LastRebuild=max(TimeGenerated),RebuildCount=count(RequestId) by Command\r\n| order by RebuildCount desc\r\n| limit 15\r\n", "size": 3, "showAnalytics": true, "title": "Top 15 Most Rebuilds by Table", "noDataMessage": "No replicated table rebuilds found in the last 7 days", "noDataMessageStyle": 4, "timeContext": { "durationMs": 604800000 }, "exportFieldName": "Command", "exportParameterName": "QueryText", "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command_s", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "40%" } } ] } }, "showPin": true, "name": "query - 0" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Build cache count by day\r\nlet databaseResourceName = '{DatabaseResourceName}';\r\nSynapseSqlPoolExecRequests\r\n| where _ResourceId == databaseResourceName\r\n| where StatementType == 'BuildReplicatedTableCache'\r\n| where Command == \"{QueryText}\"\r\n| where ResourceClass != \"\"\r\n| project Command,TimeGenerated,RequestId\r\n| summarize count() by Command,bin(TimeGenerated,24h)\r\n| limit 20\r\n| render timechart", "size": 0, "showAnalytics": true, "title": "Rebuilds per Day for Selected Table", "noDataMessage": "Select a query above to see runs by day", "noDataMessageStyle": 4, "timeContext": { "durationMs": 604800000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "chartSettings": { "group": "Command_s", "createOtherGroup": 20, "ySettings": { "min": 0 } } }, "showPin": true, "name": "query - 0 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Build cache count by day\r\nlet databaseResourceName = '{DatabaseResourceName}';\r\n//Long-Running Queries - Just Actual Queries\r\n//If 'Command' is empty - you need to set a bigger time window, the older record with the command is outside of your window\r\nSynapseSqlPoolExecRequests\r\n| where _ResourceId == databaseResourceName\r\n| where StatementType == 'BuildReplicatedTableCache'\r\n| where Command != \"\"\r\n| where ResourceClass != \"\"\r\n| project Command,TimeGenerated,RequestId\r\n| summarize count() by Command, bin(TimeGenerated,24h)\r\n//| where count_ > 7\r\n| order by count_ desc\r\n\r\n", "size": 2, "showAnalytics": true, "title": "Rebuild Count by Table by Day", "noDataMessage": " Only tables with more than 7 total rebuilds will show up. If no talbes with that many rebuilds are found this chart will be empty", "noDataMessageStyle": 4, "timeContext": { "durationMs": 604800000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "categoricalbar", "gridSettings": { "sortBy": [ { "itemKey": "count_", "sortOrder": 1 } ] }, "sortBy": [ { "itemKey": "count_", "sortOrder": 1 } ], "tileSettings": { "showBorder": false, "titleContent": { "columnMatch": "Command_s", "formatter": 1 }, "leftContent": { "columnMatch": "count_", "formatter": 12, "formatOptions": { "palette": "auto" }, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "graphSettings": { "type": 0, "topContent": { "columnMatch": "Command_s", "formatter": 1 }, "centerContent": { "columnMatch": "count_", "formatter": 1, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "chartSettings": { "group": "Command_s", "createOtherGroup": 99, "showDataPoints": true } }, "showPin": true, "name": "query - 0 - Copy - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databaseResourceName = '{DatabaseResourceName}';\r\n//Long-Running Queries - Just Actual Queries\r\n//If 'Command' is empty - you need to set a bigger time window, the older record with the command is outside of your window\r\nSynapseSqlPoolExecRequests\r\n| where _ResourceId == databaseResourceName\r\n| where StatementType == 'BuildReplicatedTableCache'\r\n| summarize Start_Time=max(StartTime), End_Time=max(EndTime), Command=max(Command), Statement_Type=max(StatementType), Resource_class=max(ResourceClass) by RequestId\r\n| join kind= inner\r\n(\r\n SynapseSqlPoolExecRequests\r\n | where _ResourceId == databaseResourceName\r\n | where StatementType == 'BuildReplicatedTableCache'\r\n | where StatementType == 'BuildReplicatedTableCache'\r\n | where EndTime > ago(7d)\r\n | where StartTime > ago(7d)\r\n | extend elapsedTime_min = (EndTime - StartTime)/1m\r\n | order by elapsedTime_min desc\r\n | project RequestId,elapsedTime_min \r\n)\r\non RequestId\r\n| order by elapsedTime_min desc\r\n| project RequestId,Start_Time,End_Time,Elapsed_Time=round(elapsedTime_min,1) ,Command\r\n| limit 15\r\n", "size": 3, "showAnalytics": true, "title": "Top 15 Elapsed Time per Rebuild", "noDataMessageStyle": 4, "timeContext": { "durationMs": 604800000 }, "exportFieldName": "RequestId", "exportParameterName": "RequestId", "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "40%" } } ] } }, "showPin": true, "name": "query - 3" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": " let databaseResourceName = '{DatabaseResourceName}';\r\nSynapseSqlPoolRequestSteps \r\n| where _ResourceId == databaseResourceName\r\n| where RequestId == '{RequestId}'\r\n| where Status != 'Running'\r\n| summarize max(StartTime),max(EndTime),max(RequestId),max(OperationType),max(RowCount),max(Command),max(Status) by StepIndex\r\n| order by StepIndex asc", "size": 3, "showAnalytics": true, "title": "Query Plan for Selected Query", "noDataMessage": "Select a query above to view plan", "noDataMessageStyle": 4, "timeContext": { "durationMs": 604800000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "showPin": true, "name": "query - 4" } ] }, "conditionalVisibilities": [ { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "ReplicatedTables" }, { "parameterName": "DiagnosticsState", "comparison": "isEqualTo", "value": "enabled" } ], "name": "ReplicatedTablesGroup" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 10, "content": { "chartId": "workbook72446028-6edb-4cb0-8952-e0c13bda488f", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.synapse/workspaces/sqlpools", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 31597002, "endTime": "2022-01-21T03:06:58.357Z" }, "metrics": [ { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool Workload management-WLGAllocationBySystemPercent", "aggregation": 3, "splitBy": "WorkloadGroup" } ], "title": "Workload Group Allocation By System Percent", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "name": "metric - 0" }, { "type": 10, "content": { "chartId": "workbookc898119a-7381-469d-b51a-d505b4f80e73", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.synapse/workspaces/sqlpools", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 31597002, "endTime": "2022-01-21T03:06:58.357Z" }, "metrics": [ { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool Workload management-WLGActiveQueries", "aggregation": 1, "splitBy": null } ], "title": "Query Count by Workload Group", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "name": "metric - 1" }, { "type": 10, "content": { "chartId": "workbook8d175f6c-427b-47fc-85ea-37edd0be707c", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.synapse/workspaces/sqlpools", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 31597002, "endTime": "2022-01-21T03:06:58.357Z" }, "metrics": [ { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-WLGQueuedQueries", "aggregation": 1, "splitBy": "WorkloadGroup" } ], "title": "Queued Queries by Workload Group", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "name": "Queued Queries by Workload Group" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "parameters": [ { "id": "6f50577d-7b00-4e4a-acf9-d45c7a5ee813", "version": "KqlParameterItem/1.0", "name": "WorkloadGroupName", "type": 2, "multiSelect": true, "quote": "'", "delimiter": ",", "query": "SynapseSqlPoolExecRequests \r\n| where _ResourceId == '{DatabaseResourceName}'\r\n and ResourceClass != \"\"\r\n| distinct ResourceClass", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "typeSettings": { "additionalResourceOptions": [ "value::all" ], "showDefault": false }, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "defaultValue": "value::all", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 2" }, { "type": 10, "content": { "chartId": "workbook3da1d18a-1bf5-46c5-b3b7-211f71d329cc", "version": "MetricsItem/2.0", "size": 0, "chartType": 2, "resourceType": "microsoft.synapse/workspaces/sqlpools", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 31597002, "endTime": "2022-01-21T03:06:58.357Z" }, "metrics": [ { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-WLGActiveQueries", "aggregation": 1, "splitBy": null }, { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-WLGQueuedQueries", "aggregation": 1 }, { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-WLGAllocationBySystemPercent", "aggregation": 3 }, { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-WLGEffectiveCapResourcePercent", "aggregation": 3 } ], "filters": [ { "id": "5", "key": "WorkloadGroup", "operator": 0, "valueParam": "WorkloadGroupName" } ], "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "name": "metric - 3" } ] }, "conditionalVisibilities": [ { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "WorkloadManagement" }, { "parameterName": "DiagnosticsState", "comparison": "isEqualTo", "value": "enabled" } ], "name": "WorkloadManagementGroup" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 1, "content": { "json": "## Select a Principal or Application name to filter results - leave to 'unset' to view all results\r\nSQL Auditing must be enabled and sending to the same Log Analytics Workspace for this page to work. " }, "name": "text - 5" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "parameters": [ { "id": "8d25c043-d1ff-4546-a1fa-f4bcbfdab8af", "version": "KqlParameterItem/1.0", "name": "User", "type": 2, "description": "User to filter subsequent queries - leave to 'unset' for all users", "query": "SQLSecurityAuditEvents \r\n| where LogicalServerName == '{LogicalServerName}'\r\n| summarize by ServerPrincipalName", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "value": null, "typeSettings": { "additionalResourceOptions": [], "showDefault": false }, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "id": "aa766d64-693f-4024-b4a4-b5b56b28376b", "version": "KqlParameterItem/1.0", "name": "Application", "type": 2, "query": "SQLSecurityAuditEvents \r\n| where LogicalServerName == '{LogicalServerName}'\r\n| summarize by ApplicationName", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "value": null, "typeSettings": { "additionalResourceOptions": [], "showDefault": false }, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "customWidth": "30", "name": "parameters - 1" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SQLSecurityAuditEvents \r\n| where LogicalServerName == '{LogicalServerName}'\r\n| where DurationMs > 0\r\n| extend duration_seconds = DurationMs /1000.0\r\n| where Statement != 'select @@version'\r\n| where Statement != 'SELECT @@SPID;'\r\n| where ServerPrincipalName has '{User}'\r\n| where ApplicationName has '{Application}'\r\n| project ServerPrincipalName, EventTime, LogicalServerName, DurationMs, duration_seconds, AffectedRows, Statement, ApplicationName\r\n| summarize duration_seconds = round(sum(duration_seconds)) , query_count = count() by EventDay = bin(EventTime,1d), UserName = ServerPrincipalName, Application = ApplicationName \r\n| order by EventDay, duration_seconds desc", "size": 0, "showAnalytics": true, "title": "Query Summary for Selected User {User} {Application}", "noDataMessage": "Select a user to see query activity", "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "showPin": true, "name": "query - 0 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SQLSecurityAuditEvents \r\n| where LogicalServerName == '{LogicalServerName}'\r\n| where DurationMs > 0\r\n| extend duration_seconds = DurationMs /1000.0\r\n| where Statement != 'select @@version'\r\n| where Statement != 'SELECT @@SPID;'\r\n| where ServerPrincipalName has '{User}'\r\n| where ApplicationName has '{Application}'\r\n| project ServerPrincipalName, EventTime, LogicalServerName, DurationMs, duration_seconds, AffectedRows, Statement, ApplicationName\r\n| summarize duration_seconds = round(sum(duration_seconds)) , query_count = count() by EventDay = bin(EventTime,1d), UserName = ServerPrincipalName, Application = ApplicationName \r\n| order by EventDay, duration_seconds desc", "size": 0, "showAnalytics": true, "title": "Query Summary for Selected User {User} {Application}", "noDataMessage": "Select a user to see query activity", "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "unstackedbar", "tileSettings": { "showBorder": false, "titleContent": { "columnMatch": "UserName", "formatter": 1 }, "leftContent": { "columnMatch": "duration_seconds", "formatter": 12, "formatOptions": { "palette": "auto" }, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "graphSettings": { "type": 0, "topContent": { "columnMatch": "UserName", "formatter": 1 }, "centerContent": { "columnMatch": "duration_seconds", "formatter": 1, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "chartSettings": { "xAxis": "UserName" }, "mapSettings": { "locInfo": "LatLong", "sizeSettings": "duration_seconds", "sizeAggregation": "Sum", "legendMetric": "duration_seconds", "legendAggregation": "Sum", "itemColorSettings": { "type": "heatmap", "colorAggregation": "Sum", "nodeColorField": "duration_seconds", "heatmapPalette": "greenRed" } } }, "showPin": true, "name": "query - 0 - Copy - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SQLSecurityAuditEvents \r\n | where LogicalServerName == \"{LogicalServerName}\"\r\n | where DurationMs > 0\r\n | extend duration_seconds = DurationMs /1000.0\r\n | where Statement != 'select @@version'\r\n | where Statement != 'SELECT @@SPID;'\r\n | where ServerPrincipalName has '{User}'\r\n | where ApplicationName has '{Application}'\r\n | project DatabaseName= DatabaseName, UserName= ServerPrincipalName, EventTime= EventTime, Host= HostName, duration_seconds = round(duration_seconds), Statement, QuerySource = ApplicationName , AffectedRows\r\n | project-reorder DatabaseName, UserName, Host, EventTime, duration_seconds, Statement, QuerySource\r\n\r\n\r\n\r\n\r\n\r\n", "size": 0, "showAnalytics": true, "title": "Queries {User} {Application}", "noDataMessage": "Select a user to see query activity", "timeContextFromParameter": "TimeRange", "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "showPin": true, "name": "query - 0 - Copy - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SQLSecurityAuditEvents \r\n | where LogicalServerName == \"{LogicalServerName}\"\r\n | where DurationMs > 0\r\n | extend duration_seconds = DurationMs /1000.0\r\n | where Statement != 'select @@version'\r\n | where Statement != 'SELECT @@SPID;'\r\n | where ServerPrincipalName has '{User}'\r\n | where ApplicationName has '{Application}'\r\n | project DatabaseName= DatabaseName, UserName= ServerPrincipalName, EventTime= EventTime, Host= HostName, duration_seconds = round(duration_seconds), Statement, QuerySource = ApplicationName , AffectedRows\r\n | project-reorder AffectedRows,DatabaseName, UserName, Host, EventTime, duration_seconds, Statement, QuerySource\r\n\r\n\r\n\r\n\r\n\r\n", "size": 0, "showAnalytics": true, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "barchart", "chartSettings": { "xAxis": "Host", "group": "UserName", "createOtherGroup": null, "showLegend": true } }, "showPin": true, "name": "query - 6" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SQLSecurityAuditEvents\r\n| where LogicalServerName == \"{LogicalServerName}\"\r\n | where DurationMs > 0\r\n| extend Duration = round(DurationMs /1000.0)\r\n| extend TimeBin = case (datetime_part(\"Hour\",TimeGenerated) in (6,7,8,9,10,11,12), \"Morning_6-12\", datetime_part(\"Hour\",TimeGenerated) in (13,14,15,16,17,18), \"Afternoon_12-18\", \"Overnight_18-6\")\r\n| where ServerPrincipalName has '{User}'\r\n| where ApplicationName has '{Application}'\r\n| summarize QueryDuration = sum(Duration) by EventTime = bin(EventTime, 1d), TimeBin", "size": 0, "showAnalytics": true, "title": "Query Activity by time - sum(Duration) {User} {Application}", "noDataMessage": "Select a user to see query activity", "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "barchart" }, "showPin": true, "name": "query - 0 - Copy" } ] }, "conditionalVisibilities": [ { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "QueryAudit" }, { "parameterName": "AuditingState", "comparison": "isEqualTo", "value": "enabled" } ], "name": "QueryAuditGroup", "styleSettings": { "showBorder": true } }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "7fa3187e-9225-4faa-8f80-dc1bc40c5aab", "version": "KqlParameterItem/1.0", "name": "RequestId1", "type": 1, "value": "" } ], "style": "above", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "customWidth": "50", "name": "parameters - 3 - Copy" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "315fc476-469a-4d8d-b421-028d1113ab06", "version": "KqlParameterItem/1.0", "name": "RequestId2", "type": 1, "value": "", "timeContext": { "durationMs": 86400000 } } ], "style": "above", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "customWidth": "50", "name": "parameters - 2" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 9, "content": { "version": "KqlParameterItem/1.0", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "parameters": [ { "id": "1537c5b3-0b6c-4b1d-89be-946cd8268020", "version": "KqlParameterItem/1.0", "name": "QueryText1", "type": 1, "query": "SynapseSqlPoolExecRequests\r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where StatementType !in ('Batch','Execute') and RequestId == '{RequestId1}'\r\n| summarize max(Command)", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" } ], "style": "above", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 5" }, { "type": 1, "content": { "json": "#### {RequestId1} Query Text" }, "conditionalVisibility": { "parameterName": "RequestId1", "comparison": "isNotEqualTo" }, "name": "text - 5" }, { "type": 1, "content": { "json": "```{QueryText1}```" }, "conditionalVisibility": { "parameterName": "RequestId1", "comparison": "isNotEqualTo" }, "name": "text - 3" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolExecRequests\r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where StatementType !in ('Batch','Execute') and RequestId == '{RequestId1}'\r\n| summarize \r\n Request_ID=any(RequestId),\r\n Start_Time=max(StartTime),\r\n End_Time=max(EndTime),\r\n //Command=any(Command),\r\n Status=min(Status), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType),\r\n Resource_class=any(ResourceClass)\r\n by RequestId\r\n| summarize Start_Time=any(Start_Time), End_Time=any(End_Time),ElapsedTime_min=anyif((End_Time - Start_Time)/1m,Start_Time > ago(30d))\r\n//,Command=any(Command)\r\n,Status=any(Status),Statement_Type=any(Statement_Type),Resource_class=any(Resource_class) by Request_ID\r\n| project ElapsedTime_min\r\n//,Command\r\n,Resource_class,Start_Time\r\n//,End_Time\r\n,Statement_Type,Status\r\n", "size": 4, "title": "Exec Requests", "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "conditionalVisibility": { "parameterName": "RequestId1", "comparison": "isNotEqualTo" }, "name": "query - 2" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolRequestSteps \r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where RequestId == '{RequestId1}' and RequestId != ''\r\n| summarize StartTime=max(StartTime)\r\n ,EndTime=max(EndTime)\r\n ,RequestID=max(RequestId)\r\n ,Operation=max(OperationType)\r\n ,RowCount=max(RowCount)\r\n ,Command=max(Command)\r\n ,Status=min(Status)\r\n by StepIndex\r\n| order by StepIndex asc\r\n| project StartTime,EndTime,Operation,RowCount,Command,Status,StepIndex", "size": 3, "title": "Request Steps", "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "conditionalVisibility": { "parameterName": "RequestId1", "comparison": "isNotEqualTo" }, "name": "StepQueryRequest1", "styleSettings": { "margin": "0", "padding": "10px" } }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolExecRequests\r\n | where StatementType =='CreateStatistics'\r\n | where _ResourceId has '{DatabaseName}'\r\n | summarize \r\n Root_Query_Id=max(RootQueryId), \r\n Start_Time=max(StartTime),\r\n End_Compile_Time=max(EndCompileTime), \r\n End_Time=max(EndTime), \r\n Command=max(Command), \r\n Last_Status=min(Status),\r\n Statement_Type=max(StatementType),\r\n Resource_class=max(ResourceClass) \r\n by RequestId\r\n | where Root_Query_Id == '{RequestId1}'", "size": 0, "title": "Triggered Auto-Stats Statements", "noDataMessage": "No triggered autostats statements found", "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Submit_Time", "formatter": 0, "numberFormat": { "unit": 0, "options": { "style": "decimal" } } }, { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "100ch" } } ], "sortBy": [ { "itemKey": "End_Time", "sortOrder": 2 } ] }, "sortBy": [ { "itemKey": "End_Time", "sortOrder": 2 } ] }, "conditionalVisibility": { "parameterName": "RequestId1", "comparison": "isNotEqualTo" }, "name": "All triggered auto-stats statements" } ] }, "customWidth": "50", "name": "RequestId1Group", "styleSettings": { "showBorder": true } }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 9, "content": { "version": "KqlParameterItem/1.0", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "parameters": [ { "id": "1537c5b3-0b6c-4b1d-89be-946cd8268020", "version": "KqlParameterItem/1.0", "name": "QueryText2", "type": 1, "query": "SynapseSqlPoolExecRequests\r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where StatementType !in ('Batch','Execute') and RequestId == '{RequestId2}'\r\n| summarize max(Command)", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" } ], "style": "above", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 5" }, { "type": 1, "content": { "json": "#### {RequestId2} Query Text" }, "conditionalVisibility": { "parameterName": "RequestId2", "comparison": "isNotEqualTo" }, "name": "text - 5" }, { "type": 1, "content": { "json": "```{QueryText2}```" }, "conditionalVisibility": { "parameterName": "RequestId2", "comparison": "isNotEqualTo" }, "name": "text - 4" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolExecRequests\r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where StatementType !in ('Batch','Execute') and RequestId == '{RequestId2}'\r\n| summarize \r\n Request_ID=any(RequestId),\r\n Start_Time=max(StartTime),\r\n End_Time=max(EndTime),\r\n //Command=any(Command),\r\n Status=min(Status), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType),\r\n Resource_class=any(ResourceClass)\r\n by RequestId\r\n| summarize Start_Time=any(Start_Time), End_Time=any(End_Time),ElapsedTime_min=anyif((End_Time - Start_Time)/1m,Start_Time > ago(30d))\r\n//,Command=any(Command)\r\n,Status=any(Status),Statement_Type=any(Statement_Type),Resource_class=any(Resource_class) by Request_ID\r\n| project ElapsedTime_min\r\n//,Command\r\n,Resource_class,Start_Time\r\n//,End_Time\r\n,Statement_Type,Status\r\n", "size": 4, "title": "Exec Requests", "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "conditionalVisibility": { "parameterName": "RequestId2", "comparison": "isNotEqualTo" }, "name": "query - 2 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolRequestSteps \r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where RequestId == '{RequestId2}' and RequestId != ''\r\n| summarize StartTime=max(StartTime)\r\n ,EndTime=max(EndTime)\r\n ,RequestID=max(RequestId)\r\n ,Operation=max(OperationType)\r\n ,RowCount=max(RowCount)\r\n ,Command=max(Command)\r\n ,Status=min(Status)\r\n by StepIndex\r\n| order by StepIndex asc\r\n| project StartTime,EndTime,Operation,RowCount,Command,Status,StepIndex", "size": 3, "title": "Request Steps", "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "conditionalVisibility": { "parameterName": "RequestId2", "comparison": "isNotEqualTo" }, "name": "query - 4 - Copy", "styleSettings": { "padding": "10px" } }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolExecRequests\r\n | where StatementType =='CreateStatistics'\r\n | where _ResourceId has '{DatabaseName}'\r\n | summarize \r\n Root_Query_Id=max(RootQueryId), \r\n Start_Time=max(StartTime),\r\n End_Compile_Time=max(EndCompileTime), \r\n End_Time=max(EndTime), \r\n Command=max(Command), \r\n Last_Status=min(Status),\r\n Statement_Type=max(StatementType),\r\n Resource_class=max(ResourceClass) \r\n by RequestId\r\n | where Root_Query_Id == '{RequestId2}'", "size": 0, "title": "Triggered Auto-Stats Statements", "noDataMessage": "No triggered autostats statements found", "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Submit_Time", "formatter": 0, "numberFormat": { "unit": 0, "options": { "style": "decimal" } } }, { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "100ch" } } ] } }, "conditionalVisibility": { "parameterName": "RequestId2", "comparison": "isNotEqualTo" }, "name": "All triggered auto-stats statements" } ] }, "customWidth": "50", "name": "RequestId2Group", "styleSettings": { "showBorder": true } } ] }, "conditionalVisibilities": [ { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "QueryComparison" }, { "parameterName": "DiagnosticsState", "comparison": "isEqualTo", "value": "enabled" } ], "name": "QueryComparison" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 1, "content": { "json": "## This tab is used to determine what statements triggerred autostats creation jobs. \r\nThe flow of autostats creation is as follows\r\n1. Query Submit Time\r\n2. \tCreate Statistics submit Time\r\n3. \tCreate Statistics end Time\r\n4. Query end_compile_time\r\n5. Query Start_Time\r\n6. Query End_Time\r\n\r\nFurther, if multiple stats are created, then the creation of all stats for this query will fall between query submit_time and end_compile_time. \r\n\r\nThe charts on this page allow you to search for an autostats job by requestID or my snippet of the autostats statement text, which can just be the schema, table, or column name. Then it will show you all commands that include that request ID or text. It will then show you all statements in the create stat statement because the query we are trying to identify will wait for all of those stats creations to complete before proceeding. \r\n\r\nThe last chart will list the statement that triggered the stats creation. " }, "name": "text - 6" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "df5b9b85-4188-4f2c-88cb-1369e09f6742", "version": "KqlParameterItem/1.0", "name": "RootQueryId", "type": 1, "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 } }, { "id": "560c9ec5-6341-4fa1-9ce6-35ff010151b1", "version": "KqlParameterItem/1.0", "name": "RequestId", "type": 1, "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 } } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 5" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "0911bd4b-d471-480b-bdf4-1a2d4ba1ea6e", "version": "KqlParameterItem/1.0", "name": "RequestIdSearch", "type": 1, "value": "", "label": "RequestId for AutoStats Job" }, { "id": "c12e6495-4fd1-473c-8ffc-0bf502f54706", "version": "KqlParameterItem/1.0", "name": "QueryTextSnippet", "type": 1, "value": "", "timeContext": { "durationMs": 86400000 }, "label": "Snippet of autostats creation statement (Schema, table or column)" } ], "style": "formVertical", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "customWidth": "60", "name": "parameters - 3 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolExecRequests\r\n | where StatementType =='CreateStatistics'\r\n | where _ResourceId has '{DatabaseName}'\r\n| summarize \r\n Root_Query_Id=max(RootQueryId), \r\n Start_Time=max(StartTime),\r\n End_Time=max(EndTime), \r\n Command=max(Command), \r\n Last_Status=min(Status),\r\n Statement_Type=max(StatementType)\r\n by RequestId\r\n| where Command has 'CREATE STATISTICS _wa_sys'\r\n| where Command has '{QueryTextSnippet}' and RequestId has '{RequestIdSearch}'\r\n//| extend elapsedTime_sec = iif(End_Time > ago(365d),(End_Time - Submit_Time)/1s,real(null)) \r\n//| extend CompileTime_sec = (End_Compile_Time - Submit_Time)/1s\r\n//| order by elapsedTime_sec\r\n//| summarize \r\n // Executions = count(),\r\n // Max_Elapsed_Time_sec = bin(max(elapsedTime_sec),1),\r\n // Min_Elapsed_Time_sec = bin(min(elapsedTime_sec),1),\r\n // Variability_sec=bin((max(elapsedTime_sec)-min(elapsedTime_sec)),1),\r\n // SampleQID = any(RequestId),\r\n // SampleSessionID = any(Session_ID)\r\n // by Command\r\n//| order by Max_Elapsed_Time_sec\r\n\r\n\r\n", "size": 0, "showAnalytics": true, "title": "Matching Autostats Queries", "noDataMessageStyle": 4, "timeContextFromParameter": "TimeRange", "exportedParameters": [ { "fieldName": "RequestId", "parameterName": "RequestId", "parameterType": 1 }, { "fieldName": "Root_Query_Id", "parameterName": "RootQueryId", "parameterType": 1 } ], "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "50%" } } ], "sortBy": [ { "itemKey": "Command", "sortOrder": 1 } ] }, "sortBy": [ { "itemKey": "Command", "sortOrder": 1 } ] }, "name": "query - 0 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolExecRequests\r\n | where StatementType !='CreateStatistics'\r\n | where _ResourceId has '{DatabaseName}'\r\n | where RequestId == '{RootQueryId}'\r\n | summarize \r\n Start_Time=max(StartTime),\r\n End_Compile_Time=max(EndCompileTime), \r\n End_Time=max(EndTime), \r\n Command=max(Command), \r\n Last_Status=min(Status),\r\n Statement_Type=max(StatementType),\r\n Resource_class=max(ResourceClass) \r\n by RequestId", "size": 3, "showAnalytics": true, "title": "Statement that Triggered Selected Autostat", "noDataMessage": "Select an autostats query above to see what query triggered it", "noDataMessageStyle": 4, "timeContextFromParameter": "TimeRange", "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "150ch" } } ], "sortBy": [ { "itemKey": "Command", "sortOrder": 1 } ] }, "sortBy": [ { "itemKey": "Command", "sortOrder": 1 } ] }, "name": "query - 0 - Copy - Copy - Copy - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolExecRequests\r\n | where StatementType =='CreateStatistics'\r\n | where _ResourceId has '{DatabaseName}'\r\n| summarize \r\n Root_Query_Id=max(RootQueryId), \r\n Start_Time=max(StartTime),\r\n End_Time=max(EndTime), \r\n Command=max(Command), \r\n Last_Status=min(Status),\r\n Statement_Type=max(StatementType)\r\n by RequestId\r\n| where Command has 'CREATE STATISTICS _wa_sys'\r\n| where Root_Query_Id == '{RootQueryId}'", "size": 3, "showAnalytics": true, "title": "All Stats Statements Triggered by selected Query", "noDataMessageStyle": 4, "timeContextFromParameter": "TimeRange", "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 13" } ] }, "conditionalVisibilities": [ { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "Statistics" }, { "parameterName": "DiagnosticsState", "comparison": "isEqualTo", "value": "enabled" } ], "name": "statistics" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 1, "content": { "json": "" }, "customWidth": "60", "showPin": false, "name": "Image" }, { "type": 1, "content": { "json": "Enable SQL Auditing to get additional visibility into user activity against your SQL Pool\r\n\r\nThis section provides additional monitoring coverage that is based on SQL Audit logs.
\r\nIf you have not activated SQL Auditing for your dedeciated SQL Pool, you must enable them to go to the same Log Analytics workspace as the rest of your diagnostic settings for it to show up here. [Learn more](https://docs.microsoft.com/en-us/azure/azure-sql/database/auditing-overview)\r\n" }, "customWidth": "60", "name": "text - 2" }, { "type": 11, "content": { "version": "LinkItem/1.0", "style": "paragraph", "links": [ { "id": "f4df7a1e-2124-4620-9005-f9b66e47f550", "cellValue": "{DatabaseResourceName}", "linkTarget": "Resource", "linkLabel": "Configure Logs for Auditing >", "subTarget": "auditing", "preText": "", "postText": "", "style": "primary" } ] }, "customWidth": "70", "name": "links - 8" } ] }, "customWidth": "90", "name": "Onboarding Message - Not onboarded yet" } ] }, "conditionalVisibilities": [ { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "QueryAudit" }, { "parameterName": "AuditingState", "comparison": "isEqualTo", "value": "disabled" } ], "name": "AuditingDisabledGroup" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 1, "content": { "json": "" }, "customWidth": "60", "showPin": false, "name": "Image" }, { "type": 1, "content": { "json": "Get more visibility into the usage and performance of your Azure Synapse Dedicated SQL Pool\r\n\r\nThis section provides additional monitoring coverage that is based on diagnostic logs.
\r\n\r\nIf you have not activated monitoring in diagnostic settings, you must enable the **ExecRequests** and **RequestSteps** logs and send them to a Log Analytics workspace. You may choose to enable the **SQLSecurityAuditEvents** table at the same time to take full advantage of this monitoring workbook. [Learn more](https://docs.microsoft.com/en-us/azure/synapse-analytics/monitoring/how-to-monitor-using-azure-monitor#logs)" }, "customWidth": "60", "name": "text - 2" }, { "type": 11, "content": { "version": "LinkItem/1.0", "style": "paragraph", "links": [ { "id": "f4df7a1e-2124-4620-9005-f9b66e47f550", "cellValue": "{DatabaseResourceName}", "linkTarget": "Resource", "linkLabel": "Configure Logs for Monitoring >", "subTarget": "diagnostics", "preText": "", "postText": "", "style": "primary" } ] }, "customWidth": "70", "name": "links - 8" } ] }, "customWidth": "90", "name": "Onboarding Message - Not onboarded yet" } ] }, "conditionalVisibilities": [ { "parameterName": "GroupSelection", "comparison": "isNotEqualTo", "value": "QueryAudit" }, { "parameterName": "DiagnosticsState", "comparison": "isEqualTo", "value": "disabled" } ], "name": "DiagnosticsDisabledGroup" }, { "type": 1, "content": { "json": "Workbook version: v1.0", "style": "info" }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "Overview" }, "customWidth": "15", "name": "version", "styleSettings": { "showBorder": true } } ], "fallbackResourceIds": [ "Azure Monitor" ], "$schema": "https://github.com/Microsoft/Application-Insights-Workbooks/blob/master/schema/workbook.json" } ================================================ FILE: Monitor_Workbooks/archive/DedicatedSQLPool_workspace_v1.1.workbook ================================================ { "version": "Notebook/1.0", "items": [ { "type": 9, "content": { "version": "KqlParameterItem/1.0", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "parameters": [ { "id": "f5852627-70ca-4959-8d60-53b48864603f", "version": "KqlParameterItem/1.0", "name": "TimeRange", "type": 4, "isGlobal": true, "value": { "durationMs": 86400000 }, "typeSettings": { "selectableValues": [ { "durationMs": 300000 }, { "durationMs": 900000 }, { "durationMs": 1800000 }, { "durationMs": 3600000 }, { "durationMs": 14400000 }, { "durationMs": 43200000 }, { "durationMs": 86400000 }, { "durationMs": 172800000 }, { "durationMs": 259200000 }, { "durationMs": 604800000 }, { "durationMs": 1209600000 }, { "durationMs": 2419200000 }, { "durationMs": 2592000000 } ], "allowCustom": true }, "timeContext": { "durationMs": 86400000 } }, { "id": "28da10ec-a308-47f5-9819-92ebf810b292", "version": "KqlParameterItem/1.0", "name": "LogAnalyticsSubscription", "type": 6, "value": null, "typeSettings": { "additionalResourceOptions": [], "includeAll": true, "showDefault": false }, "timeContext": { "durationMs": 86400000 } }, { "id": "e383ed24-52ae-447b-9b80-51fd3ab6b919", "version": "KqlParameterItem/1.0", "name": "LogAnalyticsWorkspace", "type": 5, "query": "Resources\r\n| where type == 'microsoft.operationalinsights/workspaces'\r\n| project id\r\n", "crossComponentResources": [ "{LogAnalyticsSubscription}" ], "value": null, "typeSettings": { "additionalResourceOptions": [], "showDefault": false }, "timeContext": { "durationMs": 86400000 }, "queryType": 1, "resourceType": "microsoft.resourcegraph/resources" }, { "id": "9b9fe566-0f52-4a75-a35b-a79c50c6a6f0", "version": "KqlParameterItem/1.0", "name": "DatabaseResourceName", "type": 5, "query": "SynapseSqlPoolExecRequests \r\n| distinct _ResourceId", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "value": null, "typeSettings": { "additionalResourceOptions": [], "showDefault": false }, "timeContext": { "durationMs": 2592000000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "id": "6da2f63f-45a3-4b37-9108-5e8b7e358d85", "version": "KqlParameterItem/1.0", "name": "DatabaseName", "type": 1, "query": "print split (\"{DatabaseResourceName}\",\"/\")[-1]", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "id": "8bba835b-f319-43b3-8ec6-4e051fc6d446", "version": "KqlParameterItem/1.0", "name": "LogicalServerName", "type": 1, "query": "SynapseSqlPoolExecRequests\r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| distinct LogicalServerName", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "id": "b86cd4a2-2303-4288-b48c-1c119cb420ba", "version": "KqlParameterItem/1.0", "name": "AuditingState", "type": 1, "query": "let hasNonEmptyTable = (T:string) \r\n{ \r\n toscalar( \r\n union isfuzzy=true \r\n ( table(T) \r\n | where DatabaseName has '{DatabaseName}'\r\n | where TimeGenerated > ago(30d)| take 1 | count as Count ),\r\n (print Count=0) \r\n | summarize sum(Count) \r\n ) > 0\r\n};\r\nlet TableName = 'SQLSecurityAuditEvents';\r\nprint IsPresent=iif(hasNonEmptyTable(TableName ), \"enabled\", \"disabled\")", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 604800000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "id": "4025bcb8-f6d7-4e81-b805-84253835f8fb", "version": "KqlParameterItem/1.0", "name": "DiagnosticsState", "type": 1, "query": "let hasNonEmptyTable = (T:string, T2:string) \r\n{ \r\n toscalar( \r\n union isfuzzy=true \r\n ( table(T) | where TimeGenerated > ago(30d) | where _ResourceId endswith '/sqlpools/{DatabaseName}'| take 1 | count as Count ),\r\n ( table(T2) | where TimeGenerated > ago(30d) | where _ResourceId endswith '/sqlpools/{DatabaseName}'| take 1 | count as Count),\r\n (print Count=0) \r\n | summarize sum(Count) \r\n ) > 1\r\n};\r\nlet TableName = 'SynapseSqlPoolExecRequests';\r\nlet TableName2 = 'SynapseSqlPoolRequestSteps';\r\nprint IsPresent=iif(hasNonEmptyTable(TableName,TableName2 ), \"enabled\", \"disabled\")", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 2592000000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "customWidth": "90", "name": "parameters - 2" }, { "type": 1, "content": { "json": "Select your Log Analytics Workspace by setting the parameters above from left to right. ", "style": "warning" }, "conditionalVisibility": { "parameterName": "DatabaseResourceName", "comparison": "isEqualTo" }, "customWidth": "30", "name": "text - 14" }, { "type": 11, "content": { "version": "LinkItem/1.0", "style": "tabs", "links": [ { "id": "202cbbc0-8d63-416d-89ed-451d6fe7c4b3", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Overview", "subTarget": "Overview", "preText": "Workload", "style": "link" }, { "id": "a7901bd0-a1f4-4491-b953-57555d764e00", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Workload Management", "subTarget": "WorkloadManagement", "style": "link" }, { "id": "45e12a14-8548-4477-aae3-c142b906dc9f", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "TempDB", "subTarget": "TempDB", "style": "link" }, { "id": "9ef8f730-d73d-432b-9b75-55095d1155f2", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Replicated Tables", "subTarget": "ReplicatedTables", "style": "link" }, { "id": "79d10d16-0696-4214-b306-c7a0e46cd64f", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Query Investigation", "subTarget": "QueryInvestigation", "style": "link" }, { "id": "31c1cf1c-74b5-44e2-ba9a-9497834ca3dc", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Query Comparison", "subTarget": "QueryComparison", "style": "link" }, { "id": "db43bb45-1611-47ce-a2ad-517943f2aa1a", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "AutoStats", "subTarget": "Statistics", "style": "link" }, { "id": "482ccc46-8a10-4ace-bfd6-63ac73b380af", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Query Audit", "subTarget": "QueryAudit", "style": "link" }, { "id": "f42ddeea-8cc0-4095-bc90-11eac0b7f94c", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Audit Search", "subTarget": "AuditSearch", "style": "link" } ] }, "name": "links - 0" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 10, "content": { "chartId": "workbook90867bfc-5c33-464f-ac31-2c2e006b97f4", "version": "MetricsItem/2.0", "size": 0, "chartType": 2, "resourceType": "microsoft.synapse/workspaces/sqlpools", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 86400000 }, "metrics": [ { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-DWUUsedPercent", "aggregation": 3, "splitBy": null, "columnName": "DWU Usaed %" }, { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-CPUPercent", "aggregation": 3, "columnName": "CPU Used %" } ], "title": "DWU Resource Utilization", "showOpenInMe": true, "showCreateAlertRule": true, "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "showPin": true, "name": "metric - 1" }, { "type": 10, "content": { "chartId": "workbookb954d4a0-82ef-4409-88fb-837aaff80c8d", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.synapse/workspaces/sqlpools", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 86400000 }, "metrics": [ { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-ActiveQueries", "aggregation": 1, "splitBy": null }, { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-QueuedQueries", "aggregation": 1 } ], "title": "Active and Queued Queries", "showOpenInMe": true, "showCreateAlertRule": true, "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "showPin": true, "name": "metric - 1" }, { "type": 10, "content": { "chartId": "workbookb954d4a0-82ef-4409-88fb-837aaff80c8d", "version": "MetricsItem/2.0", "size": 0, "chartType": 3, "resourceType": "microsoft.synapse/workspaces/sqlpools", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 86400000 }, "metrics": [ { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-LocalTempDBUsedPercent", "aggregation": 3, "splitBy": null, "columnName": "TempDB Utilization Percentage" } ], "title": "TempDB Utilization", "showOpenInMe": true, "showCreateAlertRule": true, "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "showPin": true, "name": "metric - 1 - Copy" }, { "type": 10, "content": { "chartId": "workbookb954d4a0-82ef-4409-88fb-837aaff80c8d", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.synapse/workspaces/sqlpools", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 86400000 }, "metrics": [ { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool Workload management-WLGAllocationBySystemPercent", "aggregation": 3, "splitBy": null, "columnName": "Workload Group Allocation by System %" } ], "title": "Workload Group Utilization", "showOpenInMe": true, "showCreateAlertRule": true, "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "showPin": true, "name": "Workload Group Utilization" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Long-Running Queries - Just Actual Queries\r\n//If 'Command' is empty - you need to set a bigger time window, the older record with the command is outside of your window\r\nSynapseSqlPoolExecRequests \r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where StatementType !in ('Batch','Execute')\r\n| summarize //Session_ID=any(SessionId),\r\n Request_ID=any(RequestId),\r\n //Submit_Time=max(SubmitTime),\r\n Start_Time=max(StartTime),\r\n End_Time=max(EndTime),\r\n Command=any(Command),\r\n Status=min(Status), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType),\r\n Resource_class=any(ResourceClass)\r\n by RequestId\r\n| summarize ElapsedTime_min=bin(anyif(((End_Time - Start_Time)/1m),Start_Time > ago(30d)),1),\r\n //Session_ID=any(Session_ID), \r\n // Submit_Time=any(Submit_Time) ,\r\n Start_Time=any(Start_Time), \r\n End_Time=any(End_Time),\r\n Command=any(Command),\r\n Status=any(Status),\r\n Statement_Type=any(Statement_Type)\r\n ,Resource_class=any(Resource_class) \r\n by Request_ID\r\n| where End_Time > ago(365d)\r\n| summarize count() by Status, bin(End_Time,5m)\r\n| render barchart \r\n", "size": 0, "showAnalytics": true, "title": "Query Completion Count by End Time - 5m buckets", "color": "redBright", "timeContextFromParameter": "TimeRange", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "chartSettings": { "seriesLabelSettings": [ { "seriesName": "Completed", "color": "green" }, { "seriesName": "Failed", "color": "red" }, { "seriesName": "Cancelled", "color": "yellow" } ] } }, "showPin": true, "name": "query - 4" }, { "type": 1, "content": { "json": "Use the buttons below to filter the next chart for Success or Failed queries. In many cases a failed query may not have a 'Command' column populated depending on what stage the query failed in. ", "style": "info" }, "customWidth": "25", "name": "text - 3" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "e2a833ac-48b4-4ccd-bbcd-33fccf1dbd75", "version": "KqlParameterItem/1.0", "name": "QueryCompletionType", "type": 1, "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 } } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 4" }, { "type": 11, "content": { "version": "LinkItem/1.0", "style": "nav", "links": [ { "id": "8e89112f-c67f-42c0-9622-02fa306fb7a5", "cellValue": "QueryCompletionType", "linkTarget": "parameter", "linkLabel": "All Queries", "subTarget": "''", "style": "primary" }, { "id": "6abe39c7-4d4e-4c45-aa54-dc9a4c5e876e", "cellValue": "QueryCompletionType", "linkTarget": "parameter", "linkLabel": "Success Only", "subTarget": "Completed", "preText": "", "style": "secondary" }, { "id": "e41b4a0b-8464-491e-92be-a57217d6dcac", "cellValue": "QueryCompletionType", "linkTarget": "parameter", "linkLabel": "Failures Only", "subTarget": "Failed", "preText": "", "style": "secondary" } ] }, "name": "links - 11" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Long-Running Queries - Just Actual Queries\r\n//If 'Command' is empty - you need to set a bigger time window, the older record with the command is outside of your window\r\nSynapseSqlPoolExecRequests \r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where StatementType !in ('Batch','Execute')\r\n| summarize //Session_ID=any(SessionId),\r\n Request_ID=any(RequestId),\r\n Start_Time=max(StartTime),\r\n End_Time=max(EndTime),\r\n Command=any(Command),\r\n Status=min(Status), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType),\r\n Resource_class=any(ResourceClass)\r\n by RequestId\r\n| summarize ElapsedTime_min=bin(anyif(((End_Time - Start_Time)/1m),Start_Time > ago(30d)),1),\r\n Start_Time=any(Start_Time), \r\n End_Time=any(End_Time),\r\n Command=any(Command),\r\n Status=any(Status),\r\n Statement_Type=any(Statement_Type)\r\n ,Resource_class=any(Resource_class) \r\n by Request_ID\r\n| where Status has '{QueryCompletionType}'\r\n| order by Start_Time\r\n\r\n", "size": 0, "showAnalytics": true, "title": "Query Completions - use above buttons to filter", "color": "redBright", "timeContextFromParameter": "TimeRange", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "rowLimit": 100 }, "chartSettings": { "seriesLabelSettings": [ { "seriesName": "Completed", "color": "green" }, { "seriesName": "Failed", "color": "red" }, { "seriesName": "Cancelled", "color": "yellow" } ] } }, "showPin": true, "name": "query - 4 - Copy" } ] }, "name": "Query Completions", "styleSettings": { "showBorder": true } }, { "type": 10, "content": { "chartId": "workbook1afc57e6-0b32-4968-b299-db319bd21635", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.synapse/workspaces/sqlpools", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 86400000 }, "metrics": [ { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-Connections", "aggregation": 1, "splitBy": null }, { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-ConnectionsBlockedByFirewall", "aggregation": 1 } ], "title": "Successful and Failed Connections", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "name": "metric - 5" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 3, "content": { "version": "KqlItem/1.0", "query": " SQLSecurityAuditEvents\r\n | where LogicalServerName == '{LogicalServerName}'\r\n | where ActionName in ('DATABASE AUTHENTICATION SUCCEEDED','DATABASE AUTHENTICATION FAILED')\r\n | project SourceSystem,ClientTlsVersion ,Succeeded,SessionId,ClientIp,SessionServerPrincipalName,ServerPrincipalName,DatabasePrincipalName,ApplicationName,HostName,TimeGenerated\r\n | summarize count() by Succeeded,bin(TimeGenerated,1m)\r\n | render barchart\r\n\r\n\r\n\r\n", "size": 0, "showAnalytics": true, "title": "Database Authentication success/failure rate", "timeContextFromParameter": "TimeRange", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "chartSettings": { "xAxis": "TimeGenerated", "group": "succeeded_s", "createOtherGroup": null } }, "showPin": true, "name": "query - 8" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "f7485a11-48df-4b61-a70e-9f56d6a00ec6", "version": "KqlParameterItem/1.0", "name": "AuthResult", "type": 1, "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 } } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 3" }, { "type": 11, "content": { "version": "LinkItem/1.0", "style": "nav", "links": [ { "id": "2ed22e0a-2b53-4ed0-8f65-d2c621f34dad", "cellValue": "AuthResult", "linkTarget": "parameter", "linkLabel": "All Authentications", "subTarget": "''", "style": "primary" }, { "id": "2789ab13-ae8a-472e-bad4-9c9bdc934d4d", "cellValue": "AuthResult", "linkTarget": "parameter", "linkLabel": "Success Only", "subTarget": "true", "style": "secondary" }, { "id": "5cf4ddd4-e189-4b71-b456-0d4f1572a0a3", "cellValue": "AuthResult", "linkTarget": "parameter", "linkLabel": "Failures Only", "subTarget": "false", "style": "secondary" } ] }, "name": "links - 10" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": " SQLSecurityAuditEvents\r\n | where LogicalServerName == '{LogicalServerName}'\r\n | where ActionName in ('DATABASE AUTHENTICATION SUCCEEDED','DATABASE AUTHENTICATION FAILED')\r\n | where Succeeded == '{AuthResult}'\r\n | project SourceSystem,ClientTlsVersion ,Succeeded,SessionId,ClientIp,SessionServerPrincipalName,ServerPrincipalName,DatabasePrincipalName,ApplicationName,HostName,TimeGenerated\r\n //| summarize count() by Succeeded,bin(TimeGenerated,1m)\r\n\r\n\r\n\r\n\r\n\r\n", "size": 0, "showAnalytics": true, "title": "Database Authentication success/failure rate", "noDataMessage": "No Results", "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "rowLimit": 100 }, "chartSettings": { "xAxis": "TimeGenerated", "group": "succeeded_s", "createOtherGroup": null, "showLegend": true } }, "showPin": true, "name": "query - 8 - Copy" } ] }, "conditionalVisibility": { "parameterName": "AuditingState", "comparison": "isEqualTo", "value": "enabled" }, "name": "Database Authentication Group", "styleSettings": { "showBorder": true } }, { "type": 10, "content": { "chartId": "workbook993837ad-66d6-4cbc-ae1a-7c3f6623236b", "version": "MetricsItem/2.0", "size": 0, "chartType": 2, "resourceType": "microsoft.synapse/workspaces/sqlpools", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 86400000 }, "metrics": [ { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-AdaptiveCacheUsedPercent", "aggregation": 3, "splitBy": null }, { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-AdaptiveCacheHitPercent", "aggregation": 3 } ], "title": "Adaptive Cache Used vs Hit Percentage", "showCreateAlertRule": true, "gridSettings": { "rowLimit": 10000 } }, "showPin": true, "name": "metric - 6" } ] }, "conditionalVisibilities": [ { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "Overview" }, { "parameterName": "DiagnosticsState", "comparison": "isEqualTo", "value": "enabled" } ], "name": "overviewGroup" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 10, "content": { "chartId": "workbook4a9cf761-cce2-45b2-8947-8a9428ec7e1c", "version": "MetricsItem/2.0", "size": 0, "chartType": 3, "resourceType": "microsoft.synapse/workspaces/sqlpools", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 31597002, "endTime": "2022-01-21T03:06:58.357Z" }, "metrics": [ { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-LocalTempDBUsedPercent", "aggregation": 3, "splitBy": null, "columnName": "TempDB Util" } ], "title": "TempDB Max and Avg Utilization", "showOpenInMe": true, "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "showPin": true, "name": "metric - 0" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "19ee48f5-8f4e-4939-a0ef-c6bf656a93f9", "version": "KqlParameterItem/1.0", "name": "WeightParameter", "type": 1, "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 } }, { "id": "00553ec8-1a41-4dd9-a024-d607639c9bbb", "version": "KqlParameterItem/1.0", "name": "RequestID", "type": 1, "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 }, "value": "" } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 3" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databaseResourceName = '{DatabaseResourceName}';\r\n//Weighted query steps\r\nSynapseSqlPoolRequestSteps \r\n| where _ResourceId == databaseResourceName\r\n| where RowCount > 0\r\n| summarize sum(RowCount) by RequestId, OperationType\r\n| order by sum_RowCount desc\r\n| limit 20\r\n| render columnchart ", "size": 0, "showAnalytics": true, "title": "20 Largest Query Steps by Most Rows Moved", "timeContextFromParameter": "TimeRange", "exportFieldName": "Request_ID", "exportParameterName": "RequestID", "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "chartSettings": { "xAxis": "RequestId", "group": "OperationType", "createOtherGroup": 20, "showLegend": true } }, "showPin": true, "name": "query - 1 - Copy" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "8afacdd5-2690-48d0-b125-fb118378e90c", "version": "KqlParameterItem/1.0", "name": "WeightParameter", "type": 1, "value": "Unweighted", "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 } } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 8" }, { "type": 11, "content": { "version": "LinkItem/1.0", "style": "nav", "links": [ { "id": "c98d3722-9907-43ab-9306-1957d6f7f858", "cellValue": "WeightParameter", "linkTarget": "parameter", "linkLabel": "Weighted Rowcounts", "subTarget": "Weighted", "preText": "", "postText": "", "style": "secondary" }, { "id": "a06ae99a-ad62-45e9-8c25-c219b81f59c0", "cellValue": "WeightParameter", "linkTarget": "parameter", "linkLabel": "Unweighted Rowcounts", "subTarget": "Unweighted", "preText": "", "postText": "", "style": "secondary" } ] }, "name": "links - 3" }, { "type": 1, "content": { "json": "Current Setting: {WeightParameter}", "style": "info" }, "customWidth": "25", "name": "text - 4" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databaseResourceName = '{DatabaseResourceName}';\r\n//Weighted query steps\r\nlet RequestSteps = SynapseSqlPoolRequestSteps\r\n| where _ResourceId == databaseResourceName\r\n//| where RowCount > 10000000\r\n| extend Step_Elapsed_Min = round((EndTime - StartTime) /1m, 2)\r\n| extend Weighted_cnt = iff('{WeightParameter}'=='Weighted',(case(OperationType == 'BroadcastMoveOperation', (RowCount*10), RowCount)),RowCount)\r\n| project-rename StepStatus = Status, StepStart = StartTime, StepEnd = EndTime//, StepResource = Resource\r\n| top 100 by Weighted_cnt desc\r\n| order by Weighted_cnt desc\r\n| project Request_ID=RequestId,OperationType, RowCount,Weighted_cnt,Step_Elapsed_Min, StepStart, StepEnd, StepStatus, StepIndex;\r\nRequestSteps | join (\r\nSynapseSqlPoolExecRequests\r\n| where _ResourceId == databaseResourceName\r\n| where StatementType !in ('Batch','Execute')\r\n| summarize //Session_ID=any(SessionId),\r\n Request_ID=any(RequestId),\r\n //Submit_Time=max(SubmitTime),\r\n Start_Time=max(StartTime),\r\n End_Time=max(EndTime),\r\n Command=any(Command),\r\n Status=min(Status), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType),\r\n Resource_class=any(ResourceClass)\r\n by RequestId\r\n| summarize //Session_ID=any(Session_ID), \r\n//Submit_Time=any(Submit_Time) ,\r\nStart_Time=any(Start_Time), End_Time=any(End_Time),Command=any(Command),Status=any(Status),Statement_Type=any(Statement_Type),Resource_class=any(Resource_class) by Request_ID\r\n//| order by Step_Elapsed_Min desc\r\n| extend Request_Elapsed_Min = round((End_Time - Start_Time)/1m, 2)\r\n| project-rename ReqStatus = Status, ReqStart = Start_Time, ReqEnd = End_Time\r\n) on Request_ID\r\n| project-reorder //Session_ID, \r\nRequest_ID, Request_Elapsed_Min, ReqStart, ReqEnd, ReqStatus,StepIndex, OperationType, RowCount,Weighted_cnt,Step_Elapsed_Min, StepStart, StepEnd, StepStatus, Statement_Type, Command, Resource_class\r\n| order by Weighted_cnt desc\r\n| limit 20", "size": 3, "showAnalytics": true, "title": "20 Largest Query Steps by Most Rows Moved", "timeContextFromParameter": "TimeRange", "exportFieldName": "Request_ID1", "exportParameterName": "RequestID", "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "sortBy": [ { "itemKey": "Weighted_cnt", "sortOrder": 2 } ] }, "sortBy": [ { "itemKey": "Weighted_cnt", "sortOrder": 2 } ] }, "showPin": true, "name": "query - 1" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databaseResourceName = '{DatabaseResourceName}';\r\n//Long-Running Queries - Just Actual Queries\r\n//If 'Command' is empty - you need to set a bigger time window, the older record with the command is outside of your window\r\nSynapseSqlPoolExecRequests\r\n| where _ResourceId == databaseResourceName\r\n| where StatementType !in ('Batch','Execute')\r\n| summarize //Session_ID=any(SessionId),\r\n Request_ID=any(RequestId),\r\n Start_Time=max(StartTime),\r\n End_Time=max(EndTime),\r\n Command=any(Command),\r\n Status=min(Status), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType),\r\n Resource_class=any(ResourceClass)\r\n by RequestId\r\n| summarize ElapsedTime_min=bin(anyif(((End_Time - Start_Time)/1m),Start_Time > ago(30d)),1),\r\n Start_Time=any(Start_Time), \r\n End_Time=any(End_Time),\r\n Command=any(Command),\r\n Status=any(Status),\r\n Statement_Type=any(Statement_Type)\r\n ,Resource_class=any(Resource_class) \r\n by Request_ID\r\n| where Request_ID == '{RequestID}' and Request_ID != ''\r\n\r\n", "size": 4, "showAnalytics": true, "title": "Selected Query", "noDataMessage": "Select a query above to view details", "noDataMessageStyle": 4, "timeContextFromParameter": "TimeRange", "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "35%" } } ] } }, "showPin": true, "name": "query - 6" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolRequestSteps \r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where RequestId == '{RequestID}' and RequestId != '' //Put your QueryID here\r\n| where Status != 'Running'\r\n| summarize max(StartTime),max(EndTime),max(RequestId),max(OperationType),max(RowCount),max(Command),max(Status) by StepIndex\r\n| order by StepIndex asc", "size": 3, "showAnalytics": true, "title": "Query Plan", "noDataMessage": "Select a query above to view the plan", "noDataMessageStyle": 4, "timeContextFromParameter": "TimeRange", "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "showPin": true, "name": "query - 7" } ] }, "conditionalVisibilities": [ { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "TempDB" }, { "parameterName": "DiagnosticsState", "comparison": "isEqualTo", "value": "enabled" } ], "name": "TempDBGroup" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 1, "content": { "json": "## Search Criteria\r\nUse the following fields to search either using a query text snippet or using a Request ID. If using a query text snippet, try to keep it as simple as possible becuase minor changes in formatting may cause your queries not to show up in the results. It's best to pick something like a table name, then choose the proper query from the list that will populate. " }, "customWidth": "50", "name": "text - 4" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "4b98dd26-4ccf-420e-a990-8d015f27fb76", "version": "KqlParameterItem/1.0", "name": "SampleQID", "type": 1, "value": "999", "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 } }, { "id": "d5524dd5-cf7e-41cf-beb3-474b3290289e", "version": "KqlParameterItem/1.0", "name": "RequestId", "type": 1, "value": "", "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 } } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "initializeQueryInvestigationParameters" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "0c2128d0-d979-4562-a28c-e7ceb955f126", "version": "KqlParameterItem/1.0", "name": "RequestId", "type": 1, "value": "", "label": "Request Id Search" }, { "id": "29880874-2d41-4bd5-bf22-3e47ae8b1145", "version": "KqlParameterItem/1.0", "name": "QueryTextSnippet", "type": 1, "value": "", "timeContext": { "durationMs": 86400000 } } ], "style": "formVertical", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "customWidth": "60", "name": "parameters - 3" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolExecRequests\r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where StatementType !in ('Batch','Execute')\r\n| summarize \r\n Request_ID=max(RequestId), \r\n Start_Time=max(StartTime),\r\n End_Compile_Time=max(EndCompileTime), \r\n End_Time=max(EndTime), \r\n QueryText = any(Command), \r\n Last_Status=min(Status),\r\n Statement_Type=max(StatementType),\r\n Resource_class=max(ResourceClass) \r\n by RequestId\r\n| extend Elapsed_Time_s=(End_Time - Start_Time)/1s\r\n| where QueryText has '{QueryTextSnippet}'\r\nand RequestId has '{RequestId}'\r\n| summarize \r\n Executions = count(),\r\n SampleQID = any(RequestId),\r\n Elapsed_Time_s=max(Elapsed_Time_s)\r\n by QueryText\r\n| order by Elapsed_Time_s\r\n\r\n\r\n\r\n", "size": 0, "showAnalytics": true, "title": "Matching Queries", "timeContextFromParameter": "TimeRange", "exportedParameters": [ { "fieldName": "SampleQID", "parameterName": "SampleQID" }, { "fieldName": "SampleQID", "parameterName": "RequestId", "parameterType": 1 }, { "fieldName": "QueryText", "parameterName": "QueryText", "parameterType": 1 } ], "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "50%" } } ], "sortBy": [ { "itemKey": "Elapsed_Time_s", "sortOrder": 2 } ] }, "sortBy": [ { "itemKey": "Elapsed_Time_s", "sortOrder": 2 } ] }, "showPin": true, "name": "query - 0" }, { "type": 1, "content": { "json": "## DSQL Command " }, "conditionalVisibility": { "parameterName": "QueryText", "comparison": "isNotEqualTo" }, "name": "text - 8" }, { "type": 1, "content": { "json": "```{QueryText}```\r\n" }, "conditionalVisibility": { "parameterName": "QueryText", "comparison": "isNotEqualTo" }, "name": "ShowQueryText", "styleSettings": { "showBorder": true } }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolExecRequests\r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where StatementType !in ('Batch','Execute')\r\n| where RequestId == '{SampleQID}'\r\n| summarize \r\n Request_ID=max(RequestId), \r\n Start_Time=max(StartTime),\r\n End_Compile_Time=max(EndCompileTime), \r\n End_Time=max(EndTime), \r\n Command=max(Command), \r\n Last_Status=min(Status),\r\n Statement_Type=max(StatementType),\r\n Resource_class=max(ResourceClass) \r\n by RequestId\r\n| extend elapsedTime_sec = iif(End_Time > ago(365d),(End_Time - Start_Time)/1s,real(null)) \r\n| join kind=inner\r\n (SynapseSqlPoolExecRequests\r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where StatementType !in ('Batch','Execute')\r\n | summarize \r\n Request_ID=max(RequestId), \r\n Start_Time=max(StartTime),\r\n End_Compile_Time=max(EndCompileTime), \r\n End_Time=max(EndTime), \r\n Command=max(Command), \r\n Last_Status=min(Status),\r\n Statement_Type=max(StatementType),\r\n Resource_class=max(ResourceClass) \r\n by RequestId\r\n //| extend elapsedTime_sec = (End_Time - Start_Time)/1s\r\n | extend elapsedTime_sec = iif(End_Time > ago(365d),(End_Time - Start_Time)/1s,real(null)) \r\n )\r\non Command \r\n| project Request_ID1,Start_Time1,End_Compile_Time1,End_Time1,Last_Status1,Statement_Type1,Resource_class1,elapsedTime_sec1\r\n", "size": 0, "showAnalytics": true, "title": "All Executions of Selected Query Text", "noDataMessage": "Select a query above to see individual executions", "noDataMessageStyle": 4, "timeContextFromParameter": "TimeRange", "exportFieldName": "Request_ID1", "exportParameterName": "RequestId", "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "sortBy": [] }, "showPin": true, "name": "query - 0 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolRequestSteps \r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where RequestId == '{RequestId}' and RequestId != ''\r\n| where Status != 'Running'\r\n| summarize max(StartTime),max(EndTime),max(RequestId),max(OperationType),max(RowCount),max(Command),max(Status) by StepIndex\r\n| order by StepIndex asc", "size": 3, "showAnalytics": true, "title": "Query Plan for Selected Query", "noDataMessage": "Select a Query Above to See the Query Plan", "noDataMessageStyle": 4, "timeContextFromParameter": "TimeRange", "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 0 - Copy - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolExecRequests\r\n | where StatementType =='CreateStatistics'\r\n | where _ResourceId has '{DatabaseName}'\r\n | summarize \r\n Root_Query_Id=max(RootQueryId), \r\n Start_Time=max(StartTime),\r\n End_Compile_Time=max(EndCompileTime), \r\n End_Time=max(EndTime), \r\n Command=max(Command), \r\n Last_Status=min(Status),\r\n Statement_Type=max(StatementType),\r\n Resource_class=max(ResourceClass) \r\n by RequestId\r\n | where Root_Query_Id == '{RequestId}'", "size": 0, "showAnalytics": true, "title": "Triggered Auto-Stats Statements", "noDataMessage": "No triggered autostats statements found", "timeContextFromParameter": "TimeRange", "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Submit_Time", "formatter": 0, "numberFormat": { "unit": 0, "options": { "style": "decimal" } } }, { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "100ch" } } ] } }, "name": "All triggered auto-stats statements" } ] }, "conditionalVisibilities": [ { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "QueryInvestigation" }, { "parameterName": "DiagnosticsState", "comparison": "isEqualTo", "value": "enabled" } ], "name": "QueryInvestigationGroup", "styleSettings": { "showBorder": true } }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 1, "content": { "json": "All Charts on this page are based on the last 7 days of data", "style": "info" }, "customWidth": "25", "name": "text - 5" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "533ff6bb-97cd-4aaa-9372-171cad378bcd", "version": "KqlParameterItem/1.0", "name": "QueryText", "type": 1, "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 } }, { "id": "99de0056-d4f3-465e-a27e-599d69b23c77", "version": "KqlParameterItem/1.0", "name": "RequestId", "type": 1, "value": "999", "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 } } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "initializeTempDBVariables" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Build cache count by day\r\nlet databaseResourceName = '{DatabaseResourceName}';\r\n//Long-Running Queries - Just Actual Queries\r\n//If 'Command' is empty - you need to set a bigger time window, the older record with the command is outside of your window\r\nSynapseSqlPoolExecRequests\r\n| where _ResourceId == databaseResourceName\r\n| where StatementType == 'BuildReplicatedTableCache'\r\n| where Command != \"\"\r\n| where ResourceClass != \"\"\r\n| project Command,TimeGenerated,RequestId\r\n| summarize LastRebuild=max(TimeGenerated),RebuildCount=count(RequestId) by Command\r\n| order by RebuildCount desc\r\n| limit 15\r\n", "size": 3, "showAnalytics": true, "title": "Top 15 Most Rebuilds by Table", "noDataMessage": "No replicated table rebuilds found in the last 7 days", "noDataMessageStyle": 4, "timeContext": { "durationMs": 604800000 }, "exportFieldName": "Command", "exportParameterName": "QueryText", "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command_s", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "40%" } } ] } }, "showPin": true, "name": "query - 0" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Build cache count by day\r\nlet databaseResourceName = '{DatabaseResourceName}';\r\nSynapseSqlPoolExecRequests\r\n| where _ResourceId == databaseResourceName\r\n| where StatementType == 'BuildReplicatedTableCache'\r\n| where Command == \"{QueryText}\"\r\n| where ResourceClass != \"\"\r\n| project Command,TimeGenerated,RequestId\r\n| summarize count() by Command,bin(TimeGenerated,24h)\r\n| limit 20\r\n| render timechart", "size": 0, "showAnalytics": true, "title": "Rebuilds per Day for Selected Table", "noDataMessage": "Select a query above to see runs by day", "noDataMessageStyle": 4, "timeContext": { "durationMs": 604800000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "chartSettings": { "group": "Command_s", "createOtherGroup": 20, "ySettings": { "min": 0 } } }, "showPin": true, "name": "query - 0 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Build cache count by day\r\nlet databaseResourceName = '{DatabaseResourceName}';\r\n//Long-Running Queries - Just Actual Queries\r\n//If 'Command' is empty - you need to set a bigger time window, the older record with the command is outside of your window\r\nSynapseSqlPoolExecRequests\r\n| where _ResourceId == databaseResourceName\r\n| where StatementType == 'BuildReplicatedTableCache'\r\n| where Command != \"\"\r\n| where ResourceClass != \"\"\r\n| project Command,TimeGenerated,RequestId\r\n| summarize count() by Command, bin(TimeGenerated,24h)\r\n//| where count_ > 7\r\n| order by count_ desc\r\n\r\n", "size": 2, "showAnalytics": true, "title": "Rebuild Count by Table by Day", "noDataMessage": " Only tables with more than 7 total rebuilds will show up. If no talbes with that many rebuilds are found this chart will be empty", "noDataMessageStyle": 4, "timeContext": { "durationMs": 604800000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "categoricalbar", "gridSettings": { "sortBy": [ { "itemKey": "count_", "sortOrder": 1 } ] }, "sortBy": [ { "itemKey": "count_", "sortOrder": 1 } ], "tileSettings": { "showBorder": false, "titleContent": { "columnMatch": "Command_s", "formatter": 1 }, "leftContent": { "columnMatch": "count_", "formatter": 12, "formatOptions": { "palette": "auto" }, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "graphSettings": { "type": 0, "topContent": { "columnMatch": "Command_s", "formatter": 1 }, "centerContent": { "columnMatch": "count_", "formatter": 1, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "chartSettings": { "group": "Command_s", "createOtherGroup": 99, "showDataPoints": true } }, "showPin": true, "name": "query - 0 - Copy - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databaseResourceName = '{DatabaseResourceName}';\r\n//Long-Running Queries - Just Actual Queries\r\n//If 'Command' is empty - you need to set a bigger time window, the older record with the command is outside of your window\r\nSynapseSqlPoolExecRequests\r\n| where _ResourceId == databaseResourceName\r\n| where StatementType == 'BuildReplicatedTableCache'\r\n| summarize Start_Time=max(StartTime), End_Time=max(EndTime), Command=max(Command), Statement_Type=max(StatementType), Resource_class=max(ResourceClass) by RequestId\r\n| join kind= inner\r\n(\r\n SynapseSqlPoolExecRequests\r\n | where _ResourceId == databaseResourceName\r\n | where StatementType == 'BuildReplicatedTableCache'\r\n | where StatementType == 'BuildReplicatedTableCache'\r\n | where EndTime > ago(7d)\r\n | where StartTime > ago(7d)\r\n | extend elapsedTime_min = (EndTime - StartTime)/1m\r\n | order by elapsedTime_min desc\r\n | project RequestId,elapsedTime_min \r\n)\r\non RequestId\r\n| order by elapsedTime_min desc\r\n| project RequestId,Start_Time,End_Time,Elapsed_Time=round(elapsedTime_min,1) ,Command\r\n| limit 15\r\n", "size": 3, "showAnalytics": true, "title": "Top 15 Elapsed Time per Rebuild", "noDataMessageStyle": 4, "timeContext": { "durationMs": 604800000 }, "exportFieldName": "RequestId", "exportParameterName": "RequestId", "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "40%" } } ] } }, "showPin": true, "name": "query - 3" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": " let databaseResourceName = '{DatabaseResourceName}';\r\nSynapseSqlPoolRequestSteps \r\n| where _ResourceId == databaseResourceName\r\n| where RequestId == '{RequestId}'\r\n| where Status != 'Running'\r\n| summarize max(StartTime),max(EndTime),max(RequestId),max(OperationType),max(RowCount),max(Command),max(Status) by StepIndex\r\n| order by StepIndex asc", "size": 3, "showAnalytics": true, "title": "Query Plan for Selected Query", "noDataMessage": "Select a query above to view plan", "noDataMessageStyle": 4, "timeContext": { "durationMs": 604800000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "showPin": true, "name": "query - 4" } ] }, "conditionalVisibilities": [ { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "ReplicatedTables" }, { "parameterName": "DiagnosticsState", "comparison": "isEqualTo", "value": "enabled" } ], "name": "ReplicatedTablesGroup" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 10, "content": { "chartId": "workbook72446028-6edb-4cb0-8952-e0c13bda488f", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.synapse/workspaces/sqlpools", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 31597002, "endTime": "2022-01-21T03:06:58.357Z" }, "metrics": [ { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool Workload management-WLGAllocationBySystemPercent", "aggregation": 3, "splitBy": "WorkloadGroup" } ], "title": "Workload Group Allocation By System Percent", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "name": "metric - 0" }, { "type": 10, "content": { "chartId": "workbookc898119a-7381-469d-b51a-d505b4f80e73", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.synapse/workspaces/sqlpools", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 31597002, "endTime": "2022-01-21T03:06:58.357Z" }, "metrics": [ { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool Workload management-WLGActiveQueries", "aggregation": 1, "splitBy": null } ], "title": "Query Count by Workload Group", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "name": "metric - 1" }, { "type": 10, "content": { "chartId": "workbook8d175f6c-427b-47fc-85ea-37edd0be707c", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.synapse/workspaces/sqlpools", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 31597002, "endTime": "2022-01-21T03:06:58.357Z" }, "metrics": [ { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-WLGQueuedQueries", "aggregation": 1, "splitBy": "WorkloadGroup" } ], "title": "Queued Queries by Workload Group", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "name": "Queued Queries by Workload Group" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "parameters": [ { "id": "6f50577d-7b00-4e4a-acf9-d45c7a5ee813", "version": "KqlParameterItem/1.0", "name": "WorkloadGroupName", "type": 2, "multiSelect": true, "quote": "'", "delimiter": ",", "query": "SynapseSqlPoolExecRequests \r\n| where _ResourceId == '{DatabaseResourceName}'\r\n and ResourceClass != \"\"\r\n| distinct ResourceClass", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "typeSettings": { "additionalResourceOptions": [ "value::all" ], "showDefault": false }, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "defaultValue": "value::all", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 2" }, { "type": 10, "content": { "chartId": "workbook3da1d18a-1bf5-46c5-b3b7-211f71d329cc", "version": "MetricsItem/2.0", "size": 0, "chartType": 2, "resourceType": "microsoft.synapse/workspaces/sqlpools", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 31597002, "endTime": "2022-01-21T03:06:58.357Z" }, "metrics": [ { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-WLGActiveQueries", "aggregation": 1, "splitBy": null }, { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-WLGQueuedQueries", "aggregation": 1 }, { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-WLGAllocationBySystemPercent", "aggregation": 3 }, { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-WLGEffectiveCapResourcePercent", "aggregation": 3 } ], "filters": [ { "id": "5", "key": "WorkloadGroup", "operator": 0, "valueParam": "WorkloadGroupName" } ], "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "name": "metric - 3" } ] }, "conditionalVisibilities": [ { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "WorkloadManagement" }, { "parameterName": "DiagnosticsState", "comparison": "isEqualTo", "value": "enabled" } ], "name": "WorkloadManagementGroup" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 1, "content": { "json": "## Select a Principal or Application name to filter results - leave to 'unset' to view all results\r\nSQL Auditing must be enabled and sending to the same Log Analytics Workspace for this page to work. " }, "name": "text - 5" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "parameters": [ { "id": "8d25c043-d1ff-4546-a1fa-f4bcbfdab8af", "version": "KqlParameterItem/1.0", "name": "User", "type": 2, "description": "User to filter subsequent queries - leave to 'unset' for all users", "query": "SQLSecurityAuditEvents \r\n| where LogicalServerName == '{LogicalServerName}'\r\n| summarize by ServerPrincipalName", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "value": null, "typeSettings": { "additionalResourceOptions": [], "showDefault": false }, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "id": "aa766d64-693f-4024-b4a4-b5b56b28376b", "version": "KqlParameterItem/1.0", "name": "Application", "type": 2, "query": "SQLSecurityAuditEvents \r\n| where LogicalServerName == '{LogicalServerName}'\r\n| summarize by ApplicationName", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "value": null, "typeSettings": { "additionalResourceOptions": [], "showDefault": false }, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "customWidth": "30", "name": "parameters - 1" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SQLSecurityAuditEvents \r\n| where LogicalServerName == '{LogicalServerName}'\r\n| where DurationMs > 0\r\n| extend duration_seconds = DurationMs /1000.0\r\n| where Statement != 'select @@version'\r\n| where Statement != 'SELECT @@SPID;'\r\n| where ServerPrincipalName has '{User}'\r\n| where ApplicationName has '{Application}'\r\n| project ServerPrincipalName, EventTime, LogicalServerName, DurationMs, duration_seconds, AffectedRows, Statement, ApplicationName\r\n| summarize duration_seconds = round(sum(duration_seconds)) , query_count = count() by EventDay = bin(EventTime,1d), UserName = ServerPrincipalName, Application = ApplicationName \r\n| order by EventDay, duration_seconds desc", "size": 0, "showAnalytics": true, "title": "Query Summary for Selected User {User} {Application}", "noDataMessage": "Select a user to see query activity", "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "showPin": true, "name": "query - 0 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SQLSecurityAuditEvents \r\n| where LogicalServerName == '{LogicalServerName}'\r\n| where DurationMs > 0\r\n| extend duration_seconds = DurationMs /1000.0\r\n| where Statement != 'select @@version'\r\n| where Statement != 'SELECT @@SPID;'\r\n| where ServerPrincipalName has '{User}'\r\n| where ApplicationName has '{Application}'\r\n| project ServerPrincipalName, EventTime, LogicalServerName, DurationMs, duration_seconds, AffectedRows, Statement, ApplicationName\r\n| summarize duration_seconds = round(sum(duration_seconds)) , query_count = count() by EventDay = bin(EventTime,1d), UserName = ServerPrincipalName, Application = ApplicationName \r\n| order by EventDay, duration_seconds desc", "size": 0, "showAnalytics": true, "title": "Query Summary for Selected User {User} {Application}", "noDataMessage": "Select a user to see query activity", "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "unstackedbar", "tileSettings": { "showBorder": false, "titleContent": { "columnMatch": "UserName", "formatter": 1 }, "leftContent": { "columnMatch": "duration_seconds", "formatter": 12, "formatOptions": { "palette": "auto" }, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "graphSettings": { "type": 0, "topContent": { "columnMatch": "UserName", "formatter": 1 }, "centerContent": { "columnMatch": "duration_seconds", "formatter": 1, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "chartSettings": { "xAxis": "UserName" }, "mapSettings": { "locInfo": "LatLong", "sizeSettings": "duration_seconds", "sizeAggregation": "Sum", "legendMetric": "duration_seconds", "legendAggregation": "Sum", "itemColorSettings": { "type": "heatmap", "colorAggregation": "Sum", "nodeColorField": "duration_seconds", "heatmapPalette": "greenRed" } } }, "showPin": true, "name": "query - 0 - Copy - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SQLSecurityAuditEvents \r\n | where LogicalServerName == \"{LogicalServerName}\"\r\n | where DurationMs > 0\r\n | extend duration_seconds = DurationMs /1000.0\r\n | where Statement != 'select @@version'\r\n | where Statement != 'SELECT @@SPID;'\r\n | where ServerPrincipalName has '{User}'\r\n | where ApplicationName has '{Application}'\r\n | project DatabaseName= DatabaseName, UserName= ServerPrincipalName, EventTime= EventTime, Host= HostName, duration_seconds = round(duration_seconds), Statement, QuerySource = ApplicationName , AffectedRows\r\n | project-reorder DatabaseName, UserName, Host, EventTime, duration_seconds, Statement, QuerySource\r\n\r\n\r\n\r\n\r\n\r\n", "size": 0, "showAnalytics": true, "title": "Queries {User} {Application}", "noDataMessage": "Select a user to see query activity", "timeContextFromParameter": "TimeRange", "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "showPin": true, "name": "query - 0 - Copy - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SQLSecurityAuditEvents \r\n | where LogicalServerName == \"{LogicalServerName}\"\r\n | where DurationMs > 0\r\n | extend duration_seconds = DurationMs /1000.0\r\n | where Statement != 'select @@version'\r\n | where Statement != 'SELECT @@SPID;'\r\n | where ServerPrincipalName has '{User}'\r\n | where ApplicationName has '{Application}'\r\n | project DatabaseName= DatabaseName, UserName= ServerPrincipalName, EventTime= EventTime, Host= HostName, duration_seconds = round(duration_seconds), Statement, QuerySource = ApplicationName , AffectedRows\r\n | project-reorder AffectedRows,DatabaseName, UserName, Host, EventTime, duration_seconds, Statement, QuerySource\r\n\r\n\r\n\r\n\r\n\r\n", "size": 0, "showAnalytics": true, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "barchart", "chartSettings": { "xAxis": "Host", "group": "UserName", "createOtherGroup": null, "showLegend": true } }, "showPin": true, "name": "query - 6" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SQLSecurityAuditEvents\r\n| where LogicalServerName == \"{LogicalServerName}\"\r\n | where DurationMs > 0\r\n| extend Duration = round(DurationMs /1000.0)\r\n| extend TimeBin = case (datetime_part(\"Hour\",TimeGenerated) in (6,7,8,9,10,11,12), \"Morning_6-12\", datetime_part(\"Hour\",TimeGenerated) in (13,14,15,16,17,18), \"Afternoon_12-18\", \"Overnight_18-6\")\r\n| where ServerPrincipalName has '{User}'\r\n| where ApplicationName has '{Application}'\r\n| summarize QueryDuration = sum(Duration) by EventTime = bin(EventTime, 1d), TimeBin", "size": 0, "showAnalytics": true, "title": "Query Activity by time - sum(Duration) {User} {Application}", "noDataMessage": "Select a user to see query activity", "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "barchart" }, "showPin": true, "name": "query - 0 - Copy" } ] }, "conditionalVisibilities": [ { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "QueryAudit" }, { "parameterName": "AuditingState", "comparison": "isEqualTo", "value": "enabled" } ], "name": "QueryAuditGroup", "styleSettings": { "showBorder": true } }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "7fa3187e-9225-4faa-8f80-dc1bc40c5aab", "version": "KqlParameterItem/1.0", "name": "RequestId1", "type": 1, "value": "" } ], "style": "above", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "customWidth": "50", "name": "parameters - 3 - Copy" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "315fc476-469a-4d8d-b421-028d1113ab06", "version": "KqlParameterItem/1.0", "name": "RequestId2", "type": 1, "value": "", "timeContext": { "durationMs": 86400000 } } ], "style": "above", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "customWidth": "50", "name": "parameters - 2" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 9, "content": { "version": "KqlParameterItem/1.0", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "parameters": [ { "id": "1537c5b3-0b6c-4b1d-89be-946cd8268020", "version": "KqlParameterItem/1.0", "name": "QueryText1", "type": 1, "query": "SynapseSqlPoolExecRequests\r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where StatementType !in ('Batch','Execute') and RequestId == '{RequestId1}'\r\n| summarize max(Command)", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" } ], "style": "above", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 5" }, { "type": 1, "content": { "json": "#### {RequestId1} Query Text" }, "conditionalVisibility": { "parameterName": "RequestId1", "comparison": "isNotEqualTo" }, "name": "text - 5" }, { "type": 1, "content": { "json": "```{QueryText1}```" }, "conditionalVisibility": { "parameterName": "RequestId1", "comparison": "isNotEqualTo" }, "name": "text - 3" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolExecRequests\r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where StatementType !in ('Batch','Execute') and RequestId == '{RequestId1}'\r\n| summarize \r\n Request_ID=any(RequestId),\r\n Start_Time=max(StartTime),\r\n End_Time=max(EndTime),\r\n //Command=any(Command),\r\n Status=min(Status), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType),\r\n Resource_class=any(ResourceClass)\r\n by RequestId\r\n| summarize Start_Time=any(Start_Time), End_Time=any(End_Time),ElapsedTime_min=anyif((End_Time - Start_Time)/1m,Start_Time > ago(30d))\r\n//,Command=any(Command)\r\n,Status=any(Status),Statement_Type=any(Statement_Type),Resource_class=any(Resource_class) by Request_ID\r\n| project ElapsedTime_min\r\n//,Command\r\n,Resource_class,Start_Time\r\n//,End_Time\r\n,Statement_Type,Status\r\n", "size": 4, "title": "Exec Requests", "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "conditionalVisibility": { "parameterName": "RequestId1", "comparison": "isNotEqualTo" }, "name": "query - 2" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolRequestSteps \r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where RequestId == '{RequestId1}' and RequestId != ''\r\n| summarize StartTime=max(StartTime)\r\n ,EndTime=max(EndTime)\r\n ,RequestID=max(RequestId)\r\n ,Operation=max(OperationType)\r\n ,RowCount=max(RowCount)\r\n ,Command=max(Command)\r\n ,Status=min(Status)\r\n by StepIndex\r\n| order by StepIndex asc\r\n| project StartTime,EndTime,Operation,RowCount,Command,Status,StepIndex", "size": 3, "title": "Request Steps", "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "conditionalVisibility": { "parameterName": "RequestId1", "comparison": "isNotEqualTo" }, "name": "StepQueryRequest1", "styleSettings": { "margin": "0", "padding": "10px" } }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolExecRequests\r\n | where StatementType =='CreateStatistics'\r\n | where _ResourceId has '{DatabaseName}'\r\n | summarize \r\n Root_Query_Id=max(RootQueryId), \r\n Start_Time=max(StartTime),\r\n End_Compile_Time=max(EndCompileTime), \r\n End_Time=max(EndTime), \r\n Command=max(Command), \r\n Last_Status=min(Status),\r\n Statement_Type=max(StatementType),\r\n Resource_class=max(ResourceClass) \r\n by RequestId\r\n | where Root_Query_Id == '{RequestId1}'", "size": 0, "title": "Triggered Auto-Stats Statements", "noDataMessage": "No triggered autostats statements found", "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Submit_Time", "formatter": 0, "numberFormat": { "unit": 0, "options": { "style": "decimal" } } }, { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "100ch" } } ], "sortBy": [ { "itemKey": "End_Time", "sortOrder": 2 } ] }, "sortBy": [ { "itemKey": "End_Time", "sortOrder": 2 } ] }, "conditionalVisibility": { "parameterName": "RequestId1", "comparison": "isNotEqualTo" }, "name": "All triggered auto-stats statements" } ] }, "customWidth": "50", "name": "RequestId1Group", "styleSettings": { "showBorder": true } }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 9, "content": { "version": "KqlParameterItem/1.0", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "parameters": [ { "id": "1537c5b3-0b6c-4b1d-89be-946cd8268020", "version": "KqlParameterItem/1.0", "name": "QueryText2", "type": 1, "query": "SynapseSqlPoolExecRequests\r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where StatementType !in ('Batch','Execute') and RequestId == '{RequestId2}'\r\n| summarize max(Command)", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" } ], "style": "above", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 5" }, { "type": 1, "content": { "json": "#### {RequestId2} Query Text" }, "conditionalVisibility": { "parameterName": "RequestId2", "comparison": "isNotEqualTo" }, "name": "text - 5" }, { "type": 1, "content": { "json": "```{QueryText2}```" }, "conditionalVisibility": { "parameterName": "RequestId2", "comparison": "isNotEqualTo" }, "name": "text - 4" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolExecRequests\r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where StatementType !in ('Batch','Execute') and RequestId == '{RequestId2}'\r\n| summarize \r\n Request_ID=any(RequestId),\r\n Start_Time=max(StartTime),\r\n End_Time=max(EndTime),\r\n //Command=any(Command),\r\n Status=min(Status), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType),\r\n Resource_class=any(ResourceClass)\r\n by RequestId\r\n| summarize Start_Time=any(Start_Time), End_Time=any(End_Time),ElapsedTime_min=anyif((End_Time - Start_Time)/1m,Start_Time > ago(30d))\r\n//,Command=any(Command)\r\n,Status=any(Status),Statement_Type=any(Statement_Type),Resource_class=any(Resource_class) by Request_ID\r\n| project ElapsedTime_min\r\n//,Command\r\n,Resource_class,Start_Time\r\n//,End_Time\r\n,Statement_Type,Status\r\n", "size": 4, "title": "Exec Requests", "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "conditionalVisibility": { "parameterName": "RequestId2", "comparison": "isNotEqualTo" }, "name": "query - 2 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolRequestSteps \r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where RequestId == '{RequestId2}' and RequestId != ''\r\n| summarize StartTime=max(StartTime)\r\n ,EndTime=max(EndTime)\r\n ,RequestID=max(RequestId)\r\n ,Operation=max(OperationType)\r\n ,RowCount=max(RowCount)\r\n ,Command=max(Command)\r\n ,Status=min(Status)\r\n by StepIndex\r\n| order by StepIndex asc\r\n| project StartTime,EndTime,Operation,RowCount,Command,Status,StepIndex", "size": 3, "title": "Request Steps", "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "conditionalVisibility": { "parameterName": "RequestId2", "comparison": "isNotEqualTo" }, "name": "query - 4 - Copy", "styleSettings": { "padding": "10px" } }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolExecRequests\r\n | where StatementType =='CreateStatistics'\r\n | where _ResourceId has '{DatabaseName}'\r\n | summarize \r\n Root_Query_Id=max(RootQueryId), \r\n Start_Time=max(StartTime),\r\n End_Compile_Time=max(EndCompileTime), \r\n End_Time=max(EndTime), \r\n Command=max(Command), \r\n Last_Status=min(Status),\r\n Statement_Type=max(StatementType),\r\n Resource_class=max(ResourceClass) \r\n by RequestId\r\n | where Root_Query_Id == '{RequestId2}'", "size": 0, "title": "Triggered Auto-Stats Statements", "noDataMessage": "No triggered autostats statements found", "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Submit_Time", "formatter": 0, "numberFormat": { "unit": 0, "options": { "style": "decimal" } } }, { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "100ch" } } ] } }, "conditionalVisibility": { "parameterName": "RequestId2", "comparison": "isNotEqualTo" }, "name": "All triggered auto-stats statements" } ] }, "customWidth": "50", "name": "RequestId2Group", "styleSettings": { "showBorder": true } } ] }, "conditionalVisibilities": [ { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "QueryComparison" }, { "parameterName": "DiagnosticsState", "comparison": "isEqualTo", "value": "enabled" } ], "name": "QueryComparison" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 1, "content": { "json": "## This tab is used to determine what statements triggerred autostats creation jobs. \r\nThe flow of autostats creation is as follows\r\n1. Query Submit Time\r\n2. \tCreate Statistics submit Time\r\n3. \tCreate Statistics end Time\r\n4. Query end_compile_time\r\n5. Query Start_Time\r\n6. Query End_Time\r\n\r\nFurther, if multiple stats are created, then the creation of all stats for this query will fall between query submit_time and end_compile_time. \r\n\r\nThe charts on this page allow you to search for an autostats job by requestID or my snippet of the autostats statement text, which can just be the schema, table, or column name. Then it will show you all commands that include that request ID or text. It will then show you all statements in the create stat statement because the query we are trying to identify will wait for all of those stats creations to complete before proceeding. \r\n\r\nThe last chart will list the statement that triggered the stats creation. " }, "name": "text - 6" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "df5b9b85-4188-4f2c-88cb-1369e09f6742", "version": "KqlParameterItem/1.0", "name": "RootQueryId", "type": 1, "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 } }, { "id": "560c9ec5-6341-4fa1-9ce6-35ff010151b1", "version": "KqlParameterItem/1.0", "name": "RequestId", "type": 1, "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 } } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 5" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "0911bd4b-d471-480b-bdf4-1a2d4ba1ea6e", "version": "KqlParameterItem/1.0", "name": "RequestIdSearch", "type": 1, "value": "", "label": "RequestId for AutoStats Job" }, { "id": "c12e6495-4fd1-473c-8ffc-0bf502f54706", "version": "KqlParameterItem/1.0", "name": "QueryTextSnippet", "type": 1, "value": "", "timeContext": { "durationMs": 86400000 }, "label": "Snippet of autostats creation statement (Schema, table or column)" } ], "style": "formVertical", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "customWidth": "60", "name": "parameters - 3 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolExecRequests\r\n | where StatementType =='CreateStatistics'\r\n | where _ResourceId has '{DatabaseName}'\r\n| summarize \r\n Root_Query_Id=max(RootQueryId), \r\n Start_Time=max(StartTime),\r\n End_Time=max(EndTime), \r\n Command=max(Command), \r\n Last_Status=min(Status),\r\n Statement_Type=max(StatementType)\r\n by RequestId\r\n| where Command has 'CREATE STATISTICS _wa_sys'\r\n| where Command has '{QueryTextSnippet}' and RequestId has '{RequestIdSearch}'\r\n//| extend elapsedTime_sec = iif(End_Time > ago(365d),(End_Time - Submit_Time)/1s,real(null)) \r\n//| extend CompileTime_sec = (End_Compile_Time - Submit_Time)/1s\r\n//| order by elapsedTime_sec\r\n//| summarize \r\n // Executions = count(),\r\n // Max_Elapsed_Time_sec = bin(max(elapsedTime_sec),1),\r\n // Min_Elapsed_Time_sec = bin(min(elapsedTime_sec),1),\r\n // Variability_sec=bin((max(elapsedTime_sec)-min(elapsedTime_sec)),1),\r\n // SampleQID = any(RequestId),\r\n // SampleSessionID = any(Session_ID)\r\n // by Command\r\n//| order by Max_Elapsed_Time_sec\r\n\r\n\r\n", "size": 0, "showAnalytics": true, "title": "Matching Autostats Queries", "noDataMessageStyle": 4, "timeContextFromParameter": "TimeRange", "exportedParameters": [ { "fieldName": "RequestId", "parameterName": "RequestId", "parameterType": 1 }, { "fieldName": "Root_Query_Id", "parameterName": "RootQueryId", "parameterType": 1 } ], "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "50%" } } ], "sortBy": [ { "itemKey": "Command", "sortOrder": 1 } ] }, "sortBy": [ { "itemKey": "Command", "sortOrder": 1 } ] }, "name": "query - 0 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolExecRequests\r\n | where StatementType !='CreateStatistics'\r\n | where _ResourceId has '{DatabaseName}'\r\n | where RequestId == '{RootQueryId}'\r\n | summarize \r\n Start_Time=max(StartTime),\r\n End_Compile_Time=max(EndCompileTime), \r\n End_Time=max(EndTime), \r\n Command=max(Command), \r\n Last_Status=min(Status),\r\n Statement_Type=max(StatementType),\r\n Resource_class=max(ResourceClass) \r\n by RequestId", "size": 3, "showAnalytics": true, "title": "Statement that Triggered Selected Autostat", "noDataMessage": "Select an autostats query above to see what query triggered it", "noDataMessageStyle": 4, "timeContextFromParameter": "TimeRange", "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "150ch" } } ], "sortBy": [ { "itemKey": "Command", "sortOrder": 1 } ] }, "sortBy": [ { "itemKey": "Command", "sortOrder": 1 } ] }, "name": "query - 0 - Copy - Copy - Copy - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolExecRequests\r\n | where StatementType =='CreateStatistics'\r\n | where _ResourceId has '{DatabaseName}'\r\n| summarize \r\n Root_Query_Id=max(RootQueryId), \r\n Start_Time=max(StartTime),\r\n End_Time=max(EndTime), \r\n Command=max(Command), \r\n Last_Status=min(Status),\r\n Statement_Type=max(StatementType)\r\n by RequestId\r\n| where Command has 'CREATE STATISTICS _wa_sys'\r\n| where Root_Query_Id == '{RootQueryId}'", "size": 3, "showAnalytics": true, "title": "All Stats Statements Triggered by selected Query", "noDataMessageStyle": 4, "timeContextFromParameter": "TimeRange", "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 13" } ] }, "conditionalVisibilities": [ { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "Statistics" }, { "parameterName": "DiagnosticsState", "comparison": "isEqualTo", "value": "enabled" } ], "name": "statistics" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 1, "content": { "json": "" }, "customWidth": "60", "showPin": false, "name": "Image" }, { "type": 1, "content": { "json": "Enable SQL Auditing to get additional visibility into user activity against your SQL Pool\r\n\r\nThis section provides additional monitoring coverage that is based on SQL Audit logs.
\r\nIf you have not activated SQL Auditing for your dedeciated SQL Pool, you must enable them to go to the same Log Analytics workspace as the rest of your diagnostic settings for it to show up here. [Learn more](https://docs.microsoft.com/en-us/azure/azure-sql/database/auditing-overview)\r\n" }, "customWidth": "60", "name": "text - 2" }, { "type": 11, "content": { "version": "LinkItem/1.0", "style": "paragraph", "links": [ { "id": "f4df7a1e-2124-4620-9005-f9b66e47f550", "cellValue": "{DatabaseResourceName}", "linkTarget": "Resource", "linkLabel": "Configure Logs for Auditing >", "subTarget": "auditing", "preText": "", "postText": "", "style": "primary" } ] }, "customWidth": "70", "name": "links - 8" } ] }, "customWidth": "90", "name": "Onboarding Message - Not onboarded yet" } ] }, "conditionalVisibilities": [ { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "QueryAudit" }, { "parameterName": "AuditingState", "comparison": "isEqualTo", "value": "disabled" } ], "name": "AuditingDisabledGroup" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 1, "content": { "json": "" }, "customWidth": "60", "showPin": false, "name": "Image" }, { "type": 1, "content": { "json": "Get more visibility into the usage and performance of your Azure Synapse Dedicated SQL Pool\r\n\r\nThis section provides additional monitoring coverage that is based on diagnostic logs.
\r\n\r\nIf you have not activated monitoring in diagnostic settings, you must enable the **ExecRequests** and **RequestSteps** logs and send them to a Log Analytics workspace. You may choose to enable the **SQLSecurityAuditEvents** table at the same time to take full advantage of this monitoring workbook. [Learn more](https://docs.microsoft.com/en-us/azure/synapse-analytics/monitoring/how-to-monitor-using-azure-monitor#logs)" }, "customWidth": "60", "name": "text - 2" }, { "type": 11, "content": { "version": "LinkItem/1.0", "style": "paragraph", "links": [ { "id": "f4df7a1e-2124-4620-9005-f9b66e47f550", "cellValue": "{DatabaseResourceName}", "linkTarget": "Resource", "linkLabel": "Configure Logs for Monitoring >", "subTarget": "diagnostics", "preText": "", "postText": "", "style": "primary" } ] }, "customWidth": "70", "name": "links - 8" } ] }, "customWidth": "90", "name": "Onboarding Message - Not onboarded yet" } ] }, "conditionalVisibilities": [ { "parameterName": "GroupSelection", "comparison": "isNotEqualTo", "value": "QueryAudit" }, { "parameterName": "DiagnosticsState", "comparison": "isEqualTo", "value": "disabled" } ], "name": "DiagnosticsDisabledGroup" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 1, "content": { "json": "# Use this page to search the audit logs for a particular query\r\nYou can search using a combination of: \r\n* Date: Set the time range using the parameter at the top of the workbook\r\n* User: only show queries for the specified user\r\n* Application: only show queries submitted by the specified application\r\n* Query Text Snippet(s) - mutliple fields are provided, if you enter data into multiple fields then it will look for all of those values combined in the results\r\nYou can then sort your results in teh chart below by duration or affected rows to find what you are looking for.\r\n\r\nNOTE: query text is limited to the first 4,000 characters" }, "name": "text - 3" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "parameters": [ { "id": "8d25c043-d1ff-4546-a1fa-f4bcbfdab8af", "version": "KqlParameterItem/1.0", "name": "User", "type": 2, "description": "User to filter subsequent queries - leave to 'unset' for all users", "query": "SQLSecurityAuditEvents \r\n| where LogicalServerName == '{LogicalServerName}'\r\n| summarize by ServerPrincipalName", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "value": null, "typeSettings": { "additionalResourceOptions": [], "showDefault": false }, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "id": "aa766d64-693f-4024-b4a4-b5b56b28376b", "version": "KqlParameterItem/1.0", "name": "Application", "type": 2, "query": "SQLSecurityAuditEvents \r\n| where LogicalServerName == '{LogicalServerName}'\r\n| summarize by ApplicationName", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "value": null, "typeSettings": { "additionalResourceOptions": [], "showDefault": false }, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "customWidth": "30", "name": "parameters - 1" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "add4bc9a-505f-4d22-9ba2-882be91adde0", "version": "KqlParameterItem/1.0", "name": "QueryTextSnippet", "type": 1, "timeContext": { "durationMs": 86400000 }, "value": "" }, { "id": "b78f8304-3dad-4b47-a624-380f6664dc35", "version": "KqlParameterItem/1.0", "name": "QueryTextSnippet2", "type": 1, "timeContext": { "durationMs": 86400000 }, "value": "" }, { "id": "516249a7-52fe-4ec4-9826-6f1b756405a8", "version": "KqlParameterItem/1.0", "name": "QueryTextSnippet3", "type": 1, "timeContext": { "durationMs": 86400000 } } ], "style": "formHorizontal", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 7" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SQLSecurityAuditEvents \r\n | where LogicalServerName == \"{LogicalServerName}\"\r\n | where DurationMs > 0\r\n | extend duration_seconds = DurationMs /1000.0\r\n | where Statement has '{QueryTextSnippet}' and Statement has '{QueryTextSnippet2}' and Statement has '{QueryTextSnippet3}'\r\n | where Statement != 'select @@version'\r\n | where Statement != 'SELECT @@SPID;'\r\n | where ServerPrincipalName has '{User}'\r\n | where ApplicationName has '{Application}'\r\n | project DatabaseName= DatabaseName, UserName= ServerPrincipalName, QueryEndTime= EventTime, Host= HostName, duration_seconds = round(duration_seconds), AffectedRows, Statement, QuerySource = ApplicationName \r\n | project-reorder DatabaseName, UserName, Host, QueryEndTime, duration_seconds, AffectedRows,Statement, QuerySource\r\n\r\n\r\n\r\n\r\n\r\n", "size": 2, "showAnalytics": true, "title": "Queries {User} {Application}", "noDataMessage": "Select a user to see query activity", "timeContextFromParameter": "TimeRange", "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Statement", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "96.4286ch" } } ], "sortBy": [ { "itemKey": "AffectedRows", "sortOrder": 2 } ] }, "sortBy": [ { "itemKey": "AffectedRows", "sortOrder": 2 } ] }, "showPin": true, "name": "query - 0 - Copy - Copy" } ] }, "conditionalVisibilities": [ { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "AuditSearch" }, { "parameterName": "AuditingState", "comparison": "isEqualTo", "value": "enabled" } ], "name": "AuditSearchGroup", "styleSettings": { "showBorder": true } }, { "type": 1, "content": { "json": "Workbook version: v1.1", "style": "info" }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "Overview" }, "customWidth": "15", "name": "version", "styleSettings": { "showBorder": true } } ], "fallbackResourceIds": [ "Azure Monitor" ], "$schema": "https://github.com/Microsoft/Application-Insights-Workbooks/blob/master/schema/workbook.json" } ================================================ FILE: Monitor_Workbooks/archive/DedicatedSQLPool_workspace_v1.1.workbook.bak ================================================ { "version": "Notebook/1.0", "items": [ { "type": 9, "content": { "version": "KqlParameterItem/1.0", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "parameters": [ { "id": "f5852627-70ca-4959-8d60-53b48864603f", "version": "KqlParameterItem/1.0", "name": "TimeRange", "type": 4, "isGlobal": true, "value": { "durationMs": 86400000 }, "typeSettings": { "selectableValues": [ { "durationMs": 300000 }, { "durationMs": 900000 }, { "durationMs": 1800000 }, { "durationMs": 3600000 }, { "durationMs": 14400000 }, { "durationMs": 43200000 }, { "durationMs": 86400000 }, { "durationMs": 172800000 }, { "durationMs": 259200000 }, { "durationMs": 604800000 }, { "durationMs": 1209600000 }, { "durationMs": 2419200000 }, { "durationMs": 2592000000 } ], "allowCustom": true }, "timeContext": { "durationMs": 86400000 } }, { "id": "28da10ec-a308-47f5-9819-92ebf810b292", "version": "KqlParameterItem/1.0", "name": "LogAnalyticsSubscription", "type": 6, "value": null, "typeSettings": { "additionalResourceOptions": [], "includeAll": true, "showDefault": false }, "timeContext": { "durationMs": 86400000 } }, { "id": "e383ed24-52ae-447b-9b80-51fd3ab6b919", "version": "KqlParameterItem/1.0", "name": "LogAnalyticsWorkspace", "type": 5, "query": "Resources\r\n| where type == 'microsoft.operationalinsights/workspaces'\r\n| project id\r\n", "crossComponentResources": [ "{LogAnalyticsSubscription}" ], "value": null, "typeSettings": { "additionalResourceOptions": [], "showDefault": false }, "timeContext": { "durationMs": 86400000 }, "queryType": 1, "resourceType": "microsoft.resourcegraph/resources" }, { "id": "9b9fe566-0f52-4a75-a35b-a79c50c6a6f0", "version": "KqlParameterItem/1.0", "name": "DatabaseResourceName", "type": 5, "query": "SynapseSqlPoolExecRequests \r\n| distinct _ResourceId", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "value": null, "typeSettings": { "additionalResourceOptions": [], "showDefault": false }, "timeContext": { "durationMs": 2592000000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "id": "6da2f63f-45a3-4b37-9108-5e8b7e358d85", "version": "KqlParameterItem/1.0", "name": "DatabaseName", "type": 1, "query": "print split (\"{DatabaseResourceName}\",\"/\")[-1]", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "id": "8bba835b-f319-43b3-8ec6-4e051fc6d446", "version": "KqlParameterItem/1.0", "name": "LogicalServerName", "type": 1, "query": "SynapseSqlPoolExecRequests\r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| distinct LogicalServerName", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "id": "b86cd4a2-2303-4288-b48c-1c119cb420ba", "version": "KqlParameterItem/1.0", "name": "AuditingState", "type": 1, "query": "let hasNonEmptyTable = (T:string) \r\n{ \r\n toscalar( \r\n union isfuzzy=true \r\n ( table(T) \r\n | where DatabaseName has '{DatabaseName}'\r\n | where TimeGenerated > ago(30d)| take 1 | count as Count ),\r\n (print Count=0) \r\n | summarize sum(Count) \r\n ) > 0\r\n};\r\nlet TableName = 'SQLSecurityAuditEvents';\r\nprint IsPresent=iif(hasNonEmptyTable(TableName ), \"enabled\", \"disabled\")", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 604800000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "id": "4025bcb8-f6d7-4e81-b805-84253835f8fb", "version": "KqlParameterItem/1.0", "name": "DiagnosticsState", "type": 1, "query": "let hasNonEmptyTable = (T:string, T2:string) \r\n{ \r\n toscalar( \r\n union isfuzzy=true \r\n ( table(T) | where TimeGenerated > ago(30d) | where _ResourceId endswith '/sqlpools/{DatabaseName}'| take 1 | count as Count ),\r\n ( table(T2) | where TimeGenerated > ago(30d) | where _ResourceId endswith '/sqlpools/{DatabaseName}'| take 1 | count as Count),\r\n (print Count=0) \r\n | summarize sum(Count) \r\n ) > 1\r\n};\r\nlet TableName = 'SynapseSqlPoolExecRequests';\r\nlet TableName2 = 'SynapseSqlPoolRequestSteps';\r\nprint IsPresent=iif(hasNonEmptyTable(TableName,TableName2 ), \"enabled\", \"disabled\")", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 2592000000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "customWidth": "90", "name": "parameters - 2" }, { "type": 1, "content": { "json": "Select your Log Analytics Workspace by setting the parameters above from left to right. ", "style": "warning" }, "conditionalVisibility": { "parameterName": "DatabaseResourceName", "comparison": "isEqualTo" }, "customWidth": "30", "name": "text - 14" }, { "type": 11, "content": { "version": "LinkItem/1.0", "style": "tabs", "links": [ { "id": "202cbbc0-8d63-416d-89ed-451d6fe7c4b3", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Overview", "subTarget": "Overview", "preText": "Workload", "style": "link" }, { "id": "a7901bd0-a1f4-4491-b953-57555d764e00", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Workload Management", "subTarget": "WorkloadManagement", "style": "link" }, { "id": "45e12a14-8548-4477-aae3-c142b906dc9f", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "TempDB", "subTarget": "TempDB", "style": "link" }, { "id": "9ef8f730-d73d-432b-9b75-55095d1155f2", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Replicated Tables", "subTarget": "ReplicatedTables", "style": "link" }, { "id": "79d10d16-0696-4214-b306-c7a0e46cd64f", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Query Investigation", "subTarget": "QueryInvestigation", "style": "link" }, { "id": "31c1cf1c-74b5-44e2-ba9a-9497834ca3dc", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Query Comparison", "subTarget": "QueryComparison", "style": "link" }, { "id": "db43bb45-1611-47ce-a2ad-517943f2aa1a", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "AutoStats", "subTarget": "Statistics", "style": "link" }, { "id": "482ccc46-8a10-4ace-bfd6-63ac73b380af", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Query Audit", "subTarget": "QueryAudit", "style": "link" }, { "id": "f42ddeea-8cc0-4095-bc90-11eac0b7f94c", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Audit Search", "subTarget": "AuditSearch", "style": "link" } ] }, "name": "links - 0" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 10, "content": { "chartId": "workbook90867bfc-5c33-464f-ac31-2c2e006b97f4", "version": "MetricsItem/2.0", "size": 0, "chartType": 2, "resourceType": "microsoft.synapse/workspaces/sqlpools", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 86400000 }, "metrics": [ { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-DWUUsedPercent", "aggregation": 3, "splitBy": null, "columnName": "DWU Usaed %" }, { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-CPUPercent", "aggregation": 3, "columnName": "CPU Used %" } ], "title": "DWU Resource Utilization", "showOpenInMe": true, "showCreateAlertRule": true, "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "showPin": true, "name": "metric - 1" }, { "type": 10, "content": { "chartId": "workbookb954d4a0-82ef-4409-88fb-837aaff80c8d", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.synapse/workspaces/sqlpools", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 86400000 }, "metrics": [ { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-ActiveQueries", "aggregation": 1, "splitBy": null }, { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-QueuedQueries", "aggregation": 1 } ], "title": "Active and Queued Queries", "showOpenInMe": true, "showCreateAlertRule": true, "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "showPin": true, "name": "metric - 1" }, { "type": 10, "content": { "chartId": "workbookb954d4a0-82ef-4409-88fb-837aaff80c8d", "version": "MetricsItem/2.0", "size": 0, "chartType": 3, "resourceType": "microsoft.synapse/workspaces/sqlpools", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 86400000 }, "metrics": [ { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-LocalTempDBUsedPercent", "aggregation": 3, "splitBy": null, "columnName": "TempDB Utilization Percentage" } ], "title": "TempDB Utilization", "showOpenInMe": true, "showCreateAlertRule": true, "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "showPin": true, "name": "metric - 1 - Copy" }, { "type": 10, "content": { "chartId": "workbookb954d4a0-82ef-4409-88fb-837aaff80c8d", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.synapse/workspaces/sqlpools", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 86400000 }, "metrics": [ { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool Workload management-WLGAllocationBySystemPercent", "aggregation": 3, "splitBy": null, "columnName": "Workload Group Allocation by System %" } ], "title": "Workload Group Utilization", "showOpenInMe": true, "showCreateAlertRule": true, "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "showPin": true, "name": "Workload Group Utilization" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Long-Running Queries - Just Actual Queries\r\n//If 'Command' is empty - you need to set a bigger time window, the older record with the command is outside of your window\r\nSynapseSqlPoolExecRequests \r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where StatementType !in ('Batch','Execute')\r\n| summarize //Session_ID=any(SessionId),\r\n Request_ID=any(RequestId),\r\n //Submit_Time=max(SubmitTime),\r\n Start_Time=max(StartTime),\r\n End_Time=max(EndTime),\r\n Command=any(Command),\r\n Status=min(Status), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType),\r\n Resource_class=any(ResourceClass)\r\n by RequestId\r\n| summarize ElapsedTime_min=bin(anyif(((End_Time - Start_Time)/1m),Start_Time > ago(30d)),1),\r\n //Session_ID=any(Session_ID), \r\n // Submit_Time=any(Submit_Time) ,\r\n Start_Time=any(Start_Time), \r\n End_Time=any(End_Time),\r\n Command=any(Command),\r\n Status=any(Status),\r\n Statement_Type=any(Statement_Type)\r\n ,Resource_class=any(Resource_class) \r\n by Request_ID\r\n| where End_Time > ago(365d)\r\n| summarize count() by Status, bin(End_Time,5m)\r\n| render barchart \r\n", "size": 0, "showAnalytics": true, "title": "Query Completion Count by End Time - 5m buckets", "color": "redBright", "timeContextFromParameter": "TimeRange", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "chartSettings": { "seriesLabelSettings": [ { "seriesName": "Completed", "color": "green" }, { "seriesName": "Failed", "color": "red" }, { "seriesName": "Cancelled", "color": "yellow" } ] } }, "showPin": true, "name": "query - 4" }, { "type": 1, "content": { "json": "Use the buttons below to filter the next chart for Success or Failed queries. In many cases a failed query may not have a 'Command' column populated depending on what stage the query failed in. ", "style": "info" }, "customWidth": "25", "name": "text - 3" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "e2a833ac-48b4-4ccd-bbcd-33fccf1dbd75", "version": "KqlParameterItem/1.0", "name": "QueryCompletionType", "type": 1, "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 } } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 4" }, { "type": 11, "content": { "version": "LinkItem/1.0", "style": "nav", "links": [ { "id": "8e89112f-c67f-42c0-9622-02fa306fb7a5", "cellValue": "QueryCompletionType", "linkTarget": "parameter", "linkLabel": "All Queries", "subTarget": "''", "style": "primary" }, { "id": "6abe39c7-4d4e-4c45-aa54-dc9a4c5e876e", "cellValue": "QueryCompletionType", "linkTarget": "parameter", "linkLabel": "Success Only", "subTarget": "Completed", "preText": "", "style": "secondary" }, { "id": "e41b4a0b-8464-491e-92be-a57217d6dcac", "cellValue": "QueryCompletionType", "linkTarget": "parameter", "linkLabel": "Failures Only", "subTarget": "Failed", "preText": "", "style": "secondary" } ] }, "name": "links - 11" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Long-Running Queries - Just Actual Queries\r\n//If 'Command' is empty - you need to set a bigger time window, the older record with the command is outside of your window\r\nSynapseSqlPoolExecRequests \r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where StatementType !in ('Batch','Execute')\r\n| summarize //Session_ID=any(SessionId),\r\n Request_ID=any(RequestId),\r\n Start_Time=max(StartTime),\r\n End_Time=max(EndTime),\r\n Command=any(Command),\r\n Status=min(Status), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType),\r\n Resource_class=any(ResourceClass)\r\n by RequestId\r\n| summarize ElapsedTime_min=bin(anyif(((End_Time - Start_Time)/1m),Start_Time > ago(30d)),1),\r\n Start_Time=any(Start_Time), \r\n End_Time=any(End_Time),\r\n Command=any(Command),\r\n Status=any(Status),\r\n Statement_Type=any(Statement_Type)\r\n ,Resource_class=any(Resource_class) \r\n by Request_ID\r\n| where Status has '{QueryCompletionType}'\r\n| order by Start_Time\r\n\r\n", "size": 0, "showAnalytics": true, "title": "Query Completions - use above buttons to filter", "color": "redBright", "timeContextFromParameter": "TimeRange", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "rowLimit": 100 }, "chartSettings": { "seriesLabelSettings": [ { "seriesName": "Completed", "color": "green" }, { "seriesName": "Failed", "color": "red" }, { "seriesName": "Cancelled", "color": "yellow" } ] } }, "showPin": true, "name": "query - 4 - Copy" } ] }, "name": "Query Completions", "styleSettings": { "showBorder": true } }, { "type": 10, "content": { "chartId": "workbook1afc57e6-0b32-4968-b299-db319bd21635", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.synapse/workspaces/sqlpools", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 86400000 }, "metrics": [ { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-Connections", "aggregation": 1, "splitBy": null }, { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-ConnectionsBlockedByFirewall", "aggregation": 1 } ], "title": "Successful and Failed Connections", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "name": "metric - 5" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 3, "content": { "version": "KqlItem/1.0", "query": " SQLSecurityAuditEvents\r\n | where LogicalServerName == '{LogicalServerName}'\r\n | where ActionName in ('DATABASE AUTHENTICATION SUCCEEDED','DATABASE AUTHENTICATION FAILED')\r\n | project SourceSystem,ClientTlsVersion ,Succeeded,SessionId,ClientIp,SessionServerPrincipalName,ServerPrincipalName,DatabasePrincipalName,ApplicationName,HostName,TimeGenerated\r\n | summarize count() by Succeeded,bin(TimeGenerated,1m)\r\n | render barchart\r\n\r\n\r\n\r\n", "size": 0, "showAnalytics": true, "title": "Database Authentication success/failure rate", "timeContextFromParameter": "TimeRange", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "chartSettings": { "xAxis": "TimeGenerated", "group": "succeeded_s", "createOtherGroup": null } }, "showPin": true, "name": "query - 8" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "f7485a11-48df-4b61-a70e-9f56d6a00ec6", "version": "KqlParameterItem/1.0", "name": "AuthResult", "type": 1, "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 } } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 3" }, { "type": 11, "content": { "version": "LinkItem/1.0", "style": "nav", "links": [ { "id": "2ed22e0a-2b53-4ed0-8f65-d2c621f34dad", "cellValue": "AuthResult", "linkTarget": "parameter", "linkLabel": "All Authentications", "subTarget": "''", "style": "primary" }, { "id": "2789ab13-ae8a-472e-bad4-9c9bdc934d4d", "cellValue": "AuthResult", "linkTarget": "parameter", "linkLabel": "Success Only", "subTarget": "true", "style": "secondary" }, { "id": "5cf4ddd4-e189-4b71-b456-0d4f1572a0a3", "cellValue": "AuthResult", "linkTarget": "parameter", "linkLabel": "Failures Only", "subTarget": "false", "style": "secondary" } ] }, "name": "links - 10" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": " SQLSecurityAuditEvents\r\n | where LogicalServerName == '{LogicalServerName}'\r\n | where ActionName in ('DATABASE AUTHENTICATION SUCCEEDED','DATABASE AUTHENTICATION FAILED')\r\n | where Succeeded == '{AuthResult}'\r\n | project SourceSystem,ClientTlsVersion ,Succeeded,SessionId,ClientIp,SessionServerPrincipalName,ServerPrincipalName,DatabasePrincipalName,ApplicationName,HostName,TimeGenerated\r\n //| summarize count() by Succeeded,bin(TimeGenerated,1m)\r\n\r\n\r\n\r\n\r\n\r\n", "size": 0, "showAnalytics": true, "title": "Database Authentication success/failure rate", "noDataMessage": "No Results", "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "rowLimit": 100 }, "chartSettings": { "xAxis": "TimeGenerated", "group": "succeeded_s", "createOtherGroup": null, "showLegend": true } }, "showPin": true, "name": "query - 8 - Copy" } ] }, "conditionalVisibility": { "parameterName": "AuditingState", "comparison": "isEqualTo", "value": "enabled" }, "name": "Database Authentication Group", "styleSettings": { "showBorder": true } }, { "type": 10, "content": { "chartId": "workbook993837ad-66d6-4cbc-ae1a-7c3f6623236b", "version": "MetricsItem/2.0", "size": 0, "chartType": 2, "resourceType": "microsoft.synapse/workspaces/sqlpools", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 86400000 }, "metrics": [ { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-AdaptiveCacheUsedPercent", "aggregation": 3, "splitBy": null }, { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-AdaptiveCacheHitPercent", "aggregation": 3 } ], "title": "Adaptive Cache Used vs Hit Percentage", "showCreateAlertRule": true, "gridSettings": { "rowLimit": 10000 } }, "showPin": true, "name": "metric - 6" } ] }, "conditionalVisibilities": [ { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "Overview" }, { "parameterName": "DiagnosticsState", "comparison": "isEqualTo", "value": "enabled" } ], "name": "overviewGroup" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 10, "content": { "chartId": "workbook4a9cf761-cce2-45b2-8947-8a9428ec7e1c", "version": "MetricsItem/2.0", "size": 0, "chartType": 3, "resourceType": "microsoft.synapse/workspaces/sqlpools", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 31597002, "endTime": "2022-01-21T03:06:58.357Z" }, "metrics": [ { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-LocalTempDBUsedPercent", "aggregation": 3, "splitBy": null, "columnName": "TempDB Util" } ], "title": "TempDB Max and Avg Utilization", "showOpenInMe": true, "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "showPin": true, "name": "metric - 0" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "19ee48f5-8f4e-4939-a0ef-c6bf656a93f9", "version": "KqlParameterItem/1.0", "name": "WeightParameter", "type": 1, "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 } }, { "id": "00553ec8-1a41-4dd9-a024-d607639c9bbb", "version": "KqlParameterItem/1.0", "name": "RequestID", "type": 1, "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 }, "value": "" } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 3" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databaseResourceName = '{DatabaseResourceName}';\r\n//Weighted query steps\r\nSynapseSqlPoolRequestSteps \r\n| where _ResourceId == databaseResourceName\r\n| where RowCount > 0\r\n| summarize sum(RowCount) by RequestId, OperationType\r\n| order by sum_RowCount desc\r\n| limit 20\r\n| render columnchart ", "size": 0, "showAnalytics": true, "title": "20 Largest Query Steps by Most Rows Moved", "timeContextFromParameter": "TimeRange", "exportFieldName": "Request_ID", "exportParameterName": "RequestID", "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "chartSettings": { "xAxis": "RequestId", "group": "OperationType", "createOtherGroup": 20, "showLegend": true } }, "showPin": true, "name": "query - 1 - Copy" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "8afacdd5-2690-48d0-b125-fb118378e90c", "version": "KqlParameterItem/1.0", "name": "WeightParameter", "type": 1, "value": "Unweighted", "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 } } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 8" }, { "type": 11, "content": { "version": "LinkItem/1.0", "style": "nav", "links": [ { "id": "c98d3722-9907-43ab-9306-1957d6f7f858", "cellValue": "WeightParameter", "linkTarget": "parameter", "linkLabel": "Weighted Rowcounts", "subTarget": "Weighted", "preText": "", "postText": "", "style": "secondary" }, { "id": "a06ae99a-ad62-45e9-8c25-c219b81f59c0", "cellValue": "WeightParameter", "linkTarget": "parameter", "linkLabel": "Unweighted Rowcounts", "subTarget": "Unweighted", "preText": "", "postText": "", "style": "secondary" } ] }, "name": "links - 3" }, { "type": 1, "content": { "json": "Current Setting: {WeightParameter}", "style": "info" }, "customWidth": "25", "name": "text - 4" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databaseResourceName = '{DatabaseResourceName}';\r\n//Weighted query steps\r\nlet RequestSteps = SynapseSqlPoolRequestSteps\r\n| where _ResourceId == databaseResourceName\r\n//| where RowCount > 10000000\r\n| extend Step_Elapsed_Min = round((EndTime - StartTime) /1m, 2)\r\n| extend Weighted_cnt = iff('{WeightParameter}'=='Weighted',(case(OperationType == 'BroadcastMoveOperation', (RowCount*10), RowCount)),RowCount)\r\n| project-rename StepStatus = Status, StepStart = StartTime, StepEnd = EndTime//, StepResource = Resource\r\n| top 100 by Weighted_cnt desc\r\n| order by Weighted_cnt desc\r\n| project Request_ID=RequestId,OperationType, RowCount,Weighted_cnt,Step_Elapsed_Min, StepStart, StepEnd, StepStatus, StepIndex;\r\nRequestSteps | join (\r\nSynapseSqlPoolExecRequests\r\n| where _ResourceId == databaseResourceName\r\n| where StatementType !in ('Batch','Execute')\r\n| summarize //Session_ID=any(SessionId),\r\n Request_ID=any(RequestId),\r\n //Submit_Time=max(SubmitTime),\r\n Start_Time=max(StartTime),\r\n End_Time=max(EndTime),\r\n Command=any(Command),\r\n Status=min(Status), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType),\r\n Resource_class=any(ResourceClass)\r\n by RequestId\r\n| summarize //Session_ID=any(Session_ID), \r\n//Submit_Time=any(Submit_Time) ,\r\nStart_Time=any(Start_Time), End_Time=any(End_Time),Command=any(Command),Status=any(Status),Statement_Type=any(Statement_Type),Resource_class=any(Resource_class) by Request_ID\r\n//| order by Step_Elapsed_Min desc\r\n| extend Request_Elapsed_Min = round((End_Time - Start_Time)/1m, 2)\r\n| project-rename ReqStatus = Status, ReqStart = Start_Time, ReqEnd = End_Time\r\n) on Request_ID\r\n| project-reorder //Session_ID, \r\nRequest_ID, Request_Elapsed_Min, ReqStart, ReqEnd, ReqStatus,StepIndex, OperationType, RowCount,Weighted_cnt,Step_Elapsed_Min, StepStart, StepEnd, StepStatus, Statement_Type, Command, Resource_class\r\n| order by Weighted_cnt desc\r\n| limit 20", "size": 3, "showAnalytics": true, "title": "20 Largest Query Steps by Most Rows Moved", "timeContextFromParameter": "TimeRange", "exportFieldName": "Request_ID1", "exportParameterName": "RequestID", "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "sortBy": [ { "itemKey": "Weighted_cnt", "sortOrder": 2 } ] }, "sortBy": [ { "itemKey": "Weighted_cnt", "sortOrder": 2 } ] }, "showPin": true, "name": "query - 1" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databaseResourceName = '{DatabaseResourceName}';\r\n//Long-Running Queries - Just Actual Queries\r\n//If 'Command' is empty - you need to set a bigger time window, the older record with the command is outside of your window\r\nSynapseSqlPoolExecRequests\r\n| where _ResourceId == databaseResourceName\r\n| where StatementType !in ('Batch','Execute')\r\n| summarize //Session_ID=any(SessionId),\r\n Request_ID=any(RequestId),\r\n Start_Time=max(StartTime),\r\n End_Time=max(EndTime),\r\n Command=any(Command),\r\n Status=min(Status), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType),\r\n Resource_class=any(ResourceClass)\r\n by RequestId\r\n| summarize ElapsedTime_min=bin(anyif(((End_Time - Start_Time)/1m),Start_Time > ago(30d)),1),\r\n Start_Time=any(Start_Time), \r\n End_Time=any(End_Time),\r\n Command=any(Command),\r\n Status=any(Status),\r\n Statement_Type=any(Statement_Type)\r\n ,Resource_class=any(Resource_class) \r\n by Request_ID\r\n| where Request_ID == '{RequestID}' and Request_ID != ''\r\n\r\n", "size": 4, "showAnalytics": true, "title": "Selected Query", "noDataMessage": "Select a query above to view details", "noDataMessageStyle": 4, "timeContextFromParameter": "TimeRange", "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "35%" } } ] } }, "showPin": true, "name": "query - 6" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolRequestSteps \r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where RequestId == '{RequestID}' and RequestId != '' //Put your QueryID here\r\n| where Status != 'Running'\r\n| summarize max(StartTime),max(EndTime),max(RequestId),max(OperationType),max(RowCount),max(Command),max(Status) by StepIndex\r\n| order by StepIndex asc", "size": 3, "showAnalytics": true, "title": "Query Plan", "noDataMessage": "Select a query above to view the plan", "noDataMessageStyle": 4, "timeContextFromParameter": "TimeRange", "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "showPin": true, "name": "query - 7" } ] }, "conditionalVisibilities": [ { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "TempDB" }, { "parameterName": "DiagnosticsState", "comparison": "isEqualTo", "value": "enabled" } ], "name": "TempDBGroup" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 1, "content": { "json": "## Search Criteria\r\nUse the following fields to search either using a query text snippet or using a Request ID. If using a query text snippet, try to keep it as simple as possible becuase minor changes in formatting may cause your queries not to show up in the results. It's best to pick something like a table name, then choose the proper query from the list that will populate. " }, "customWidth": "50", "name": "text - 4" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "4b98dd26-4ccf-420e-a990-8d015f27fb76", "version": "KqlParameterItem/1.0", "name": "SampleQID", "type": 1, "value": "999", "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 } }, { "id": "d5524dd5-cf7e-41cf-beb3-474b3290289e", "version": "KqlParameterItem/1.0", "name": "RequestId", "type": 1, "value": "", "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 } } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "initializeQueryInvestigationParameters" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "0c2128d0-d979-4562-a28c-e7ceb955f126", "version": "KqlParameterItem/1.0", "name": "RequestId", "type": 1, "value": "", "label": "Request Id Search" }, { "id": "29880874-2d41-4bd5-bf22-3e47ae8b1145", "version": "KqlParameterItem/1.0", "name": "QueryTextSnippet", "type": 1, "value": "", "timeContext": { "durationMs": 86400000 } } ], "style": "formVertical", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "customWidth": "60", "name": "parameters - 3" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolExecRequests\r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where StatementType !in ('Batch','Execute')\r\n| summarize \r\n Request_ID=max(RequestId), \r\n Start_Time=max(StartTime),\r\n End_Compile_Time=max(EndCompileTime), \r\n End_Time=max(EndTime), \r\n QueryText = any(Command), \r\n Last_Status=min(Status),\r\n Statement_Type=max(StatementType),\r\n Resource_class=max(ResourceClass) \r\n by RequestId\r\n| extend Elapsed_Time_s=(End_Time - Start_Time)/1s\r\n| where QueryText has '{QueryTextSnippet}'\r\nand RequestId has '{RequestId}'\r\n| summarize \r\n Executions = count(),\r\n SampleQID = any(RequestId),\r\n Elapsed_Time_s=max(Elapsed_Time_s)\r\n by QueryText\r\n| order by Elapsed_Time_s\r\n\r\n\r\n\r\n", "size": 0, "showAnalytics": true, "title": "Matching Queries", "timeContextFromParameter": "TimeRange", "exportedParameters": [ { "fieldName": "SampleQID", "parameterName": "SampleQID" }, { "fieldName": "SampleQID", "parameterName": "RequestId", "parameterType": 1 }, { "fieldName": "QueryText", "parameterName": "QueryText", "parameterType": 1 } ], "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "50%" } } ], "sortBy": [ { "itemKey": "Elapsed_Time_s", "sortOrder": 2 } ] }, "sortBy": [ { "itemKey": "Elapsed_Time_s", "sortOrder": 2 } ] }, "showPin": true, "name": "query - 0" }, { "type": 1, "content": { "json": "## DSQL Command " }, "conditionalVisibility": { "parameterName": "QueryText", "comparison": "isNotEqualTo" }, "name": "text - 8" }, { "type": 1, "content": { "json": "```{QueryText}```\r\n" }, "conditionalVisibility": { "parameterName": "QueryText", "comparison": "isNotEqualTo" }, "name": "ShowQueryText", "styleSettings": { "showBorder": true } }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolExecRequests\r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where StatementType !in ('Batch','Execute')\r\n| where RequestId == '{SampleQID}'\r\n| summarize \r\n Request_ID=max(RequestId), \r\n Start_Time=max(StartTime),\r\n End_Compile_Time=max(EndCompileTime), \r\n End_Time=max(EndTime), \r\n Command=max(Command), \r\n Last_Status=min(Status),\r\n Statement_Type=max(StatementType),\r\n Resource_class=max(ResourceClass) \r\n by RequestId\r\n| extend elapsedTime_sec = iif(End_Time > ago(365d),(End_Time - Start_Time)/1s,real(null)) \r\n| join kind=inner\r\n (SynapseSqlPoolExecRequests\r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where StatementType !in ('Batch','Execute')\r\n | summarize \r\n Request_ID=max(RequestId), \r\n Start_Time=max(StartTime),\r\n End_Compile_Time=max(EndCompileTime), \r\n End_Time=max(EndTime), \r\n Command=max(Command), \r\n Last_Status=min(Status),\r\n Statement_Type=max(StatementType),\r\n Resource_class=max(ResourceClass) \r\n by RequestId\r\n //| extend elapsedTime_sec = (End_Time - Start_Time)/1s\r\n | extend elapsedTime_sec = iif(End_Time > ago(365d),(End_Time - Start_Time)/1s,real(null)) \r\n )\r\non Command \r\n| project Request_ID1,Start_Time1,End_Compile_Time1,End_Time1,Last_Status1,Statement_Type1,Resource_class1,elapsedTime_sec1\r\n", "size": 0, "showAnalytics": true, "title": "All Executions of Selected Query Text", "noDataMessage": "Select a query above to see individual executions", "noDataMessageStyle": 4, "timeContextFromParameter": "TimeRange", "exportFieldName": "Request_ID1", "exportParameterName": "RequestId", "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "sortBy": [] }, "showPin": true, "name": "query - 0 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolRequestSteps \r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where RequestId == '{RequestId}' and RequestId != ''\r\n| where Status != 'Running'\r\n| summarize max(StartTime),max(EndTime),max(RequestId),max(OperationType),max(RowCount),max(Command),max(Status) by StepIndex\r\n| order by StepIndex asc", "size": 3, "showAnalytics": true, "title": "Query Plan for Selected Query", "noDataMessage": "Select a Query Above to See the Query Plan", "noDataMessageStyle": 4, "timeContextFromParameter": "TimeRange", "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 0 - Copy - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolExecRequests\r\n | where StatementType =='CreateStatistics'\r\n | where _ResourceId has '{DatabaseName}'\r\n | summarize \r\n Root_Query_Id=max(RootQueryId), \r\n Start_Time=max(StartTime),\r\n End_Compile_Time=max(EndCompileTime), \r\n End_Time=max(EndTime), \r\n Command=max(Command), \r\n Last_Status=min(Status),\r\n Statement_Type=max(StatementType),\r\n Resource_class=max(ResourceClass) \r\n by RequestId\r\n | where Root_Query_Id == '{RequestId}'", "size": 0, "showAnalytics": true, "title": "Triggered Auto-Stats Statements", "noDataMessage": "No triggered autostats statements found", "timeContextFromParameter": "TimeRange", "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Submit_Time", "formatter": 0, "numberFormat": { "unit": 0, "options": { "style": "decimal" } } }, { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "100ch" } } ] } }, "name": "All triggered auto-stats statements" } ] }, "conditionalVisibilities": [ { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "QueryInvestigation" }, { "parameterName": "DiagnosticsState", "comparison": "isEqualTo", "value": "enabled" } ], "name": "QueryInvestigationGroup", "styleSettings": { "showBorder": true } }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 1, "content": { "json": "All Charts on this page are based on the last 7 days of data", "style": "info" }, "customWidth": "25", "name": "text - 5" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "533ff6bb-97cd-4aaa-9372-171cad378bcd", "version": "KqlParameterItem/1.0", "name": "QueryText", "type": 1, "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 } }, { "id": "99de0056-d4f3-465e-a27e-599d69b23c77", "version": "KqlParameterItem/1.0", "name": "RequestId", "type": 1, "value": "999", "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 } } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "initializeTempDBVariables" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Build cache count by day\r\nlet databaseResourceName = '{DatabaseResourceName}';\r\n//Long-Running Queries - Just Actual Queries\r\n//If 'Command' is empty - you need to set a bigger time window, the older record with the command is outside of your window\r\nSynapseSqlPoolExecRequests\r\n| where _ResourceId == databaseResourceName\r\n| where StatementType == 'BuildReplicatedTableCache'\r\n| where Command != \"\"\r\n| where ResourceClass != \"\"\r\n| project Command,TimeGenerated,RequestId\r\n| summarize LastRebuild=max(TimeGenerated),RebuildCount=count(RequestId) by Command\r\n| order by RebuildCount desc\r\n| limit 15\r\n", "size": 3, "showAnalytics": true, "title": "Top 15 Most Rebuilds by Table", "noDataMessage": "No replicated table rebuilds found in the last 7 days", "noDataMessageStyle": 4, "timeContext": { "durationMs": 604800000 }, "exportFieldName": "Command", "exportParameterName": "QueryText", "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command_s", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "40%" } } ] } }, "showPin": true, "name": "query - 0" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Build cache count by day\r\nlet databaseResourceName = '{DatabaseResourceName}';\r\nSynapseSqlPoolExecRequests\r\n| where _ResourceId == databaseResourceName\r\n| where StatementType == 'BuildReplicatedTableCache'\r\n| where Command == \"{QueryText}\"\r\n| where ResourceClass != \"\"\r\n| project Command,TimeGenerated,RequestId\r\n| summarize count() by Command,bin(TimeGenerated,24h)\r\n| limit 20\r\n| render timechart", "size": 0, "showAnalytics": true, "title": "Rebuilds per Day for Selected Table", "noDataMessage": "Select a query above to see runs by day", "noDataMessageStyle": 4, "timeContext": { "durationMs": 604800000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "chartSettings": { "group": "Command_s", "createOtherGroup": 20, "ySettings": { "min": 0 } } }, "showPin": true, "name": "query - 0 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Build cache count by day\r\nlet databaseResourceName = '{DatabaseResourceName}';\r\n//Long-Running Queries - Just Actual Queries\r\n//If 'Command' is empty - you need to set a bigger time window, the older record with the command is outside of your window\r\nSynapseSqlPoolExecRequests\r\n| where _ResourceId == databaseResourceName\r\n| where StatementType == 'BuildReplicatedTableCache'\r\n| where Command != \"\"\r\n| where ResourceClass != \"\"\r\n| project Command,TimeGenerated,RequestId\r\n| summarize count() by Command, bin(TimeGenerated,24h)\r\n//| where count_ > 7\r\n| order by count_ desc\r\n\r\n", "size": 2, "showAnalytics": true, "title": "Rebuild Count by Table by Day", "noDataMessage": " Only tables with more than 7 total rebuilds will show up. If no talbes with that many rebuilds are found this chart will be empty", "noDataMessageStyle": 4, "timeContext": { "durationMs": 604800000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "categoricalbar", "gridSettings": { "sortBy": [ { "itemKey": "count_", "sortOrder": 1 } ] }, "sortBy": [ { "itemKey": "count_", "sortOrder": 1 } ], "tileSettings": { "showBorder": false, "titleContent": { "columnMatch": "Command_s", "formatter": 1 }, "leftContent": { "columnMatch": "count_", "formatter": 12, "formatOptions": { "palette": "auto" }, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "graphSettings": { "type": 0, "topContent": { "columnMatch": "Command_s", "formatter": 1 }, "centerContent": { "columnMatch": "count_", "formatter": 1, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "chartSettings": { "group": "Command_s", "createOtherGroup": 99, "showDataPoints": true } }, "showPin": true, "name": "query - 0 - Copy - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databaseResourceName = '{DatabaseResourceName}';\r\n//Long-Running Queries - Just Actual Queries\r\n//If 'Command' is empty - you need to set a bigger time window, the older record with the command is outside of your window\r\nSynapseSqlPoolExecRequests\r\n| where _ResourceId == databaseResourceName\r\n| where StatementType == 'BuildReplicatedTableCache'\r\n| summarize Start_Time=max(StartTime), End_Time=max(EndTime), Command=max(Command), Statement_Type=max(StatementType), Resource_class=max(ResourceClass) by RequestId\r\n| join kind= inner\r\n(\r\n SynapseSqlPoolExecRequests\r\n | where _ResourceId == databaseResourceName\r\n | where StatementType == 'BuildReplicatedTableCache'\r\n | where StatementType == 'BuildReplicatedTableCache'\r\n | where EndTime > ago(7d)\r\n | where StartTime > ago(7d)\r\n | extend elapsedTime_min = (EndTime - StartTime)/1m\r\n | order by elapsedTime_min desc\r\n | project RequestId,elapsedTime_min \r\n)\r\non RequestId\r\n| order by elapsedTime_min desc\r\n| project RequestId,Start_Time,End_Time,Elapsed_Time=round(elapsedTime_min,1) ,Command\r\n| limit 15\r\n", "size": 3, "showAnalytics": true, "title": "Top 15 Elapsed Time per Rebuild", "noDataMessageStyle": 4, "timeContext": { "durationMs": 604800000 }, "exportFieldName": "RequestId", "exportParameterName": "RequestId", "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "40%" } } ] } }, "showPin": true, "name": "query - 3" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": " let databaseResourceName = '{DatabaseResourceName}';\r\nSynapseSqlPoolRequestSteps \r\n| where _ResourceId == databaseResourceName\r\n| where RequestId == '{RequestId}'\r\n| where Status != 'Running'\r\n| summarize max(StartTime),max(EndTime),max(RequestId),max(OperationType),max(RowCount),max(Command),max(Status) by StepIndex\r\n| order by StepIndex asc", "size": 3, "showAnalytics": true, "title": "Query Plan for Selected Query", "noDataMessage": "Select a query above to view plan", "noDataMessageStyle": 4, "timeContext": { "durationMs": 604800000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "showPin": true, "name": "query - 4" } ] }, "conditionalVisibilities": [ { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "ReplicatedTables" }, { "parameterName": "DiagnosticsState", "comparison": "isEqualTo", "value": "enabled" } ], "name": "ReplicatedTablesGroup" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 10, "content": { "chartId": "workbook72446028-6edb-4cb0-8952-e0c13bda488f", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.synapse/workspaces/sqlpools", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 31597002, "endTime": "2022-01-21T03:06:58.357Z" }, "metrics": [ { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool Workload management-WLGAllocationBySystemPercent", "aggregation": 3, "splitBy": "WorkloadGroup" } ], "title": "Workload Group Allocation By System Percent", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "name": "metric - 0" }, { "type": 10, "content": { "chartId": "workbookc898119a-7381-469d-b51a-d505b4f80e73", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.synapse/workspaces/sqlpools", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 31597002, "endTime": "2022-01-21T03:06:58.357Z" }, "metrics": [ { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool Workload management-WLGActiveQueries", "aggregation": 1, "splitBy": null } ], "title": "Query Count by Workload Group", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "name": "metric - 1" }, { "type": 10, "content": { "chartId": "workbook8d175f6c-427b-47fc-85ea-37edd0be707c", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.synapse/workspaces/sqlpools", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 31597002, "endTime": "2022-01-21T03:06:58.357Z" }, "metrics": [ { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-WLGQueuedQueries", "aggregation": 1, "splitBy": "WorkloadGroup" } ], "title": "Queued Queries by Workload Group", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "name": "Queued Queries by Workload Group" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "parameters": [ { "id": "6f50577d-7b00-4e4a-acf9-d45c7a5ee813", "version": "KqlParameterItem/1.0", "name": "WorkloadGroupName", "type": 2, "multiSelect": true, "quote": "'", "delimiter": ",", "query": "SynapseSqlPoolExecRequests \r\n| where _ResourceId == '{DatabaseResourceName}'\r\n and ResourceClass != \"\"\r\n| distinct ResourceClass", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "typeSettings": { "additionalResourceOptions": [ "value::all" ], "showDefault": false }, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "defaultValue": "value::all", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 2" }, { "type": 10, "content": { "chartId": "workbook3da1d18a-1bf5-46c5-b3b7-211f71d329cc", "version": "MetricsItem/2.0", "size": 0, "chartType": 2, "resourceType": "microsoft.synapse/workspaces/sqlpools", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 31597002, "endTime": "2022-01-21T03:06:58.357Z" }, "metrics": [ { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-WLGActiveQueries", "aggregation": 1, "splitBy": null }, { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-WLGQueuedQueries", "aggregation": 1 }, { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-WLGAllocationBySystemPercent", "aggregation": 3 }, { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-WLGEffectiveCapResourcePercent", "aggregation": 3 } ], "filters": [ { "id": "5", "key": "WorkloadGroup", "operator": 0, "valueParam": "WorkloadGroupName" } ], "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "name": "metric - 3" } ] }, "conditionalVisibilities": [ { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "WorkloadManagement" }, { "parameterName": "DiagnosticsState", "comparison": "isEqualTo", "value": "enabled" } ], "name": "WorkloadManagementGroup" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 1, "content": { "json": "## Select a Principal or Application name to filter results - leave to 'unset' to view all results\r\nSQL Auditing must be enabled and sending to the same Log Analytics Workspace for this page to work. " }, "name": "text - 5" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "parameters": [ { "id": "8d25c043-d1ff-4546-a1fa-f4bcbfdab8af", "version": "KqlParameterItem/1.0", "name": "User", "type": 2, "description": "User to filter subsequent queries - leave to 'unset' for all users", "query": "SQLSecurityAuditEvents \r\n| where LogicalServerName == '{LogicalServerName}'\r\n| summarize by ServerPrincipalName", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "value": null, "typeSettings": { "additionalResourceOptions": [], "showDefault": false }, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "id": "aa766d64-693f-4024-b4a4-b5b56b28376b", "version": "KqlParameterItem/1.0", "name": "Application", "type": 2, "query": "SQLSecurityAuditEvents \r\n| where LogicalServerName == '{LogicalServerName}'\r\n| summarize by ApplicationName", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "value": null, "typeSettings": { "additionalResourceOptions": [], "showDefault": false }, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "customWidth": "30", "name": "parameters - 1" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SQLSecurityAuditEvents \r\n| where LogicalServerName == '{LogicalServerName}'\r\n| where DurationMs > 0\r\n| extend duration_seconds = DurationMs /1000.0\r\n| where Statement != 'select @@version'\r\n| where Statement != 'SELECT @@SPID;'\r\n| where ServerPrincipalName has '{User}'\r\n| where ApplicationName has '{Application}'\r\n| project ServerPrincipalName, EventTime, LogicalServerName, DurationMs, duration_seconds, AffectedRows, Statement, ApplicationName\r\n| summarize duration_seconds = round(sum(duration_seconds)) , query_count = count() by EventDay = bin(EventTime,1d), UserName = ServerPrincipalName, Application = ApplicationName \r\n| order by EventDay, duration_seconds desc", "size": 0, "showAnalytics": true, "title": "Query Summary for Selected User {User} {Application}", "noDataMessage": "Select a user to see query activity", "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "showPin": true, "name": "query - 0 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SQLSecurityAuditEvents \r\n| where LogicalServerName == '{LogicalServerName}'\r\n| where DurationMs > 0\r\n| extend duration_seconds = DurationMs /1000.0\r\n| where Statement != 'select @@version'\r\n| where Statement != 'SELECT @@SPID;'\r\n| where ServerPrincipalName has '{User}'\r\n| where ApplicationName has '{Application}'\r\n| project ServerPrincipalName, EventTime, LogicalServerName, DurationMs, duration_seconds, AffectedRows, Statement, ApplicationName\r\n| summarize duration_seconds = round(sum(duration_seconds)) , query_count = count() by EventDay = bin(EventTime,1d), UserName = ServerPrincipalName, Application = ApplicationName \r\n| order by EventDay, duration_seconds desc", "size": 0, "showAnalytics": true, "title": "Query Summary for Selected User {User} {Application}", "noDataMessage": "Select a user to see query activity", "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "unstackedbar", "tileSettings": { "showBorder": false, "titleContent": { "columnMatch": "UserName", "formatter": 1 }, "leftContent": { "columnMatch": "duration_seconds", "formatter": 12, "formatOptions": { "palette": "auto" }, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "graphSettings": { "type": 0, "topContent": { "columnMatch": "UserName", "formatter": 1 }, "centerContent": { "columnMatch": "duration_seconds", "formatter": 1, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "chartSettings": { "xAxis": "UserName" }, "mapSettings": { "locInfo": "LatLong", "sizeSettings": "duration_seconds", "sizeAggregation": "Sum", "legendMetric": "duration_seconds", "legendAggregation": "Sum", "itemColorSettings": { "type": "heatmap", "colorAggregation": "Sum", "nodeColorField": "duration_seconds", "heatmapPalette": "greenRed" } } }, "showPin": true, "name": "query - 0 - Copy - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SQLSecurityAuditEvents \r\n | where LogicalServerName == \"{LogicalServerName}\"\r\n | where DurationMs > 0\r\n | extend duration_seconds = DurationMs /1000.0\r\n | where Statement != 'select @@version'\r\n | where Statement != 'SELECT @@SPID;'\r\n | where ServerPrincipalName has '{User}'\r\n | where ApplicationName has '{Application}'\r\n | project DatabaseName= DatabaseName, UserName= ServerPrincipalName, EventTime= EventTime, Host= HostName, duration_seconds = round(duration_seconds), Statement, QuerySource = ApplicationName , AffectedRows\r\n | project-reorder DatabaseName, UserName, Host, EventTime, duration_seconds, Statement, QuerySource\r\n\r\n\r\n\r\n\r\n\r\n", "size": 0, "showAnalytics": true, "title": "Queries {User} {Application}", "noDataMessage": "Select a user to see query activity", "timeContextFromParameter": "TimeRange", "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "showPin": true, "name": "query - 0 - Copy - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SQLSecurityAuditEvents \r\n | where LogicalServerName == \"{LogicalServerName}\"\r\n | where DurationMs > 0\r\n | extend duration_seconds = DurationMs /1000.0\r\n | where Statement != 'select @@version'\r\n | where Statement != 'SELECT @@SPID;'\r\n | where ServerPrincipalName has '{User}'\r\n | where ApplicationName has '{Application}'\r\n | project DatabaseName= DatabaseName, UserName= ServerPrincipalName, EventTime= EventTime, Host= HostName, duration_seconds = round(duration_seconds), Statement, QuerySource = ApplicationName , AffectedRows\r\n | project-reorder AffectedRows,DatabaseName, UserName, Host, EventTime, duration_seconds, Statement, QuerySource\r\n\r\n\r\n\r\n\r\n\r\n", "size": 0, "showAnalytics": true, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "barchart", "chartSettings": { "xAxis": "Host", "group": "UserName", "createOtherGroup": null, "showLegend": true } }, "showPin": true, "name": "query - 6" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SQLSecurityAuditEvents\r\n| where LogicalServerName == \"{LogicalServerName}\"\r\n | where DurationMs > 0\r\n| extend Duration = round(DurationMs /1000.0)\r\n| extend TimeBin = case (datetime_part(\"Hour\",TimeGenerated) in (6,7,8,9,10,11,12), \"Morning_6-12\", datetime_part(\"Hour\",TimeGenerated) in (13,14,15,16,17,18), \"Afternoon_12-18\", \"Overnight_18-6\")\r\n| where ServerPrincipalName has '{User}'\r\n| where ApplicationName has '{Application}'\r\n| summarize QueryDuration = sum(Duration) by EventTime = bin(EventTime, 1d), TimeBin", "size": 0, "showAnalytics": true, "title": "Query Activity by time - sum(Duration) {User} {Application}", "noDataMessage": "Select a user to see query activity", "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "barchart" }, "showPin": true, "name": "query - 0 - Copy" } ] }, "conditionalVisibilities": [ { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "QueryAudit" }, { "parameterName": "AuditingState", "comparison": "isEqualTo", "value": "enabled" } ], "name": "QueryAuditGroup", "styleSettings": { "showBorder": true } }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "7fa3187e-9225-4faa-8f80-dc1bc40c5aab", "version": "KqlParameterItem/1.0", "name": "RequestId1", "type": 1, "value": "" } ], "style": "above", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "customWidth": "50", "name": "parameters - 3 - Copy" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "315fc476-469a-4d8d-b421-028d1113ab06", "version": "KqlParameterItem/1.0", "name": "RequestId2", "type": 1, "value": "", "timeContext": { "durationMs": 86400000 } } ], "style": "above", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "customWidth": "50", "name": "parameters - 2" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 9, "content": { "version": "KqlParameterItem/1.0", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "parameters": [ { "id": "1537c5b3-0b6c-4b1d-89be-946cd8268020", "version": "KqlParameterItem/1.0", "name": "QueryText1", "type": 1, "query": "SynapseSqlPoolExecRequests\r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where StatementType !in ('Batch','Execute') and RequestId == '{RequestId1}'\r\n| summarize max(Command)", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" } ], "style": "above", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 5" }, { "type": 1, "content": { "json": "#### {RequestId1} Query Text" }, "conditionalVisibility": { "parameterName": "RequestId1", "comparison": "isNotEqualTo" }, "name": "text - 5" }, { "type": 1, "content": { "json": "```{QueryText1}```" }, "conditionalVisibility": { "parameterName": "RequestId1", "comparison": "isNotEqualTo" }, "name": "text - 3" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolExecRequests\r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where StatementType !in ('Batch','Execute') and RequestId == '{RequestId1}'\r\n| summarize \r\n Request_ID=any(RequestId),\r\n Start_Time=max(StartTime),\r\n End_Time=max(EndTime),\r\n //Command=any(Command),\r\n Status=min(Status), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType),\r\n Resource_class=any(ResourceClass)\r\n by RequestId\r\n| summarize Start_Time=any(Start_Time), End_Time=any(End_Time),ElapsedTime_min=anyif((End_Time - Start_Time)/1m,Start_Time > ago(30d))\r\n//,Command=any(Command)\r\n,Status=any(Status),Statement_Type=any(Statement_Type),Resource_class=any(Resource_class) by Request_ID\r\n| project ElapsedTime_min\r\n//,Command\r\n,Resource_class,Start_Time\r\n//,End_Time\r\n,Statement_Type,Status\r\n", "size": 4, "title": "Exec Requests", "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "conditionalVisibility": { "parameterName": "RequestId1", "comparison": "isNotEqualTo" }, "name": "query - 2" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolRequestSteps \r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where RequestId == '{RequestId1}' and RequestId != ''\r\n| summarize StartTime=max(StartTime)\r\n ,EndTime=max(EndTime)\r\n ,RequestID=max(RequestId)\r\n ,Operation=max(OperationType)\r\n ,RowCount=max(RowCount)\r\n ,Command=max(Command)\r\n ,Status=min(Status)\r\n by StepIndex\r\n| order by StepIndex asc\r\n| project StartTime,EndTime,Operation,RowCount,Command,Status,StepIndex", "size": 3, "title": "Request Steps", "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "conditionalVisibility": { "parameterName": "RequestId1", "comparison": "isNotEqualTo" }, "name": "StepQueryRequest1", "styleSettings": { "margin": "0", "padding": "10px" } }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolExecRequests\r\n | where StatementType =='CreateStatistics'\r\n | where _ResourceId has '{DatabaseName}'\r\n | summarize \r\n Root_Query_Id=max(RootQueryId), \r\n Start_Time=max(StartTime),\r\n End_Compile_Time=max(EndCompileTime), \r\n End_Time=max(EndTime), \r\n Command=max(Command), \r\n Last_Status=min(Status),\r\n Statement_Type=max(StatementType),\r\n Resource_class=max(ResourceClass) \r\n by RequestId\r\n | where Root_Query_Id == '{RequestId1}'", "size": 0, "title": "Triggered Auto-Stats Statements", "noDataMessage": "No triggered autostats statements found", "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Submit_Time", "formatter": 0, "numberFormat": { "unit": 0, "options": { "style": "decimal" } } }, { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "100ch" } } ], "sortBy": [ { "itemKey": "End_Time", "sortOrder": 2 } ] }, "sortBy": [ { "itemKey": "End_Time", "sortOrder": 2 } ] }, "conditionalVisibility": { "parameterName": "RequestId1", "comparison": "isNotEqualTo" }, "name": "All triggered auto-stats statements" } ] }, "customWidth": "50", "name": "RequestId1Group", "styleSettings": { "showBorder": true } }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 9, "content": { "version": "KqlParameterItem/1.0", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "parameters": [ { "id": "1537c5b3-0b6c-4b1d-89be-946cd8268020", "version": "KqlParameterItem/1.0", "name": "QueryText2", "type": 1, "query": "SynapseSqlPoolExecRequests\r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where StatementType !in ('Batch','Execute') and RequestId == '{RequestId2}'\r\n| summarize max(Command)", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" } ], "style": "above", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 5" }, { "type": 1, "content": { "json": "#### {RequestId2} Query Text" }, "conditionalVisibility": { "parameterName": "RequestId2", "comparison": "isNotEqualTo" }, "name": "text - 5" }, { "type": 1, "content": { "json": "```{QueryText2}```" }, "conditionalVisibility": { "parameterName": "RequestId2", "comparison": "isNotEqualTo" }, "name": "text - 4" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolExecRequests\r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where StatementType !in ('Batch','Execute') and RequestId == '{RequestId2}'\r\n| summarize \r\n Request_ID=any(RequestId),\r\n Start_Time=max(StartTime),\r\n End_Time=max(EndTime),\r\n //Command=any(Command),\r\n Status=min(Status), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType),\r\n Resource_class=any(ResourceClass)\r\n by RequestId\r\n| summarize Start_Time=any(Start_Time), End_Time=any(End_Time),ElapsedTime_min=anyif((End_Time - Start_Time)/1m,Start_Time > ago(30d))\r\n//,Command=any(Command)\r\n,Status=any(Status),Statement_Type=any(Statement_Type),Resource_class=any(Resource_class) by Request_ID\r\n| project ElapsedTime_min\r\n//,Command\r\n,Resource_class,Start_Time\r\n//,End_Time\r\n,Statement_Type,Status\r\n", "size": 4, "title": "Exec Requests", "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "conditionalVisibility": { "parameterName": "RequestId2", "comparison": "isNotEqualTo" }, "name": "query - 2 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolRequestSteps \r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where RequestId == '{RequestId2}' and RequestId != ''\r\n| summarize StartTime=max(StartTime)\r\n ,EndTime=max(EndTime)\r\n ,RequestID=max(RequestId)\r\n ,Operation=max(OperationType)\r\n ,RowCount=max(RowCount)\r\n ,Command=max(Command)\r\n ,Status=min(Status)\r\n by StepIndex\r\n| order by StepIndex asc\r\n| project StartTime,EndTime,Operation,RowCount,Command,Status,StepIndex", "size": 3, "title": "Request Steps", "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "conditionalVisibility": { "parameterName": "RequestId2", "comparison": "isNotEqualTo" }, "name": "query - 4 - Copy", "styleSettings": { "padding": "10px" } }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolExecRequests\r\n | where StatementType =='CreateStatistics'\r\n | where _ResourceId has '{DatabaseName}'\r\n | summarize \r\n Root_Query_Id=max(RootQueryId), \r\n Start_Time=max(StartTime),\r\n End_Compile_Time=max(EndCompileTime), \r\n End_Time=max(EndTime), \r\n Command=max(Command), \r\n Last_Status=min(Status),\r\n Statement_Type=max(StatementType),\r\n Resource_class=max(ResourceClass) \r\n by RequestId\r\n | where Root_Query_Id == '{RequestId2}'", "size": 0, "title": "Triggered Auto-Stats Statements", "noDataMessage": "No triggered autostats statements found", "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Submit_Time", "formatter": 0, "numberFormat": { "unit": 0, "options": { "style": "decimal" } } }, { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "100ch" } } ] } }, "conditionalVisibility": { "parameterName": "RequestId2", "comparison": "isNotEqualTo" }, "name": "All triggered auto-stats statements" } ] }, "customWidth": "50", "name": "RequestId2Group", "styleSettings": { "showBorder": true } } ] }, "conditionalVisibilities": [ { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "QueryComparison" }, { "parameterName": "DiagnosticsState", "comparison": "isEqualTo", "value": "enabled" } ], "name": "QueryComparison" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 1, "content": { "json": "## This tab is used to determine what statements triggerred autostats creation jobs. \r\nThe flow of autostats creation is as follows\r\n1. Query Submit Time\r\n2. \tCreate Statistics submit Time\r\n3. \tCreate Statistics end Time\r\n4. Query end_compile_time\r\n5. Query Start_Time\r\n6. Query End_Time\r\n\r\nFurther, if multiple stats are created, then the creation of all stats for this query will fall between query submit_time and end_compile_time. \r\n\r\nThe charts on this page allow you to search for an autostats job by requestID or my snippet of the autostats statement text, which can just be the schema, table, or column name. Then it will show you all commands that include that request ID or text. It will then show you all statements in the create stat statement because the query we are trying to identify will wait for all of those stats creations to complete before proceeding. \r\n\r\nThe last chart will list the statement that triggered the stats creation. " }, "name": "text - 6" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "df5b9b85-4188-4f2c-88cb-1369e09f6742", "version": "KqlParameterItem/1.0", "name": "RootQueryId", "type": 1, "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 } }, { "id": "560c9ec5-6341-4fa1-9ce6-35ff010151b1", "version": "KqlParameterItem/1.0", "name": "RequestId", "type": 1, "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 } } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 5" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "0911bd4b-d471-480b-bdf4-1a2d4ba1ea6e", "version": "KqlParameterItem/1.0", "name": "RequestIdSearch", "type": 1, "value": "", "label": "RequestId for AutoStats Job" }, { "id": "c12e6495-4fd1-473c-8ffc-0bf502f54706", "version": "KqlParameterItem/1.0", "name": "QueryTextSnippet", "type": 1, "value": "", "timeContext": { "durationMs": 86400000 }, "label": "Snippet of autostats creation statement (Schema, table or column)" } ], "style": "formVertical", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "customWidth": "60", "name": "parameters - 3 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolExecRequests\r\n | where StatementType =='CreateStatistics'\r\n | where _ResourceId has '{DatabaseName}'\r\n| summarize \r\n Root_Query_Id=max(RootQueryId), \r\n Start_Time=max(StartTime),\r\n End_Time=max(EndTime), \r\n Command=max(Command), \r\n Last_Status=min(Status),\r\n Statement_Type=max(StatementType)\r\n by RequestId\r\n| where Command has 'CREATE STATISTICS _wa_sys'\r\n| where Command has '{QueryTextSnippet}' and RequestId has '{RequestIdSearch}'\r\n//| extend elapsedTime_sec = iif(End_Time > ago(365d),(End_Time - Submit_Time)/1s,real(null)) \r\n//| extend CompileTime_sec = (End_Compile_Time - Submit_Time)/1s\r\n//| order by elapsedTime_sec\r\n//| summarize \r\n // Executions = count(),\r\n // Max_Elapsed_Time_sec = bin(max(elapsedTime_sec),1),\r\n // Min_Elapsed_Time_sec = bin(min(elapsedTime_sec),1),\r\n // Variability_sec=bin((max(elapsedTime_sec)-min(elapsedTime_sec)),1),\r\n // SampleQID = any(RequestId),\r\n // SampleSessionID = any(Session_ID)\r\n // by Command\r\n//| order by Max_Elapsed_Time_sec\r\n\r\n\r\n", "size": 0, "showAnalytics": true, "title": "Matching Autostats Queries", "noDataMessageStyle": 4, "timeContextFromParameter": "TimeRange", "exportedParameters": [ { "fieldName": "RequestId", "parameterName": "RequestId", "parameterType": 1 }, { "fieldName": "Root_Query_Id", "parameterName": "RootQueryId", "parameterType": 1 } ], "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "50%" } } ], "sortBy": [ { "itemKey": "Command", "sortOrder": 1 } ] }, "sortBy": [ { "itemKey": "Command", "sortOrder": 1 } ] }, "name": "query - 0 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolExecRequests\r\n | where StatementType !='CreateStatistics'\r\n | where _ResourceId has '{DatabaseName}'\r\n | where RequestId == '{RootQueryId}'\r\n | summarize \r\n Start_Time=max(StartTime),\r\n End_Compile_Time=max(EndCompileTime), \r\n End_Time=max(EndTime), \r\n Command=max(Command), \r\n Last_Status=min(Status),\r\n Statement_Type=max(StatementType),\r\n Resource_class=max(ResourceClass) \r\n by RequestId", "size": 3, "showAnalytics": true, "title": "Statement that Triggered Selected Autostat", "noDataMessage": "Select an autostats query above to see what query triggered it", "noDataMessageStyle": 4, "timeContextFromParameter": "TimeRange", "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "150ch" } } ], "sortBy": [ { "itemKey": "Command", "sortOrder": 1 } ] }, "sortBy": [ { "itemKey": "Command", "sortOrder": 1 } ] }, "name": "query - 0 - Copy - Copy - Copy - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolExecRequests\r\n | where StatementType =='CreateStatistics'\r\n | where _ResourceId has '{DatabaseName}'\r\n| summarize \r\n Root_Query_Id=max(RootQueryId), \r\n Start_Time=max(StartTime),\r\n End_Time=max(EndTime), \r\n Command=max(Command), \r\n Last_Status=min(Status),\r\n Statement_Type=max(StatementType)\r\n by RequestId\r\n| where Command has 'CREATE STATISTICS _wa_sys'\r\n| where Root_Query_Id == '{RootQueryId}'", "size": 3, "showAnalytics": true, "title": "All Stats Statements Triggered by selected Query", "noDataMessageStyle": 4, "timeContextFromParameter": "TimeRange", "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 13" } ] }, "conditionalVisibilities": [ { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "Statistics" }, { "parameterName": "DiagnosticsState", "comparison": "isEqualTo", "value": "enabled" } ], "name": "statistics" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 1, "content": { "json": "" }, "customWidth": "60", "showPin": false, "name": "Image" }, { "type": 1, "content": { "json": "Enable SQL Auditing to get additional visibility into user activity against your SQL Pool\r\n\r\nThis section provides additional monitoring coverage that is based on SQL Audit logs.
\r\nIf you have not activated SQL Auditing for your dedeciated SQL Pool, you must enable them to go to the same Log Analytics workspace as the rest of your diagnostic settings for it to show up here. [Learn more](https://docs.microsoft.com/en-us/azure/azure-sql/database/auditing-overview)\r\n" }, "customWidth": "60", "name": "text - 2" }, { "type": 11, "content": { "version": "LinkItem/1.0", "style": "paragraph", "links": [ { "id": "f4df7a1e-2124-4620-9005-f9b66e47f550", "cellValue": "{DatabaseResourceName}", "linkTarget": "Resource", "linkLabel": "Configure Logs for Auditing >", "subTarget": "auditing", "preText": "", "postText": "", "style": "primary" } ] }, "customWidth": "70", "name": "links - 8" } ] }, "customWidth": "90", "name": "Onboarding Message - Not onboarded yet" } ] }, "conditionalVisibilities": [ { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "QueryAudit" }, { "parameterName": "AuditingState", "comparison": "isEqualTo", "value": "disabled" } ], "name": "AuditingDisabledGroup" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 1, "content": { "json": "" }, "customWidth": "60", "showPin": false, "name": "Image" }, { "type": 1, "content": { "json": "Get more visibility into the usage and performance of your Azure Synapse Dedicated SQL Pool\r\n\r\nThis section provides additional monitoring coverage that is based on diagnostic logs.
\r\n\r\nIf you have not activated monitoring in diagnostic settings, you must enable the **ExecRequests** and **RequestSteps** logs and send them to a Log Analytics workspace. You may choose to enable the **SQLSecurityAuditEvents** table at the same time to take full advantage of this monitoring workbook. [Learn more](https://docs.microsoft.com/en-us/azure/synapse-analytics/monitoring/how-to-monitor-using-azure-monitor#logs)" }, "customWidth": "60", "name": "text - 2" }, { "type": 11, "content": { "version": "LinkItem/1.0", "style": "paragraph", "links": [ { "id": "f4df7a1e-2124-4620-9005-f9b66e47f550", "cellValue": "{DatabaseResourceName}", "linkTarget": "Resource", "linkLabel": "Configure Logs for Monitoring >", "subTarget": "diagnostics", "preText": "", "postText": "", "style": "primary" } ] }, "customWidth": "70", "name": "links - 8" } ] }, "customWidth": "90", "name": "Onboarding Message - Not onboarded yet" } ] }, "conditionalVisibilities": [ { "parameterName": "GroupSelection", "comparison": "isNotEqualTo", "value": "QueryAudit" }, { "parameterName": "DiagnosticsState", "comparison": "isEqualTo", "value": "disabled" } ], "name": "DiagnosticsDisabledGroup" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 1, "content": { "json": "# Use this page to search the audit logs for a particular query\r\nYou can search using a combination of: \r\n* Date: Set the time range using the parameter at the top of the workbook\r\n* User: only show queries for the specified user\r\n* Application: only show queries submitted by the specified application\r\n* Query Text Snippet(s) - mutliple fields are provided, if you enter data into multiple fields then it will look for all of those values combined in the results\r\nYou can then sort your results in teh chart below by duration or affected rows to find what you are looking for.\r\n\r\nNOTE: query text is limited to the first 4,000 characters" }, "name": "text - 3" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "parameters": [ { "id": "8d25c043-d1ff-4546-a1fa-f4bcbfdab8af", "version": "KqlParameterItem/1.0", "name": "User", "type": 2, "description": "User to filter subsequent queries - leave to 'unset' for all users", "query": "SQLSecurityAuditEvents \r\n| where LogicalServerName == '{LogicalServerName}'\r\n| summarize by ServerPrincipalName", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "value": null, "typeSettings": { "additionalResourceOptions": [], "showDefault": false }, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "id": "aa766d64-693f-4024-b4a4-b5b56b28376b", "version": "KqlParameterItem/1.0", "name": "Application", "type": 2, "query": "SQLSecurityAuditEvents \r\n| where LogicalServerName == '{LogicalServerName}'\r\n| summarize by ApplicationName", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "value": null, "typeSettings": { "additionalResourceOptions": [], "showDefault": false }, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "customWidth": "30", "name": "parameters - 1" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "add4bc9a-505f-4d22-9ba2-882be91adde0", "version": "KqlParameterItem/1.0", "name": "QueryTextSnippet", "type": 1, "timeContext": { "durationMs": 86400000 }, "value": "" }, { "id": "b78f8304-3dad-4b47-a624-380f6664dc35", "version": "KqlParameterItem/1.0", "name": "QueryTextSnippet2", "type": 1, "timeContext": { "durationMs": 86400000 }, "value": "" }, { "id": "516249a7-52fe-4ec4-9826-6f1b756405a8", "version": "KqlParameterItem/1.0", "name": "QueryTextSnippet3", "type": 1, "timeContext": { "durationMs": 86400000 } } ], "style": "formHorizontal", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 7" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SQLSecurityAuditEvents \r\n | where LogicalServerName == \"{LogicalServerName}\"\r\n | where DurationMs > 0\r\n | extend duration_seconds = DurationMs /1000.0\r\n | where Statement has '{QueryTextSnippet}' and Statement has '{QueryTextSnippet2}' and Statement has '{QueryTextSnippet3}'\r\n | where Statement != 'select @@version'\r\n | where Statement != 'SELECT @@SPID;'\r\n | where ServerPrincipalName has '{User}'\r\n | where ApplicationName has '{Application}'\r\n | project DatabaseName= DatabaseName, UserName= ServerPrincipalName, QueryEndTime= EventTime, Host= HostName, duration_seconds = round(duration_seconds), AffectedRows, Statement, QuerySource = ApplicationName \r\n | project-reorder DatabaseName, UserName, Host, QueryEndTime, duration_seconds, AffectedRows,Statement, QuerySource\r\n\r\n\r\n\r\n\r\n\r\n", "size": 2, "showAnalytics": true, "title": "Queries {User} {Application}", "noDataMessage": "Select a user to see query activity", "timeContextFromParameter": "TimeRange", "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Statement", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "96.4286ch" } } ], "sortBy": [ { "itemKey": "AffectedRows", "sortOrder": 2 } ] }, "sortBy": [ { "itemKey": "AffectedRows", "sortOrder": 2 } ] }, "showPin": true, "name": "query - 0 - Copy - Copy" } ] }, "conditionalVisibilities": [ { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "AuditSearch" }, { "parameterName": "AuditingState", "comparison": "isEqualTo", "value": "enabled" } ], "name": "AuditSearchGroup", "styleSettings": { "showBorder": true } }, { "type": 1, "content": { "json": "Workbook version: v1.0", "style": "info" }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "Overview" }, "customWidth": "15", "name": "version", "styleSettings": { "showBorder": true } } ], "fallbackResourceIds": [ "Azure Monitor" ], "$schema": "https://github.com/Microsoft/Application-Insights-Workbooks/blob/master/schema/workbook.json" } ================================================ FILE: Monitor_Workbooks/archive/DedicatedSqlPool_Non-Workspace_v1.32.workbook ================================================ { "version": "Notebook/1.0", "items": [ { "type": 9, "content": { "version": "KqlParameterItem/1.0", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "parameters": [ { "id": "28da10ec-a308-47f5-9819-92ebf810b292", "version": "KqlParameterItem/1.0", "name": "LogAnalyticsSubscription", "type": 6, "value": null, "typeSettings": { "additionalResourceOptions": [], "includeAll": true, "showDefault": false }, "timeContext": { "durationMs": 86400000 } }, { "id": "e383ed24-52ae-447b-9b80-51fd3ab6b919", "version": "KqlParameterItem/1.0", "name": "LogAnalyticsWorkspace", "type": 5, "query": "Resources\r\n| where type == 'microsoft.operationalinsights/workspaces'\r\n| project id\r\n", "crossComponentResources": [ "{LogAnalyticsSubscription}" ], "value": null, "typeSettings": { "additionalResourceOptions": [], "showDefault": false }, "timeContext": { "durationMs": 86400000 }, "queryType": 1, "resourceType": "microsoft.resourcegraph/resources" }, { "id": "9b9fe566-0f52-4a75-a35b-a79c50c6a6f0", "version": "KqlParameterItem/1.0", "name": "DatabaseResourceName", "type": 5, "query": "AzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| distinct ResourceId", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "value": null, "typeSettings": { "additionalResourceOptions": [], "showDefault": false }, "timeContext": { "durationMs": 2592000000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "id": "f5852627-70ca-4959-8d60-53b48864603f", "version": "KqlParameterItem/1.0", "name": "TimeRange", "type": 4, "isGlobal": true, "value": { "durationMs": 14400000 }, "typeSettings": { "selectableValues": [ { "durationMs": 300000 }, { "durationMs": 900000 }, { "durationMs": 1800000 }, { "durationMs": 3600000 }, { "durationMs": 14400000 }, { "durationMs": 43200000 }, { "durationMs": 86400000 }, { "durationMs": 172800000 }, { "durationMs": 259200000 }, { "durationMs": 604800000 }, { "durationMs": 1209600000 }, { "durationMs": 2419200000 }, { "durationMs": 2592000000 } ], "allowCustom": true }, "timeContext": { "durationMs": 86400000 } }, { "id": "6da2f63f-45a3-4b37-9108-5e8b7e358d85", "version": "KqlParameterItem/1.0", "name": "DatabaseName", "type": 1, "query": "AzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where ResourceId == '{DatabaseResourceName}'\r\n| distinct Resource ", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 604800000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "id": "8bba835b-f319-43b3-8ec6-4e051fc6d446", "version": "KqlParameterItem/1.0", "name": "LogicalServerName", "type": 1, "query": "AzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where ResourceId == '{DatabaseResourceName}'\r\n| distinct LogicalServerName_s", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 2" }, { "type": 11, "content": { "version": "LinkItem/1.0", "style": "tabs", "links": [ { "id": "202cbbc0-8d63-416d-89ed-451d6fe7c4b3", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Overview", "subTarget": "Workload", "preText": "Workload", "style": "link" }, { "id": "a7901bd0-a1f4-4491-b953-57555d764e00", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Workload Management", "subTarget": "WorkloadManagement", "style": "link" }, { "id": "45e12a14-8548-4477-aae3-c142b906dc9f", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "TempDB", "subTarget": "TempDB", "style": "link" }, { "id": "9ef8f730-d73d-432b-9b75-55095d1155f2", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Replicated Tables", "subTarget": "ReplicatedTables", "style": "link" }, { "id": "79d10d16-0696-4214-b306-c7a0e46cd64f", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Query Investigation", "subTarget": "QueryInvestigation", "style": "link" }, { "id": "31c1cf1c-74b5-44e2-ba9a-9497834ca3dc", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Query Comparison", "subTarget": "QueryComparison", "style": "link" }, { "id": "5ff681ee-e005-481f-b743-b66ab1b9d71d", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Session Investigation", "subTarget": "SessionInvestigation", "style": "link" }, { "id": "482ccc46-8a10-4ace-bfd6-63ac73b380af", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Query Audit", "subTarget": "QueryAudit", "style": "link" }, { "id": "db43bb45-1611-47ce-a2ad-517943f2aa1a", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "AutoStats", "subTarget": "Statistics", "style": "link" } ] }, "name": "links - 0" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "title": "Workload", "items": [ { "type": 10, "content": { "chartId": "workbook90867bfc-5c33-464f-ac31-2c2e006b97f4", "version": "MetricsItem/2.0", "size": 0, "chartType": 2, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 14400000 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-dwu_consumption_percent", "aggregation": 3, "splitBy": null, "columnName": "DWU Percentage" }, { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-cpu_percent", "aggregation": 3 }, { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-physical_data_read_percent", "aggregation": 3 } ], "title": "DWU Resource Utilization", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "name": "metric - 1" }, { "type": 10, "content": { "chartId": "workbookb954d4a0-82ef-4409-88fb-837aaff80c8d", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 14400000 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-active_queries", "aggregation": 1, "splitBy": null }, { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-queued_queries", "aggregation": 1 } ], "title": "Active and Queued Queries", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "name": "metric - 1" }, { "type": 10, "content": { "chartId": "workbookb954d4a0-82ef-4409-88fb-837aaff80c8d", "version": "MetricsItem/2.0", "size": 0, "chartType": 3, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 14400000 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-local_tempdb_usage_percent", "aggregation": 3, "splitBy": null, "columnName": "TempDB Utilization Percentage" } ], "title": "TempDB Utilization", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "name": "metric - 1 - Copy" }, { "type": 10, "content": { "chartId": "workbookb954d4a0-82ef-4409-88fb-837aaff80c8d", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 14400000 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-WorkloadManagement-wlg_allocation_relative_to_system_percent", "aggregation": 3, "splitBy": "WorkloadGroupName" } ], "title": "Workload Group Utilization", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "name": "Workload Group Utilization" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databaseName = '{DatabaseName}';\r\n//Long-Running Queries - Just Actual Queries\r\n//If 'Command' is empty - you need to set a bigger time window, the older record with the command is outside of your window\r\nAzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where Resource == databaseName\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize Session_ID=any(SessionId_s),\r\n Request_ID=any(RequestId_s),\r\n Submit_Time=max(SubmitTime_t),\r\n Start_Time=max(StartTime_t),\r\n End_Time=max(EndTime_t),\r\n Command=any(Command_s),\r\n Status=min(Status_s), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType_s),\r\n Resource_class=any(ResourceClass_s)\r\n by RequestId_s\r\n| summarize ElapsedTime_min=bin(anyif(((End_Time - Start_Time)/1m),Start_Time > ago(30d)),1),\r\n Session_ID=any(Session_ID), \r\n Submit_Time=any(Submit_Time) ,\r\n Start_Time=any(Start_Time), \r\n End_Time=any(End_Time),\r\n Command=any(Command),\r\n Status=any(Status),\r\n Statement_Type=any(Statement_Type)\r\n ,Resource_class=any(Resource_class) \r\n by Request_ID\r\n| where End_Time > ago(365d)\r\n| summarize count() by Status, bin(End_Time,5m)\r\n| render barchart \r\n", "size": 0, "title": "Query Completion Count by End Time - 5m buckets", "color": "redBright", "timeContextFromParameter": "TimeRange", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "chartSettings": { "seriesLabelSettings": [ { "seriesName": "Completed", "color": "green" }, { "seriesName": "Failed", "color": "red" }, { "seriesName": "Cancelled", "color": "yellow" } ] } }, "name": "query - 4" }, { "type": 1, "content": { "json": "Use the buttons below to filter the next chart for Success or Failed queries. In many cases a failed query may not have a 'Command' column populated depending on what stage the query failed in. ", "style": "info" }, "name": "text - 3" }, { "type": 11, "content": { "version": "LinkItem/1.0", "style": "nav", "links": [ { "id": "8e89112f-c67f-42c0-9622-02fa306fb7a5", "cellValue": "QueryCompletionType", "linkTarget": "parameter", "linkLabel": "All Queries", "subTarget": "''", "style": "primary" }, { "id": "6abe39c7-4d4e-4c45-aa54-dc9a4c5e876e", "cellValue": "QueryCompletionType", "linkTarget": "parameter", "linkLabel": "Success Only", "subTarget": "Completed", "preText": "", "style": "secondary" }, { "id": "e41b4a0b-8464-491e-92be-a57217d6dcac", "cellValue": "QueryCompletionType", "linkTarget": "parameter", "linkLabel": "Failures Only", "subTarget": "Failed", "preText": "", "style": "secondary" } ] }, "name": "links - 11" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databaseName = '{DatabaseName}';\r\n//Long-Running Queries - Just Actual Queries\r\n//If 'Command' is empty - you need to set a bigger time window, the older record with the command is outside of your window\r\nAzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where Resource == databaseName\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize Session_ID=any(SessionId_s),\r\n Request_ID=any(RequestId_s),\r\n Submit_Time=max(SubmitTime_t),\r\n Start_Time=max(StartTime_t),\r\n End_Time=max(EndTime_t),\r\n Command=max(Command_s),\r\n Status=min(Status_s), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType_s),\r\n Resource_class=any(ResourceClass_s)\r\n by RequestId_s\r\n| summarize ElapsedTime_min=bin(anyif(((End_Time - Start_Time)/1m),Start_Time > ago(30d)),1),\r\n Session_ID=any(Session_ID), \r\n Submit_Time=min(Submit_Time) ,\r\n Start_Time=any(Start_Time), \r\n End_Time=any(End_Time),\r\n Command=any(Command),\r\n Status=any(Status),\r\n Statement_Type=any(Statement_Type)\r\n ,Resource_class=any(Resource_class) \r\n by Request_ID\r\n//| where End_Time > ago(365d)\r\n| where Status has '{QueryCompletionType}'\r\n| order by Submit_Time\r\n\r\n", "size": 0, "title": "Query Completions - use above buttons to filter", "color": "redBright", "timeContextFromParameter": "TimeRange", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "rowLimit": 100 }, "chartSettings": { "seriesLabelSettings": [ { "seriesName": "Completed", "color": "green" }, { "seriesName": "Failed", "color": "red" }, { "seriesName": "Cancelled", "color": "yellow" } ] } }, "name": "query - 4 - Copy" } ] }, "name": "Query Completions", "styleSettings": { "showBorder": true } }, { "type": 10, "content": { "chartId": "workbook1afc57e6-0b32-4968-b299-db319bd21635", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 14400000 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-connection_successful", "aggregation": 1, "splitBy": null }, { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-connection_failed", "aggregation": 1 } ], "title": "Successful and Failed Connections", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "name": "metric - 5" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 3, "content": { "version": "KqlItem/1.0", "query": " AzureDiagnostics\r\n | where Category == 'SQLSecurityAuditEvents' and LogicalServerName_s == 'lasr-sqldwdb-eastus2-prd'\r\n | where action_name_s in ('DATABASE AUTHENTICATION SUCCEEDED','DATABASE AUTHENTICATION FAILED')\r\n | project SourceSystem,client_tls_version_d,succeeded_s,session_id_d,client_ip_s,session_server_principal_name_s,server_principal_name_s,database_principal_name_s,application_name_s,host_name_s,TimeGenerated\r\n | summarize count() by succeeded_s,bin(TimeGenerated,1m)\r\n | render barchart\r\n\r\n\r\n\r\n", "size": 0, "title": "Database Authentication success/failure rate", "timeContextFromParameter": "TimeRange", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "chartSettings": { "xAxis": "TimeGenerated", "group": "succeeded_s", "createOtherGroup": null } }, "name": "query - 8" }, { "type": 11, "content": { "version": "LinkItem/1.0", "style": "nav", "links": [ { "id": "2ed22e0a-2b53-4ed0-8f65-d2c621f34dad", "cellValue": "AuthResult", "linkTarget": "parameter", "linkLabel": "All Authentications", "subTarget": "''", "style": "primary" }, { "id": "2789ab13-ae8a-472e-bad4-9c9bdc934d4d", "cellValue": "AuthResult", "linkTarget": "parameter", "linkLabel": "Success Only", "subTarget": "true", "style": "secondary" }, { "id": "5cf4ddd4-e189-4b71-b456-0d4f1572a0a3", "cellValue": "AuthResult", "linkTarget": "parameter", "linkLabel": "Failures Only", "subTarget": "false", "style": "secondary" } ] }, "name": "links - 10" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": " AzureDiagnostics\r\n | where Category == 'SQLSecurityAuditEvents' and LogicalServerName_s == 'lasr-sqldwdb-eastus2-prd'\r\n | where action_name_s in ('DATABASE AUTHENTICATION SUCCEEDED','DATABASE AUTHENTICATION FAILED')\r\n | where succeeded_s has '{AuthResult}'\r\n | project SourceSystem,client_tls_version_d,succeeded_s,session_id_d,client_ip_s,session_server_principal_name_s,server_principal_name_s,database_principal_name_s,application_name_s,host_name_s,TimeGenerated\r\n | order by TimeGenerated\r\n\r\n\r\n\r\n\r\n", "size": 0, "title": "Database Authentication success/failure rate", "noDataMessage": "Please select a button above", "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "rowLimit": 100 }, "chartSettings": { "xAxis": "TimeGenerated", "group": "succeeded_s", "createOtherGroup": null, "showLegend": true } }, "name": "query - 8 - Copy" } ] }, "name": "Database Authentication Group", "styleSettings": { "showBorder": true } }, { "type": 10, "content": { "chartId": "workbook993837ad-66d6-4cbc-ae1a-7c3f6623236b", "version": "MetricsItem/2.0", "size": 0, "chartType": 2, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 14400000 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-cache_used_percent", "aggregation": 3, "splitBy": null }, { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-cache_hit_percent", "aggregation": 3 } ], "title": "Adaptive Cache Used vs Hit Percentage", "gridSettings": { "rowLimit": 10000 } }, "name": "metric - 6" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "Workload" }, "name": "group - 1" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "title": "TempDB ", "items": [ { "type": 10, "content": { "chartId": "workbook4a9cf761-cce2-45b2-8947-8a9428ec7e1c", "version": "MetricsItem/2.0", "size": 0, "chartType": 3, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 14400000 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-local_tempdb_usage_percent", "aggregation": 3, "splitBy": null, "columnName": "TempDB Util" } ], "title": "TempDB Max and Avg Utilization", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "name": "metric - 0" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "19ee48f5-8f4e-4939-a0ef-c6bf656a93f9", "version": "KqlParameterItem/1.0", "name": "WeightParameter", "type": 1, "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 } }, { "id": "00553ec8-1a41-4dd9-a024-d607639c9bbb", "version": "KqlParameterItem/1.0", "name": "RequestID", "type": 1, "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 } } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 3" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databaseName = '{DatabaseName}';\r\n//Weighted query steps\r\nAzureDiagnostics\r\n| where Category == 'RequestSteps'\r\n| where Resource == databaseName\r\n| where RowCount_d > 0\r\n| summarize sum(RowCount_d) by RequestId_s, OperationType_s\r\n| order by sum_RowCount_d desc\r\n| limit 20\r\n| render columnchart ", "size": 0, "title": "20 Largest Query Steps by Most Rows Moved", "timeContextFromParameter": "TimeRange", "exportFieldName": "Request_ID", "exportParameterName": "RequestID", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "chartSettings": { "xAxis": "RequestId_s", "group": "OperationType_s", "createOtherGroup": 20, "showLegend": true } }, "name": "query - 1 - Copy" }, { "type": 11, "content": { "version": "LinkItem/1.0", "style": "nav", "links": [ { "id": "c98d3722-9907-43ab-9306-1957d6f7f858", "cellValue": "WeightParameter", "linkTarget": "parameter", "linkLabel": "Weighted Rowcounts", "subTarget": "Weighted", "preText": "", "postText": "", "style": "secondary" }, { "id": "a06ae99a-ad62-45e9-8c25-c219b81f59c0", "cellValue": "WeightParameter", "linkTarget": "parameter", "linkLabel": "Unweighted Rowcounts", "subTarget": "Unweighted", "preText": "", "postText": "", "style": "secondary" } ] }, "name": "links - 3" }, { "type": 1, "content": { "json": "Current Setting: {WeightParameter}", "style": "info" }, "name": "text - 4" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databaseName = '{DatabaseName}';\r\n//Weighted query steps\r\nlet RequestSteps = AzureDiagnostics\r\n| where Category == 'RequestSteps'\r\n| where Resource == databaseName\r\n| where RowCount_d > 100000000\r\n| extend Step_Elapsed_Min = round((EndTime_t - StartTime_t)/1m, 2)\r\n| extend Weighted_cnt = iff('{WeightParameter}'=='Weighted',(case(OperationType_s == 'BroadcastMoveOperation', (RowCount_d*20), RowCount_d)),RowCount_d)\r\n| project-rename StepStatus = Status_s, StepStart = StartTime_t, StepEnd = EndTime_t//, StepResource = Resource\r\n| top 100 by Weighted_cnt desc\r\n| order by Weighted_cnt desc\r\n| project Request_ID=RequestId_s,OperationType_s, RowCount_d,Weighted_cnt,Step_Elapsed_Min, StepStart, StepEnd, StepStatus, StepIndex_d,Resource;\r\nRequestSteps | join (AzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where Resource == databaseName\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize Session_ID=any(SessionId_s),\r\n Request_ID=any(RequestId_s),\r\n Submit_Time=max(SubmitTime_t),\r\n Start_Time=max(StartTime_t),\r\n End_Time=max(EndTime_t),\r\n Command=any(Command_s),\r\n Status=min(Status_s), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType_s),\r\n Resource_class=any(ResourceClass_s)\r\n by RequestId_s\r\n| summarize Session_ID=any(Session_ID), Submit_Time=any(Submit_Time) ,Start_Time=any(Start_Time), End_Time=any(End_Time),Command=any(Command),Status=any(Status),Statement_Type=any(Statement_Type),Resource_class=any(Resource_class) by Request_ID\r\n//| order by Step_Elapsed_Min desc\r\n| extend Request_Elapsed_Min = round((End_Time - Start_Time)/1m, 2)\r\n| project-rename ReqStatus = Status, ReqStart = Start_Time, ReqEnd = End_Time\r\n) on Request_ID\r\n| project-reorder Session_ID, Request_ID, Request_Elapsed_Min, ReqStart, ReqEnd, ReqStatus,StepIndex_d, OperationType_s, RowCount_d,Weighted_cnt,Step_Elapsed_Min, StepStart, StepEnd, StepStatus, Statement_Type, Command, Resource_class\r\n| order by Weighted_cnt desc\r\n| limit 20", "size": 3, "showAnalytics": true, "title": "20 Largest Query Steps by Most Rows Moved", "timeContextFromParameter": "TimeRange", "exportFieldName": "Request_ID1", "exportParameterName": "RequestID", "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "sortBy": [ { "itemKey": "Weighted_cnt", "sortOrder": 2 } ] }, "sortBy": [ { "itemKey": "Weighted_cnt", "sortOrder": 2 } ] }, "name": "query - 1" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databaseName = '{DatabaseName}';\r\n//Long-Running Queries - Just Actual Queries\r\n//If 'Command' is empty - you need to set a bigger time window, the older record with the command is outside of your window\r\nAzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where Resource == databaseName\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize Session_ID=any(SessionId_s),\r\n Request_ID=any(RequestId_s),\r\n Submit_Time=max(SubmitTime_t),\r\n Start_Time=max(StartTime_t),\r\n End_Time=max(EndTime_t),\r\n Command=any(Command_s),\r\n Status=min(Status_s), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType_s),\r\n Resource_class=any(ResourceClass_s)\r\n by RequestId_s\r\n| summarize ElapsedTime_min=bin(anyif(((End_Time - Start_Time)/1m),Start_Time > ago(30d)),1),\r\n Session_ID=any(Session_ID), \r\n Submit_Time=any(Submit_Time) ,\r\n Start_Time=any(Start_Time), \r\n End_Time=any(End_Time),\r\n Command=any(Command),\r\n Status=any(Status),\r\n Statement_Type=any(Statement_Type)\r\n ,Resource_class=any(Resource_class) \r\n by Request_ID\r\n| where Request_ID == '{RequestID}'\r\n\r\n", "size": 4, "showAnalytics": true, "title": "Selected Query", "noDataMessage": "Select a query above to view details", "timeContextFromParameter": "TimeRange", "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "35%" } } ] } }, "name": "query - 6" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics\r\n| where Category == 'RequestSteps'\r\n| where Resource == '{DatabaseName}'\r\n| where RequestId_s == '{RequestID}' //Put your QueryID here\r\n| where Status_s != 'Running'\r\n| summarize max(StartTime_t),max(EndTime_t),max(RequestId_s),max(OperationType_s),max(RowCount_d),max(Command_s),max(Status_s) by StepIndex_d\r\n| order by StepIndex_d asc", "size": 3, "showAnalytics": true, "title": "Query Plan", "noDataMessage": "Select a query above to view the plan", "timeContextFromParameter": "TimeRange", "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 7" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "TempDB" }, "name": "group - 3" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "title": "Query Investigation", "items": [ { "type": 1, "content": { "json": "## Search Criteria\r\nUse the following fields to search either using a query text snippet or using a Request ID. If using a query text snippet, try to keep it as simple as possible becuase minor changes in formatting may cause your queries not to show up in the results. It's best to pick something like a table name, then choose the proper query from the list that will populate. " }, "customWidth": "50", "name": "text - 4" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "0c2128d0-d979-4562-a28c-e7ceb955f126", "version": "KqlParameterItem/1.0", "name": "RequestIdSearch", "type": 1, "value": "" }, { "id": "29880874-2d41-4bd5-bf22-3e47ae8b1145", "version": "KqlParameterItem/1.0", "name": "QueryTextSnippet", "type": 1, "value": "", "timeContext": { "durationMs": 86400000 } } ], "style": "formVertical", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "customWidth": "60", "name": "parameters - 3" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics \r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize \r\n Session_ID=max(SessionId_s), \r\n Request_ID=max(RequestId_s), \r\n Submit_Time=max(SubmitTime_t), \r\n Start_Time=max(StartTime_t),\r\n End_Compile_Time=max(EndCompileTime_t), \r\n End_Time=max(EndTime_t), \r\n Command=max(Command_s), \r\n Last_Status=min(Status_s),\r\n Statement_Type=max(StatementType_s),\r\n Resource_class=max(ResourceClass_s) \r\n by RequestId_s\r\n| where Command has '{QueryTextSnippet}'\r\nand RequestId_s has '{RequestIdSearch}'\r\n| extend elapsedTime_sec = iif(End_Time > ago(365d),(End_Time - Submit_Time)/1s,real(null)) \r\n| extend CompileTime_sec = (End_Compile_Time - Submit_Time)/1s\r\n| order by elapsedTime_sec\r\n| summarize \r\n Executions = count(),\r\n Max_Elapsed_Time_sec = bin(max(elapsedTime_sec),1),\r\n Min_Elapsed_Time_sec = bin(min(elapsedTime_sec),1),\r\n Variability_sec=bin((max(elapsedTime_sec)-min(elapsedTime_sec)),1),\r\n SampleQID = any(RequestId_s),\r\n SampleSessionID = any(Session_ID)\r\n by Command\r\n| order by Max_Elapsed_Time_sec\r\n\r\n\r\n", "size": 0, "showAnalytics": true, "title": "Matching Queries", "timeContextFromParameter": "TimeRange", "exportedParameters": [ { "fieldName": "SampleQID", "parameterName": "SampleQID" }, { "fieldName": "SampleSessionID", "parameterName": "Samp", "parameterType": 1 } ], "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "50%" } } ], "sortBy": [ { "itemKey": "Command", "sortOrder": 1 } ] }, "sortBy": [ { "itemKey": "Command", "sortOrder": 1 } ] }, "name": "query - 0" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics \r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s !in ('Batch','Execute')\r\n| where RequestId_s == '{SampleQID}'\r\n| summarize \r\n Session_ID=max(SessionId_s), \r\n Request_ID=max(RequestId_s), \r\n Submit_Time=min(SubmitTime_t), \r\n Start_Time=max(StartTime_t),\r\n End_Compile_Time=max(EndCompileTime_t), \r\n End_Time=max(EndTime_t), \r\n Command=max(Command_s), \r\n Last_Status=min(Status_s),\r\n Statement_Type=max(StatementType_s),\r\n Resource_class=max(ResourceClass_s) \r\n by RequestId_s\r\n| extend elapsedTime_sec = iif(End_Time > ago(365d),(End_Time - Submit_Time)/1s,real(null)) \r\n| extend CompileTime_sec = (End_Compile_Time - Submit_Time)/1s\r\n| join kind=inner\r\n (AzureDiagnostics \r\n | where Category == 'ExecRequests'\r\n | where Resource == '{DatabaseName}'\r\n | where StatementType_s !in ('Batch','Execute')\r\n | summarize \r\n Session_ID=max(SessionId_s), \r\n Request_ID=max(RequestId_s), \r\n Submit_Time=min(SubmitTime_t), \r\n Start_Time=max(StartTime_t),\r\n End_Compile_Time=max(EndCompileTime_t), \r\n End_Time=max(EndTime_t), \r\n Command=max(Command_s), \r\n Last_Status=min(Status_s),\r\n Statement_Type=max(StatementType_s),\r\n Resource_class=max(ResourceClass_s) \r\n by RequestId_s\r\n | extend elapsedTime_sec = (End_Time - Submit_Time)/1s\r\n | extend elapsedTime_sec = iif(End_Time > ago(365d),(End_Time - Submit_Time)/1s,real(null)) \r\n | extend CompileTime_sec = (End_Compile_Time - Submit_Time)/1s\r\n )\r\non Command \r\n| project Request_ID1,Session_ID1,Submit_Time1,Start_Time1,End_Compile_Time1,End_Time1,Last_Status1,Statement_Type1,Resource_class1,elapsedTime_sec1,CompileTime_sec1\r\n", "size": 0, "showAnalytics": true, "title": "All Executions of Selected Query", "noDataMessage": "Select a query above to see individual executions", "timeContextFromParameter": "TimeRange", "exportFieldName": "Request_ID1", "exportParameterName": "RequestId", "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "sortBy": [] }, "name": "query - 0 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics\r\n| where Category == 'RequestSteps'\r\n| where Resource == '{DatabaseName}'\r\n| where RequestId_s == '{RequestId}'\r\n//| where Status_s != 'Running'\r\n| summarize max(StartTime_t),max(EndTime_t),max(RequestId_s),max(OperationType_s),max(RowCount_d),max(Command_s),min(Status_s) by StepIndex_d\r\n| order by StepIndex_d asc", "size": 3, "showAnalytics": true, "title": "Query Plan for Selected Query", "noDataMessage": "Select a Query Above to See the Query Plan", "timeContextFromParameter": "TimeRange", "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 0 - Copy - Copy" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "parameters": [ { "id": "1191e58a-c1f9-4853-b36b-4be8eecbb48f", "version": "KqlParameterItem/1.0", "name": "Query_Submit_Time", "type": 1, "query": " AzureDiagnostics \r\n | where Category == 'ExecRequests'\r\n | where Resource == '{DatabaseName}'\r\n | where StatementType_s !in ('Batch','Execute')\r\n | where RequestId_s =='{RequestId}'\r\n | summarize \r\n Submit_Time=min(SubmitTime_t)\r\n by RequestId_s\r\n | project Submit_Time", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "id": "f6bcb2a4-3356-4110-ba13-99c7d13a26f0", "version": "KqlParameterItem/1.0", "name": "Query_End_Compile_Time", "type": 1, "query": " AzureDiagnostics \r\n | where Category == 'ExecRequests'\r\n | where Resource == '{DatabaseName}'\r\n | where StatementType_s !in ('Batch','Execute')\r\n | where RequestId_s =='{RequestId}'\r\n | summarize \r\n End_Compile_Time=max(EndCompileTime_t) \r\n by RequestId_s\r\n | project End_Compile_Time", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 6" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": " AzureDiagnostics \r\n | where Category == 'ExecRequests'\r\n | where Resource == 'LASR-SQLDWDB-PRD'\r\n | where StatementType_s =='CreateStatistics'\r\n | summarize \r\n Session_ID=max(SessionId_s), \r\n Request_ID=max(RequestId_s), \r\n Submit_Time=min(SubmitTime_t), \r\n Start_Time=max(StartTime_t),\r\n End_Compile_Time=max(EndCompileTime_t), \r\n End_Time=max(EndTime_t), \r\n Command=max(Command_s), \r\n Last_Status=min(Status_s),\r\n Statement_Type=max(StatementType_s),\r\n Resource_class=max(ResourceClass_s) \r\n by RequestId_s\r\n | where Submit_Time > datetime('{Query_Submit_Time}') and End_Time < datetime('{Query_End_Compile_Time}')// or RequestId_s == '{RequestId}'\r\n", "size": 0, "showAnalytics": true, "title": "All possibly related auto-stats statements based on time", "noDataMessage": "no auto stats statements found that could be related", "timeContextFromParameter": "TimeRange", "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Submit_Time", "formatter": 0, "numberFormat": { "unit": 0, "options": { "style": "decimal" } } }, { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "100ch" } } ] } }, "name": "All possibly related auto-stats statements" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "QueryInvestigation" }, "name": "group - 4", "styleSettings": { "showBorder": true } }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "title": "Replicated Tables", "items": [ { "type": 1, "content": { "json": "All Charts on this page are based on the last 7 days of data", "style": "info" }, "name": "text - 5" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Build cache count by day\r\nAzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s == 'BuildReplicatedTableCache'\r\n| where Command_s != \"\"\r\n| where ResourceClass_s != \"\"\r\n| project Command_s,TimeGenerated,RequestId_s\r\n| summarize LastRebuild=max(TimeGenerated),RebuildCount=count(RequestId_s) by Command_s\r\n| order by RebuildCount desc\r\n| limit 15\r\n", "size": 3, "showAnalytics": true, "title": "Top 15 Most Rebuilds by Table", "timeContext": { "durationMs": 604800000 }, "exportFieldName": "Command_s", "exportParameterName": "QueryText", "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command_s", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "40%" } } ] } }, "name": "query - 0" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Build cache count by day\r\nAzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s == 'BuildReplicatedTableCache'\r\n| where Command_s == \"{QueryText}\"\r\n| where ResourceClass_s != \"\"\r\n| project Command_s,TimeGenerated,RequestId_s\r\n| summarize count() by Command_s,bin(TimeGenerated,24h)\r\n| limit 20\r\n| render timechart", "size": 0, "showAnalytics": true, "title": "Rebuilds per Day for Selected Table", "noDataMessage": "Select a query above to see runs by day", "timeContext": { "durationMs": 604800000 }, "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "chartSettings": { "group": "Command_s", "createOtherGroup": 20, "ySettings": { "min": 0 } } }, "name": "query - 0 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Build cache count by day\r\nAzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s == 'BuildReplicatedTableCache'\r\n| where Command_s != \"\"\r\n| where ResourceClass_s != \"\"\r\n| project Command_s,TimeGenerated,RequestId_s\r\n| summarize count() by Command_s, bin(TimeGenerated,24h)\r\n| where count_ > 7\r\n| order by count_ desc\r\n\r\n", "size": 2, "title": "Rebuild Count by Table by Day", "noDataMessage": " Only tables with more than 7 total rebuilds will show up. If no talbes with that many rebuilds are found this chart will be empty", "timeContext": { "durationMs": 604800000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "categoricalbar", "gridSettings": { "sortBy": [ { "itemKey": "count_", "sortOrder": 1 } ] }, "sortBy": [ { "itemKey": "count_", "sortOrder": 1 } ], "tileSettings": { "showBorder": false, "titleContent": { "columnMatch": "Command_s", "formatter": 1 }, "leftContent": { "columnMatch": "count_", "formatter": 12, "formatOptions": { "palette": "auto" }, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "graphSettings": { "type": 0, "topContent": { "columnMatch": "Command_s", "formatter": 1 }, "centerContent": { "columnMatch": "count_", "formatter": 1, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "chartSettings": { "group": "Command_s", "createOtherGroup": 99, "showDataPoints": true } }, "name": "query - 0 - Copy - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Long-Running Queries - Just Actual Queries\r\nAzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize Session_ID=max(SessionId_s), Request_ID=max(RequestId_s), Submit_Time=max(SubmitTime_t), Start_Time=max(StartTime_t), End_Time=max(EndTime_t), Command=max(Command_s), Statement_Type=max(StatementType_s), Resource_class=max(ResourceClass_s) by RequestId_s\r\n| join kind= inner\r\n(\r\n AzureDiagnostics\r\n | where Category == 'ExecRequests'\r\n | where Resource == '{DatabaseName}'\r\n //| where StatementType_s !in ('Batch','Execute')\r\n | where StatementType_s == 'BuildReplicatedTableCache'\r\n | where EndTime_t > ago(7d)\r\n | where StartTime_t > ago(7d)\r\n | extend elapsedTime_min = (EndTime_t - StartTime_t)/1m\r\n //| extend elapsedTime_min = elapsedTime/1m\r\n | order by elapsedTime_min desc\r\n | project Request_ID=RequestId_s,elapsedTime_min \r\n)\r\non Request_ID\r\n| order by elapsedTime_min desc\r\n| project Request_ID,Submit_Time,Start_Time,End_Time,Elapsed_Time=round(elapsedTime_min,1) ,Command\r\n| limit 15\r\n", "size": 3, "showAnalytics": true, "title": "Top 15 Elapsed Time per Rebuild", "timeContext": { "durationMs": 604800000 }, "exportFieldName": "Request_ID", "exportParameterName": "RequestId", "exportDefaultValue": "999999", "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "40%" } } ] } }, "name": "query - 3" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics\r\n| where Category == 'RequestSteps'\r\n| where Resource == '{DatabaseName}'\r\n| where RequestId_s == '{RequestId}'\r\n| where Status_s != 'Running'\r\n| summarize max(StartTime_t),max(EndTime_t),max(RequestId_s),max(OperationType_s),max(RowCount_d),max(Command_s),max(Status_s) by StepIndex_d\r\n| order by StepIndex_d asc", "size": 3, "showAnalytics": true, "title": "Query Plan for Selected Query", "noDataMessage": "Select a query above to view plan", "timeContext": { "durationMs": 604800000 }, "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 4" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "ReplicatedTables" }, "name": "ReplicatedTablesGroup" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "title": "Workload Management", "items": [ { "type": 10, "content": { "chartId": "workbook72446028-6edb-4cb0-8952-e0c13bda488f", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 14400000 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-WorkloadManagement-wlg_allocation_relative_to_system_percent", "aggregation": 3, "splitBy": null } ], "title": "Workload Group Allocation By System Percent", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "name": "metric - 0" }, { "type": 10, "content": { "chartId": "workbookc898119a-7381-469d-b51a-d505b4f80e73", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 14400000 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-WorkloadManagement-wlg_active_queries", "aggregation": 1, "splitBy": null } ], "title": "Query Count by Workload Group", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "name": "metric - 1" }, { "type": 10, "content": { "chartId": "workbook8d175f6c-427b-47fc-85ea-37edd0be707c", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 14400000 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-WorkloadManagement-wlg_queued_queries", "aggregation": 1, "splitBy": null } ], "title": "Queued Queries by Workload Group", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "name": "Queued Queries by Workload Group" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "parameters": [ { "id": "6f50577d-7b00-4e4a-acf9-d45c7a5ee813", "version": "KqlParameterItem/1.0", "name": "WorkloadGroupName", "type": 2, "query": "AzureDiagnostics\r\n| where Category == 'ExecRequests'\r\nand Resource == '{DatabaseName}'\r\n and ResourceClass_s != \"\"\r\n| distinct ResourceClass_s", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "value": null, "typeSettings": { "additionalResourceOptions": [], "showDefault": false }, "timeContext": { "durationMs": 604800000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 2" }, { "type": 10, "content": { "chartId": "workbook3da1d18a-1bf5-46c5-b3b7-211f71d329cc", "version": "MetricsItem/2.0", "size": 0, "chartType": 2, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 14400000 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-WorkloadManagement-wlg_active_queries", "aggregation": 1, "splitBy": null }, { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-WorkloadManagement-wlg_queued_queries", "aggregation": 1 }, { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-WorkloadManagement-wlg_allocation_relative_to_system_percent", "aggregation": 3 } ], "filters": [ { "id": "3", "key": "WorkloadGroupName", "operator": 0, "valueParam": "WorkloadGroupName" } ], "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "name": "metric - 3" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "WorkloadManagement" }, "name": "group - 6" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "title": "Query Audit", "items": [ { "type": 1, "content": { "json": "## Select a Principal or Application name to filter results - leave to 'unset' to view all results\r\nSQL Auditing must be enabled and sending to the same Log Analytics Workspace for this page to work. " }, "name": "text - 5" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "parameters": [ { "id": "8d25c043-d1ff-4546-a1fa-f4bcbfdab8af", "version": "KqlParameterItem/1.0", "name": "User", "type": 2, "description": "User to filter subsequent queries - leave to 'unset' for all users", "query": "AzureDiagnostics\r\n| where Category == 'SQLSecurityAuditEvents' and LogicalServerName_s == '{LogicalServerName}'\r\n| summarize by server_principal_name_s", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "value": null, "typeSettings": { "additionalResourceOptions": [], "showDefault": false }, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "id": "aa766d64-693f-4024-b4a4-b5b56b28376b", "version": "KqlParameterItem/1.0", "name": "Application", "type": 2, "query": "AzureDiagnostics\r\n| where Category == 'SQLSecurityAuditEvents' and LogicalServerName_s == '{LogicalServerName}'\r\n| summarize by application_name_s", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "value": null, "typeSettings": { "additionalResourceOptions": [], "showDefault": false }, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "customWidth": "30", "name": "parameters - 1" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics\r\n| where Category == 'SQLSecurityAuditEvents' and LogicalServerName_s == \"{LogicalServerName}\"\r\n| where duration_milliseconds_d > 0\r\n| extend duration_seconds = duration_milliseconds_d /1000.0\r\n| where statement_s != 'select @@version'\r\n| where statement_s != 'SELECT @@SPID;'\r\n| where server_principal_name_s has '{User}'\r\n| where application_name_s has '{Application}'\r\n| project server_principal_name_s, succeeded_s, event_time_t, LogicalServerName_s, duration_milliseconds_d, duration_seconds, affected_rows_d, statement_s, application_name_s\r\n| summarize duration_seconds = round(sum(duration_seconds)) , query_count = count(statement_s) by EventDay = bin(event_time_t,1d), UserName = server_principal_name_s, Application = application_name_s \r\n| order by EventDay, duration_seconds desc", "size": 0, "showAnalytics": true, "title": "Query Summary for Selected User {User} {Application}", "noDataMessage": "Select a user to see query activity", "timeContextFromParameter": "TimeRange", "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 0 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics\r\n| where Category == 'SQLSecurityAuditEvents' and LogicalServerName_s == \"{LogicalServerName}\"\r\n| where duration_milliseconds_d > 0\r\n| extend duration_seconds = duration_milliseconds_d /1000.0\r\n| where statement_s != 'select @@version'\r\n| where statement_s != 'SELECT @@SPID;'\r\n| where server_principal_name_s has '{User}'\r\n| where application_name_s has '{Application}'\r\n| project server_principal_name_s, succeeded_s, event_time_t, LogicalServerName_s, duration_milliseconds_d, duration_seconds, affected_rows_d, statement_s, application_name_s\r\n| summarize duration_seconds = round(sum(duration_seconds)) , query_count = count(statement_s) by EventDay = bin(event_time_t,1d), UserName = server_principal_name_s, Application = application_name_s \r\n| order by EventDay, duration_seconds desc", "size": 0, "title": "Query Summary for Selected User {User} {Application}", "noDataMessage": "Select a user to see query activity", "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "unstackedbar", "tileSettings": { "showBorder": false, "titleContent": { "columnMatch": "UserName", "formatter": 1 }, "leftContent": { "columnMatch": "duration_seconds", "formatter": 12, "formatOptions": { "palette": "auto" }, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "graphSettings": { "type": 0, "topContent": { "columnMatch": "UserName", "formatter": 1 }, "centerContent": { "columnMatch": "duration_seconds", "formatter": 1, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "chartSettings": { "xAxis": "UserName" }, "mapSettings": { "locInfo": "LatLong", "sizeSettings": "duration_seconds", "sizeAggregation": "Sum", "legendMetric": "duration_seconds", "legendAggregation": "Sum", "itemColorSettings": { "type": "heatmap", "colorAggregation": "Sum", "nodeColorField": "duration_seconds", "heatmapPalette": "greenRed" } } }, "name": "query - 0 - Copy - Copy" }, { "type": 1, "content": { "json": "## This next chart is a work in progress\r\nThe next chart uses an approximate join based on end time. If the Exec Requests Query Text and the Audit Log Query text don't match up, then it is likely not a real match and the data in teh row shoudl not be trusted. ", "style": "warning" }, "name": "text - 7" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databasename='{DatabaseName}';\r\nAzureDiagnostics \r\n| where Category == 'ExecRequests'\r\n| where Resource == databasename\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize Session_ID=max(SessionId_s), \r\n Query_Submit_Time=max(SubmitTime_t), \r\n Query_Start_Time=max(StartTime_t), \r\n Query_End_Time=max(EndTime_t), \r\n Query_Text=max(Command_s), \r\n Status=min(Status_s),\r\n Resource_class=max(ResourceClass_s) ,\r\n Query_ElapsedTime_s=round((max(EndTime_t) - max(StartTime_t))/1s)\r\n by RequestId_s\r\n| join kind = leftouter \r\n(\r\n AzureDiagnostics\r\n | where Category == 'RequestSteps'\r\n | where Resource == databasename\r\n | summarize num_steps=max(StepIndex_d), \r\n max_step_rows=max(RowCount_d), \r\n max_step_sec=max(EndTime_t-StartTime_t)/1s\r\n by RequestId_s\r\n ) on RequestId_s\r\n| order by Query_Submit_Time\r\n| project Session_ID,RequestId_s,Query_Submit_Time,Query_Start_Time,EventTime = Query_End_Time,num_steps,max_step_rows,max_step_sec,Query_ElapsedTime_s,Status,Query = Query_Text,Resource_class\r\n| join kind = rightouter \r\n(\r\n AzureDiagnostics\r\n | where Category == 'SQLSecurityAuditEvents' and LogicalServerName_s == \"{LogicalServerName}\"\r\n | where duration_milliseconds_d > 0\r\n | extend duration_seconds = duration_milliseconds_d /1000.0\r\n | where statement_s != 'select @@version'\r\n | where statement_s != 'SELECT @@SPID;'\r\n | where server_principal_name_s has '{User}'\r\n // | where application_name_s has '{Application}'\r\n | project DatabaseName= database_name_s, UserName= server_principal_name_s, EventTime= event_time_t, Host= host_name_s, duration_seconds = round(duration_seconds), statement_s, QuerySource = application_name_s , affected_rows_d\r\n | project-reorder DatabaseName, UserName, Host, EventTime, duration_seconds, statement_s, QuerySource\r\n) on EventTime\r\n | order by affected_rows_d desc\r\n| project Session_ID,RequestID=RequestId_s,Submit_time=Query_Submit_Time,Start_Time=Query_Start_Time,End_Time=EventTime,Status,Resource_class,UserName,Exec_request_text=Query,Audit_Query_text=statement_s,Host,QuerySource,Affected_rows=affected_rows_d,num_steps,max_step_rows,max_step_sec,Total_Duration_s=duration_seconds\r\n\r\n\r\n\r\n\r\n", "size": 0, "showAnalytics": true, "title": "Queries {User} {Application}", "noDataMessage": "Select a user to see query activity", "timeContextFromParameter": "TimeRange", "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 0 - Copy - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": " AzureDiagnostics\r\n | where Category == 'SQLSecurityAuditEvents' and LogicalServerName_s == \"{LogicalServerName}\"\r\n | where duration_milliseconds_d > 0\r\n| extend Duration = round(duration_milliseconds_d /1000.0)\r\n| extend TimeBin = case (datetime_part(\"Hour\",TimeGenerated) in (6,7,8,9,10,11,12), \"Morning_6-12\", datetime_part(\"Hour\",TimeGenerated) in (13,14,15,16,17,18), \"Afternoon_12-18\", \"Overnight_18-6\")\r\n| where server_principal_name_s has '{User}'\r\n| where application_name_s has '{Application}'\r\n| summarize QueryDuration = sum(Duration) by EventTime = bin(event_time_t, 1d), TimeBin", "size": 0, "title": "Query Activity by time - sum(Duration) {User} {Application}", "noDataMessage": "Select a user to see query activity", "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "barchart" }, "name": "query - 0 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databasename='{DatabaseName}';\r\nAzureDiagnostics \r\n| where Category == 'ExecRequests'\r\n| where Resource == databasename\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize Session_ID=max(SessionId_s), \r\n Query_Submit_Time=max(SubmitTime_t), \r\n Query_Start_Time=max(StartTime_t), \r\n Query_End_Time=max(EndTime_t), \r\n Query_Text=max(Command_s), \r\n Status=min(Status_s),\r\n Resource_class=max(ResourceClass_s) ,\r\n Query_ElapsedTime_s=round((max(EndTime_t) - max(StartTime_t))/1s)\r\n by RequestId_s\r\n| join kind = leftouter \r\n(\r\n AzureDiagnostics\r\n | where Category == 'RequestSteps'\r\n | where Resource == databasename\r\n | summarize num_steps=max(StepIndex_d), \r\n max_step_rows=max(RowCount_d), \r\n max_step_sec=max(EndTime_t-StartTime_t)/1s\r\n by RequestId_s\r\n ) on RequestId_s\r\n| order by Query_Submit_Time\r\n| project Session_ID,RequestId_s,Query_Submit_Time,Query_Start_Time,EventTime = Query_End_Time,num_steps,max_step_rows,max_step_sec,Query_ElapsedTime_s,Status,Query = Query_Text,Resource_class\r\n| join kind = rightouter \r\n(\r\n AzureDiagnostics\r\n | where Category == 'SQLSecurityAuditEvents' and LogicalServerName_s == \"{LogicalServerName}\"\r\n | where duration_milliseconds_d > 0\r\n | extend duration_seconds = duration_milliseconds_d /1000.0\r\n | where statement_s != 'select @@version'\r\n | where statement_s != 'SELECT @@SPID;'\r\n | where server_principal_name_s has '{User}'\r\n // | where application_name_s has '{Application}'\r\n | project DatabaseName= database_name_s, UserName= server_principal_name_s, EventTime= event_time_t, Host= host_name_s, duration_seconds = round(duration_seconds), statement_s, QuerySource = application_name_s , affected_rows_d\r\n | project-reorder DatabaseName, UserName, Host, EventTime, duration_seconds, statement_s, QuerySource\r\n) on EventTime\r\n | order by affected_rows_d desc\r\n| project Session_ID,RequestID=RequestId_s,Submit_time=Query_Submit_Time,Start_Time=Query_Start_Time,End_Time=EventTime,Status,Resource_class,UserName,Query_text=statement_s,Host,QuerySource,Affected_rows=affected_rows_d,num_steps,max_step_rows,max_step_sec,Total_Duration_s=duration_seconds\r\n\r\n\r\n\r\n\r\n", "size": 0, "title": "Affected Rows By Session ID", "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "linechart", "chartSettings": { "xAxis": "RequestID", "yAxis": [ "Affected_rows" ] } }, "name": "query - 6" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "QueryAudit" }, "name": "QueryAuditGroup", "styleSettings": { "showBorder": true } }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "title": "Query Comparison", "items": [ { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "7fa3187e-9225-4faa-8f80-dc1bc40c5aab", "version": "KqlParameterItem/1.0", "name": "RequestId1", "type": 1, "value": "" } ], "style": "above", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "customWidth": "50", "name": "parameters - 3 - Copy" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "315fc476-469a-4d8d-b421-028d1113ab06", "version": "KqlParameterItem/1.0", "name": "RequestId2", "type": 1, "value": "", "timeContext": { "durationMs": 86400000 } } ], "style": "above", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "customWidth": "50", "name": "parameters - 2" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s !in ('Batch','Execute') and RequestId_s == '{RequestId1}'\r\n| summarize Session_ID=any(SessionId_s),\r\n Request_ID=any(RequestId_s),\r\n Submit_Time=min(SubmitTime_t),\r\n Start_Time=max(StartTime_t),\r\n End_Time=max(EndTime_t),\r\n Command=any(Command_s),\r\n Status=min(Status_s), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType_s),\r\n Resource_class=any(ResourceClass_s)\r\n by RequestId_s\r\n| summarize Session_ID=any(Session_ID), Submit_Time=any(Submit_Time) ,Start_Time=any(Start_Time), End_Time=any(End_Time),ElapsedTime_min=anyif((End_Time - Start_Time)/1m,Start_Time > ago(30d)),Command=any(Command),Status=any(Status),Statement_Type=any(Statement_Type),Resource_class=any(Resource_class) by Request_ID\r\n| project Session_ID,Request_ID,ElapsedTime_min,Command,Resource_class,Submit_Time,Start_Time,End_Time,Statement_Type,Status\r\n", "size": 4, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "customWidth": "50", "name": "query - 2" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s !in ('Batch','Execute') and RequestId_s == '{RequestId2}'\r\n| summarize Session_ID=any(SessionId_s),\r\n Request_ID=any(RequestId_s),\r\n Submit_Time=min(SubmitTime_t),\r\n Start_Time=max(StartTime_t),\r\n End_Time=max(EndTime_t),\r\n Command=any(Command_s),\r\n Status=min(Status_s), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType_s),\r\n Resource_class=any(ResourceClass_s)\r\n by RequestId_s\r\n| summarize Session_ID=any(Session_ID), Submit_Time=any(Submit_Time) ,Start_Time=any(Start_Time), End_Time=any(End_Time),ElapsedTime_min=anyif((End_Time - Start_Time)/1m,Start_Time > ago(30d)),Command=any(Command),Status=any(Status),Statement_Type=any(Statement_Type),Resource_class=any(Resource_class) by Request_ID\r\n| project Session_ID,Request_ID,ElapsedTime_min,Command,Resource_class,Submit_Time,Start_Time,End_Time,Statement_Type,Status\r\n", "size": 4, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "customWidth": "50", "name": "query - 2 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics\r\n| where Category == 'RequestSteps'\r\n| where Resource == '{DatabaseName}'\r\n| where RequestId_s == '{RequestId1}'\r\n| summarize StartTime=max(StartTime_t)\r\n ,EndTime=max(EndTime_t)\r\n ,RequestID=max(RequestId_s)\r\n ,Operation=max(OperationType_s)\r\n ,RowCount=max(RowCount_d)\r\n ,Command=max(Command_s)\r\n ,Status=max(Status_s)\r\n by StepIndex_d\r\n| order by StepIndex_d asc\r\n| project StartTime,EndTime,RequestID,Operation,RowCount,Command,Status,StepIndex_d", "size": 3, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "customWidth": "50", "name": "query - 4", "styleSettings": { "margin": "0", "padding": "10px" } }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics\r\n| where Category == 'RequestSteps'\r\n| where Resource == '{DatabaseName}'\r\n| where RequestId_s == '{RequestId2}'\r\n| summarize StartTime=max(StartTime_t)\r\n ,EndTime=max(EndTime_t)\r\n ,RequestID=max(RequestId_s)\r\n ,Operation=max(OperationType_s)\r\n ,RowCount=max(RowCount_d)\r\n ,Command=max(Command_s)\r\n ,Status=max(Status_s)\r\n by StepIndex_d\r\n| order by StepIndex_d asc\r\n| project StartTime,EndTime,RequestID,Operation,RowCount,Command,Status,StepIndex_d", "size": 3, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "customWidth": "50", "name": "query - 4 - Copy", "styleSettings": { "padding": "10px" } }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "parameters": [ { "id": "03d1c3ba-0d28-4584-bb63-388f8477034a", "version": "KqlParameterItem/1.0", "name": "Query_Submit_Time1", "type": 1, "query": " AzureDiagnostics \r\n | where Category == 'ExecRequests'\r\n | where Resource == '{DatabaseName}'\r\n | where StatementType_s !in ('Batch','Execute')\r\n | where RequestId_s =='{RequestId1}'\r\n | summarize \r\n Submit_Time=min(SubmitTime_t)\r\n by RequestId_s\r\n | project Submit_Time", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "id": "af36efd7-c5a0-429e-8908-a24e22ee6087", "version": "KqlParameterItem/1.0", "name": "Query_End_Compile_Time1", "type": 1, "query": " AzureDiagnostics \r\n | where Category == 'ExecRequests'\r\n | where Resource == '{DatabaseName}'\r\n | where StatementType_s !in ('Batch','Execute')\r\n | where RequestId_s =='{RequestId1}'\r\n | summarize \r\n End_Compile_Time=max(EndCompileTime_t) \r\n by RequestId_s\r\n | project End_Compile_Time", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "version": "KqlParameterItem/1.0", "name": "Query_Submit_Time2", "type": 1, "query": " AzureDiagnostics \r\n | where Category == 'ExecRequests'\r\n | where Resource == '{DatabaseName}'\r\n | where StatementType_s !in ('Batch','Execute')\r\n | where RequestId_s =='{RequestId2}'\r\n | summarize \r\n Submit_Time=min(SubmitTime_t)\r\n by RequestId_s\r\n | project Submit_Time", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "id": "3e691c5e-2c25-4b1a-b845-032901fb08b6" }, { "version": "KqlParameterItem/1.0", "name": "Query_End_Compile_Time2", "type": 1, "query": " AzureDiagnostics \r\n | where Category == 'ExecRequests'\r\n | where Resource == '{DatabaseName}'\r\n | where StatementType_s !in ('Batch','Execute')\r\n | where RequestId_s =='{RequestId2}'\r\n | summarize \r\n End_Compile_Time=max(EndCompileTime_t) \r\n by RequestId_s\r\n | project End_Compile_Time", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "id": "6dd3ddbe-09bd-485f-b202-296f391ede6d" } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 6 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": " AzureDiagnostics \r\n | where Category == 'ExecRequests'\r\n | where Resource == '{DatabaseName}'\r\n | where StatementType_s =='CreateStatistics'\r\n | summarize \r\n Session_ID=max(SessionId_s), \r\n //Request_ID=max(RequestId_s), \r\n Submit_Time=min(SubmitTime_t), \r\n //Start_Time=max(StartTime_t),\r\n //End_Compile_Time=max(EndCompileTime_t), \r\n End_Time=max(EndTime_t), \r\n Command=max(Command_s), \r\n Last_Status=min(Status_s),\r\n Statement_Type=max(StatementType_s),\r\n Resource_class=max(ResourceClass_s) \r\n by RequestId_s\r\n | where Submit_Time > datetime('{Query_Submit_Time1}') and End_Time < datetime('{Query_End_Compile_Time1}') and End_Time > ago(30d)\r\n| project Command, Status=Last_Status ,Submit_Time,End_Time,Session_ID,Request_ID=RequestId_s,Statement_Type\r\n", "size": 0, "title": "All possibly related auto-stats statements based on time", "noDataMessage": "no auto stats statements found that could be related", "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Submit_Time", "formatter": 0, "numberFormat": { "unit": 0, "options": { "style": "decimal" } } }, { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "100ch" } } ], "sortBy": [ { "itemKey": "End_Time", "sortOrder": 2 } ] }, "sortBy": [ { "itemKey": "End_Time", "sortOrder": 2 } ] }, "customWidth": "50", "name": "All possibly related auto-stats statements - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": " AzureDiagnostics \r\n | where Category == 'ExecRequests'\r\n | where Resource == '{DatabaseName}'\r\n | where StatementType_s =='CreateStatistics'\r\n | summarize \r\n Session_ID=max(SessionId_s), \r\n //Request_ID=max(RequestId_s), \r\n Submit_Time=min(SubmitTime_t), \r\n //Start_Time=max(StartTime_t),\r\n //End_Compile_Time=max(EndCompileTime_t), \r\n End_Time=max(EndTime_t), \r\n Command=max(Command_s), \r\n Last_Status=min(Status_s),\r\n Statement_Type=max(StatementType_s),\r\n Resource_class=max(ResourceClass_s) \r\n by RequestId_s\r\n | where Submit_Time > datetime('{Query_Submit_Time2}') and End_Time < datetime('{Query_End_Compile_Time2}') and End_Time > ago(30d)\r\n| project Command, Status=Last_Status ,Submit_Time,End_Time,Session_ID,Request_ID=RequestId_s,Statement_Type\r\n", "size": 0, "title": "All possibly related auto-stats statements based on time", "noDataMessage": "no auto stats statements found that could be related", "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Submit_Time", "formatter": 0, "numberFormat": { "unit": 0, "options": { "style": "decimal" } } }, { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "100ch" } } ] } }, "customWidth": "50", "name": "All possibly related auto-stats statements - Copy - Copy" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "QueryComparison" }, "name": "QueryComparison" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "title": "Session Investigation", "items": [ { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "feb2ac70-2555-456e-bfa6-6ad4a2dcad0f", "version": "KqlParameterItem/1.0", "name": "SessionID", "type": 1, "value": "", "timeContext": { "durationMs": 86400000 } } ], "style": "above", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 0" }, { "type": 1, "content": { "json": "The matching of the user information in the next chart is approximate. This information is a work in progress", "style": "warning" }, "name": "text - 4" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databasename='{DatabaseName}';\r\nAzureDiagnostics \r\n| where Category == 'ExecRequests'\r\n| where Resource == databasename\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize Query_End_Time = max(EndTime_t ) by SessionId_s\r\n| where SessionId_s == '{SessionID}'\r\n| join kind = rightouter \r\n( \r\n AzureDiagnostics\r\n | where Category == 'SQLSecurityAuditEvents' \r\n | where duration_milliseconds_d > 0\r\n | extend duration_seconds = duration_milliseconds_d /1000.0\r\n | where statement_s != 'select @@version' and statement_s != 'SELECT @@SPID;' and server_principal_name_s != '##MS_InstanceCertificate##'\r\n) on $left.Query_End_Time==$right.event_time_t \r\n| summarize DatabaseName= max(database_name_s)\r\n , UserName= any(server_principal_name_s)\r\n , Host= max(host_name_s)\r\n , Application=max(application_name_s)\r\n by SessionId_s\r\n\r\n\r\n\r\n", "size": 4, "showAnalytics": true, "timeContextFromParameter": "TimeRange", "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "table", "tileSettings": { "titleContent": { "columnMatch": "UserName" }, "subtitleContent": { "columnMatch": "SessionId_s" }, "leftContent": { "columnMatch": "Application" }, "rightContent": { "columnMatch": "Host" }, "secondaryContent": { "columnMatch": "DatabaseName" }, "showBorder": false, "size": "full" }, "graphSettings": { "type": 0 } }, "name": "query - 3" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics \r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize \r\n Session_ID=max(SessionId_s), \r\n Submit_Time=max(SubmitTime_t), \r\n Start_Time=max(StartTime_t),\r\n End_Compile_Time=max(EndCompileTime_t), \r\n End_Time=max(EndTime_t), \r\n Command=max(Command_s), \r\n Last_Status=min(Status_s),\r\n Statement_Type=max(StatementType_s),\r\n Resource_class=max(ResourceClass_s) \r\n by RequestId_s\r\n| where Session_ID has '{SessionID}'\r\n| extend elapsedTime_sec = iif(End_Time > ago(365d),(End_Time - Submit_Time)/1s,real(null)) \r\n| order by Submit_Time asc\r\n\r\n\r\n\r\n\r\n", "size": 0, "showAnalytics": true, "timeContextFromParameter": "TimeRange", "exportFieldName": "RequestId_s", "exportParameterName": "RequestID", "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 1" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics\r\n| where Category == 'RequestSteps'\r\n| where Resource == '{DatabaseName}'\r\n| where RequestId_s == '{RequestID}'\r\n//| where Status_s != 'Running'\r\n| summarize Start_Time=max(StartTime_t),End_Time=max(EndTime_t),Request_ID=max(RequestId_s),Operation_Type=max(OperationType_s),Row_Count=max(RowCount_d),Statement=max(Command_s),Status=min(Status_s) by StepIndex_d\r\n| order by StepIndex_d asc", "size": 3, "showAnalytics": true, "timeContextFromParameter": "TimeRange", "showExportToExcel": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 2" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "SessionInvestigation" }, "name": "group - 9" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 1, "content": { "json": "## This tab is used to determine what statements triggerred autostats creation jobs. \r\nThe flow of autostats creation is as follows\r\n1. Query Submit Time\r\n2. \tCreate Statistics submit Time\r\n3. \tCreate Statistics end Time\r\n4. Query end_compile_time\r\n5. Query Start_Time\r\n6. Query End_Time\r\n\r\nFurther, if multiple stats are created, then the creation of all stats for this query will fall between query submit_time and end_compile_time. \r\n\r\nThe charts on this page allow you to search for an autostats job by requestID or my snippet of the autostats statement text, which can just be the schema, table, or column name. Then it will show you all commands that include that request ID or text. It will then show you all statements in the create stat statement because the query we are trying to identify will wait for all of those stats creations to complete before proceeding. \r\n\r\nThe last chart will list out all statements that could possibly have triggerred the stats creation job based on their submite/end_compile_time. " }, "name": "text - 6" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "0911bd4b-d471-480b-bdf4-1a2d4ba1ea6e", "version": "KqlParameterItem/1.0", "name": "RequestIdSearch", "type": 1, "value": "", "label": "RequestId for AutoStats Job" }, { "id": "c12e6495-4fd1-473c-8ffc-0bf502f54706", "version": "KqlParameterItem/1.0", "name": "QueryTextSnippet", "type": 1, "value": "", "timeContext": { "durationMs": 86400000 }, "label": "Snippet of autostats creation statement (Schema, table or column)" } ], "style": "formVertical", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "customWidth": "60", "name": "parameters - 3 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics \r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize \r\n Session_ID=max(SessionId_s), \r\n Request_ID=max(RequestId_s), \r\n Submit_Time=max(SubmitTime_t), \r\n Start_Time=max(StartTime_t),\r\n End_Compile_Time=max(EndCompileTime_t), \r\n End_Time=max(EndTime_t), \r\n Command=max(Command_s), \r\n Last_Status=min(Status_s),\r\n Statement_Type=max(StatementType_s),\r\n Resource_class=max(ResourceClass_s) \r\n by RequestId_s\r\n| where Command has 'CREATE STATISTICS _wa_sys'\r\n| where Command has '{QueryTextSnippet}'\r\nand RequestId_s has '{RequestIdSearch}'\r\n| extend elapsedTime_sec = iif(End_Time > ago(365d),(End_Time - Submit_Time)/1s,real(null)) \r\n| extend CompileTime_sec = (End_Compile_Time - Submit_Time)/1s\r\n| order by elapsedTime_sec\r\n| summarize \r\n Executions = count(),\r\n Max_Elapsed_Time_sec = bin(max(elapsedTime_sec),1),\r\n Min_Elapsed_Time_sec = bin(min(elapsedTime_sec),1),\r\n Variability_sec=bin((max(elapsedTime_sec)-min(elapsedTime_sec)),1),\r\n SampleQID = any(RequestId_s),\r\n SampleSessionID = any(Session_ID)\r\n by Command\r\n| order by Max_Elapsed_Time_sec\r\n\r\n\r\n", "size": 0, "title": "Matching Queries", "timeContextFromParameter": "TimeRange", "exportedParameters": [ { "fieldName": "SampleQID", "parameterName": "SampleQID" }, { "fieldName": "SampleSessionID", "parameterName": "Samp", "parameterType": 1 } ], "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "50%" } } ], "sortBy": [ { "itemKey": "Command", "sortOrder": 1 } ] }, "sortBy": [ { "itemKey": "Command", "sortOrder": 1 } ] }, "name": "query - 0 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics \r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s !in ('Batch','Execute')\r\n| where RequestId_s == '{SampleQID}'\r\n| summarize \r\n Session_ID=max(SessionId_s), \r\n Request_ID=max(RequestId_s), \r\n Submit_Time=min(SubmitTime_t), \r\n Start_Time=max(StartTime_t),\r\n End_Compile_Time=max(EndCompileTime_t), \r\n End_Time=max(EndTime_t), \r\n Command=max(Command_s), \r\n Last_Status=min(Status_s),\r\n Statement_Type=max(StatementType_s),\r\n Resource_class=max(ResourceClass_s) \r\n by RequestId_s\r\n| extend elapsedTime_sec = iif(End_Time > ago(365d),(End_Time - Submit_Time)/1s,real(null)) \r\n| extend CompileTime_sec = (End_Compile_Time - Submit_Time)/1s\r\n| join kind=inner\r\n (AzureDiagnostics \r\n | where Category == 'ExecRequests'\r\n | where Resource == '{DatabaseName}'\r\n | where StatementType_s !in ('Batch','Execute')\r\n | summarize \r\n Session_ID=max(SessionId_s), \r\n Request_ID=max(RequestId_s), \r\n Submit_Time=min(SubmitTime_t), \r\n Start_Time=max(StartTime_t),\r\n End_Compile_Time=max(EndCompileTime_t), \r\n End_Time=max(EndTime_t), \r\n Command=max(Command_s), \r\n Last_Status=min(Status_s),\r\n Statement_Type=max(StatementType_s),\r\n Resource_class=max(ResourceClass_s) \r\n by RequestId_s\r\n | extend elapsedTime_sec = (End_Time - Submit_Time)/1s\r\n | extend elapsedTime_sec = iif(End_Time > ago(365d),(End_Time - Submit_Time)/1s,real(null)) \r\n | extend CompileTime_sec = (End_Compile_Time - Submit_Time)/1s\r\n )\r\non Command \r\n| project Request_ID1,Session_ID1,Submit_Time1,Start_Time1,End_Compile_Time1,End_Time1,Last_Status1,Statement_Type1,elapsedTime_sec1,CompileTime_sec1\r\n", "size": 0, "title": "All Executions of Selected Query", "noDataMessage": "Select a query above to see individual executions", "timeContextFromParameter": "TimeRange", "exportedParameters": [ { "fieldName": "Request_ID1", "parameterName": "RequestId" }, { "fieldName": "End_Time1", "parameterName": "StatEndTime", "parameterType": 1 }, { "fieldName": "Submit_Time1", "parameterName": "StatSubmitTime", "parameterType": 1 }, { "fieldName": "Session_ID1", "parameterName": "SessionId", "parameterType": 1 } ], "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "sortBy": [ { "itemKey": "End_Time1", "sortOrder": 1 } ] }, "sortBy": [ { "itemKey": "End_Time1", "sortOrder": 1 } ] }, "name": "query - 0 - Copy - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": " AzureDiagnostics \r\n | where Category == 'ExecRequests'\r\n | where Resource == '{DatabaseName}'\r\n | where StatementType_s !in ('Batch','Execute')\r\n | where SessionId_s == '{SessionId}'\r\n | summarize \r\n Session_ID=max(SessionId_s), \r\n Request_ID=max(RequestId_s), \r\n Submit_Time=min(SubmitTime_t), \r\n Start_Time=max(StartTime_t),\r\n End_Compile_Time=max(EndCompileTime_t), \r\n End_Time=max(EndTime_t), \r\n Command=max(Command_s), \r\n Last_Status=min(Status_s),\r\n Statement_Type=max(StatementType_s),\r\n Resource_class=max(ResourceClass_s) \r\n by RequestId_s\r\n| project Session_ID,Request_ID,Submit_Time,End_Compile_Time,Start_Time,End_Time,Last_Status,Statement_Type,Command\r\n\r\n\r\n", "size": 0, "title": "All Statements in Stats Statement Session", "noDataMessage": "Select a query above to see individual executions", "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "150ch" } } ], "sortBy": [ { "itemKey": "Command", "sortOrder": 1 } ] }, "sortBy": [ { "itemKey": "Command", "sortOrder": 1 } ] }, "name": "query - 0 - Copy - Copy - Copy - Copy" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "parameters": [ { "id": "4e005821-785a-4246-aae8-de00987cba18", "version": "KqlParameterItem/1.0", "name": "Session_Submit_Time", "type": 1, "query": "AzureDiagnostics \r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s !in ('Batch','Execute')\r\n| where SessionId_s == '{SessionId}'\r\n| summarize \r\n Session_Submit_Time=min(SubmitTime_t) \r\n by SessionId_s\r\n| project Session_Submit_Time\r\n\r\n\r\n", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 259200000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "id": "b046db56-e6b3-4f3d-afb3-9687240c21f1", "version": "KqlParameterItem/1.0", "name": "Session_End_Time", "type": 1, "query": "AzureDiagnostics \r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s !in ('Batch','Execute')\r\n| where SessionId_s == '{SessionId}'\r\n| summarize \r\n Session_End_Time=max(EndTime_t) \r\n by SessionId_s\r\n| project Session_End_Time", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 259200000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 7" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics \r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s !in ('Batch','Execute')\r\n| where SubmitTime_t < datetime('{Session_Submit_Time}') and EndCompileTime_t > datetime('{Session_End_Time}') or RequestId_s == '{RequestId}'\r\n| summarize by RequestId_s\r\n| join kind=inner\r\n (\r\n AzureDiagnostics \r\n | where Category == 'ExecRequests'\r\n | where Resource == '{DatabaseName}'\r\n | where StatementType_s !in ('Batch','Execute')\r\n | summarize \r\n Session_ID=max(SessionId_s), \r\n Request_ID=max(RequestId_s), \r\n Submit_Time=min(SubmitTime_t), \r\n Start_Time=max(StartTime_t),\r\n End_Compile_Time=max(EndCompileTime_t), \r\n End_Time=max(EndTime_t), \r\n Command=max(Command_s), \r\n Last_Status=min(Status_s),\r\n Statement_Type=max(StatementType_s),\r\n Resource_class=max(ResourceClass_s) \r\n by RequestId_s\r\n ) on RequestId_s\r\n| order by End_Compile_Time\r\n| project Session_ID,Request_ID,Submit_Time,End_Compile_Time,Start_Time,End_Time,Last_Status,Statement_Type,Command\r\n\r\n", "size": 0, "title": "Query Executions that could have triggered Stats Statement based on Time of total session", "noDataMessage": "Select a query above to see individual executions", "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "150ch" } } ], "sortBy": [ { "itemKey": "Command", "sortOrder": 1 } ] }, "sortBy": [ { "itemKey": "Command", "sortOrder": 1 } ] }, "name": "query - 0 - Copy - Copy - Copy - Copy" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "Statistics" }, "name": "statistics" } ], "fallbackResourceIds": [ "Azure Monitor" ], "$schema": "https://github.com/Microsoft/Application-Insights-Workbooks/blob/master/schema/workbook.json" } ================================================ FILE: Monitor_Workbooks/archive/StandaloneSqlPoolWorkbook_v1.31.json ================================================ { "version": "Notebook/1.0", "items": [ { "type": 9, "content": { "version": "KqlParameterItem/1.0", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "parameters": [ { "id": "28da10ec-a308-47f5-9819-92ebf810b292", "version": "KqlParameterItem/1.0", "name": "LogAnalyticsSubscription", "type": 6, "value": null, "typeSettings": { "additionalResourceOptions": [], "includeAll": true, "showDefault": false }, "timeContext": { "durationMs": 86400000 } }, { "id": "e383ed24-52ae-447b-9b80-51fd3ab6b919", "version": "KqlParameterItem/1.0", "name": "LogAnalyticsWorkspace", "type": 5, "query": "Resources\r\n| where type == 'microsoft.operationalinsights/workspaces'\r\n| project id\r\n", "crossComponentResources": [ "{LogAnalyticsSubscription}" ], "value": null, "typeSettings": { "additionalResourceOptions": [], "showDefault": false }, "timeContext": { "durationMs": 86400000 }, "queryType": 1, "resourceType": "microsoft.resourcegraph/resources" }, { "id": "9b9fe566-0f52-4a75-a35b-a79c50c6a6f0", "version": "KqlParameterItem/1.0", "name": "DatabaseResourceName", "type": 5, "query": "AzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| distinct ResourceId", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "value": null, "typeSettings": { "additionalResourceOptions": [], "showDefault": false }, "timeContext": { "durationMs": 2592000000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "id": "f5852627-70ca-4959-8d60-53b48864603f", "version": "KqlParameterItem/1.0", "name": "TimeRange", "type": 4, "isGlobal": true, "value": { "durationMs": 14400000 }, "typeSettings": { "selectableValues": [ { "durationMs": 300000 }, { "durationMs": 900000 }, { "durationMs": 1800000 }, { "durationMs": 3600000 }, { "durationMs": 14400000 }, { "durationMs": 43200000 }, { "durationMs": 86400000 }, { "durationMs": 172800000 }, { "durationMs": 259200000 }, { "durationMs": 604800000 }, { "durationMs": 1209600000 }, { "durationMs": 2419200000 }, { "durationMs": 2592000000 } ], "allowCustom": true }, "timeContext": { "durationMs": 86400000 } }, { "id": "6da2f63f-45a3-4b37-9108-5e8b7e358d85", "version": "KqlParameterItem/1.0", "name": "DatabaseName", "type": 1, "query": "AzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where ResourceId == '{DatabaseResourceName}'\r\n| distinct Resource ", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 604800000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "id": "8bba835b-f319-43b3-8ec6-4e051fc6d446", "version": "KqlParameterItem/1.0", "name": "LogicalServerName", "type": 1, "query": "AzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where ResourceId == '{DatabaseResourceName}'\r\n| distinct LogicalServerName_s", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 2" }, { "type": 11, "content": { "version": "LinkItem/1.0", "style": "tabs", "links": [ { "id": "202cbbc0-8d63-416d-89ed-451d6fe7c4b3", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Workload", "subTarget": "Workload", "preText": "Workload", "style": "link" }, { "id": "a7901bd0-a1f4-4491-b953-57555d764e00", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Workload Management", "subTarget": "WorkloadManagement", "style": "link" }, { "id": "45e12a14-8548-4477-aae3-c142b906dc9f", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "TempDB", "subTarget": "TempDB", "style": "link" }, { "id": "9ef8f730-d73d-432b-9b75-55095d1155f2", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Replicated Tables", "subTarget": "ReplicatedTables", "style": "link" }, { "id": "79d10d16-0696-4214-b306-c7a0e46cd64f", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Query Investigation", "subTarget": "QueryInvestigation", "style": "link" }, { "id": "31c1cf1c-74b5-44e2-ba9a-9497834ca3dc", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Query Comparison", "subTarget": "QueryComparison", "style": "link" }, { "id": "5ff681ee-e005-481f-b743-b66ab1b9d71d", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Session Investigation", "subTarget": "SessionInvestigation", "style": "link" }, { "id": "482ccc46-8a10-4ace-bfd6-63ac73b380af", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Query Audit", "subTarget": "QueryAudit", "style": "link" }, { "id": "db43bb45-1611-47ce-a2ad-517943f2aa1a", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "AutoStats", "subTarget": "Statistics", "style": "link" } ] }, "name": "links - 0" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "title": "Workload", "items": [ { "type": 10, "content": { "chartId": "workbook90867bfc-5c33-464f-ac31-2c2e006b97f4", "version": "MetricsItem/2.0", "size": 0, "chartType": 2, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 14400000 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-dwu_consumption_percent", "aggregation": 3, "splitBy": null, "columnName": "DWU Percentage" }, { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-cpu_percent", "aggregation": 3 }, { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-physical_data_read_percent", "aggregation": 3 } ], "title": "DWU Resource Utilization", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "name": "metric - 1" }, { "type": 10, "content": { "chartId": "workbookb954d4a0-82ef-4409-88fb-837aaff80c8d", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 14400000 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-active_queries", "aggregation": 1, "splitBy": null }, { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-queued_queries", "aggregation": 1 } ], "title": "Active and Queued Queries", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "name": "metric - 1" }, { "type": 10, "content": { "chartId": "workbookb954d4a0-82ef-4409-88fb-837aaff80c8d", "version": "MetricsItem/2.0", "size": 0, "chartType": 3, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 14400000 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-local_tempdb_usage_percent", "aggregation": 3, "splitBy": null, "columnName": "TempDB Utilization Percentage" } ], "title": "TempDB Utilization", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "name": "metric - 1 - Copy" }, { "type": 10, "content": { "chartId": "workbookb954d4a0-82ef-4409-88fb-837aaff80c8d", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 14400000 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-WorkloadManagement-wlg_allocation_relative_to_system_percent", "aggregation": 3, "splitBy": "WorkloadGroupName" } ], "title": "Workload Group Utilization", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "name": "Workload Group Utilization" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databaseName = '{DatabaseName}';\r\n//Long-Running Queries - Just Actual Queries\r\n//If 'Command' is empty - you need to set a bigger time window, the older record with the command is outside of your window\r\nAzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where Resource == databaseName\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize Session_ID=any(SessionId_s),\r\n Request_ID=any(RequestId_s),\r\n Submit_Time=max(SubmitTime_t),\r\n Start_Time=max(StartTime_t),\r\n End_Time=max(EndTime_t),\r\n Command=any(Command_s),\r\n Status=min(Status_s), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType_s),\r\n Resource_class=any(ResourceClass_s)\r\n by RequestId_s\r\n| summarize ElapsedTime_min=bin(anyif(((End_Time - Start_Time)/1m),Start_Time > ago(30d)),1),\r\n Session_ID=any(Session_ID), \r\n Submit_Time=any(Submit_Time) ,\r\n Start_Time=any(Start_Time), \r\n End_Time=any(End_Time),\r\n Command=any(Command),\r\n Status=any(Status),\r\n Statement_Type=any(Statement_Type)\r\n ,Resource_class=any(Resource_class) \r\n by Request_ID\r\n| where End_Time > ago(365d)\r\n| summarize count() by Status, bin(End_Time,5m)\r\n| render barchart \r\n", "size": 0, "title": "Query Completion Count by End Time - 5m buckets", "color": "redBright", "timeContext": { "durationMs": 14400000 }, "timeContextFromParameter": "TimeRange", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "chartSettings": { "seriesLabelSettings": [ { "seriesName": "Completed", "color": "green" }, { "seriesName": "Failed", "color": "red" }, { "seriesName": "Cancelled", "color": "yellow" } ] } }, "name": "query - 4" }, { "type": 1, "content": { "json": "Use the buttons below to filter the next chart for Success or Failed queries. In many cases a failed query may not have a 'Command' column populated depending on what stage the query failed in. ", "style": "info" }, "name": "text - 3" }, { "type": 11, "content": { "version": "LinkItem/1.0", "style": "nav", "links": [ { "id": "8e89112f-c67f-42c0-9622-02fa306fb7a5", "cellValue": "QueryCompletionType", "linkTarget": "parameter", "linkLabel": "All Queries", "subTarget": "''", "style": "primary" }, { "id": "6abe39c7-4d4e-4c45-aa54-dc9a4c5e876e", "cellValue": "QueryCompletionType", "linkTarget": "parameter", "linkLabel": "Success Only", "subTarget": "Completed", "preText": "", "style": "secondary" }, { "id": "e41b4a0b-8464-491e-92be-a57217d6dcac", "cellValue": "QueryCompletionType", "linkTarget": "parameter", "linkLabel": "Failures Only", "subTarget": "Failed", "preText": "", "style": "secondary" } ] }, "name": "links - 11" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databaseName = '{DatabaseName}';\r\n//Long-Running Queries - Just Actual Queries\r\n//If 'Command' is empty - you need to set a bigger time window, the older record with the command is outside of your window\r\nAzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where Resource == databaseName\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize Session_ID=any(SessionId_s),\r\n Request_ID=any(RequestId_s),\r\n Submit_Time=max(SubmitTime_t),\r\n Start_Time=max(StartTime_t),\r\n End_Time=max(EndTime_t),\r\n Command=max(Command_s),\r\n Status=min(Status_s), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType_s),\r\n Resource_class=any(ResourceClass_s)\r\n by RequestId_s\r\n| summarize ElapsedTime_min=bin(anyif(((End_Time - Start_Time)/1m),Start_Time > ago(30d)),1),\r\n Session_ID=any(Session_ID), \r\n Submit_Time=min(Submit_Time) ,\r\n Start_Time=any(Start_Time), \r\n End_Time=any(End_Time),\r\n Command=any(Command),\r\n Status=any(Status),\r\n Statement_Type=any(Statement_Type)\r\n ,Resource_class=any(Resource_class) \r\n by Request_ID\r\n//| where End_Time > ago(365d)\r\n| where Status has '{QueryCompletionType}'\r\n| order by Submit_Time\r\n\r\n", "size": 0, "title": "Query Completions - use above buttons to filter", "color": "redBright", "timeContext": { "durationMs": 14400000 }, "timeContextFromParameter": "TimeRange", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "rowLimit": 100 }, "chartSettings": { "seriesLabelSettings": [ { "seriesName": "Completed", "color": "green" }, { "seriesName": "Failed", "color": "red" }, { "seriesName": "Cancelled", "color": "yellow" } ] } }, "name": "query - 4 - Copy" } ] }, "name": "Query Completions", "styleSettings": { "showBorder": true } }, { "type": 10, "content": { "chartId": "workbook1afc57e6-0b32-4968-b299-db319bd21635", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 14400000 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-connection_successful", "aggregation": 1, "splitBy": null }, { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-connection_failed", "aggregation": 1 } ], "title": "Successful and Failed Connections", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "name": "metric - 5" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 3, "content": { "version": "KqlItem/1.0", "query": " AzureDiagnostics\r\n | where Category == 'SQLSecurityAuditEvents' and LogicalServerName_s == 'lasr-sqldwdb-eastus2-prd'\r\n | where action_name_s in ('DATABASE AUTHENTICATION SUCCEEDED','DATABASE AUTHENTICATION FAILED')\r\n | project SourceSystem,client_tls_version_d,succeeded_s,session_id_d,client_ip_s,session_server_principal_name_s,server_principal_name_s,database_principal_name_s,application_name_s,host_name_s,TimeGenerated\r\n | summarize count() by succeeded_s,bin(TimeGenerated,1m)\r\n | render barchart\r\n\r\n\r\n\r\n", "size": 0, "title": "Database Authentication success/failure rate", "timeContext": { "durationMs": 14400000 }, "timeContextFromParameter": "TimeRange", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "chartSettings": { "xAxis": "TimeGenerated", "group": "succeeded_s", "createOtherGroup": null } }, "name": "query - 8" }, { "type": 11, "content": { "version": "LinkItem/1.0", "style": "nav", "links": [ { "id": "2ed22e0a-2b53-4ed0-8f65-d2c621f34dad", "cellValue": "AuthResult", "linkTarget": "parameter", "linkLabel": "All Authentications", "subTarget": "''", "style": "primary" }, { "id": "2789ab13-ae8a-472e-bad4-9c9bdc934d4d", "cellValue": "AuthResult", "linkTarget": "parameter", "linkLabel": "Success Only", "subTarget": "true", "style": "secondary" }, { "id": "5cf4ddd4-e189-4b71-b456-0d4f1572a0a3", "cellValue": "AuthResult", "linkTarget": "parameter", "linkLabel": "Failures Only", "subTarget": "false", "style": "secondary" } ] }, "name": "links - 10" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": " AzureDiagnostics\r\n | where Category == 'SQLSecurityAuditEvents' and LogicalServerName_s == 'lasr-sqldwdb-eastus2-prd'\r\n | where action_name_s in ('DATABASE AUTHENTICATION SUCCEEDED','DATABASE AUTHENTICATION FAILED')\r\n | where succeeded_s has '{AuthResult}'\r\n | project SourceSystem,client_tls_version_d,succeeded_s,session_id_d,client_ip_s,session_server_principal_name_s,server_principal_name_s,database_principal_name_s,application_name_s,host_name_s,TimeGenerated\r\n | order by TimeGenerated\r\n\r\n\r\n\r\n\r\n", "size": 0, "title": "Database Authentication success/failure rate", "noDataMessage": "Please select a button above", "timeContext": { "durationMs": 14400000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "rowLimit": 100 }, "chartSettings": { "xAxis": "TimeGenerated", "group": "succeeded_s", "createOtherGroup": null, "showLegend": true } }, "name": "query - 8 - Copy" } ] }, "name": "Database Authentication Group", "styleSettings": { "showBorder": true } }, { "type": 10, "content": { "chartId": "workbook993837ad-66d6-4cbc-ae1a-7c3f6623236b", "version": "MetricsItem/2.0", "size": 0, "chartType": 2, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 14400000 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-cache_used_percent", "aggregation": 3, "splitBy": null }, { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-cache_hit_percent", "aggregation": 3 } ], "title": "Adaptive Cache Used vs Hit Percentage", "gridSettings": { "rowLimit": 10000 } }, "name": "metric - 6" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "Workload" }, "name": "group - 1" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "title": "TempDB ", "items": [ { "type": 10, "content": { "chartId": "workbook4a9cf761-cce2-45b2-8947-8a9428ec7e1c", "version": "MetricsItem/2.0", "size": 0, "chartType": 3, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 14400000 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-local_tempdb_usage_percent", "aggregation": 3, "splitBy": null, "columnName": "TempDB Util" } ], "title": "TempDB Max and Avg Utilization", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "name": "metric - 0" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "19ee48f5-8f4e-4939-a0ef-c6bf656a93f9", "version": "KqlParameterItem/1.0", "name": "WeightParameter", "type": 1, "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 } }, { "id": "00553ec8-1a41-4dd9-a024-d607639c9bbb", "version": "KqlParameterItem/1.0", "name": "RequestID", "type": 1, "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 } } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 3" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databaseName = '{DatabaseName}';\r\n//Weighted query steps\r\nAzureDiagnostics\r\n| where Category == 'RequestSteps'\r\n| where Resource == databaseName\r\n| where RowCount_d > 0\r\n| summarize sum(RowCount_d) by RequestId_s, OperationType_s\r\n| order by sum_RowCount_d desc\r\n| limit 20\r\n| render columnchart ", "size": 0, "title": "20 Largest Query Steps by Most Rows Moved", "timeContext": { "durationMs": 14400000 }, "timeContextFromParameter": "TimeRange", "exportFieldName": "Request_ID", "exportParameterName": "RequestID", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "chartSettings": { "xAxis": "RequestId_s", "group": "OperationType_s", "createOtherGroup": 20, "showLegend": true } }, "name": "query - 1 - Copy" }, { "type": 11, "content": { "version": "LinkItem/1.0", "style": "nav", "links": [ { "id": "c98d3722-9907-43ab-9306-1957d6f7f858", "cellValue": "WeightParameter", "linkTarget": "parameter", "linkLabel": "Weighted Rowcounts", "subTarget": "Weighted", "preText": "", "postText": "", "style": "secondary" }, { "id": "a06ae99a-ad62-45e9-8c25-c219b81f59c0", "cellValue": "WeightParameter", "linkTarget": "parameter", "linkLabel": "Unweighted Rowcounts", "subTarget": "Unweighted", "preText": "", "postText": "", "style": "secondary" } ] }, "name": "links - 3" }, { "type": 1, "content": { "json": "Current Setting: {WeightParameter}", "style": "info" }, "name": "text - 4" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databaseName = '{DatabaseName}';\r\n//Weighted query steps\r\nlet RequestSteps = AzureDiagnostics\r\n| where Category == 'RequestSteps'\r\n| where Resource == databaseName\r\n| where RowCount_d > 100000000\r\n| extend Step_Elapsed_Min = round((EndTime_t - StartTime_t)/1m, 2)\r\n| extend Weighted_cnt = iff('{WeightParameter}'=='Weighted',(case(OperationType_s == 'BroadcastMoveOperation', (RowCount_d*20), RowCount_d)),RowCount_d)\r\n| project-rename StepStatus = Status_s, StepStart = StartTime_t, StepEnd = EndTime_t//, StepResource = Resource\r\n| top 100 by Weighted_cnt desc\r\n| order by Weighted_cnt desc\r\n| project Request_ID=RequestId_s,OperationType_s, RowCount_d,Weighted_cnt,Step_Elapsed_Min, StepStart, StepEnd, StepStatus, StepIndex_d,Resource;\r\nRequestSteps | join (AzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where Resource == databaseName\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize Session_ID=any(SessionId_s),\r\n Request_ID=any(RequestId_s),\r\n Submit_Time=max(SubmitTime_t),\r\n Start_Time=max(StartTime_t),\r\n End_Time=max(EndTime_t),\r\n Command=any(Command_s),\r\n Status=min(Status_s), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType_s),\r\n Resource_class=any(ResourceClass_s)\r\n by RequestId_s\r\n| summarize Session_ID=any(Session_ID), Submit_Time=any(Submit_Time) ,Start_Time=any(Start_Time), End_Time=any(End_Time),Command=any(Command),Status=any(Status),Statement_Type=any(Statement_Type),Resource_class=any(Resource_class) by Request_ID\r\n//| order by Step_Elapsed_Min desc\r\n| extend Request_Elapsed_Min = round((End_Time - Start_Time)/1m, 2)\r\n| project-rename ReqStatus = Status, ReqStart = Start_Time, ReqEnd = End_Time\r\n) on Request_ID\r\n| project-reorder Session_ID, Request_ID, Request_Elapsed_Min, ReqStart, ReqEnd, ReqStatus,StepIndex_d, OperationType_s, RowCount_d,Weighted_cnt,Step_Elapsed_Min, StepStart, StepEnd, StepStatus, Statement_Type, Command, Resource_class\r\n| order by Weighted_cnt desc\r\n| limit 20", "size": 3, "title": "20 Largest Query Steps by Most Rows Moved", "timeContext": { "durationMs": 14400000 }, "timeContextFromParameter": "TimeRange", "exportFieldName": "Request_ID1", "exportParameterName": "RequestID", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "sortBy": [ { "itemKey": "Weighted_cnt", "sortOrder": 2 } ] }, "sortBy": [ { "itemKey": "Weighted_cnt", "sortOrder": 2 } ] }, "name": "query - 1" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databaseName = '{DatabaseName}';\r\n//Long-Running Queries - Just Actual Queries\r\n//If 'Command' is empty - you need to set a bigger time window, the older record with the command is outside of your window\r\nAzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where Resource == databaseName\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize Session_ID=any(SessionId_s),\r\n Request_ID=any(RequestId_s),\r\n Submit_Time=max(SubmitTime_t),\r\n Start_Time=max(StartTime_t),\r\n End_Time=max(EndTime_t),\r\n Command=any(Command_s),\r\n Status=min(Status_s), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType_s),\r\n Resource_class=any(ResourceClass_s)\r\n by RequestId_s\r\n| summarize ElapsedTime_min=bin(anyif(((End_Time - Start_Time)/1m),Start_Time > ago(30d)),1),\r\n Session_ID=any(Session_ID), \r\n Submit_Time=any(Submit_Time) ,\r\n Start_Time=any(Start_Time), \r\n End_Time=any(End_Time),\r\n Command=any(Command),\r\n Status=any(Status),\r\n Statement_Type=any(Statement_Type)\r\n ,Resource_class=any(Resource_class) \r\n by Request_ID\r\n| where Request_ID == '{RequestID}'\r\n\r\n", "size": 4, "title": "Selected Query", "noDataMessage": "Select a query above to view details", "timeContext": { "durationMs": 14400000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "35%" } } ] } }, "name": "query - 6" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics\r\n| where Category == 'RequestSteps'\r\n| where Resource == '{DatabaseName}'\r\n| where RequestId_s == '{RequestID}' //Put your QueryID here\r\n| where Status_s != 'Running'\r\n| summarize max(StartTime_t),max(EndTime_t),max(RequestId_s),max(OperationType_s),max(RowCount_d),max(Command_s),max(Status_s) by StepIndex_d\r\n| order by StepIndex_d asc", "size": 3, "title": "Query Plan", "noDataMessage": "Select a query above to view the plan", "timeContext": { "durationMs": 14400000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 7" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "TempDB" }, "name": "group - 3" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "title": "Query Investigation", "items": [ { "type": 1, "content": { "json": "## Search Criteria\r\nUse the following fields to search either using a query text snippet or using a Request ID. If using a query text snippet, try to keep it as simple as possible becuase minor changes in formatting may cause your queries not to show up in the results. It's best to pick something like a table name, then choose the proper query from the list that will populate. " }, "customWidth": "50", "name": "text - 4" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "0c2128d0-d979-4562-a28c-e7ceb955f126", "version": "KqlParameterItem/1.0", "name": "RequestIdSearch", "type": 1, "value": "" }, { "id": "29880874-2d41-4bd5-bf22-3e47ae8b1145", "version": "KqlParameterItem/1.0", "name": "QueryTextSnippet", "type": 1, "value": "", "timeContext": { "durationMs": 86400000 } } ], "style": "formVertical", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "customWidth": "60", "name": "parameters - 3" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics \r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize \r\n Session_ID=max(SessionId_s), \r\n Request_ID=max(RequestId_s), \r\n Submit_Time=max(SubmitTime_t), \r\n Start_Time=max(StartTime_t),\r\n End_Compile_Time=max(EndCompileTime_t), \r\n End_Time=max(EndTime_t), \r\n Command=max(Command_s), \r\n Last_Status=min(Status_s),\r\n Statement_Type=max(StatementType_s),\r\n Resource_class=max(ResourceClass_s) \r\n by RequestId_s\r\n| where Command has '{QueryTextSnippet}'\r\nand RequestId_s has '{RequestIdSearch}'\r\n| extend elapsedTime_sec = iif(End_Time > ago(365d),(End_Time - Submit_Time)/1s,real(null)) \r\n| extend CompileTime_sec = (End_Compile_Time - Submit_Time)/1s\r\n| order by elapsedTime_sec\r\n| summarize \r\n Executions = count(),\r\n Max_Elapsed_Time_sec = bin(max(elapsedTime_sec),1),\r\n Min_Elapsed_Time_sec = bin(min(elapsedTime_sec),1),\r\n Variability_sec=bin((max(elapsedTime_sec)-min(elapsedTime_sec)),1),\r\n SampleQID = any(RequestId_s),\r\n SampleSessionID = any(Session_ID)\r\n by Command\r\n| order by Max_Elapsed_Time_sec\r\n\r\n\r\n", "size": 0, "title": "Matching Queries", "timeContext": { "durationMs": 14400000 }, "timeContextFromParameter": "TimeRange", "exportedParameters": [ { "fieldName": "SampleQID", "parameterName": "SampleQID" }, { "fieldName": "SampleSessionID", "parameterName": "Samp", "parameterType": 1 } ], "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "50%" } } ], "sortBy": [ { "itemKey": "Command", "sortOrder": 1 } ] }, "sortBy": [ { "itemKey": "Command", "sortOrder": 1 } ] }, "name": "query - 0" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics \r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s !in ('Batch','Execute')\r\n| where RequestId_s == '{SampleQID}'\r\n| summarize \r\n Session_ID=max(SessionId_s), \r\n Request_ID=max(RequestId_s), \r\n Submit_Time=min(SubmitTime_t), \r\n Start_Time=max(StartTime_t),\r\n End_Compile_Time=max(EndCompileTime_t), \r\n End_Time=max(EndTime_t), \r\n Command=max(Command_s), \r\n Last_Status=min(Status_s),\r\n Statement_Type=max(StatementType_s),\r\n Resource_class=max(ResourceClass_s) \r\n by RequestId_s\r\n| extend elapsedTime_sec = iif(End_Time > ago(365d),(End_Time - Submit_Time)/1s,real(null)) \r\n| extend CompileTime_sec = (End_Compile_Time - Submit_Time)/1s\r\n| join kind=inner\r\n (AzureDiagnostics \r\n | where Category == 'ExecRequests'\r\n | where Resource == '{DatabaseName}'\r\n | where StatementType_s !in ('Batch','Execute')\r\n | summarize \r\n Session_ID=max(SessionId_s), \r\n Request_ID=max(RequestId_s), \r\n Submit_Time=min(SubmitTime_t), \r\n Start_Time=max(StartTime_t),\r\n End_Compile_Time=max(EndCompileTime_t), \r\n End_Time=max(EndTime_t), \r\n Command=max(Command_s), \r\n Last_Status=min(Status_s),\r\n Statement_Type=max(StatementType_s),\r\n Resource_class=max(ResourceClass_s) \r\n by RequestId_s\r\n | extend elapsedTime_sec = (End_Time - Submit_Time)/1s\r\n | extend elapsedTime_sec = iif(End_Time > ago(365d),(End_Time - Submit_Time)/1s,real(null)) \r\n | extend CompileTime_sec = (End_Compile_Time - Submit_Time)/1s\r\n )\r\non Command \r\n| project Request_ID1,Session_ID1,Submit_Time1,Start_Time1,End_Compile_Time1,End_Time1,Last_Status1,Statement_Type1,Resource_class1,elapsedTime_sec1,CompileTime_sec1\r\n", "size": 0, "title": "All Executions of Selected Query", "noDataMessage": "Select a query above to see individual executions", "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "exportFieldName": "Request_ID1", "exportParameterName": "RequestId", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "sortBy": [] }, "name": "query - 0 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics\r\n| where Category == 'RequestSteps'\r\n| where Resource == '{DatabaseName}'\r\n| where RequestId_s == '{RequestId}'\r\n//| where Status_s != 'Running'\r\n| summarize max(StartTime_t),max(EndTime_t),max(RequestId_s),max(OperationType_s),max(RowCount_d),max(Command_s),min(Status_s) by StepIndex_d\r\n| order by StepIndex_d asc", "size": 3, "title": "Query Plan for Selected Query", "noDataMessage": "Select a Query Above to See the Query Plan", "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 0 - Copy - Copy" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "parameters": [ { "id": "1191e58a-c1f9-4853-b36b-4be8eecbb48f", "version": "KqlParameterItem/1.0", "name": "Query_Submit_Time", "type": 1, "query": " AzureDiagnostics \r\n | where Category == 'ExecRequests'\r\n | where Resource == '{DatabaseName}'\r\n | where StatementType_s !in ('Batch','Execute')\r\n | where RequestId_s =='{RequestId}'\r\n | summarize \r\n Submit_Time=min(SubmitTime_t)\r\n by RequestId_s\r\n | project Submit_Time", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "id": "f6bcb2a4-3356-4110-ba13-99c7d13a26f0", "version": "KqlParameterItem/1.0", "name": "Query_End_Compile_Time", "type": 1, "query": " AzureDiagnostics \r\n | where Category == 'ExecRequests'\r\n | where Resource == '{DatabaseName}'\r\n | where StatementType_s !in ('Batch','Execute')\r\n | where RequestId_s =='{RequestId}'\r\n | summarize \r\n End_Compile_Time=max(EndCompileTime_t) \r\n by RequestId_s\r\n | project End_Compile_Time", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 6" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": " AzureDiagnostics \r\n | where Category == 'ExecRequests'\r\n | where Resource == 'LASR-SQLDWDB-PRD'\r\n | where StatementType_s =='CreateStatistics'\r\n | summarize \r\n Session_ID=max(SessionId_s), \r\n Request_ID=max(RequestId_s), \r\n Submit_Time=min(SubmitTime_t), \r\n Start_Time=max(StartTime_t),\r\n End_Compile_Time=max(EndCompileTime_t), \r\n End_Time=max(EndTime_t), \r\n Command=max(Command_s), \r\n Last_Status=min(Status_s),\r\n Statement_Type=max(StatementType_s),\r\n Resource_class=max(ResourceClass_s) \r\n by RequestId_s\r\n | where Submit_Time > datetime('{Query_Submit_Time}') and End_Time < datetime('{Query_End_Compile_Time}')// or RequestId_s == '{RequestId}'\r\n", "size": 0, "title": "All possibly related auto-stats statements based on time", "noDataMessage": "no auto stats statements found that could be related", "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Submit_Time", "formatter": 0, "numberFormat": { "unit": 0, "options": { "style": "decimal" } } }, { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "100ch" } } ] } }, "name": "All possibly related auto-stats statements" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "QueryInvestigation" }, "name": "group - 4", "styleSettings": { "showBorder": true } }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "title": "Replicated Tables", "items": [ { "type": 1, "content": { "json": "All Charts on this page are based on the last 7 days of data", "style": "info" }, "name": "text - 5" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Build cache count by day\r\nAzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s == 'BuildReplicatedTableCache'\r\n| where Command_s != \"\"\r\n| where ResourceClass_s != \"\"\r\n| project Command_s,TimeGenerated,RequestId_s\r\n| summarize LastRebuild=max(TimeGenerated),RebuildCount=count(RequestId_s) by Command_s\r\n| order by RebuildCount desc\r\n| limit 15\r\n", "size": 3, "title": "Top 15 Most Rebuilds by Table", "timeContext": { "durationMs": 604800000 }, "exportFieldName": "Command_s", "exportParameterName": "QueryText", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command_s", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "40%" } } ] } }, "name": "query - 0" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Build cache count by day\r\nAzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s == 'BuildReplicatedTableCache'\r\n| where Command_s == \"{QueryText}\"\r\n| where ResourceClass_s != \"\"\r\n| project Command_s,TimeGenerated,RequestId_s\r\n| summarize count() by Command_s,bin(TimeGenerated,24h)\r\n| limit 20\r\n| render timechart", "size": 0, "title": "Rebuilds per Day for Selected Table", "noDataMessage": "Select a query above to see runs by day", "timeContext": { "durationMs": 604800000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "chartSettings": { "group": "Command_s", "createOtherGroup": 20, "ySettings": { "min": 0 } } }, "name": "query - 0 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Build cache count by day\r\nAzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s == 'BuildReplicatedTableCache'\r\n| where Command_s != \"\"\r\n| where ResourceClass_s != \"\"\r\n| project Command_s,TimeGenerated,RequestId_s\r\n| summarize count() by Command_s, bin(TimeGenerated,24h)\r\n| where count_ > 7\r\n| order by count_ desc\r\n\r\n", "size": 2, "title": "Rebuild Count by Table by Day", "noDataMessage": " Only tables with more than 7 total rebuilds will show up. If no talbes with that many rebuilds are found this chart will be empty", "timeContext": { "durationMs": 604800000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "categoricalbar", "gridSettings": { "sortBy": [ { "itemKey": "count_", "sortOrder": 1 } ] }, "sortBy": [ { "itemKey": "count_", "sortOrder": 1 } ], "tileSettings": { "showBorder": false, "titleContent": { "columnMatch": "Command_s", "formatter": 1 }, "leftContent": { "columnMatch": "count_", "formatter": 12, "formatOptions": { "palette": "auto" }, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "graphSettings": { "type": 0, "topContent": { "columnMatch": "Command_s", "formatter": 1 }, "centerContent": { "columnMatch": "count_", "formatter": 1, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "chartSettings": { "group": "Command_s", "createOtherGroup": 99, "showDataPoints": true } }, "name": "query - 0 - Copy - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Long-Running Queries - Just Actual Queries\r\nAzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize Session_ID=max(SessionId_s), Request_ID=max(RequestId_s), Submit_Time=max(SubmitTime_t), Start_Time=max(StartTime_t), End_Time=max(EndTime_t), Command=max(Command_s), Statement_Type=max(StatementType_s), Resource_class=max(ResourceClass_s) by RequestId_s\r\n| join kind= inner\r\n(\r\n AzureDiagnostics\r\n | where Category == 'ExecRequests'\r\n | where Resource == '{DatabaseName}'\r\n //| where StatementType_s !in ('Batch','Execute')\r\n | where StatementType_s == 'BuildReplicatedTableCache'\r\n | where EndTime_t > ago(7d)\r\n | where StartTime_t > ago(7d)\r\n | extend elapsedTime_min = (EndTime_t - StartTime_t)/1m\r\n //| extend elapsedTime_min = elapsedTime/1m\r\n | order by elapsedTime_min desc\r\n | project Request_ID=RequestId_s,elapsedTime_min \r\n)\r\non Request_ID\r\n| order by elapsedTime_min desc\r\n| project Request_ID,Submit_Time,Start_Time,End_Time,Elapsed_Time=round(elapsedTime_min,1) ,Command\r\n| limit 15\r\n", "size": 3, "title": "Top 15 Elapsed Time per Rebuild", "timeContext": { "durationMs": 604800000 }, "exportFieldName": "Request_ID", "exportParameterName": "RequestId", "exportDefaultValue": "999999", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "40%" } } ] } }, "name": "query - 3" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics\r\n| where Category == 'RequestSteps'\r\n| where Resource == '{DatabaseName}'\r\n| where RequestId_s == '{RequestId}'\r\n| where Status_s != 'Running'\r\n| summarize max(StartTime_t),max(EndTime_t),max(RequestId_s),max(OperationType_s),max(RowCount_d),max(Command_s),max(Status_s) by StepIndex_d\r\n| order by StepIndex_d asc", "size": 3, "title": "Query Plan for Selected Query", "noDataMessage": "Select a query above to view plan", "timeContext": { "durationMs": 604800000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 4" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "ReplicatedTables" }, "name": "ReplicatedTablesGroup" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "title": "Workload Management", "items": [ { "type": 10, "content": { "chartId": "workbook72446028-6edb-4cb0-8952-e0c13bda488f", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 0 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-WorkloadManagement-wlg_allocation_relative_to_system_percent", "aggregation": 3, "splitBy": null } ], "title": "Workload Group Allocation By System Percent", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "name": "metric - 0" }, { "type": 10, "content": { "chartId": "workbookc898119a-7381-469d-b51a-d505b4f80e73", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 0 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-WorkloadManagement-wlg_active_queries", "aggregation": 1, "splitBy": null } ], "title": "Query Count by Workload Group", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "name": "metric - 1" }, { "type": 10, "content": { "chartId": "workbook8d175f6c-427b-47fc-85ea-37edd0be707c", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 0 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-WorkloadManagement-wlg_queued_queries", "aggregation": 1, "splitBy": null } ], "title": "Queued Queries by Workload Group", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "name": "Queued Queries by Workload Group" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "parameters": [ { "id": "6f50577d-7b00-4e4a-acf9-d45c7a5ee813", "version": "KqlParameterItem/1.0", "name": "WorkloadGroupName", "type": 2, "query": "AzureDiagnostics\r\n| where Category == 'ExecRequests'\r\nand Resource == '{DatabaseName}'\r\n and ResourceClass_s != \"\"\r\n| distinct ResourceClass_s", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "value": null, "typeSettings": { "additionalResourceOptions": [], "showDefault": false }, "timeContext": { "durationMs": 604800000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 2" }, { "type": 10, "content": { "chartId": "workbook3da1d18a-1bf5-46c5-b3b7-211f71d329cc", "version": "MetricsItem/2.0", "size": 0, "chartType": 2, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 0 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-WorkloadManagement-wlg_active_queries", "aggregation": 1, "splitBy": null }, { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-WorkloadManagement-wlg_queued_queries", "aggregation": 1 }, { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-WorkloadManagement-wlg_allocation_relative_to_system_percent", "aggregation": 3 } ], "filters": [ { "id": "3", "key": "WorkloadGroupName", "operator": 0, "valueParam": "WorkloadGroupName" } ], "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "name": "metric - 3" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "WorkloadManagement" }, "name": "group - 6" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "title": "Query Audit", "items": [ { "type": 1, "content": { "json": "## Select a Principal or Application name to filter results - leave to 'unset' to view all results\r\nSQL Auditing must be enabled and sending to the same Log Analytics Workspace for this page to work. " }, "name": "text - 5" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "parameters": [ { "id": "8d25c043-d1ff-4546-a1fa-f4bcbfdab8af", "version": "KqlParameterItem/1.0", "name": "User", "type": 2, "description": "User to filter subsequent queries - leave to 'unset' for all users", "query": "AzureDiagnostics\r\n| where Category == 'SQLSecurityAuditEvents' and LogicalServerName_s == '{LogicalServerName}'\r\n| summarize by server_principal_name_s", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "value": null, "typeSettings": { "additionalResourceOptions": [], "showDefault": false }, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "id": "aa766d64-693f-4024-b4a4-b5b56b28376b", "version": "KqlParameterItem/1.0", "name": "Application", "type": 2, "query": "AzureDiagnostics\r\n| where Category == 'SQLSecurityAuditEvents' and LogicalServerName_s == '{LogicalServerName}'\r\n| summarize by application_name_s", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "value": null, "typeSettings": { "additionalResourceOptions": [], "showDefault": false }, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "customWidth": "30", "name": "parameters - 1" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics\r\n| where Category == 'SQLSecurityAuditEvents' and LogicalServerName_s == \"{LogicalServerName}\"\r\n| where duration_milliseconds_d > 0\r\n| extend duration_seconds = duration_milliseconds_d /1000.0\r\n| where statement_s != 'select @@version'\r\n| where statement_s != 'SELECT @@SPID;'\r\n| where server_principal_name_s has '{User}'\r\n| where application_name_s has '{Application}'\r\n| project server_principal_name_s, succeeded_s, event_time_t, LogicalServerName_s, duration_milliseconds_d, duration_seconds, affected_rows_d, statement_s, application_name_s\r\n| summarize duration_seconds = round(sum(duration_seconds)) , query_count = count(statement_s) by EventDay = bin(event_time_t,1d), UserName = server_principal_name_s, Application = application_name_s \r\n| order by EventDay, duration_seconds desc", "size": 0, "title": "Query Summary for Selected User {User} {Application}", "noDataMessage": "Select a user to see query activity", "timeContext": { "durationMs": 14400000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 0 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics\r\n| where Category == 'SQLSecurityAuditEvents' and LogicalServerName_s == \"{LogicalServerName}\"\r\n| where duration_milliseconds_d > 0\r\n| extend duration_seconds = duration_milliseconds_d /1000.0\r\n| where statement_s != 'select @@version'\r\n| where statement_s != 'SELECT @@SPID;'\r\n| where server_principal_name_s has '{User}'\r\n| where application_name_s has '{Application}'\r\n| project server_principal_name_s, succeeded_s, event_time_t, LogicalServerName_s, duration_milliseconds_d, duration_seconds, affected_rows_d, statement_s, application_name_s\r\n| summarize duration_seconds = round(sum(duration_seconds)) , query_count = count(statement_s) by EventDay = bin(event_time_t,1d), UserName = server_principal_name_s, Application = application_name_s \r\n| order by EventDay, duration_seconds desc", "size": 0, "title": "Query Summary for Selected User {User} {Application}", "noDataMessage": "Select a user to see query activity", "timeContext": { "durationMs": 14400000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "unstackedbar", "tileSettings": { "showBorder": false, "titleContent": { "columnMatch": "UserName", "formatter": 1 }, "leftContent": { "columnMatch": "duration_seconds", "formatter": 12, "formatOptions": { "palette": "auto" }, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "graphSettings": { "type": 0, "topContent": { "columnMatch": "UserName", "formatter": 1 }, "centerContent": { "columnMatch": "duration_seconds", "formatter": 1, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "chartSettings": { "xAxis": "UserName" }, "mapSettings": { "locInfo": "LatLong", "sizeSettings": "duration_seconds", "sizeAggregation": "Sum", "legendMetric": "duration_seconds", "legendAggregation": "Sum", "itemColorSettings": { "type": "heatmap", "colorAggregation": "Sum", "nodeColorField": "duration_seconds", "heatmapPalette": "greenRed" } } }, "name": "query - 0 - Copy - Copy" }, { "type": 1, "content": { "json": "## This next chart is a work in progress\r\nThe next chart uses an approximate join based on end time. If the Exec Requests Query Text and the Audit Log Query text don't match up, then it is likely not a real match and the data in teh row shoudl not be trusted. ", "style": "warning" }, "name": "text - 7" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databasename='{DatabaseName}';\r\nAzureDiagnostics \r\n| where Category == 'ExecRequests'\r\n| where Resource == databasename\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize Session_ID=max(SessionId_s), \r\n Query_Submit_Time=max(SubmitTime_t), \r\n Query_Start_Time=max(StartTime_t), \r\n Query_End_Time=max(EndTime_t), \r\n Query_Text=max(Command_s), \r\n Status=min(Status_s),\r\n Resource_class=max(ResourceClass_s) ,\r\n Query_ElapsedTime_s=round((max(EndTime_t) - max(StartTime_t))/1s)\r\n by RequestId_s\r\n| join kind = leftouter \r\n(\r\n AzureDiagnostics\r\n | where Category == 'RequestSteps'\r\n | where Resource == databasename\r\n | summarize num_steps=max(StepIndex_d), \r\n max_step_rows=max(RowCount_d), \r\n max_step_sec=max(EndTime_t-StartTime_t)/1s\r\n by RequestId_s\r\n ) on RequestId_s\r\n| order by Query_Submit_Time\r\n| project Session_ID,RequestId_s,Query_Submit_Time,Query_Start_Time,EventTime = Query_End_Time,num_steps,max_step_rows,max_step_sec,Query_ElapsedTime_s,Status,Query = Query_Text,Resource_class\r\n| join kind = rightouter \r\n(\r\n AzureDiagnostics\r\n | where Category == 'SQLSecurityAuditEvents' and LogicalServerName_s == \"{LogicalServerName}\"\r\n | where duration_milliseconds_d > 0\r\n | extend duration_seconds = duration_milliseconds_d /1000.0\r\n | where statement_s != 'select @@version'\r\n | where statement_s != 'SELECT @@SPID;'\r\n | where server_principal_name_s has '{User}'\r\n // | where application_name_s has '{Application}'\r\n | project DatabaseName= database_name_s, UserName= server_principal_name_s, EventTime= event_time_t, Host= host_name_s, duration_seconds = round(duration_seconds), statement_s, QuerySource = application_name_s , affected_rows_d\r\n | project-reorder DatabaseName, UserName, Host, EventTime, duration_seconds, statement_s, QuerySource\r\n) on EventTime\r\n | order by affected_rows_d desc\r\n| project Session_ID,RequestID=RequestId_s,Submit_time=Query_Submit_Time,Start_Time=Query_Start_Time,End_Time=EventTime,Status,Resource_class,UserName,Exec_request_text=Query,Audit_Query_text=statement_s,Host,QuerySource,Affected_rows=affected_rows_d,num_steps,max_step_rows,max_step_sec,Total_Duration_s=duration_seconds\r\n\r\n\r\n\r\n\r\n", "size": 0, "title": "Queries {User} {Application}", "noDataMessage": "Select a user to see query activity", "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 0 - Copy - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": " AzureDiagnostics\r\n | where Category == 'SQLSecurityAuditEvents' and LogicalServerName_s == \"{LogicalServerName}\"\r\n | where duration_milliseconds_d > 0\r\n| extend Duration = round(duration_milliseconds_d /1000.0)\r\n| extend TimeBin = case (datetime_part(\"Hour\",TimeGenerated) in (6,7,8,9,10,11,12), \"Morning_6-12\", datetime_part(\"Hour\",TimeGenerated) in (13,14,15,16,17,18), \"Afternoon_12-18\", \"Overnight_18-6\")\r\n| where server_principal_name_s has '{User}'\r\n| where application_name_s has '{Application}'\r\n| summarize QueryDuration = sum(Duration) by EventTime = bin(event_time_t, 1d), TimeBin", "size": 0, "title": "Query Activity by time - sum(Duration) {User} {Application}", "noDataMessage": "Select a user to see query activity", "timeContext": { "durationMs": 14400000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "barchart" }, "name": "query - 0 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databasename='{DatabaseName}';\r\nAzureDiagnostics \r\n| where Category == 'ExecRequests'\r\n| where Resource == databasename\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize Session_ID=max(SessionId_s), \r\n Query_Submit_Time=max(SubmitTime_t), \r\n Query_Start_Time=max(StartTime_t), \r\n Query_End_Time=max(EndTime_t), \r\n Query_Text=max(Command_s), \r\n Status=min(Status_s),\r\n Resource_class=max(ResourceClass_s) ,\r\n Query_ElapsedTime_s=round((max(EndTime_t) - max(StartTime_t))/1s)\r\n by RequestId_s\r\n| join kind = leftouter \r\n(\r\n AzureDiagnostics\r\n | where Category == 'RequestSteps'\r\n | where Resource == databasename\r\n | summarize num_steps=max(StepIndex_d), \r\n max_step_rows=max(RowCount_d), \r\n max_step_sec=max(EndTime_t-StartTime_t)/1s\r\n by RequestId_s\r\n ) on RequestId_s\r\n| order by Query_Submit_Time\r\n| project Session_ID,RequestId_s,Query_Submit_Time,Query_Start_Time,EventTime = Query_End_Time,num_steps,max_step_rows,max_step_sec,Query_ElapsedTime_s,Status,Query = Query_Text,Resource_class\r\n| join kind = rightouter \r\n(\r\n AzureDiagnostics\r\n | where Category == 'SQLSecurityAuditEvents' and LogicalServerName_s == \"{LogicalServerName}\"\r\n | where duration_milliseconds_d > 0\r\n | extend duration_seconds = duration_milliseconds_d /1000.0\r\n | where statement_s != 'select @@version'\r\n | where statement_s != 'SELECT @@SPID;'\r\n | where server_principal_name_s has '{User}'\r\n // | where application_name_s has '{Application}'\r\n | project DatabaseName= database_name_s, UserName= server_principal_name_s, EventTime= event_time_t, Host= host_name_s, duration_seconds = round(duration_seconds), statement_s, QuerySource = application_name_s , affected_rows_d\r\n | project-reorder DatabaseName, UserName, Host, EventTime, duration_seconds, statement_s, QuerySource\r\n) on EventTime\r\n | order by affected_rows_d desc\r\n| project Session_ID,RequestID=RequestId_s,Submit_time=Query_Submit_Time,Start_Time=Query_Start_Time,End_Time=EventTime,Status,Resource_class,UserName,Query_text=statement_s,Host,QuerySource,Affected_rows=affected_rows_d,num_steps,max_step_rows,max_step_sec,Total_Duration_s=duration_seconds\r\n\r\n\r\n\r\n\r\n", "size": 0, "title": "Affected Rows By Session ID", "timeContext": { "durationMs": 14400000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "linechart", "chartSettings": { "xAxis": "RequestID", "yAxis": [ "Affected_rows" ] } }, "name": "query - 6" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "QueryAudit" }, "name": "QueryAuditGroup", "styleSettings": { "showBorder": true } }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "title": "Query Comparison", "items": [ { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "7fa3187e-9225-4faa-8f80-dc1bc40c5aab", "version": "KqlParameterItem/1.0", "name": "RequestId1", "type": 1, "value": "" } ], "style": "above", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "customWidth": "50", "name": "parameters - 3 - Copy" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "315fc476-469a-4d8d-b421-028d1113ab06", "version": "KqlParameterItem/1.0", "name": "RequestId2", "type": 1, "value": "", "timeContext": { "durationMs": 86400000 } } ], "style": "above", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "customWidth": "50", "name": "parameters - 2" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s !in ('Batch','Execute') and RequestId_s == '{RequestId1}'\r\n| summarize Session_ID=any(SessionId_s),\r\n Request_ID=any(RequestId_s),\r\n Submit_Time=min(SubmitTime_t),\r\n Start_Time=max(StartTime_t),\r\n End_Time=max(EndTime_t),\r\n Command=any(Command_s),\r\n Status=min(Status_s), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType_s),\r\n Resource_class=any(ResourceClass_s)\r\n by RequestId_s\r\n| summarize Session_ID=any(Session_ID), Submit_Time=any(Submit_Time) ,Start_Time=any(Start_Time), End_Time=any(End_Time),ElapsedTime_min=anyif((End_Time - Start_Time)/1m,Start_Time > ago(30d)),Command=any(Command),Status=any(Status),Statement_Type=any(Statement_Type),Resource_class=any(Resource_class) by Request_ID\r\n| project Session_ID,Request_ID,ElapsedTime_min,Command,Resource_class,Submit_Time,Start_Time,End_Time,Statement_Type,Status\r\n", "size": 4, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "customWidth": "50", "name": "query - 2" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s !in ('Batch','Execute') and RequestId_s == '{RequestId2}'\r\n| summarize Session_ID=any(SessionId_s),\r\n Request_ID=any(RequestId_s),\r\n Submit_Time=min(SubmitTime_t),\r\n Start_Time=max(StartTime_t),\r\n End_Time=max(EndTime_t),\r\n Command=any(Command_s),\r\n Status=min(Status_s), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType_s),\r\n Resource_class=any(ResourceClass_s)\r\n by RequestId_s\r\n| summarize Session_ID=any(Session_ID), Submit_Time=any(Submit_Time) ,Start_Time=any(Start_Time), End_Time=any(End_Time),ElapsedTime_min=anyif((End_Time - Start_Time)/1m,Start_Time > ago(30d)),Command=any(Command),Status=any(Status),Statement_Type=any(Statement_Type),Resource_class=any(Resource_class) by Request_ID\r\n| project Session_ID,Request_ID,ElapsedTime_min,Command,Resource_class,Submit_Time,Start_Time,End_Time,Statement_Type,Status\r\n", "size": 4, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "customWidth": "50", "name": "query - 2 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics\r\n| where Category == 'RequestSteps'\r\n| where Resource == '{DatabaseName}'\r\n| where RequestId_s == '{RequestId1}'\r\n| summarize StartTime=max(StartTime_t)\r\n ,EndTime=max(EndTime_t)\r\n ,RequestID=max(RequestId_s)\r\n ,Operation=max(OperationType_s)\r\n ,RowCount=max(RowCount_d)\r\n ,Command=max(Command_s)\r\n ,Status=max(Status_s)\r\n by StepIndex_d\r\n| order by StepIndex_d asc\r\n| project StartTime,EndTime,RequestID,Operation,RowCount,Command,Status,StepIndex_d", "size": 3, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "customWidth": "50", "name": "query - 4", "styleSettings": { "margin": "0", "padding": "10px" } }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics\r\n| where Category == 'RequestSteps'\r\n| where Resource == '{DatabaseName}'\r\n| where RequestId_s == '{RequestId2}'\r\n| summarize StartTime=max(StartTime_t)\r\n ,EndTime=max(EndTime_t)\r\n ,RequestID=max(RequestId_s)\r\n ,Operation=max(OperationType_s)\r\n ,RowCount=max(RowCount_d)\r\n ,Command=max(Command_s)\r\n ,Status=max(Status_s)\r\n by StepIndex_d\r\n| order by StepIndex_d asc\r\n| project StartTime,EndTime,RequestID,Operation,RowCount,Command,Status,StepIndex_d", "size": 3, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "customWidth": "50", "name": "query - 4 - Copy", "styleSettings": { "padding": "10px" } }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "parameters": [ { "id": "03d1c3ba-0d28-4584-bb63-388f8477034a", "version": "KqlParameterItem/1.0", "name": "Query_Submit_Time1", "type": 1, "query": " AzureDiagnostics \r\n | where Category == 'ExecRequests'\r\n | where Resource == '{DatabaseName}'\r\n | where StatementType_s !in ('Batch','Execute')\r\n | where RequestId_s =='{RequestId1}'\r\n | summarize \r\n Submit_Time=min(SubmitTime_t)\r\n by RequestId_s\r\n | project Submit_Time", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "id": "af36efd7-c5a0-429e-8908-a24e22ee6087", "version": "KqlParameterItem/1.0", "name": "Query_End_Compile_Time1", "type": 1, "query": " AzureDiagnostics \r\n | where Category == 'ExecRequests'\r\n | where Resource == '{DatabaseName}'\r\n | where StatementType_s !in ('Batch','Execute')\r\n | where RequestId_s =='{RequestId1}'\r\n | summarize \r\n End_Compile_Time=max(EndCompileTime_t) \r\n by RequestId_s\r\n | project End_Compile_Time", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "id": "03d1c3ba-0d28-4584-bb63-388f8477034a", "version": "KqlParameterItem/1.0", "name": "Query_Submit_Time2", "type": 1, "query": " AzureDiagnostics \r\n | where Category == 'ExecRequests'\r\n | where Resource == '{DatabaseName}'\r\n | where StatementType_s !in ('Batch','Execute')\r\n | where RequestId_s =='{RequestId2}'\r\n | summarize \r\n Submit_Time=min(SubmitTime_t)\r\n by RequestId_s\r\n | project Submit_Time", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "id": "af36efd7-c5a0-429e-8908-a24e22ee6087", "version": "KqlParameterItem/1.0", "name": "Query_End_Compile_Time2", "type": 1, "query": " AzureDiagnostics \r\n | where Category == 'ExecRequests'\r\n | where Resource == '{DatabaseName}'\r\n | where StatementType_s !in ('Batch','Execute')\r\n | where RequestId_s =='{RequestId2}'\r\n | summarize \r\n End_Compile_Time=max(EndCompileTime_t) \r\n by RequestId_s\r\n | project End_Compile_Time", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 6 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": " AzureDiagnostics \r\n | where Category == 'ExecRequests'\r\n | where Resource == '{DatabaseName}'\r\n | where StatementType_s =='CreateStatistics'\r\n | summarize \r\n Session_ID=max(SessionId_s), \r\n //Request_ID=max(RequestId_s), \r\n Submit_Time=min(SubmitTime_t), \r\n //Start_Time=max(StartTime_t),\r\n //End_Compile_Time=max(EndCompileTime_t), \r\n End_Time=max(EndTime_t), \r\n Command=max(Command_s), \r\n Last_Status=min(Status_s),\r\n Statement_Type=max(StatementType_s),\r\n Resource_class=max(ResourceClass_s) \r\n by RequestId_s\r\n | where Submit_Time > datetime('{Query_Submit_Time1}') and End_Time < datetime('{Query_End_Compile_Time1}') and End_Time > ago(30d)\r\n| project Command, Status=Last_Status ,Submit_Time,End_Time,Session_ID,Request_ID=RequestId_s,Statement_Type\r\n", "size": 0, "title": "All possibly related auto-stats statements based on time", "noDataMessage": "no auto stats statements found that could be related", "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Submit_Time", "formatter": 0, "numberFormat": { "unit": 0, "options": { "style": "decimal" } } }, { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "100ch" } } ], "sortBy": [ { "itemKey": "End_Time", "sortOrder": 2 } ] }, "sortBy": [ { "itemKey": "End_Time", "sortOrder": 2 } ] }, "customWidth": "50", "name": "All possibly related auto-stats statements - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": " AzureDiagnostics \r\n | where Category == 'ExecRequests'\r\n | where Resource == '{DatabaseName}'\r\n | where StatementType_s =='CreateStatistics'\r\n | summarize \r\n Session_ID=max(SessionId_s), \r\n //Request_ID=max(RequestId_s), \r\n Submit_Time=min(SubmitTime_t), \r\n //Start_Time=max(StartTime_t),\r\n //End_Compile_Time=max(EndCompileTime_t), \r\n End_Time=max(EndTime_t), \r\n Command=max(Command_s), \r\n Last_Status=min(Status_s),\r\n Statement_Type=max(StatementType_s),\r\n Resource_class=max(ResourceClass_s) \r\n by RequestId_s\r\n | where Submit_Time > datetime('{Query_Submit_Time2}') and End_Time < datetime('{Query_End_Compile_Time2}') and End_Time > ago(30d)\r\n| project Command, Status=Last_Status ,Submit_Time,End_Time,Session_ID,Request_ID=RequestId_s,Statement_Type\r\n", "size": 0, "title": "All possibly related auto-stats statements based on time", "noDataMessage": "no auto stats statements found that could be related", "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Submit_Time", "formatter": 0, "numberFormat": { "unit": 0, "options": { "style": "decimal" } } }, { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "100ch" } } ] } }, "customWidth": "50", "name": "All possibly related auto-stats statements - Copy - Copy" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "QueryComparison" }, "name": "QueryComparison" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "title": "Session Investigation", "items": [ { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "feb2ac70-2555-456e-bfa6-6ad4a2dcad0f", "version": "KqlParameterItem/1.0", "name": "SessionID", "type": 1, "value": "", "timeContext": { "durationMs": 86400000 } } ], "style": "above", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 0" }, { "type": 1, "content": { "json": "The matching of the user information in the next chart is approximate. This information is a work in progress", "style": "warning" }, "name": "text - 4" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databasename='{DatabaseName}';\r\nAzureDiagnostics \r\n| where Category == 'ExecRequests'\r\n| where Resource == databasename\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize Query_End_Time = max(EndTime_t ) by SessionId_s\r\n| where SessionId_s == '{SessionID}'\r\n| join kind = rightouter \r\n( \r\n AzureDiagnostics\r\n | where Category == 'SQLSecurityAuditEvents' \r\n | where duration_milliseconds_d > 0\r\n | extend duration_seconds = duration_milliseconds_d /1000.0\r\n | where statement_s != 'select @@version' and statement_s != 'SELECT @@SPID;' and server_principal_name_s != '##MS_InstanceCertificate##'\r\n) on $left.Query_End_Time==$right.event_time_t \r\n| summarize DatabaseName= max(database_name_s)\r\n , UserName= any(server_principal_name_s)\r\n , Host= max(host_name_s)\r\n , Application=max(application_name_s)\r\n by SessionId_s\r\n\r\n\r\n\r\n", "size": 4, "timeContext": { "durationMs": 14400000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "table", "tileSettings": { "titleContent": { "columnMatch": "UserName" }, "subtitleContent": { "columnMatch": "SessionId_s" }, "leftContent": { "columnMatch": "Application" }, "rightContent": { "columnMatch": "Host" }, "secondaryContent": { "columnMatch": "DatabaseName" }, "showBorder": false, "size": "full" }, "graphSettings": { "type": 0 } }, "name": "query - 3" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics \r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize \r\n Session_ID=max(SessionId_s), \r\n Submit_Time=max(SubmitTime_t), \r\n Start_Time=max(StartTime_t),\r\n End_Compile_Time=max(EndCompileTime_t), \r\n End_Time=max(EndTime_t), \r\n Command=max(Command_s), \r\n Last_Status=min(Status_s),\r\n Statement_Type=max(StatementType_s),\r\n Resource_class=max(ResourceClass_s) \r\n by RequestId_s\r\n| where Session_ID has '{SessionID}'\r\n| extend elapsedTime_sec = iif(End_Time > ago(365d),(End_Time - Submit_Time)/1s,real(null)) \r\n| order by Submit_Time asc\r\n\r\n\r\n\r\n\r\n", "size": 0, "timeContext": { "durationMs": 14400000 }, "timeContextFromParameter": "TimeRange", "exportFieldName": "RequestId_s", "exportParameterName": "RequestID", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 1" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics\r\n| where Category == 'RequestSteps'\r\n| where Resource == '{DatabaseName}'\r\n| where RequestId_s == '{RequestID}'\r\n//| where Status_s != 'Running'\r\n| summarize Start_Time=max(StartTime_t),End_Time=max(EndTime_t),Request_ID=max(RequestId_s),Operation_Type=max(OperationType_s),Row_Count=max(RowCount_d),Statement=max(Command_s),Status=min(Status_s) by StepIndex_d\r\n| order by StepIndex_d asc", "size": 3, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 2" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "SessionInvestigation" }, "name": "group - 9" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 1, "content": { "json": "## This tab is used to determine what statements triggerred autostats creation jobs. \r\nThe flow of autostats creation is as follows\r\n1. Query Submit Time\r\n2. \tCreate Statistics submit Time\r\n3. \tCreate Statistics end Time\r\n4. Query end_compile_time\r\n5. Query Start_Time\r\n6. Query End_Time\r\n\r\nFurther, if multiple stats are created, then the creation of all stats for this query will fall between query submit_time and end_compile_time. \r\n\r\nThe charts on this page allow you to search for an autostats job by requestID or my snippet of the autostats statement text, which can just be the schema, table, or column name. Then it will show you all commands that include that request ID or text. It will then show you all statements in the create stat statement because the query we are trying to identify will wait for all of those stats creations to complete before proceeding. \r\n\r\nThe last chart will list out all statements that could possibly have triggerred the stats creation job based on their submite/end_compile_time. " }, "name": "text - 6" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "0911bd4b-d471-480b-bdf4-1a2d4ba1ea6e", "version": "KqlParameterItem/1.0", "name": "RequestIdSearch", "type": 1, "value": "", "label": "RequestId for AutoStats Job" }, { "id": "c12e6495-4fd1-473c-8ffc-0bf502f54706", "version": "KqlParameterItem/1.0", "name": "QueryTextSnippet", "type": 1, "value": "", "timeContext": { "durationMs": 86400000 }, "label": "Snippet of autostats creation statement (Schema, table or column)" } ], "style": "formVertical", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "customWidth": "60", "name": "parameters - 3 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics \r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize \r\n Session_ID=max(SessionId_s), \r\n Request_ID=max(RequestId_s), \r\n Submit_Time=max(SubmitTime_t), \r\n Start_Time=max(StartTime_t),\r\n End_Compile_Time=max(EndCompileTime_t), \r\n End_Time=max(EndTime_t), \r\n Command=max(Command_s), \r\n Last_Status=min(Status_s),\r\n Statement_Type=max(StatementType_s),\r\n Resource_class=max(ResourceClass_s) \r\n by RequestId_s\r\n| where Command has 'CREATE STATISTICS _wa_sys'\r\n| where Command has '{QueryTextSnippet}'\r\nand RequestId_s has '{RequestIdSearch}'\r\n| extend elapsedTime_sec = iif(End_Time > ago(365d),(End_Time - Submit_Time)/1s,real(null)) \r\n| extend CompileTime_sec = (End_Compile_Time - Submit_Time)/1s\r\n| order by elapsedTime_sec\r\n| summarize \r\n Executions = count(),\r\n Max_Elapsed_Time_sec = bin(max(elapsedTime_sec),1),\r\n Min_Elapsed_Time_sec = bin(min(elapsedTime_sec),1),\r\n Variability_sec=bin((max(elapsedTime_sec)-min(elapsedTime_sec)),1),\r\n SampleQID = any(RequestId_s),\r\n SampleSessionID = any(Session_ID)\r\n by Command\r\n| order by Max_Elapsed_Time_sec\r\n\r\n\r\n", "size": 0, "title": "Matching Queries", "timeContext": { "durationMs": 14400000 }, "timeContextFromParameter": "TimeRange", "exportedParameters": [ { "fieldName": "SampleQID", "parameterName": "SampleQID" }, { "fieldName": "SampleSessionID", "parameterName": "Samp", "parameterType": 1 } ], "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "50%" } } ], "sortBy": [ { "itemKey": "Command", "sortOrder": 1 } ] }, "sortBy": [ { "itemKey": "Command", "sortOrder": 1 } ] }, "name": "query - 0 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics \r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s !in ('Batch','Execute')\r\n| where RequestId_s == '{SampleQID}'\r\n| summarize \r\n Session_ID=max(SessionId_s), \r\n Request_ID=max(RequestId_s), \r\n Submit_Time=min(SubmitTime_t), \r\n Start_Time=max(StartTime_t),\r\n End_Compile_Time=max(EndCompileTime_t), \r\n End_Time=max(EndTime_t), \r\n Command=max(Command_s), \r\n Last_Status=min(Status_s),\r\n Statement_Type=max(StatementType_s),\r\n Resource_class=max(ResourceClass_s) \r\n by RequestId_s\r\n| extend elapsedTime_sec = iif(End_Time > ago(365d),(End_Time - Submit_Time)/1s,real(null)) \r\n| extend CompileTime_sec = (End_Compile_Time - Submit_Time)/1s\r\n| join kind=inner\r\n (AzureDiagnostics \r\n | where Category == 'ExecRequests'\r\n | where Resource == '{DatabaseName}'\r\n | where StatementType_s !in ('Batch','Execute')\r\n | summarize \r\n Session_ID=max(SessionId_s), \r\n Request_ID=max(RequestId_s), \r\n Submit_Time=min(SubmitTime_t), \r\n Start_Time=max(StartTime_t),\r\n End_Compile_Time=max(EndCompileTime_t), \r\n End_Time=max(EndTime_t), \r\n Command=max(Command_s), \r\n Last_Status=min(Status_s),\r\n Statement_Type=max(StatementType_s),\r\n Resource_class=max(ResourceClass_s) \r\n by RequestId_s\r\n | extend elapsedTime_sec = (End_Time - Submit_Time)/1s\r\n | extend elapsedTime_sec = iif(End_Time > ago(365d),(End_Time - Submit_Time)/1s,real(null)) \r\n | extend CompileTime_sec = (End_Compile_Time - Submit_Time)/1s\r\n )\r\non Command \r\n| project Request_ID1,Session_ID1,Submit_Time1,Start_Time1,End_Compile_Time1,End_Time1,Last_Status1,Statement_Type1,elapsedTime_sec1,CompileTime_sec1\r\n", "size": 0, "title": "All Executions of Selected Query", "noDataMessage": "Select a query above to see individual executions", "timeContext": { "durationMs": 14400000 }, "timeContextFromParameter": "TimeRange", "exportedParameters": [ { "fieldName": "Request_ID1", "parameterName": "RequestId" }, { "fieldName": "End_Time1", "parameterName": "StatEndTime", "parameterType": 1 }, { "fieldName": "Submit_Time1", "parameterName": "StatSubmitTime", "parameterType": 1 }, { "fieldName": "Session_ID1", "parameterName": "SessionId", "parameterType": 1 } ], "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "sortBy": [ { "itemKey": "End_Time1", "sortOrder": 1 } ] }, "sortBy": [ { "itemKey": "End_Time1", "sortOrder": 1 } ] }, "name": "query - 0 - Copy - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": " AzureDiagnostics \r\n | where Category == 'ExecRequests'\r\n | where Resource == '{DatabaseName}'\r\n | where StatementType_s !in ('Batch','Execute')\r\n | where SessionId_s == '{SessionId}'\r\n | summarize \r\n Session_ID=max(SessionId_s), \r\n Request_ID=max(RequestId_s), \r\n Submit_Time=min(SubmitTime_t), \r\n Start_Time=max(StartTime_t),\r\n End_Compile_Time=max(EndCompileTime_t), \r\n End_Time=max(EndTime_t), \r\n Command=max(Command_s), \r\n Last_Status=min(Status_s),\r\n Statement_Type=max(StatementType_s),\r\n Resource_class=max(ResourceClass_s) \r\n by RequestId_s\r\n| project Session_ID,Request_ID,Submit_Time,End_Compile_Time,Start_Time,End_Time,Last_Status,Statement_Type,Command\r\n\r\n\r\n", "size": 0, "title": "All Statements in Stats Statement Session", "noDataMessage": "Select a query above to see individual executions", "timeContext": { "durationMs": 14400000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "150ch" } } ], "sortBy": [ { "itemKey": "Command", "sortOrder": 1 } ] }, "sortBy": [ { "itemKey": "Command", "sortOrder": 1 } ] }, "name": "query - 0 - Copy - Copy - Copy - Copy" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "parameters": [ { "id": "4e005821-785a-4246-aae8-de00987cba18", "version": "KqlParameterItem/1.0", "name": "Session_Submit_Time", "type": 1, "query": "AzureDiagnostics \r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s !in ('Batch','Execute')\r\n| where SessionId_s == '{SessionId}'\r\n| summarize \r\n Session_Submit_Time=min(SubmitTime_t) \r\n by SessionId_s\r\n| project Session_Submit_Time\r\n\r\n\r\n", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 259200000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "id": "b046db56-e6b3-4f3d-afb3-9687240c21f1", "version": "KqlParameterItem/1.0", "name": "Session_End_Time", "type": 1, "query": "AzureDiagnostics \r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s !in ('Batch','Execute')\r\n| where SessionId_s == '{SessionId}'\r\n| summarize \r\n Session_End_Time=max(EndTime_t) \r\n by SessionId_s\r\n| project Session_End_Time", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 259200000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 7" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics \r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s !in ('Batch','Execute')\r\n| where SubmitTime_t < datetime('{Session_Submit_Time}') and EndCompileTime_t > datetime('{Session_End_Time}') or RequestId_s == '{RequestId}'\r\n| summarize by RequestId_s\r\n| join kind=inner\r\n (\r\n AzureDiagnostics \r\n | where Category == 'ExecRequests'\r\n | where Resource == '{DatabaseName}'\r\n | where StatementType_s !in ('Batch','Execute')\r\n | summarize \r\n Session_ID=max(SessionId_s), \r\n Request_ID=max(RequestId_s), \r\n Submit_Time=min(SubmitTime_t), \r\n Start_Time=max(StartTime_t),\r\n End_Compile_Time=max(EndCompileTime_t), \r\n End_Time=max(EndTime_t), \r\n Command=max(Command_s), \r\n Last_Status=min(Status_s),\r\n Statement_Type=max(StatementType_s),\r\n Resource_class=max(ResourceClass_s) \r\n by RequestId_s\r\n ) on RequestId_s\r\n| order by End_Compile_Time\r\n| project Session_ID,Request_ID,Submit_Time,End_Compile_Time,Start_Time,End_Time,Last_Status,Statement_Type,Command\r\n\r\n", "size": 0, "title": "Query Executions that could have triggered Stats Statement based on Time of total session", "noDataMessage": "Select a query above to see individual executions", "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "150ch" } } ], "sortBy": [ { "itemKey": "Command", "sortOrder": 1 } ] }, "sortBy": [ { "itemKey": "Command", "sortOrder": 1 } ] }, "name": "query - 0 - Copy - Copy - Copy - Copy" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "Statistics" }, "name": "statistics" } ], "fallbackResourceIds": [ "azure monitor" ], "$schema": "https://github.com/Microsoft/Application-Insights-Workbooks/blob/master/schema/workbook.json" } ================================================ FILE: Monitor_Workbooks/archive/SynapsePipelines.workbook ================================================ { "version": "Notebook/1.0", "items": [ { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "d49554d4-694d-4606-89aa-510d92eb95cd", "version": "KqlParameterItem/1.0", "name": "TimeRange", "type": 4, "value": { "durationMs": 604800000 }, "typeSettings": { "selectableValues": [ { "durationMs": 300000 }, { "durationMs": 900000 }, { "durationMs": 1800000 }, { "durationMs": 3600000 }, { "durationMs": 14400000 }, { "durationMs": 43200000 }, { "durationMs": 86400000 }, { "durationMs": 172800000 }, { "durationMs": 259200000 }, { "durationMs": 604800000 }, { "durationMs": 1209600000 }, { "durationMs": 2419200000 }, { "durationMs": 2592000000 }, { "durationMs": 5184000000 }, { "durationMs": 7776000000 } ] }, "label": "Time Range" }, { "id": "d0ad178a-e2af-4157-a902-86c94e4dad29", "version": "KqlParameterItem/1.0", "name": "LogAnalyticsSubscription", "type": 6, "value": null, "typeSettings": { "additionalResourceOptions": [], "includeAll": true, "showDefault": false }, "timeContext": { "durationMs": 7776000000 }, "timeContextFromParameter": "TimeRange", "label": "Log Analytics Subsciption" }, { "id": "fe0740a1-545a-47d0-9b91-acbd7034a551", "version": "KqlParameterItem/1.0", "name": "LogAnalyticsWorkspace", "type": 5, "query": "Resources\r\n| where type == 'microsoft.operationalinsights/workspaces'\r\n| project id\r\n", "crossComponentResources": [ "{LogAnalyticsSubscription}" ], "value": null, "typeSettings": { "additionalResourceOptions": [], "showDefault": false }, "timeContext": { "durationMs": 7776000000 }, "timeContextFromParameter": "TimeRange", "queryType": 1, "resourceType": "microsoft.resourcegraph/resources", "label": "Log Analytics Workspace" }, { "id": "fd3f9b36-6e8f-4396-8478-1c9c46174057", "version": "KqlParameterItem/1.0", "name": "DataFactory", "label": "Synpase/Data Factory", "type": 5, "isGlobal": true, "query": "let synape = SynapseIntegrationPipelineRuns\r\n| extend ResourceId = _ResourceId;\r\n\r\nlet df = ADFPipelineRun;\r\n\r\nlet allPipelines = df \r\n| union synape;\r\n\r\nallPipelines\r\n| distinct ResourceId", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "value": null, "typeSettings": { "resourceTypeFilter": { "microsoft.datafactory/factories": true, "microsoft.datafactory/datafactories": true, "microsoft.synapse/workspaces": true, "Microsoft.Synapse/workspaces": true, "Microsoft.Synapse/workspaces/bigDataPools": true, "Microsoft.Synapse/workspaces/kustopools": true, "Microsoft.Synapse/workspaces/kustopools/databases": true, "Microsoft.Synapse/workspaces/scopePools": true, "Microsoft.Synapse/workspaces/sqlPools": true }, "additionalResourceOptions": [], "showDefault": false }, "timeContext": { "durationMs": 7776000000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "id": "8dd2023d-6684-44e2-b910-82a0c0fbf879", "version": "KqlParameterItem/1.0", "name": "pipeline", "label": "Pipeline", "type": 2, "isGlobal": true, "multiSelect": true, "quote": "'", "delimiter": ",", "query": "let synape = SynapseIntegrationPipelineRuns\r\n| extend ResourceId = _ResourceId;\r\n\r\nlet df = ADFPipelineRun;\r\n\r\nlet allPipelines = df \r\n| union synape;\r\n\r\nallPipelines\r\n| where ResourceId in (\"{DataFactory}\")\r\n| project pipeId= strcat(ResourceId , PipelineName) , PipelineName\r\n//| distinct pipeId, PipelineName\r\n| distinct PipelineName", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "typeSettings": { "additionalResourceOptions": [ "value::all" ], "showDefault": false }, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "defaultValue": "value::all", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.resourcegraph/resources" }, "name": "parameters - 2" }, { "type": 11, "content": { "version": "LinkItem/1.0", "style": "tabs", "links": [ { "id": "e870a3f7-acab-4aac-93b8-35b8bab51c1c", "cellValue": "selectedTab", "linkTarget": "parameter", "linkLabel": "Overview Dashboard", "subTarget": "overview", "preText": "Overview Dashboard", "style": "link" }, { "id": "a773b8fc-30b4-480a-b1b2-a73653aa1fe5", "cellValue": "selectedTab", "linkTarget": "parameter", "linkLabel": "Pipeline Details", "subTarget": "pipeline", "preText": "Pipeline Details ", "style": "link" } ] }, "name": "links - 7" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let synape = SynapseIntegrationPipelineRuns\r\n| extend ResourceId = _ResourceId;\r\n\r\nlet df = ADFPipelineRun;\r\n\r\nlet allPipelines = df \r\n| union synape;\r\n\r\nallPipelines\r\n| where ResourceId in (\"{DataFactory}\") \r\n| where PipelineName in ({pipeline}) \r\n| extend Resource = tostring(split(ResourceId, \"/\")[8])\r\n| summarize dcount(RunId) by Resource, ResourceId\r\n", "size": 1, "title": "⚙ Runs per Synapse/Datafactory", "timeContext": { "durationMs": 7776000000 }, "timeContextFromParameter": "TimeRange", "exportFieldName": "ResourceId", "exportParameterName": "DataFactory", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "piechart", "tileSettings": { "showBorder": false, "titleContent": { "columnMatch": "ResourceId", "formatter": 1 }, "leftContent": { "columnMatch": "dcount_RunId", "formatter": 12, "formatOptions": { "palette": "auto" }, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "chartSettings": { "ySettings": {} } }, "customWidth": "33", "name": "query - 2", "styleSettings": { "showBorder": true } }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let synape = SynapseIntegrationPipelineRuns\r\n| extend ResourceId = _ResourceId;\r\n\r\nlet df = ADFPipelineRun;\r\n\r\nlet allPipelines = df \r\n| union synape;\r\n\r\nlet T= allPipelines\r\n| where ResourceId in (\"{DataFactory}\")\r\n| where PipelineName in ({pipeline}) \r\n|summarize arg_max(TimeGenerated,* ) by RunId;\r\n\r\nT\r\n| summarize Succeeded=dcountif(RunId, Status startswith \"Succeeded\"),Failed=dcountif(RunId, Status startswith \"Failed\"), Cancelled = dcountif(RunId, Status startswith \"Cancelled\") by PipelineName\r\n|render barchart with (series = PipelineName)\r\n", "size": 1, "title": "🎯 Runs per pipeline grouped by status", "timeContext": { "durationMs": 7776000000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Succeeded", "formatter": 3, "formatOptions": { "palette": "green" } }, { "columnMatch": "Failed", "formatter": 3, "formatOptions": { "palette": "red" } }, { "columnMatch": "Cancelled", "formatter": 3, "formatOptions": { "palette": "orange" }, "numberFormat": { "unit": 17, "options": { "style": "decimal" } } } ] }, "tileSettings": { "showBorder": false, "titleContent": { "columnMatch": "PipelineName", "formatter": 1 }, "leftContent": { "columnMatch": "dcount_RunId", "formatter": 12, "formatOptions": { "palette": "auto" }, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "graphSettings": { "type": 0, "topContent": { "columnMatch": "PipelineName", "formatter": 1 }, "centerContent": { "columnMatch": "dcount_RunId", "formatter": 1, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "chartSettings": { "xAxis": "PipelineName", "seriesLabelSettings": [ { "seriesName": "Succeeded", "color": "green" }, { "seriesName": "Failed", "color": "red" }, { "seriesName": "Cancelled", "color": "orange" }, { "seriesName": "Total", "color": "blue" } ], "xSettings": {}, "ySettings": {} } }, "customWidth": "33", "name": "query - 4 - Copy", "styleSettings": { "showBorder": true } }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let synape = SynapseIntegrationPipelineRuns\r\n| extend ResourceId = _ResourceId;\r\n\r\nlet df = ADFPipelineRun;\r\n\r\nlet allPipelines = df \r\n| union synape;\r\n\r\nallPipelines\r\n| where ResourceId in (\"{DataFactory}\") \r\n| where PipelineName in ({pipeline}) \r\n| where Status in ('Failed', 'Succeeded')\r\n| summarize arg_max(TimeGenerated,* ) by RunId\r\n| extend endd = iff(End == todatetime('1601-01-01T00:00:00Z'),now(),End)\r\n| extend Duration = datetime_diff('Second',endd, Start) \r\n| summarize avg(Duration) by PipelineName", "size": 1, "aggregation": 3, "title": "⏲ Average duration per pipeline", "timeContext": { "durationMs": 7776000000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "barchart", "tileSettings": { "showBorder": false, "titleContent": { "columnMatch": "PipelineName", "formatter": 1 }, "leftContent": { "columnMatch": "Duration", "formatter": 12, "formatOptions": { "palette": "auto" }, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "graphSettings": { "type": 0 }, "chartSettings": { "showMetrics": false, "showLegend": true } }, "customWidth": "34", "name": "query - 5", "styleSettings": { "showBorder": true } }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let synape = SynapseIntegrationPipelineRuns\r\n| extend ResourceId = _ResourceId, Link1 = \"https://ms.web.azuresynapse.net/en-us/monitoring/pipelineruns?workspace=\" , Link2 = \"https://ms.web.azuresynapse.net/en-us/monitoring/pipelineruns/\";\r\n\r\nlet df = ADFPipelineRun\r\n|extend Link1 = \"https://ms-adf.azure.com/monitoring/pipelineruns?factory=\", Link2 = \"https://ms-adf.azure.com/en-us/monitoring/pipelineruns/\", Link3= \"?factory=\";\r\n\r\nlet allPipelines = df \r\n| union synape;\r\n\r\nlet allActivites = ADFActivityRun\r\n| union (SynapseIntegrationActivityRuns | extend ResourceId = _ResourceId) ;\r\n\r\n\r\nlet T = allPipelines\r\n| where ResourceId in (\"{DataFactory}\") \r\n| where PipelineName in ({pipeline}) \r\n| summarize arg_max(TimeGenerated,* ) by RunId\r\n| extend StatusIcon = case(Status == \"Succeeded\", '🟢', \r\n Status == \"InProgress\", '🟡', \r\n Status == \"Queued\", '🔵',\r\n Status == \"Cancelled\",'🟠', \r\n Status == \"Failed\", '🔴', \r\n '0')\r\n|order by TimeGenerated;\r\n\r\n\r\n\r\n\r\nlet T2 = T\r\n| summarize commands_details = make_list(pack('status', StatusIcon, 'TimeGenerated', TimeGenerated)) by PipelineName\r\n| mv-apply command_details = commands_details on\r\n(\r\n order by todatetime(command_details['TimeGenerated']) asc\r\n | summarize make_list(command_details['status'])\r\n)\r\n| project-away commands_details \r\n| extend ['Last runs'] = strcat_array(list_command_details_status,'');\r\n\r\n\r\n\r\n\r\nallPipelines\r\n| where ResourceId in (\"{DataFactory}\") \r\n| where PipelineName in ({pipeline}) \r\n| summarize arg_max(TimeGenerated,* ) by PipelineName\r\n| extend ParentId = ''\r\n , Id = PipelineName\r\n ,Link = strcat(Link1, ResourceId)\r\n , Resource = ResourceId\r\n , endd = iff(End == todatetime('1601-01-01T00:00:00Z'),now(),End)\r\n| extend Duration = format_timespan(endd- Start,'hh:mm:ss') ,Pipeline = strcat('🗜️ ', PipelineName) \r\n| join T2 on PipelineName\r\n|project ParentId, Id , Resource, Pipeline, Status, Start, Duration, ['Last runs'], Link,TimeGenerated\r\n\r\n|union (T\r\n| extend ParentId = PipelineName\r\n ,Id = RunId\r\n ,Link = strcat(Link2,CorrelationId,\"?factory=\",ResourceId)\r\n , endd = iff(End == todatetime('1601-01-01T00:00:00Z'),now(),End)\r\n|extend Duration = format_timespan(endd- Start,'hh:mm:ss') \r\n|project ParentId,Id, Status,Start,Duration,Link,TimeGenerated)\r\n|union (allActivites \r\n| where ResourceId in (\"{DataFactory}\") \r\n| where PipelineName in ({pipeline}) \r\n| summarize arg_max(TimeGenerated,* ) by ActivityRunId\r\n| extend endd = iff(End == todatetime('1601-01-01T00:00:00Z'),now(),End)\r\n| extend ParentId = PipelineRunId,Id = ActivityRunId,Link=\"\",Duration = format_timespan(endd- Start,'hh:mm:ss') , Resource = ActivityName\r\n| order by TimeGenerated desc \r\n| project ParentId,Id, Status,Start,Duration,Link,TimeGenerated, Resource)\r\n| union (allActivites \r\n| where ResourceId in (\"{DataFactory}\") \r\n| where PipelineName in ({pipeline}) \r\n| summarize arg_max(TimeGenerated,* ) by ActivityRunId\r\n| where Status ==\"Failed\"\r\n| extend ParentId = ActivityRunId, Id = \"*\", ['Last runs'] = ErrorMessage\r\n| project ParentId, Id, ['Last runs']);\r\n", "size": 0, "title": "📑 Last runs", "timeContext": { "durationMs": 7776000000 }, "timeContextFromParameter": "TimeRange", "exportedParameters": [ { "fieldName": "PipelineName", "parameterName": "pipeline", "parameterType": 5 } ], "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "ParentId", "formatter": 5, "formatOptions": {} }, { "columnMatch": "Id", "formatter": 5, "formatOptions": {} }, { "columnMatch": "Resource", "formatter": 13, "formatOptions": { "linkTarget": null, "showIcon": true } }, { "columnMatch": "Status", "formatter": 18, "formatOptions": { "thresholdsOptions": "icons", "thresholdsGrid": [ { "operator": "==", "thresholdValue": "Failed", "representation": "critical", "text": "{0}{1}" }, { "operator": "==", "thresholdValue": "Succeeded", "representation": "success", "text": "{0}{1}" }, { "operator": "==", "thresholdValue": "InProgress", "representation": "pending" }, { "operator": "==", "thresholdValue": "Queued", "representation": "1", "text": "{0}{1}" }, { "operator": "==", "thresholdValue": "Cancelled", "representation": "2", "text": "{0}{1}" }, { "operator": "Default", "thresholdValue": null, "representation": "more", "text": "{0}{1}" } ] } }, { "columnMatch": "Start", "formatter": 6, "formatOptions": {} }, { "columnMatch": "Link", "formatter": 7, "formatOptions": { "linkTarget": "Url", "linkLabel": "🌐 (url)" } }, { "columnMatch": "TimeGenerated", "formatter": 5, "formatOptions": {} } ], "hierarchySettings": { "idColumn": "Id", "parentColumn": "ParentId", "treeType": 0, "expanderColumn": "Pipeline" }, "sortBy": [ { "itemKey": "Last runs", "sortOrder": 1 } ] }, "sortBy": [ { "itemKey": "Last runs", "sortOrder": 1 } ] }, "name": "query - 3", "styleSettings": { "showBorder": true } }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let synape = SynapseIntegrationPipelineRuns\r\n| extend ResourceId = _ResourceId;\r\n\r\nlet df = ADFPipelineRun;\r\n\r\nlet allPipelines = df \r\n| union synape;\r\n\r\nallPipelines\r\n| where ResourceId in (\"{DataFactory}\") \r\n| where PipelineName in ({pipeline}) \r\n| where Status in ('Failed', 'Succeeded')\r\n| summarize arg_max(TimeGenerated,* ) by RunId\r\n| summarize count() by ResourceId, PipelineName, format_datetime(bin(TimeGenerated, 1d),'yyyy-MM-dd')", "size": 1, "aggregation": 3, "showAnnotations": true, "title": "🗓 Number of runs by date", "timeContext": { "durationMs": 7776000000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "barchart", "graphSettings": { "type": 0 }, "chartSettings": { "xAxis": "TimeGenerated", "group": "PipelineName", "createOtherGroup": null, "showMetrics": false, "showLegend": true, "xSettings": { "numberFormatSettings": { "unit": 0, "options": { "style": "decimal", "useGrouping": false } } } } }, "customWidth": "50", "name": "query - 5 - Copy - Copy", "styleSettings": { "showBorder": true } }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let synape = SynapseIntegrationPipelineRuns\r\n| extend ResourceId = _ResourceId;\r\n\r\nlet df = ADFPipelineRun;\r\n\r\nlet allPipelines = df \r\n| union synape;\r\n\r\nallPipelines\r\n| where ResourceId in (\"{DataFactory}\") \r\n| where PipelineName in ({pipeline}) \r\n| where Status in ('Failed', 'Succeeded')\r\n| summarize arg_max(TimeGenerated,* ) by RunId\r\n| summarize count() by ResourceId, PipelineName, format_datetime(bin(TimeGenerated, 1h),'HH:mm')\r\n|order by TimeGenerated asc", "size": 1, "aggregation": 3, "showAnnotations": true, "title": "🕓 Number of runs over time", "timeContext": { "durationMs": 7776000000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "barchart", "graphSettings": { "type": 0 }, "chartSettings": { "xAxis": "TimeGenerated", "group": "PipelineName", "createOtherGroup": null, "showMetrics": false, "showLegend": true, "xSettings": { "numberFormatSettings": { "unit": 0, "options": { "style": "decimal", "useGrouping": false } } } } }, "customWidth": "50", "name": "query - 5 - Copy - Copy - Copy", "styleSettings": { "showBorder": true } } ] }, "conditionalVisibility": { "parameterName": "selectedTab", "comparison": "isEqualTo", "value": "overview" }, "name": "group - 8", "styleSettings": { "showBorder": true } }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let synape = SynapseIntegrationPipelineRuns\r\n| extend ResourceId = _ResourceId;\r\n\r\nlet df = ADFPipelineRun;\r\n\r\nlet allPipelines = df \r\n| union synape;\r\n\r\nallPipelines\r\n| where ResourceId in (\"{DataFactory}\") \r\n| where PipelineName in ({pipeline}) \r\n| where Status in ('Failed', 'Succeeded')\r\n| summarize arg_max(TimeGenerated,* ) by RunId\r\n| extend endd = iff(End == todatetime('1601-01-01T00:00:00Z'),now(),End)\r\n| extend Duration = datetime_diff('Second',endd, Start) \r\n| summarize avg(Duration) by PipelineName, Start", "size": 1, "aggregation": 3, "title": "⏱ Duration over time ", "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "linechart", "tileSettings": { "showBorder": false, "titleContent": { "columnMatch": "PipelineName", "formatter": 1 }, "leftContent": { "columnMatch": "Duration", "formatter": 12, "formatOptions": { "palette": "auto" }, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "graphSettings": { "type": 0 }, "chartSettings": { "showMetrics": false, "showLegend": true, "ySettings": { "numberFormatSettings": { "unit": 24, "options": { "style": "decimal", "useGrouping": true } } } } }, "name": "query - 5 - Copy", "styleSettings": { "showBorder": true } }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let allActivites = ADFActivityRun\r\n| union (SynapseIntegrationActivityRuns | extend ResourceId = _ResourceId) ;\r\n\r\nlet Activites = allActivites\r\n| extend a = todynamic(Output)\r\n| summarize Rows= sum(toint(a.rowsCopied)) by CorrelationId ;\r\n//, sum(toint(a.dataWritten)), sum(toint(a.filesRead)), sum(toint(a.rowsCopied))\r\n\r\n\r\nlet synape = SynapseIntegrationPipelineRuns\r\n| extend ResourceId = _ResourceId;\r\n\r\nlet df = ADFPipelineRun;\r\n\r\nlet allPipelines = df \r\n| union synape;\r\n\r\nallPipelines\r\n| where ResourceId in (\"{DataFactory}\") \r\n| where PipelineName in ({pipeline}) \r\n| summarize arg_max(TimeGenerated,* ) by RunId\r\n| join Activites on CorrelationId\r\n| project PipelineName, TimeGenerated, Rows", "size": 1, "title": "💾 Rows copied over time", "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "areachart" }, "customWidth": "32", "name": "query - 1 - Copy - Copy - Copy", "styleSettings": { "showBorder": true } }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let allActivites = ADFActivityRun\r\n| union (SynapseIntegrationActivityRuns | extend ResourceId = _ResourceId) ;\r\n\r\nlet Activites = allActivites\r\n| extend a = todynamic(Output)\r\n| summarize Read= sum(toint(a.dataRead)),Written = sum(toint(a.dataWritten)) by CorrelationId ;\r\n//, sum(toint(a.dataWritten)), sum(toint(a.filesRead)), sum(toint(a.rowsCopied))\r\n\r\n\r\nlet synape = SynapseIntegrationPipelineRuns\r\n| extend ResourceId = _ResourceId;\r\n\r\nlet df = ADFPipelineRun;\r\n\r\nlet allPipelines = df \r\n| union synape;\r\n\r\nallPipelines\r\n| where ResourceId in (\"{DataFactory}\") \r\n| where PipelineName in ({pipeline}) \r\n| summarize arg_max(TimeGenerated,* ) by RunId\r\n| join Activites on CorrelationId\r\n| project PipelineName, TimeGenerated, Read, Written", "size": 1, "title": "💻 Data read/written over time", "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "areachart" }, "customWidth": "33", "name": "query - 1 - Copy", "styleSettings": { "showBorder": true } }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let allActivites = ADFActivityRun\r\n| union (SynapseIntegrationActivityRuns | extend ResourceId = _ResourceId) ;\r\n\r\nlet Activites = allActivites\r\n| extend a = todynamic(Output)\r\n| summarize Read= sum(toint(a.filesRead)),Written = sum(toint(a.filesWritten)) by CorrelationId ;\r\n//, sum(toint(a.dataWritten)), sum(toint(a.filesRead)), sum(toint(a.rowsCopied))\r\n\r\n\r\nlet synape = SynapseIntegrationPipelineRuns\r\n| extend ResourceId = _ResourceId;\r\n\r\nlet df = ADFPipelineRun;\r\n\r\nlet allPipelines = df \r\n| union synape;\r\n\r\nallPipelines\r\n| where ResourceId in (\"{DataFactory}\") \r\n| where PipelineName in ({pipeline}) \r\n| summarize arg_max(TimeGenerated,* ) by RunId\r\n| join Activites on CorrelationId\r\n| project PipelineName, TimeGenerated, Read, Written", "size": 1, "title": "📄 Files read / written over time", "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "areachart" }, "customWidth": "33", "name": "query - 1 - Copy - Copy", "styleSettings": { "showBorder": true } }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let allActivites = ADFActivityRun\r\n| union (SynapseIntegrationActivityRuns | extend ResourceId = _ResourceId) ;\r\n\r\nallActivites\r\n| where ResourceId in (\"{DataFactory}\") \r\n| where PipelineName in ({pipeline}) \r\n| where Status == \"Failed\"\r\n| extend a = todynamic(Output)\r\n| summarize count() by TimeGenerated; //, ErrorMessage, FailureType, ActivityName, ActivityType;\r\n", "size": 1, "title": "🛑 Errors over time", "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "categoricalbar", "tileSettings": { "showBorder": false, "titleContent": { "columnMatch": "PipelineName", "formatter": 1 }, "leftContent": { "columnMatch": "ErrorCode", "formatter": 12, "formatOptions": { "palette": "auto" }, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "graphSettings": { "type": 0, "topContent": { "columnMatch": "PipelineName", "formatter": 1 }, "centerContent": { "columnMatch": "ErrorCode", "formatter": 1, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "chartSettings": { "showMetrics": false, "seriesLabelSettings": [ { "seriesName": "count_", "color": "redBright" } ] } }, "name": "query - 1 - Copy - Copy - Copy - Copy", "styleSettings": { "showBorder": true } }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let allActivites = ADFActivityRun\r\n| union (SynapseIntegrationActivityRuns | extend ResourceId = _ResourceId) ;\r\n\r\nallActivites\r\n| where ResourceId in (\"{DataFactory}\") \r\n| where PipelineName in ({pipeline}) \r\n| where Status == \"Failed\"\r\n| extend a = todynamic(Output)\r\n| summarize count() by ActivityType; //, ErrorMessage, FailureType, ActivityName, ActivityType;\r\n", "size": 1, "title": "🛑 Errors per Activity type", "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "categoricalbar", "tileSettings": { "showBorder": false, "titleContent": { "columnMatch": "PipelineName", "formatter": 1 }, "leftContent": { "columnMatch": "ErrorCode", "formatter": 12, "formatOptions": { "palette": "auto" }, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "graphSettings": { "type": 0, "topContent": { "columnMatch": "PipelineName", "formatter": 1 }, "centerContent": { "columnMatch": "ErrorCode", "formatter": 1, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } } }, "customWidth": "33", "name": "query - 1 - Copy - Copy - Copy", "styleSettings": { "showBorder": true } }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let allActivites = ADFActivityRun\r\n| union (SynapseIntegrationActivityRuns | extend ResourceId = _ResourceId) ;\r\n\r\nallActivites\r\n| where ResourceId in (\"{DataFactory}\") \r\n| where PipelineName in ({pipeline}) \r\n| where Status == \"Failed\"\r\n| extend a = todynamic(Output)\r\n| summarize count() by FailureType; //, ErrorMessage, FailureType, ActivityName, ActivityType;\r\n", "size": 1, "title": "🛑 Errors per failure type", "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "categoricalbar", "tileSettings": { "showBorder": false, "titleContent": { "columnMatch": "PipelineName", "formatter": 1 }, "leftContent": { "columnMatch": "ErrorCode", "formatter": 12, "formatOptions": { "palette": "auto" }, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "graphSettings": { "type": 0, "topContent": { "columnMatch": "PipelineName", "formatter": 1 }, "centerContent": { "columnMatch": "ErrorCode", "formatter": 1, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } } }, "customWidth": "33", "name": "query - 1 - Copy - Copy - Copy - Copy", "styleSettings": { "showBorder": true } }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let allActivites = ADFActivityRun\r\n| union (SynapseIntegrationActivityRuns | extend ResourceId = _ResourceId) ;\r\n\r\nallActivites\r\n| where ResourceId in (\"{DataFactory}\") \r\n| where PipelineName in ({pipeline}) \r\n| where Status == \"Failed\"\r\n| extend a = todynamic(Output)\r\n| summarize count() by ActivityName; //, ErrorMessage, FailureType, ActivityName, ActivityType;\r\n", "size": 1, "title": "🛑 Errors per activity name", "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "categoricalbar", "tileSettings": { "showBorder": false, "titleContent": { "columnMatch": "PipelineName", "formatter": 1 }, "leftContent": { "columnMatch": "ErrorCode", "formatter": 12, "formatOptions": { "palette": "auto" }, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "graphSettings": { "type": 0, "topContent": { "columnMatch": "PipelineName", "formatter": 1 }, "centerContent": { "columnMatch": "ErrorCode", "formatter": 1, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } } }, "customWidth": "33", "name": "query - 1 - Copy - Copy - Copy - Copy - Copy", "styleSettings": { "showBorder": true } }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let allActivites = ADFActivityRun\r\n| union (SynapseIntegrationActivityRuns | extend ResourceId = _ResourceId) ;\r\n\r\nallActivites\r\n| where ResourceId in (\"{DataFactory}\") \r\n| where PipelineName in ({pipeline}) \r\n| where Status == \"Failed\"\r\n| extend a = todynamic(Output)\r\n| project TimeGenerated, PipelineName, ErrorCode, ErrorMessage, FailureType, ActivityName, ActivityType\r\n| order by TimeGenerated desc;", "size": 0, "title": "❗ Last failing activites", "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "rowLimit": 1000 } }, "name": "query - 7", "styleSettings": { "showBorder": true } } ] }, "conditionalVisibility": { "parameterName": "selectedTab", "comparison": "isEqualTo", "value": "pipeline" }, "name": "PipelineGroup", "styleSettings": { "showBorder": true } } ], "fallbackResourceIds": [ "Azure Monitor" ], "$schema": "https://github.com/Microsoft/Application-Insights-Workbooks/blob/master/schema/workbook.json" } ================================================ FILE: Monitor_Workbooks/archive/SynapsePipelines.workbook.bak ================================================ { "version": "Notebook/1.0", "items": [ { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "d49554d4-694d-4606-89aa-510d92eb95cd", "version": "KqlParameterItem/1.0", "name": "TimeRange", "type": 4, "value": { "durationMs": 604800000 }, "typeSettings": { "selectableValues": [ { "durationMs": 300000 }, { "durationMs": 900000 }, { "durationMs": 1800000 }, { "durationMs": 3600000 }, { "durationMs": 14400000 }, { "durationMs": 43200000 }, { "durationMs": 86400000 }, { "durationMs": 172800000 }, { "durationMs": 259200000 }, { "durationMs": 604800000 }, { "durationMs": 1209600000 }, { "durationMs": 2419200000 }, { "durationMs": 2592000000 }, { "durationMs": 5184000000 }, { "durationMs": 7776000000 } ] }, "label": "Time Range" }, { "id": "d0ad178a-e2af-4157-a902-86c94e4dad29", "version": "KqlParameterItem/1.0", "name": "LogAnalyticsSubscription", "type": 6, "value": null, "typeSettings": { "additionalResourceOptions": [], "includeAll": true, "showDefault": false }, "timeContext": { "durationMs": 7776000000 }, "timeContextFromParameter": "TimeRange", "label": "Log Analytics Subsciption" }, { "id": "fe0740a1-545a-47d0-9b91-acbd7034a551", "version": "KqlParameterItem/1.0", "name": "LogAnalyticsWorkspace", "type": 5, "query": "Resources\r\n| where type == 'microsoft.operationalinsights/workspaces'\r\n| project id\r\n", "crossComponentResources": [ "{LogAnalyticsSubscription}" ], "value": null, "typeSettings": { "additionalResourceOptions": [], "showDefault": false }, "timeContext": { "durationMs": 7776000000 }, "timeContextFromParameter": "TimeRange", "queryType": 1, "resourceType": "microsoft.resourcegraph/resources", "label": "Log Analytics Workspace" }, { "id": "fd3f9b36-6e8f-4396-8478-1c9c46174057", "version": "KqlParameterItem/1.0", "name": "DataFactory", "label": "Synpase/Data Factory", "type": 5, "isGlobal": true, "query": "let synape = SynapseIntegrationPipelineRuns\r\n| extend ResourceId = _ResourceId;\r\n\r\nlet df = ADFPipelineRun;\r\n\r\nlet allPipelines = df \r\n| union synape;\r\n\r\nallPipelines\r\n| distinct ResourceId", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "value": null, "typeSettings": { "resourceTypeFilter": { "microsoft.datafactory/factories": true, "microsoft.datafactory/datafactories": true, "microsoft.synapse/workspaces": true, "Microsoft.Synapse/workspaces": true, "Microsoft.Synapse/workspaces/bigDataPools": true, "Microsoft.Synapse/workspaces/kustopools": true, "Microsoft.Synapse/workspaces/kustopools/databases": true, "Microsoft.Synapse/workspaces/scopePools": true, "Microsoft.Synapse/workspaces/sqlPools": true }, "additionalResourceOptions": [], "showDefault": false }, "timeContext": { "durationMs": 7776000000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "id": "8dd2023d-6684-44e2-b910-82a0c0fbf879", "version": "KqlParameterItem/1.0", "name": "pipeline", "label": "Pipeline", "type": 2, "isGlobal": true, "multiSelect": true, "quote": "'", "delimiter": ",", "query": "let synape = SynapseIntegrationPipelineRuns\r\n| extend ResourceId = _ResourceId;\r\n\r\nlet df = ADFPipelineRun;\r\n\r\nlet allPipelines = df \r\n| union synape;\r\n\r\nallPipelines\r\n| where ResourceId in (\"{DataFactory}\")\r\n| project pipeId= strcat(ResourceId , PipelineName) , PipelineName\r\n//| distinct pipeId, PipelineName\r\n| distinct PipelineName", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "typeSettings": { "additionalResourceOptions": [ "value::all" ], "showDefault": false }, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "defaultValue": "value::all", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.resourcegraph/resources" }, "name": "parameters - 2" }, { "type": 11, "content": { "version": "LinkItem/1.0", "style": "tabs", "links": [ { "id": "e870a3f7-acab-4aac-93b8-35b8bab51c1c", "cellValue": "selectedTab", "linkTarget": "parameter", "linkLabel": "Overview Dashboard", "subTarget": "overview", "preText": "Overview Dashboard", "style": "link" }, { "id": "a773b8fc-30b4-480a-b1b2-a73653aa1fe5", "cellValue": "selectedTab", "linkTarget": "parameter", "linkLabel": "Pipeline Details", "subTarget": "pipeline", "preText": "Pipeline Details ", "style": "link" } ] }, "name": "links - 7" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let synape = SynapseIntegrationPipelineRuns\r\n| extend ResourceId = _ResourceId;\r\n\r\nlet df = ADFPipelineRun;\r\n\r\nlet allPipelines = df \r\n| union synape;\r\n\r\nallPipelines\r\n| where ResourceId in (\"{DataFactory}\") \r\n| where PipelineName in ({pipeline}) \r\n| extend Resource = tostring(split(ResourceId, \"/\")[8])\r\n| summarize dcount(RunId) by Resource, ResourceId\r\n", "size": 1, "title": "⚙ Runs per Synapse/Datafactory", "timeContext": { "durationMs": 7776000000 }, "timeContextFromParameter": "TimeRange", "exportFieldName": "ResourceId", "exportParameterName": "DataFactory", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "piechart", "tileSettings": { "showBorder": false, "titleContent": { "columnMatch": "ResourceId", "formatter": 1 }, "leftContent": { "columnMatch": "dcount_RunId", "formatter": 12, "formatOptions": { "palette": "auto" }, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "chartSettings": { "ySettings": {} } }, "customWidth": "33", "name": "query - 2", "styleSettings": { "showBorder": true } }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let synape = SynapseIntegrationPipelineRuns\r\n| extend ResourceId = _ResourceId;\r\n\r\nlet df = ADFPipelineRun;\r\n\r\nlet allPipelines = df \r\n| union synape;\r\n\r\nlet T= allPipelines\r\n| where ResourceId in (\"{DataFactory}\")\r\n| where PipelineName in ({pipeline}) \r\n|summarize arg_max(TimeGenerated,* ) by RunId;\r\n\r\nT\r\n| summarize Succeeded=dcountif(RunId, Status startswith \"Succeeded\"),Failed=dcountif(RunId, Status startswith \"Failed\"), Cancelled = dcountif(RunId, Status startswith \"Cancelled\") by PipelineName\r\n|render barchart with (series = PipelineName)\r\n", "size": 1, "title": "🎯 Runs per pipeline grouped by status", "timeContext": { "durationMs": 7776000000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Succeeded", "formatter": 3, "formatOptions": { "palette": "green" } }, { "columnMatch": "Failed", "formatter": 3, "formatOptions": { "palette": "red" } }, { "columnMatch": "Cancelled", "formatter": 3, "formatOptions": { "palette": "orange" }, "numberFormat": { "unit": 17, "options": { "style": "decimal" } } } ] }, "tileSettings": { "showBorder": false, "titleContent": { "columnMatch": "PipelineName", "formatter": 1 }, "leftContent": { "columnMatch": "dcount_RunId", "formatter": 12, "formatOptions": { "palette": "auto" }, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "graphSettings": { "type": 0, "topContent": { "columnMatch": "PipelineName", "formatter": 1 }, "centerContent": { "columnMatch": "dcount_RunId", "formatter": 1, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "chartSettings": { "xAxis": "PipelineName", "seriesLabelSettings": [ { "seriesName": "Succeeded", "color": "green" }, { "seriesName": "Failed", "color": "red" }, { "seriesName": "Cancelled", "color": "orange" }, { "seriesName": "Total", "color": "blue" } ], "xSettings": {}, "ySettings": {} } }, "customWidth": "33", "name": "query - 4 - Copy", "styleSettings": { "showBorder": true } }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let synape = SynapseIntegrationPipelineRuns\r\n| extend ResourceId = _ResourceId;\r\n\r\nlet df = ADFPipelineRun;\r\n\r\nlet allPipelines = df \r\n| union synape;\r\n\r\nallPipelines\r\n| where ResourceId in (\"{DataFactory}\") \r\n| where PipelineName in ({pipeline}) \r\n| where Status in ('Failed', 'Succeeded')\r\n| summarize arg_max(TimeGenerated,* ) by RunId\r\n| extend endd = iff(End == todatetime('1601-01-01T00:00:00Z'),now(),End)\r\n| extend Duration = datetime_diff('Second',endd, Start) \r\n| summarize avg(Duration) by PipelineName", "size": 1, "aggregation": 3, "title": "⏲ Average duration per pipeline", "timeContext": { "durationMs": 7776000000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "barchart", "tileSettings": { "showBorder": false, "titleContent": { "columnMatch": "PipelineName", "formatter": 1 }, "leftContent": { "columnMatch": "Duration", "formatter": 12, "formatOptions": { "palette": "auto" }, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "graphSettings": { "type": 0 }, "chartSettings": { "showMetrics": false, "showLegend": true } }, "customWidth": "34", "name": "query - 5", "styleSettings": { "showBorder": true } }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let synape = SynapseIntegrationPipelineRuns\r\n| extend ResourceId = _ResourceId, Link1 = \"https://ms.web.azuresynapse.net/en-us/monitoring/pipelineruns?workspace=\" , Link2 = \"https://ms.web.azuresynapse.net/en-us/monitoring/pipelineruns/\";\r\n\r\nlet df = ADFPipelineRun\r\n|extend Link1 = \"https://ms-adf.azure.com/monitoring/pipelineruns?factory=\", Link2 = \"https://ms-adf.azure.com/en-us/monitoring/pipelineruns/\", Link3= \"?factory=\";\r\n\r\nlet allPipelines = df \r\n| union synape;\r\n\r\nlet allActivites = ADFActivityRun\r\n| union (SynapseIntegrationActivityRuns | extend ResourceId = _ResourceId) ;\r\n\r\n\r\nlet T = allPipelines\r\n| where ResourceId in (\"{DataFactory}\") \r\n| where PipelineName in ({pipeline}) \r\n| summarize arg_max(TimeGenerated,* ) by RunId\r\n| extend StatusIcon = case(Status == \"Succeeded\", '🟢', \r\n Status == \"InProgress\", '🟡', \r\n Status == \"Queued\", '🔵',\r\n Status == \"Cancelled\",'🟠', \r\n Status == \"Failed\", '🔴', \r\n '0')\r\n|order by TimeGenerated;\r\n\r\n\r\n\r\n\r\nlet T2 = T\r\n| summarize commands_details = make_list(pack('status', StatusIcon, 'TimeGenerated', TimeGenerated)) by PipelineName\r\n| mv-apply command_details = commands_details on\r\n(\r\n order by todatetime(command_details['TimeGenerated']) asc\r\n | summarize make_list(command_details['status'])\r\n)\r\n| project-away commands_details \r\n| extend ['Last runs'] = strcat_array(list_command_details_status,'');\r\n\r\n\r\n\r\n\r\nallPipelines\r\n| where ResourceId in (\"{DataFactory}\") \r\n| where PipelineName in ({pipeline}) \r\n| summarize arg_max(TimeGenerated,* ) by PipelineName\r\n| extend ParentId = ''\r\n , Id = PipelineName\r\n ,Link = strcat(Link1, ResourceId)\r\n , Resource = ResourceId\r\n , endd = iff(End == todatetime('1601-01-01T00:00:00Z'),now(),End)\r\n| extend Duration = format_timespan(endd- Start,'hh:mm:ss') ,Pipeline = strcat('🗜️ ', PipelineName) \r\n| join T2 on PipelineName\r\n|project ParentId, Id , Resource, Pipeline, Status, Start, Duration, ['Last runs'], Link,TimeGenerated\r\n\r\n|union (T\r\n| extend ParentId = PipelineName\r\n ,Id = RunId\r\n ,Link = strcat(Link2,CorrelationId,\"?factory=\",ResourceId)\r\n , endd = iff(End == todatetime('1601-01-01T00:00:00Z'),now(),End)\r\n|extend Duration = format_timespan(endd- Start,'hh:mm:ss') \r\n|project ParentId,Id, Status,Start,Duration,Link,TimeGenerated)\r\n|union (allActivites \r\n| where ResourceId in (\"{DataFactory}\") \r\n| where PipelineName in ({pipeline}) \r\n| summarize arg_max(TimeGenerated,* ) by ActivityRunId\r\n| extend endd = iff(End == todatetime('1601-01-01T00:00:00Z'),now(),End)\r\n| extend ParentId = PipelineRunId,Id = ActivityRunId,Link=\"\",Duration = format_timespan(endd- Start,'hh:mm:ss') , Resource = ActivityName\r\n| order by TimeGenerated desc \r\n| project ParentId,Id, Status,Start,Duration,Link,TimeGenerated, Resource)\r\n| union (allActivites \r\n| where ResourceId in (\"{DataFactory}\") \r\n| where PipelineName in ({pipeline}) \r\n| summarize arg_max(TimeGenerated,* ) by ActivityRunId\r\n| where Status ==\"Failed\"\r\n| extend ParentId = ActivityRunId, Id = \"*\", ['Last runs'] = ErrorMessage\r\n| project ParentId, Id, ['Last runs']);\r\n", "size": 0, "title": "📑 Last runs", "timeContext": { "durationMs": 7776000000 }, "timeContextFromParameter": "TimeRange", "exportedParameters": [ { "fieldName": "PipelineName", "parameterName": "pipeline", "parameterType": 5 } ], "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "ParentId", "formatter": 5, "formatOptions": {} }, { "columnMatch": "Id", "formatter": 5, "formatOptions": {} }, { "columnMatch": "Resource", "formatter": 13, "formatOptions": { "linkTarget": null, "showIcon": true } }, { "columnMatch": "Status", "formatter": 18, "formatOptions": { "thresholdsOptions": "icons", "thresholdsGrid": [ { "operator": "==", "thresholdValue": "Failed", "representation": "critical", "text": "{0}{1}" }, { "operator": "==", "thresholdValue": "Succeeded", "representation": "success", "text": "{0}{1}" }, { "operator": "==", "thresholdValue": "InProgress", "representation": "pending" }, { "operator": "==", "thresholdValue": "Queued", "representation": "1", "text": "{0}{1}" }, { "operator": "==", "thresholdValue": "Cancelled", "representation": "2", "text": "{0}{1}" }, { "operator": "Default", "thresholdValue": null, "representation": "more", "text": "{0}{1}" } ] } }, { "columnMatch": "Start", "formatter": 6, "formatOptions": {} }, { "columnMatch": "Link", "formatter": 7, "formatOptions": { "linkTarget": "Url", "linkLabel": "🌐 (url)" } }, { "columnMatch": "TimeGenerated", "formatter": 5, "formatOptions": {} } ], "hierarchySettings": { "idColumn": "Id", "parentColumn": "ParentId", "treeType": 0, "expanderColumn": "Pipeline" }, "sortBy": [ { "itemKey": "Last runs", "sortOrder": 1 } ] }, "sortBy": [ { "itemKey": "Last runs", "sortOrder": 1 } ] }, "name": "query - 3", "styleSettings": { "showBorder": true } }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let synape = SynapseIntegrationPipelineRuns\r\n| extend ResourceId = _ResourceId;\r\n\r\nlet df = ADFPipelineRun;\r\n\r\nlet allPipelines = df \r\n| union synape;\r\n\r\nallPipelines\r\n| where ResourceId in (\"{DataFactory}\") \r\n| where PipelineName in ({pipeline}) \r\n| where Status in ('Failed', 'Succeeded')\r\n| summarize arg_max(TimeGenerated,* ) by RunId\r\n| summarize count() by ResourceId, PipelineName, format_datetime(bin(TimeGenerated, 1d),'yyyy-MM-dd')", "size": 1, "aggregation": 3, "showAnnotations": true, "title": "🗓 Number of runs by date", "timeContext": { "durationMs": 7776000000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "barchart", "graphSettings": { "type": 0 }, "chartSettings": { "xAxis": "TimeGenerated", "group": "PipelineName", "createOtherGroup": null, "showMetrics": false, "showLegend": true, "xSettings": { "numberFormatSettings": { "unit": 0, "options": { "style": "decimal", "useGrouping": false } } } } }, "customWidth": "50", "name": "query - 5 - Copy - Copy", "styleSettings": { "showBorder": true } }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let synape = SynapseIntegrationPipelineRuns\r\n| extend ResourceId = _ResourceId;\r\n\r\nlet df = ADFPipelineRun;\r\n\r\nlet allPipelines = df \r\n| union synape;\r\n\r\nallPipelines\r\n| where ResourceId in (\"{DataFactory}\") \r\n| where PipelineName in ({pipeline}) \r\n| where Status in ('Failed', 'Succeeded')\r\n| summarize arg_max(TimeGenerated,* ) by RunId\r\n| summarize count() by ResourceId, PipelineName, format_datetime(bin(TimeGenerated, 1h),'HH:mm')\r\n|order by TimeGenerated asc", "size": 1, "aggregation": 3, "showAnnotations": true, "title": "🕓 Number of runs over time", "timeContext": { "durationMs": 7776000000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "barchart", "graphSettings": { "type": 0 }, "chartSettings": { "xAxis": "TimeGenerated", "group": "PipelineName", "createOtherGroup": null, "showMetrics": false, "showLegend": true, "xSettings": { "numberFormatSettings": { "unit": 0, "options": { "style": "decimal", "useGrouping": false } } } } }, "customWidth": "50", "name": "query - 5 - Copy - Copy - Copy", "styleSettings": { "showBorder": true } } ] }, "conditionalVisibility": { "parameterName": "selectedTab", "comparison": "isEqualTo", "value": "overview" }, "name": "group - 8", "styleSettings": { "showBorder": true } }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let synape = SynapseIntegrationPipelineRuns\r\n| extend ResourceId = _ResourceId;\r\n\r\nlet df = ADFPipelineRun;\r\n\r\nlet allPipelines = df \r\n| union synape;\r\n\r\nallPipelines\r\n| where ResourceId in (\"{DataFactory}\") \r\n| where PipelineName in ({pipeline}) \r\n| where Status in ('Failed', 'Succeeded')\r\n| summarize arg_max(TimeGenerated,* ) by RunId\r\n| extend endd = iff(End == todatetime('1601-01-01T00:00:00Z'),now(),End)\r\n| extend Duration = datetime_diff('Second',endd, Start) \r\n| summarize avg(Duration) by PipelineName, Start", "size": 1, "aggregation": 3, "title": "⏱ Duration over time ", "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "linechart", "tileSettings": { "showBorder": false, "titleContent": { "columnMatch": "PipelineName", "formatter": 1 }, "leftContent": { "columnMatch": "Duration", "formatter": 12, "formatOptions": { "palette": "auto" }, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "graphSettings": { "type": 0 }, "chartSettings": { "showMetrics": false, "showLegend": true, "ySettings": { "numberFormatSettings": { "unit": 24, "options": { "style": "decimal", "useGrouping": true } } } } }, "name": "query - 5 - Copy", "styleSettings": { "showBorder": true } }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let allActivites = ADFActivityRun\r\n| union (SynapseIntegrationActivityRuns | extend ResourceId = _ResourceId) ;\r\n\r\nlet Activites = allActivites\r\n| extend a = todynamic(Output)\r\n| summarize Rows= sum(toint(a.rowsCopied)) by CorrelationId ;\r\n//, sum(toint(a.dataWritten)), sum(toint(a.filesRead)), sum(toint(a.rowsCopied))\r\n\r\n\r\nlet synape = SynapseIntegrationPipelineRuns\r\n| extend ResourceId = _ResourceId;\r\n\r\nlet df = ADFPipelineRun;\r\n\r\nlet allPipelines = df \r\n| union synape;\r\n\r\nallPipelines\r\n| where ResourceId in (\"{DataFactory}\") \r\n| where PipelineName in ({pipeline}) \r\n| summarize arg_max(TimeGenerated,* ) by RunId\r\n| join Activites on CorrelationId\r\n| project PipelineName, TimeGenerated, Rows", "size": 1, "title": "💾 Rows copied over time", "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "areachart" }, "customWidth": "32", "name": "query - 1 - Copy - Copy - Copy", "styleSettings": { "showBorder": true } }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let allActivites = ADFActivityRun\r\n| union (SynapseIntegrationActivityRuns | extend ResourceId = _ResourceId) ;\r\n\r\nlet Activites = allActivites\r\n| extend a = todynamic(Output)\r\n| summarize Read= sum(toint(a.dataRead)),Written = sum(toint(a.dataWritten)) by CorrelationId ;\r\n//, sum(toint(a.dataWritten)), sum(toint(a.filesRead)), sum(toint(a.rowsCopied))\r\n\r\n\r\nlet synape = SynapseIntegrationPipelineRuns\r\n| extend ResourceId = _ResourceId;\r\n\r\nlet df = ADFPipelineRun;\r\n\r\nlet allPipelines = df \r\n| union synape;\r\n\r\nallPipelines\r\n| where ResourceId in (\"{DataFactory}\") \r\n| where PipelineName in ({pipeline}) \r\n| summarize arg_max(TimeGenerated,* ) by RunId\r\n| join Activites on CorrelationId\r\n| project PipelineName, TimeGenerated, Read, Written", "size": 1, "title": "💻 Data read/written over time", "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "areachart" }, "customWidth": "33", "name": "query - 1 - Copy", "styleSettings": { "showBorder": true } }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let allActivites = ADFActivityRun\r\n| union (SynapseIntegrationActivityRuns | extend ResourceId = _ResourceId) ;\r\n\r\nlet Activites = allActivites\r\n| extend a = todynamic(Output)\r\n| summarize Read= sum(toint(a.filesRead)),Written = sum(toint(a.filesWritten)) by CorrelationId ;\r\n//, sum(toint(a.dataWritten)), sum(toint(a.filesRead)), sum(toint(a.rowsCopied))\r\n\r\n\r\nlet synape = SynapseIntegrationPipelineRuns\r\n| extend ResourceId = _ResourceId;\r\n\r\nlet df = ADFPipelineRun;\r\n\r\nlet allPipelines = df \r\n| union synape;\r\n\r\nallPipelines\r\n| where ResourceId in (\"{DataFactory}\") \r\n| where PipelineName in ({pipeline}) \r\n| summarize arg_max(TimeGenerated,* ) by RunId\r\n| join Activites on CorrelationId\r\n| project PipelineName, TimeGenerated, Read, Written", "size": 1, "title": "📄 Files read / written over time", "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "areachart" }, "customWidth": "33", "name": "query - 1 - Copy - Copy", "styleSettings": { "showBorder": true } }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let allActivites = ADFActivityRun\r\n| union (SynapseIntegrationActivityRuns | extend ResourceId = _ResourceId) ;\r\n\r\nallActivites\r\n| where ResourceId in (\"{DataFactory}\") \r\n| where PipelineName in ({pipeline}) \r\n| where Status == \"Failed\"\r\n| extend a = todynamic(Output)\r\n| summarize count() by TimeGenerated; //, ErrorMessage, FailureType, ActivityName, ActivityType;\r\n", "size": 1, "title": "🛑 Errors over time", "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "categoricalbar", "tileSettings": { "showBorder": false, "titleContent": { "columnMatch": "PipelineName", "formatter": 1 }, "leftContent": { "columnMatch": "ErrorCode", "formatter": 12, "formatOptions": { "palette": "auto" }, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "graphSettings": { "type": 0, "topContent": { "columnMatch": "PipelineName", "formatter": 1 }, "centerContent": { "columnMatch": "ErrorCode", "formatter": 1, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "chartSettings": { "showMetrics": false, "seriesLabelSettings": [ { "seriesName": "count_", "color": "redBright" } ] } }, "name": "query - 1 - Copy - Copy - Copy - Copy", "styleSettings": { "showBorder": true } }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let allActivites = ADFActivityRun\r\n| union (SynapseIntegrationActivityRuns | extend ResourceId = _ResourceId) ;\r\n\r\nallActivites\r\n| where ResourceId in (\"{DataFactory}\") \r\n| where PipelineName in ({pipeline}) \r\n| where Status == \"Failed\"\r\n| extend a = todynamic(Output)\r\n| summarize count() by ActivityType; //, ErrorMessage, FailureType, ActivityName, ActivityType;\r\n", "size": 1, "title": "🛑 Errors per Activity type", "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "categoricalbar", "tileSettings": { "showBorder": false, "titleContent": { "columnMatch": "PipelineName", "formatter": 1 }, "leftContent": { "columnMatch": "ErrorCode", "formatter": 12, "formatOptions": { "palette": "auto" }, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "graphSettings": { "type": 0, "topContent": { "columnMatch": "PipelineName", "formatter": 1 }, "centerContent": { "columnMatch": "ErrorCode", "formatter": 1, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } } }, "customWidth": "33", "name": "query - 1 - Copy - Copy - Copy", "styleSettings": { "showBorder": true } }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let allActivites = ADFActivityRun\r\n| union (SynapseIntegrationActivityRuns | extend ResourceId = _ResourceId) ;\r\n\r\nallActivites\r\n| where ResourceId in (\"{DataFactory}\") \r\n| where PipelineName in ({pipeline}) \r\n| where Status == \"Failed\"\r\n| extend a = todynamic(Output)\r\n| summarize count() by FailureType; //, ErrorMessage, FailureType, ActivityName, ActivityType;\r\n", "size": 1, "title": "🛑 Errors per failure type", "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "categoricalbar", "tileSettings": { "showBorder": false, "titleContent": { "columnMatch": "PipelineName", "formatter": 1 }, "leftContent": { "columnMatch": "ErrorCode", "formatter": 12, "formatOptions": { "palette": "auto" }, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "graphSettings": { "type": 0, "topContent": { "columnMatch": "PipelineName", "formatter": 1 }, "centerContent": { "columnMatch": "ErrorCode", "formatter": 1, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } } }, "customWidth": "33", "name": "query - 1 - Copy - Copy - Copy - Copy", "styleSettings": { "showBorder": true } }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let allActivites = ADFActivityRun\r\n| union (SynapseIntegrationActivityRuns | extend ResourceId = _ResourceId) ;\r\n\r\nallActivites\r\n| where ResourceId in (\"{DataFactory}\") \r\n| where PipelineName in ({pipeline}) \r\n| where Status == \"Failed\"\r\n| extend a = todynamic(Output)\r\n| summarize count() by ActivityName; //, ErrorMessage, FailureType, ActivityName, ActivityType;\r\n", "size": 1, "title": "🛑 Errors per activity name", "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "categoricalbar", "tileSettings": { "showBorder": false, "titleContent": { "columnMatch": "PipelineName", "formatter": 1 }, "leftContent": { "columnMatch": "ErrorCode", "formatter": 12, "formatOptions": { "palette": "auto" }, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "graphSettings": { "type": 0, "topContent": { "columnMatch": "PipelineName", "formatter": 1 }, "centerContent": { "columnMatch": "ErrorCode", "formatter": 1, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } } }, "customWidth": "33", "name": "query - 1 - Copy - Copy - Copy - Copy - Copy", "styleSettings": { "showBorder": true } }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let allActivites = ADFActivityRun\r\n| union (SynapseIntegrationActivityRuns | extend ResourceId = _ResourceId) ;\r\n\r\nallActivites\r\n| where ResourceId in (\"{DataFactory}\") \r\n| where PipelineName in ({pipeline}) \r\n| where Status == \"Failed\"\r\n| extend a = todynamic(Output)\r\n| project TimeGenerated, PipelineName, ErrorCode, ErrorMessage, FailureType, ActivityName, ActivityType\r\n| order by TimeGenerated desc;", "size": 0, "title": "❗ Last failing activites", "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "rowLimit": 1000 } }, "name": "query - 7", "styleSettings": { "showBorder": true } } ] }, "conditionalVisibility": { "parameterName": "selectedTab", "comparison": "isEqualTo", "value": "pipeline" }, "name": "PipelineGroup", "styleSettings": { "showBorder": true } } ], "fallbackResourceIds": [ "Azure Monitor" ], "$schema": "https://github.com/Microsoft/Application-Insights-Workbooks/blob/master/schema/workbook.json" } ================================================ FILE: Monitor_Workbooks/archive/SynapsePipelines_v1.1.workbook.bak ================================================ { "version": "Notebook/1.0", "items": [ { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "d49554d4-694d-4606-89aa-510d92eb95cd", "version": "KqlParameterItem/1.0", "name": "TimeRange", "type": 4, "value": { "durationMs": 604800000 }, "typeSettings": { "selectableValues": [ { "durationMs": 300000 }, { "durationMs": 900000 }, { "durationMs": 1800000 }, { "durationMs": 3600000 }, { "durationMs": 14400000 }, { "durationMs": 43200000 }, { "durationMs": 86400000 }, { "durationMs": 172800000 }, { "durationMs": 259200000 }, { "durationMs": 604800000 }, { "durationMs": 1209600000 }, { "durationMs": 2419200000 }, { "durationMs": 2592000000 }, { "durationMs": 5184000000 }, { "durationMs": 7776000000 } ] }, "label": "Time Range" }, { "id": "d0ad178a-e2af-4157-a902-86c94e4dad29", "version": "KqlParameterItem/1.0", "name": "LogAnalyticsSubscription", "type": 6, "value": null, "typeSettings": { "additionalResourceOptions": [], "includeAll": true, "showDefault": false }, "timeContext": { "durationMs": 7776000000 }, "timeContextFromParameter": "TimeRange", "label": "Log Analytics Subsciption" }, { "id": "fe0740a1-545a-47d0-9b91-acbd7034a551", "version": "KqlParameterItem/1.0", "name": "LogAnalyticsWorkspace", "type": 5, "query": "Resources\r\n| where type == 'microsoft.operationalinsights/workspaces'\r\n| project id\r\n", "crossComponentResources": [ "{LogAnalyticsSubscription}" ], "value": null, "typeSettings": { "additionalResourceOptions": [], "showDefault": false }, "timeContext": { "durationMs": 7776000000 }, "timeContextFromParameter": "TimeRange", "queryType": 1, "resourceType": "microsoft.resourcegraph/resources", "label": "Log Analytics Workspace" }, { "id": "fd3f9b36-6e8f-4396-8478-1c9c46174057", "version": "KqlParameterItem/1.0", "name": "DataFactory", "label": "Synpase/Data Factory", "type": 5, "isGlobal": true, "query": "let synape = SynapseIntegrationPipelineRuns\r\n| extend ResourceId = _ResourceId;\r\n\r\nlet df = ADFPipelineRun;\r\n\r\nlet allPipelines = df \r\n| union synape;\r\n\r\nallPipelines\r\n| distinct ResourceId", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "value": null, "typeSettings": { "resourceTypeFilter": { "microsoft.datafactory/factories": true, "microsoft.datafactory/datafactories": true, "microsoft.synapse/workspaces": true, "Microsoft.Synapse/workspaces": true, "Microsoft.Synapse/workspaces/bigDataPools": true, "Microsoft.Synapse/workspaces/kustopools": true, "Microsoft.Synapse/workspaces/kustopools/databases": true, "Microsoft.Synapse/workspaces/scopePools": true, "Microsoft.Synapse/workspaces/sqlPools": true }, "additionalResourceOptions": [], "showDefault": false }, "timeContext": { "durationMs": 7776000000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "id": "8dd2023d-6684-44e2-b910-82a0c0fbf879", "version": "KqlParameterItem/1.0", "name": "pipeline", "label": "Pipeline", "type": 2, "isGlobal": true, "multiSelect": true, "quote": "'", "delimiter": ",", "query": "let synape = SynapseIntegrationPipelineRuns\r\n| extend ResourceId = _ResourceId;\r\n\r\nlet df = ADFPipelineRun;\r\n\r\nlet allPipelines = df \r\n| union synape;\r\n\r\nallPipelines\r\n| where ResourceId in (\"{DataFactory}\")\r\n| project pipeId= strcat(ResourceId , PipelineName) , PipelineName\r\n//| distinct pipeId, PipelineName\r\n| distinct PipelineName", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "typeSettings": { "additionalResourceOptions": [ "value::all" ], "showDefault": false }, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "defaultValue": "value::all", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.resourcegraph/resources" }, "name": "parameters - 2" }, { "type": 11, "content": { "version": "LinkItem/1.0", "style": "tabs", "links": [ { "id": "e870a3f7-acab-4aac-93b8-35b8bab51c1c", "cellValue": "selectedTab", "linkTarget": "parameter", "linkLabel": "Overview Dashboard", "subTarget": "overview", "preText": "Overview Dashboard", "style": "link" }, { "id": "a773b8fc-30b4-480a-b1b2-a73653aa1fe5", "cellValue": "selectedTab", "linkTarget": "parameter", "linkLabel": "Pipeline Details", "subTarget": "pipeline", "preText": "Pipeline Details ", "style": "link" } ] }, "name": "links - 7" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let synape = SynapseIntegrationPipelineRuns\r\n| extend ResourceId = _ResourceId;\r\n\r\nlet df = ADFPipelineRun;\r\n\r\nlet allPipelines = df \r\n| union synape;\r\n\r\nallPipelines\r\n| where ResourceId in (\"{DataFactory}\") \r\n| where PipelineName in ({pipeline}) \r\n| extend Resource = tostring(split(ResourceId, \"/\")[8])\r\n| summarize dcount(RunId) by Resource, ResourceId\r\n", "size": 1, "title": "⚙ Runs per Synapse/Datafactory", "timeContext": { "durationMs": 7776000000 }, "timeContextFromParameter": "TimeRange", "exportFieldName": "ResourceId", "exportParameterName": "DataFactory", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "piechart", "tileSettings": { "showBorder": false, "titleContent": { "columnMatch": "ResourceId", "formatter": 1 }, "leftContent": { "columnMatch": "dcount_RunId", "formatter": 12, "formatOptions": { "palette": "auto" }, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "chartSettings": { "ySettings": {} } }, "customWidth": "33", "name": "query - 2", "styleSettings": { "showBorder": true } }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let synape = SynapseIntegrationPipelineRuns\r\n| extend ResourceId = _ResourceId;\r\n\r\nlet df = ADFPipelineRun;\r\n\r\nlet allPipelines = df \r\n| union synape;\r\n\r\nlet T= allPipelines\r\n| where ResourceId in (\"{DataFactory}\")\r\n| where PipelineName in ({pipeline}) \r\n|summarize arg_max(TimeGenerated,* ) by RunId;\r\n\r\nT\r\n| summarize Succeeded=dcountif(RunId, Status startswith \"Succeeded\"),Failed=dcountif(RunId, Status startswith \"Failed\"), Cancelled = dcountif(RunId, Status startswith \"Cancelled\") by PipelineName\r\n|render barchart with (series = PipelineName)\r\n", "size": 1, "title": "🎯 Runs per pipeline grouped by status", "timeContext": { "durationMs": 7776000000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Succeeded", "formatter": 3, "formatOptions": { "palette": "green" } }, { "columnMatch": "Failed", "formatter": 3, "formatOptions": { "palette": "red" } }, { "columnMatch": "Cancelled", "formatter": 3, "formatOptions": { "palette": "orange" }, "numberFormat": { "unit": 17, "options": { "style": "decimal" } } } ] }, "tileSettings": { "showBorder": false, "titleContent": { "columnMatch": "PipelineName", "formatter": 1 }, "leftContent": { "columnMatch": "dcount_RunId", "formatter": 12, "formatOptions": { "palette": "auto" }, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "graphSettings": { "type": 0, "topContent": { "columnMatch": "PipelineName", "formatter": 1 }, "centerContent": { "columnMatch": "dcount_RunId", "formatter": 1, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "chartSettings": { "xAxis": "PipelineName", "seriesLabelSettings": [ { "seriesName": "Succeeded", "color": "green" }, { "seriesName": "Failed", "color": "red" }, { "seriesName": "Cancelled", "color": "orange" }, { "seriesName": "Total", "color": "blue" } ], "xSettings": {}, "ySettings": {} } }, "customWidth": "33", "name": "query - 4 - Copy", "styleSettings": { "showBorder": true } }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let synape = SynapseIntegrationPipelineRuns\r\n| extend ResourceId = _ResourceId;\r\n\r\nlet df = ADFPipelineRun;\r\n\r\nlet allPipelines = df \r\n| union synape;\r\n\r\nallPipelines\r\n| where ResourceId in (\"{DataFactory}\") \r\n| where PipelineName in ({pipeline}) \r\n| where Status in ('Failed', 'Succeeded')\r\n| summarize arg_max(TimeGenerated,* ) by RunId\r\n| extend endd = iff(End == todatetime('1601-01-01T00:00:00Z'),now(),End)\r\n| extend Duration = datetime_diff('Second',endd, Start) \r\n| summarize avg(Duration) by PipelineName", "size": 1, "aggregation": 3, "title": "⏲ Average duration per pipeline", "timeContext": { "durationMs": 7776000000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "barchart", "tileSettings": { "showBorder": false, "titleContent": { "columnMatch": "PipelineName", "formatter": 1 }, "leftContent": { "columnMatch": "Duration", "formatter": 12, "formatOptions": { "palette": "auto" }, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "graphSettings": { "type": 0 }, "chartSettings": { "showMetrics": false, "showLegend": true } }, "customWidth": "34", "name": "query - 5", "styleSettings": { "showBorder": true } }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let synape = SynapseIntegrationPipelineRuns\r\n| extend ResourceId = _ResourceId, Link1 = \"https://web.azuresynapse.net/en-us/monitoring/pipelineruns?workspace=\" , Link2 = \"https://web.azuresynapse.net/en-us/monitoring/pipelineruns/\";\r\n\r\nlet df = ADFPipelineRun\r\n|extend Link1 = \"https://ms-adf.azure.com/monitoring/pipelineruns?factory=\", Link2 = \"https://ms-adf.azure.com/en-us/monitoring/pipelineruns/\", Link3= \"?factory=\";\r\n\r\nlet allPipelines = df \r\n| union synape;\r\n\r\nlet allActivites = ADFActivityRun\r\n| union (SynapseIntegrationActivityRuns | extend ResourceId = _ResourceId) ;\r\n\r\n\r\nlet T = allPipelines\r\n| where ResourceId in (\"{DataFactory}\") \r\n| where PipelineName in ({pipeline}) \r\n| summarize arg_max(TimeGenerated,* ) by RunId\r\n| extend StatusIcon = case(Status == \"Succeeded\", '🟢', \r\n Status == \"InProgress\", '🟡', \r\n Status == \"Queued\", '🔵',\r\n Status == \"Cancelled\",'🟠', \r\n Status == \"Failed\", '🔴', \r\n '0')\r\n|order by TimeGenerated;\r\n\r\n\r\n\r\n\r\nlet T2 = T\r\n| summarize commands_details = make_list(pack('status', StatusIcon, 'TimeGenerated', TimeGenerated)) by PipelineName\r\n| mv-apply command_details = commands_details on\r\n(\r\n order by todatetime(command_details['TimeGenerated']) asc\r\n | summarize make_list(command_details['status'])\r\n)\r\n| project-away commands_details \r\n| extend ['Last runs'] = strcat_array(list_command_details_status,'');\r\n\r\n\r\n\r\n\r\nallPipelines\r\n| where ResourceId in (\"{DataFactory}\") \r\n| where PipelineName in ({pipeline}) \r\n| summarize arg_max(TimeGenerated,* ) by PipelineName\r\n| extend ParentId = ''\r\n , Id = PipelineName\r\n ,Link = strcat(Link1, ResourceId)\r\n , Resource = ResourceId\r\n , endd = iff(End == todatetime('1601-01-01T00:00:00Z'),now(),End)\r\n| extend Duration = format_timespan(endd- Start,'hh:mm:ss') ,Pipeline = strcat('🗜️ ', PipelineName) \r\n| join T2 on PipelineName\r\n|project ParentId, Id , Resource, Pipeline, Status, Start, Duration, ['Last runs'], Link,TimeGenerated\r\n\r\n|union (T\r\n| extend ParentId = PipelineName\r\n ,Id = RunId\r\n ,Link = strcat(Link2,CorrelationId,\"?factory=\",ResourceId)\r\n , endd = iff(End == todatetime('1601-01-01T00:00:00Z'),now(),End)\r\n|extend Duration = format_timespan(endd- Start,'hh:mm:ss') \r\n|project ParentId,Id, Status,Start,Duration,Link,TimeGenerated)\r\n|union (allActivites \r\n| where ResourceId in (\"{DataFactory}\") \r\n| where PipelineName in ({pipeline}) \r\n| summarize arg_max(TimeGenerated,* ) by ActivityRunId\r\n| extend endd = iff(End == todatetime('1601-01-01T00:00:00Z'),now(),End)\r\n| extend ParentId = PipelineRunId,Id = ActivityRunId,Link=\"\",Duration = format_timespan(endd- Start,'hh:mm:ss') , Resource = ActivityName\r\n| order by TimeGenerated desc \r\n| project ParentId,Id, Status,Start,Duration,Link,TimeGenerated, Resource)\r\n| union (allActivites \r\n| where ResourceId in (\"{DataFactory}\") \r\n| where PipelineName in ({pipeline}) \r\n| summarize arg_max(TimeGenerated,* ) by ActivityRunId\r\n| where Status ==\"Failed\"\r\n| extend ParentId = ActivityRunId, Id = \"*\", ['Last runs'] = ErrorMessage\r\n| project ParentId, Id, ['Last runs']);\r\n", "size": 0, "title": "📑 Last runs", "timeContext": { "durationMs": 7776000000 }, "timeContextFromParameter": "TimeRange", "exportedParameters": [ { "fieldName": "PipelineName", "parameterName": "pipeline", "parameterType": 5 } ], "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "ParentId", "formatter": 5, "formatOptions": {} }, { "columnMatch": "Id", "formatter": 5, "formatOptions": {} }, { "columnMatch": "Resource", "formatter": 13, "formatOptions": { "linkTarget": null, "showIcon": true } }, { "columnMatch": "Status", "formatter": 18, "formatOptions": { "thresholdsOptions": "icons", "thresholdsGrid": [ { "operator": "==", "thresholdValue": "Failed", "representation": "critical", "text": "{0}{1}" }, { "operator": "==", "thresholdValue": "Succeeded", "representation": "success", "text": "{0}{1}" }, { "operator": "==", "thresholdValue": "InProgress", "representation": "pending" }, { "operator": "==", "thresholdValue": "Queued", "representation": "1", "text": "{0}{1}" }, { "operator": "==", "thresholdValue": "Cancelled", "representation": "2", "text": "{0}{1}" }, { "operator": "Default", "thresholdValue": null, "representation": "more", "text": "{0}{1}" } ] } }, { "columnMatch": "Start", "formatter": 6, "formatOptions": {} }, { "columnMatch": "Link", "formatter": 7, "formatOptions": { "linkTarget": "Url", "linkLabel": "🌐 (url)" } }, { "columnMatch": "TimeGenerated", "formatter": 5, "formatOptions": {} } ], "hierarchySettings": { "idColumn": "Id", "parentColumn": "ParentId", "treeType": 0, "expanderColumn": "Pipeline" }, "sortBy": [ { "itemKey": "Last runs", "sortOrder": 1 } ] }, "sortBy": [ { "itemKey": "Last runs", "sortOrder": 1 } ] }, "name": "query - 3", "styleSettings": { "showBorder": true } }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let synape = SynapseIntegrationPipelineRuns\r\n| extend ResourceId = _ResourceId;\r\n\r\nlet df = ADFPipelineRun;\r\n\r\nlet allPipelines = df \r\n| union synape;\r\n\r\nallPipelines\r\n| where ResourceId in (\"{DataFactory}\") \r\n| where PipelineName in ({pipeline}) \r\n| where Status in ('Failed', 'Succeeded')\r\n| summarize arg_max(TimeGenerated,* ) by RunId\r\n| summarize count() by ResourceId, PipelineName, format_datetime(bin(TimeGenerated, 1d),'yyyy-MM-dd')", "size": 1, "aggregation": 3, "showAnnotations": true, "title": "🗓 Number of runs by date", "timeContext": { "durationMs": 7776000000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "barchart", "graphSettings": { "type": 0 }, "chartSettings": { "xAxis": "TimeGenerated", "group": "PipelineName", "createOtherGroup": null, "showMetrics": false, "showLegend": true, "xSettings": { "numberFormatSettings": { "unit": 0, "options": { "style": "decimal", "useGrouping": false } } } } }, "customWidth": "50", "name": "query - 5 - Copy - Copy", "styleSettings": { "showBorder": true } }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let synape = SynapseIntegrationPipelineRuns\r\n| extend ResourceId = _ResourceId;\r\n\r\nlet df = ADFPipelineRun;\r\n\r\nlet allPipelines = df \r\n| union synape;\r\n\r\nallPipelines\r\n| where ResourceId in (\"{DataFactory}\") \r\n| where PipelineName in ({pipeline}) \r\n| where Status in ('Failed', 'Succeeded')\r\n| summarize arg_max(TimeGenerated,* ) by RunId\r\n| summarize count() by ResourceId, PipelineName, format_datetime(bin(TimeGenerated, 1h),'HH:mm')\r\n|order by TimeGenerated asc", "size": 1, "aggregation": 3, "showAnnotations": true, "title": "🕓 Number of runs over time", "timeContext": { "durationMs": 7776000000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "barchart", "graphSettings": { "type": 0 }, "chartSettings": { "xAxis": "TimeGenerated", "group": "PipelineName", "createOtherGroup": null, "showMetrics": false, "showLegend": true, "xSettings": { "numberFormatSettings": { "unit": 0, "options": { "style": "decimal", "useGrouping": false } } } } }, "customWidth": "50", "name": "query - 5 - Copy - Copy - Copy", "styleSettings": { "showBorder": true } } ] }, "conditionalVisibility": { "parameterName": "selectedTab", "comparison": "isEqualTo", "value": "overview" }, "name": "group - 8", "styleSettings": { "showBorder": true } }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let synape = SynapseIntegrationPipelineRuns\r\n| extend ResourceId = _ResourceId;\r\n\r\nlet df = ADFPipelineRun;\r\n\r\nlet allPipelines = df \r\n| union synape;\r\n\r\nallPipelines\r\n| where ResourceId in (\"{DataFactory}\") \r\n| where PipelineName in ({pipeline}) \r\n| where Status in ('Failed', 'Succeeded')\r\n| summarize arg_max(TimeGenerated,* ) by RunId\r\n| extend endd = iff(End == todatetime('1601-01-01T00:00:00Z'),now(),End)\r\n| extend Duration = datetime_diff('Second',endd, Start) \r\n| summarize avg(Duration) by PipelineName, Start", "size": 1, "aggregation": 3, "title": "⏱ Duration over time ", "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "linechart", "tileSettings": { "showBorder": false, "titleContent": { "columnMatch": "PipelineName", "formatter": 1 }, "leftContent": { "columnMatch": "Duration", "formatter": 12, "formatOptions": { "palette": "auto" }, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "graphSettings": { "type": 0 }, "chartSettings": { "showMetrics": false, "showLegend": true, "ySettings": { "numberFormatSettings": { "unit": 24, "options": { "style": "decimal", "useGrouping": true } } } } }, "name": "query - 5 - Copy", "styleSettings": { "showBorder": true } }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let allActivites = ADFActivityRun\r\n| union (SynapseIntegrationActivityRuns | extend ResourceId = _ResourceId) ;\r\n\r\nlet Activites = allActivites\r\n| extend a = todynamic(Output)\r\n| summarize Rows= sum(toint(a.rowsCopied)) by CorrelationId ;\r\n//, sum(toint(a.dataWritten)), sum(toint(a.filesRead)), sum(toint(a.rowsCopied))\r\n\r\n\r\nlet synape = SynapseIntegrationPipelineRuns\r\n| extend ResourceId = _ResourceId;\r\n\r\nlet df = ADFPipelineRun;\r\n\r\nlet allPipelines = df \r\n| union synape;\r\n\r\nallPipelines\r\n| where ResourceId in (\"{DataFactory}\") \r\n| where PipelineName in ({pipeline}) \r\n| summarize arg_max(TimeGenerated,* ) by RunId\r\n| join Activites on CorrelationId\r\n| project PipelineName, TimeGenerated, Rows", "size": 1, "title": "💾 Rows copied over time", "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "areachart" }, "customWidth": "32", "name": "query - 1 - Copy - Copy - Copy", "styleSettings": { "showBorder": true } }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let allActivites = ADFActivityRun\r\n| union (SynapseIntegrationActivityRuns | extend ResourceId = _ResourceId) ;\r\n\r\nlet Activites = allActivites\r\n| extend a = todynamic(Output)\r\n| summarize Read= sum(toint(a.dataRead)),Written = sum(toint(a.dataWritten)) by CorrelationId ;\r\n//, sum(toint(a.dataWritten)), sum(toint(a.filesRead)), sum(toint(a.rowsCopied))\r\n\r\n\r\nlet synape = SynapseIntegrationPipelineRuns\r\n| extend ResourceId = _ResourceId;\r\n\r\nlet df = ADFPipelineRun;\r\n\r\nlet allPipelines = df \r\n| union synape;\r\n\r\nallPipelines\r\n| where ResourceId in (\"{DataFactory}\") \r\n| where PipelineName in ({pipeline}) \r\n| summarize arg_max(TimeGenerated,* ) by RunId\r\n| join Activites on CorrelationId\r\n| project PipelineName, TimeGenerated, Read, Written", "size": 1, "title": "💻 Data read/written over time", "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "areachart" }, "customWidth": "33", "name": "query - 1 - Copy", "styleSettings": { "showBorder": true } }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let allActivites = ADFActivityRun\r\n| union (SynapseIntegrationActivityRuns | extend ResourceId = _ResourceId) ;\r\n\r\nlet Activites = allActivites\r\n| extend a = todynamic(Output)\r\n| summarize Read= sum(toint(a.filesRead)),Written = sum(toint(a.filesWritten)) by CorrelationId ;\r\n//, sum(toint(a.dataWritten)), sum(toint(a.filesRead)), sum(toint(a.rowsCopied))\r\n\r\n\r\nlet synape = SynapseIntegrationPipelineRuns\r\n| extend ResourceId = _ResourceId;\r\n\r\nlet df = ADFPipelineRun;\r\n\r\nlet allPipelines = df \r\n| union synape;\r\n\r\nallPipelines\r\n| where ResourceId in (\"{DataFactory}\") \r\n| where PipelineName in ({pipeline}) \r\n| summarize arg_max(TimeGenerated,* ) by RunId\r\n| join Activites on CorrelationId\r\n| project PipelineName, TimeGenerated, Read, Written", "size": 1, "title": "📄 Files read / written over time", "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "areachart" }, "customWidth": "33", "name": "query - 1 - Copy - Copy", "styleSettings": { "showBorder": true } }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let allActivites = ADFActivityRun\r\n| union (SynapseIntegrationActivityRuns | extend ResourceId = _ResourceId) ;\r\n\r\nallActivites\r\n| where ResourceId in (\"{DataFactory}\") \r\n| where PipelineName in ({pipeline}) \r\n| where Status == \"Failed\"\r\n| extend a = todynamic(Output)\r\n| summarize count() by TimeGenerated; //, ErrorMessage, FailureType, ActivityName, ActivityType;\r\n", "size": 1, "title": "🛑 Errors over time", "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "categoricalbar", "tileSettings": { "showBorder": false, "titleContent": { "columnMatch": "PipelineName", "formatter": 1 }, "leftContent": { "columnMatch": "ErrorCode", "formatter": 12, "formatOptions": { "palette": "auto" }, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "graphSettings": { "type": 0, "topContent": { "columnMatch": "PipelineName", "formatter": 1 }, "centerContent": { "columnMatch": "ErrorCode", "formatter": 1, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "chartSettings": { "showMetrics": false, "seriesLabelSettings": [ { "seriesName": "count_", "color": "redBright" } ] } }, "name": "query - 1 - Copy - Copy - Copy - Copy", "styleSettings": { "showBorder": true } }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let allActivites = ADFActivityRun\r\n| union (SynapseIntegrationActivityRuns | extend ResourceId = _ResourceId) ;\r\n\r\nallActivites\r\n| where ResourceId in (\"{DataFactory}\") \r\n| where PipelineName in ({pipeline}) \r\n| where Status == \"Failed\"\r\n| extend a = todynamic(Output)\r\n| summarize count() by ActivityType; //, ErrorMessage, FailureType, ActivityName, ActivityType;\r\n", "size": 1, "title": "🛑 Errors per Activity type", "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "categoricalbar", "tileSettings": { "showBorder": false, "titleContent": { "columnMatch": "PipelineName", "formatter": 1 }, "leftContent": { "columnMatch": "ErrorCode", "formatter": 12, "formatOptions": { "palette": "auto" }, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "graphSettings": { "type": 0, "topContent": { "columnMatch": "PipelineName", "formatter": 1 }, "centerContent": { "columnMatch": "ErrorCode", "formatter": 1, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } } }, "customWidth": "33", "name": "query - 1 - Copy - Copy - Copy", "styleSettings": { "showBorder": true } }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let allActivites = ADFActivityRun\r\n| union (SynapseIntegrationActivityRuns | extend ResourceId = _ResourceId) ;\r\n\r\nallActivites\r\n| where ResourceId in (\"{DataFactory}\") \r\n| where PipelineName in ({pipeline}) \r\n| where Status == \"Failed\"\r\n| extend a = todynamic(Output)\r\n| summarize count() by FailureType; //, ErrorMessage, FailureType, ActivityName, ActivityType;\r\n", "size": 1, "title": "🛑 Errors per failure type", "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "categoricalbar", "tileSettings": { "showBorder": false, "titleContent": { "columnMatch": "PipelineName", "formatter": 1 }, "leftContent": { "columnMatch": "ErrorCode", "formatter": 12, "formatOptions": { "palette": "auto" }, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "graphSettings": { "type": 0, "topContent": { "columnMatch": "PipelineName", "formatter": 1 }, "centerContent": { "columnMatch": "ErrorCode", "formatter": 1, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } } }, "customWidth": "33", "name": "query - 1 - Copy - Copy - Copy - Copy", "styleSettings": { "showBorder": true } }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let allActivites = ADFActivityRun\r\n| union (SynapseIntegrationActivityRuns | extend ResourceId = _ResourceId) ;\r\n\r\nallActivites\r\n| where ResourceId in (\"{DataFactory}\") \r\n| where PipelineName in ({pipeline}) \r\n| where Status == \"Failed\"\r\n| extend a = todynamic(Output)\r\n| summarize count() by ActivityName; //, ErrorMessage, FailureType, ActivityName, ActivityType;\r\n", "size": 1, "title": "🛑 Errors per activity name", "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "categoricalbar", "tileSettings": { "showBorder": false, "titleContent": { "columnMatch": "PipelineName", "formatter": 1 }, "leftContent": { "columnMatch": "ErrorCode", "formatter": 12, "formatOptions": { "palette": "auto" }, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "graphSettings": { "type": 0, "topContent": { "columnMatch": "PipelineName", "formatter": 1 }, "centerContent": { "columnMatch": "ErrorCode", "formatter": 1, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } } }, "customWidth": "33", "name": "query - 1 - Copy - Copy - Copy - Copy - Copy", "styleSettings": { "showBorder": true } }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let allActivites = ADFActivityRun\r\n| union (SynapseIntegrationActivityRuns | extend ResourceId = _ResourceId) ;\r\n\r\nallActivites\r\n| where ResourceId in (\"{DataFactory}\") \r\n| where PipelineName in ({pipeline}) \r\n| where Status == \"Failed\"\r\n| extend a = todynamic(Output)\r\n| project TimeGenerated, PipelineName, ErrorCode, ErrorMessage, FailureType, ActivityName, ActivityType\r\n| order by TimeGenerated desc;", "size": 0, "title": "❗ Last failing activites", "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "rowLimit": 1000 } }, "name": "query - 7", "styleSettings": { "showBorder": true } } ] }, "conditionalVisibility": { "parameterName": "selectedTab", "comparison": "isEqualTo", "value": "pipeline" }, "name": "PipelineGroup", "styleSettings": { "showBorder": true } } ], "fallbackResourceIds": [ "Azure Monitor" ], "$schema": "https://github.com/Microsoft/Application-Insights-Workbooks/blob/master/schema/workbook.json" } ================================================ FILE: Monitor_Workbooks/archive/SynapseServerlessWorkbook.workbook ================================================ { "version": "Notebook/1.0", "items": [ { "type": 9, "content": { "version": "KqlParameterItem/1.0", "crossComponentResources": [ "value::all" ], "parameters": [ { "id": "c4475a86-95ea-46b8-a5c0-3ee1c3f528bc", "version": "KqlParameterItem/1.0", "name": "TimeRange", "type": 4, "value": { "durationMs": 86400000 }, "typeSettings": { "selectableValues": [ { "durationMs": 300000 }, { "durationMs": 900000 }, { "durationMs": 1800000 }, { "durationMs": 3600000 }, { "durationMs": 14400000 }, { "durationMs": 43200000 }, { "durationMs": 86400000 }, { "durationMs": 172800000 }, { "durationMs": 259200000 }, { "durationMs": 604800000 }, { "durationMs": 1209600000 }, { "durationMs": 2419200000 }, { "durationMs": 2592000000 }, { "durationMs": 5184000000 }, { "durationMs": 7776000000 } ] }, "timeContext": { "durationMs": 86400000 } }, { "id": "94b22c78-91c8-47e6-8833-70d458e199c3", "version": "KqlParameterItem/1.0", "name": "Subscriptions", "type": 6, "isRequired": true, "multiSelect": true, "quote": "'", "delimiter": ",", "value": [ "value::all" ], "typeSettings": { "additionalResourceOptions": [ "value::1", "value::all" ], "includeAll": false, "showDefault": false }, "defaultValue": "value::all" }, { "id": "3dbc1029-1a17-4a4d-a133-2d47c1e7844e", "version": "KqlParameterItem/1.0", "name": "Synapse", "type": 5, "multiSelect": true, "quote": "'", "delimiter": ",", "query": "Resources\r\n| where type == 'microsoft.synapse/workspaces'\r\n| project id\r\n", "crossComponentResources": [ "{Subscriptions}" ], "value": [ "value::all" ], "typeSettings": { "additionalResourceOptions": [ "value::1", "value::all" ], "showDefault": false }, "timeContext": { "durationMs": 86400000 }, "defaultValue": "value::all", "queryType": 1, "resourceType": "microsoft.resourcegraph/resources" }, { "id": "4d1459db-354e-4019-8e86-015d946ce892", "version": "KqlParameterItem/1.0", "name": "LogAnalyticsWorkspace", "type": 5, "multiSelect": true, "quote": "'", "delimiter": ",", "query": "Resources\r\n| where type == 'microsoft.operationalinsights/workspaces'\r\n| project id\r\n", "crossComponentResources": [ "value::all" ], "value": [ "value::all" ], "typeSettings": { "additionalResourceOptions": [ "value::1", "value::all" ], "showDefault": false }, "defaultValue": "value::all", "queryType": 1, "resourceType": "microsoft.resourcegraph/resources" } ], "style": "pills", "queryType": 1, "resourceType": "microsoft.resourcegraph/resources" }, "name": "parameters - 1" }, { "type": 1, "content": { "json": "All costs listed in this workbook are approximate based on $5/TB. The cost listed here has not yet been extensively validated.", "style": "warning" }, "name": "text - 4" }, { "type": 11, "content": { "version": "LinkItem/1.0", "style": "tabs", "links": [ { "id": "4ee15681-1a46-4207-ac59-efab22cd6d9b", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Summary", "subTarget": "Summary", "style": "link" }, { "id": "82d489b0-87d6-4875-a5de-c7eb2d1c8c4f", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Data Processed", "subTarget": "DataProcessed", "style": "link" } ] }, "name": "links - 4" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 10, "content": { "chartId": "workbook9cfd0268-d682-40bb-870c-61e05013f973", "version": "MetricsItem/2.0", "size": 4, "chartType": -1, "resourceType": "microsoft.synapse/workspaces", "metricScope": 0, "resourceParameter": "Synapse", "resourceIds": [ "{Synapse}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 86400000 }, "metrics": [ { "namespace": "microsoft.synapse/workspaces", "metric": "microsoft.synapse/workspaces-Builtin SQL Pool-BuiltinSqlPoolLoginAttempts", "aggregation": 1 } ], "title": "Login Attempts", "gridFormatType": 1, "tileSettings": { "showBorder": false, "titleContent": { "columnMatch": "Name", "formatter": 13 }, "leftContent": { "columnMatch": "Value", "formatter": 12, "formatOptions": { "palette": "auto" }, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "timeBrushParameterName": "TimeRange", "gridSettings": { "rowLimit": 10000 } }, "customWidth": "33", "name": "LoginAttemptsChart - Copy" }, { "type": 10, "content": { "chartId": "workbookdc90b0c5-4f40-4242-89b8-87eac7b9acaf", "version": "MetricsItem/2.0", "size": 4, "chartType": -1, "resourceType": "microsoft.synapse/workspaces", "metricScope": 0, "resourceParameter": "Synapse", "resourceIds": [ "{Synapse}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 86400000 }, "metrics": [ { "namespace": "microsoft.synapse/workspaces", "metric": "microsoft.synapse/workspaces-Builtin SQL Pool-BuiltinSqlPoolRequestsEnded", "aggregation": 1, "columnName": "Requests Completed" } ], "title": "Completed Requests", "gridFormatType": 1, "tileSettings": { "showBorder": false, "titleContent": { "columnMatch": "Name", "formatter": 13 }, "leftContent": { "columnMatch": "Value", "formatter": 12, "formatOptions": { "palette": "auto" }, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "33", "name": "CompletedRequestCountTile" }, { "type": 10, "content": { "chartId": "workbook1f0054e6-9715-47bb-a7fc-e92812c07403", "version": "MetricsItem/2.0", "size": 4, "chartType": -1, "resourceType": "microsoft.synapse/workspaces", "metricScope": 0, "resourceParameter": "Synapse", "resourceIds": [ "{Synapse}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 86400000 }, "metrics": [ { "namespace": "microsoft.synapse/workspaces", "metric": "microsoft.synapse/workspaces-Builtin SQL Pool-BuiltinSqlPoolDataProcessedBytes", "aggregation": 1 } ], "title": "Data Processed", "gridFormatType": 1, "tileSettings": { "showBorder": false, "titleContent": { "columnMatch": "Name", "formatter": 13 }, "leftContent": { "columnMatch": "Value", "formatter": 12, "formatOptions": { "palette": "auto" }, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "33", "name": "DataProcessed - Copy" }, { "type": 10, "content": { "chartId": "workbookdc90b0c5-4f40-4242-89b8-87eac7b9acaf", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.synapse/workspaces", "metricScope": 0, "resourceParameter": "Synapse", "resourceIds": [ "{Synapse}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 86400000 }, "metrics": [ { "namespace": "microsoft.synapse/workspaces", "metric": "microsoft.synapse/workspaces-Builtin SQL Pool-BuiltinSqlPoolRequestsEnded", "aggregation": 1, "splitBy": null, "columnName": "Requests Completed" } ], "title": "Completed Requests", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "name": "CompletedRequestCount" }, { "type": 10, "content": { "chartId": "workbook1f0054e6-9715-47bb-a7fc-e92812c07403", "version": "MetricsItem/2.0", "size": 0, "chartType": 2, "resourceType": "microsoft.synapse/workspaces", "metricScope": 0, "resourceParameter": "Synapse", "resourceIds": [ "{Synapse}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 86400000 }, "metrics": [ { "namespace": "microsoft.synapse/workspaces", "metric": "microsoft.synapse/workspaces-Builtin SQL Pool-BuiltinSqlPoolDataProcessedBytes", "aggregation": 1, "splitBy": null } ], "title": "Data Processed", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "name": "DataProcessed" }, { "type": 10, "content": { "chartId": "workbook9cfd0268-d682-40bb-870c-61e05013f973", "version": "MetricsItem/2.0", "size": 0, "chartType": 2, "resourceType": "microsoft.synapse/workspaces", "metricScope": 0, "resourceParameter": "Synapse", "resourceIds": [ "{Synapse}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 86400000 }, "metrics": [ { "namespace": "microsoft.synapse/workspaces", "metric": "microsoft.synapse/workspaces-Builtin SQL Pool-BuiltinSqlPoolLoginAttempts", "aggregation": 1, "splitBy": null } ], "title": "Login Attempts", "timeBrushParameterName": "TimeRange", "gridSettings": { "rowLimit": 10000 } }, "name": "LoginAttemptsChart" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Queries by completion type\r\nSynapseBuiltinSqlPoolRequestsEnded\r\n| where _ResourceId in~ ({Synapse})\r\n| summarize count() by ResultType\r\n| render piechart ", "size": 3, "title": "Queries by Result Type", "timeContext": { "durationMs": 86400000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "sortBy": [ { "itemKey": "$gen_link_Properties_9", "sortOrder": 1 } ] }, "sortBy": [ { "itemKey": "$gen_link_Properties_9", "sortOrder": 1 } ] }, "customWidth": "33", "name": "QueriesByResultType" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Queries by query type\r\nSynapseBuiltinSqlPoolRequestsEnded\r\n| where _ResourceId in~ ({Synapse})\r\n| project CommandType=tostring(Properties.command)\r\n| summarize count() by CommandType\r\n| render piechart \r\n\r\n", "size": 3, "title": "Queries by Query Type", "timeContext": { "durationMs": 86400000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "customWidth": "33", "name": "Queries by Query Type" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Queries by completion type\r\nSynapseBuiltinSqlPoolRequestsEnded\r\n| where _ResourceId in~ ({Synapse})\r\n| project BytesProcessed=Properties.dataProcessedBytes,tostring(Identity)\r\n| summarize sum(toint(BytesProcessed)) by Identity\r\n| render piechart \r\n\r\n", "size": 3, "title": "Data Processed By User", "timeContext": { "durationMs": 86400000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "customWidth": "33", "name": "Data Processed By User" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Most Recent Query Runs\r\nSynapseBuiltinSqlPoolRequestsEnded\r\n| order by TimeGenerated\r\n| where _ResourceId in~ ({Synapse})\r\n| project \r\n StartTime=Properties.startTime,\r\n EndTime=Properties.endTime, \r\n Identity,\r\n CommandType=Properties.command,\r\n Result=ResultType,\r\n MbProcessed=(Properties.dataProcessedBytes/1024/1024),\r\n QueryText=Properties.queryText,\r\n _ResourceId\r\n| extend elapsedTime_sec =(todatetime(EndTime) - StartTime)/1s\r\n| extend Approx_Cost=((MbProcessed)*0.000476837158203125)/100 //multiply by price per mb ($5 per TB from Microsoft Docs: https://azure.microsoft.com/en-us/pricing/details/synapse-analytics/)\r\n| project-reorder StartTime,EndTime,elapsedTime_sec,Identity,CommandType,Result,MbProcessed,Approx_Cost\r\n", "size": 2, "title": "Recent Queries", "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "StartTime", "formatter": 6 }, { "columnMatch": "EndTime", "formatter": 6 }, { "columnMatch": "elapsedTime_sec", "formatter": 8, "formatOptions": { "palette": "blue" } }, { "columnMatch": "Result", "formatter": 18, "formatOptions": { "thresholdsOptions": "icons", "thresholdsGrid": [ { "operator": "Default", "thresholdValue": null, "representation": "success", "text": "{0}{1}" } ] } }, { "columnMatch": "MbProcessed", "formatter": 3, "formatOptions": { "palette": "blue" } }, { "columnMatch": "Approx_Cost", "formatter": 8, "formatOptions": { "palette": "yellow" }, "numberFormat": { "unit": 0, "options": { "style": "decimal", "minimumFractionDigits": 2, "maximumFractionDigits": 6 } } }, { "columnMatch": "QueryText", "formatter": 7, "formatOptions": { "linkTarget": "CellDetails", "linkIsContextBlade": true, "customColumnWidthSetting": "100ch" } }, { "columnMatch": "BytesProcessed", "formatter": 8, "formatOptions": { "palette": "red" } } ] } }, "name": "Recent Queries" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "Summary" }, "name": "SummaryGroup" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 10, "content": { "chartId": "workbook1f0054e6-9715-47bb-a7fc-e92812c07403", "version": "MetricsItem/2.0", "size": 4, "chartType": -1, "resourceType": "microsoft.synapse/workspaces", "metricScope": 0, "resourceParameter": "Synapse", "resourceIds": [ "{Synapse}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 86400000 }, "metrics": [ { "namespace": "microsoft.synapse/workspaces", "metric": "microsoft.synapse/workspaces-Builtin SQL Pool-BuiltinSqlPoolDataProcessedBytes", "aggregation": 1 } ], "title": "Total Data Processed", "gridFormatType": 1, "tileSettings": { "showBorder": false, "titleContent": { "columnMatch": "Name", "formatter": 13 }, "leftContent": { "columnMatch": "Value", "formatter": 12, "formatOptions": { "palette": "auto" }, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "name": "DataProcessed" }, { "type": 10, "content": { "chartId": "workbook1f0054e6-9715-47bb-a7fc-e92812c07403", "version": "MetricsItem/2.0", "size": 0, "chartType": 2, "resourceType": "microsoft.synapse/workspaces", "metricScope": 0, "resourceParameter": "Synapse", "resourceIds": [ "{Synapse}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 86400000 }, "metrics": [ { "namespace": "microsoft.synapse/workspaces", "metric": "microsoft.synapse/workspaces-Builtin SQL Pool-BuiltinSqlPoolDataProcessedBytes", "aggregation": 1, "splitBy": null } ], "title": "Data Processed and Request Completed Count", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "name": "DataProcessed - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Queries by completion type\r\nSynapseBuiltinSqlPoolRequestsEnded\r\n| where _ResourceId in~ ({Synapse})\r\n| project \r\n BytesProcessed=Properties.dataProcessedBytes,\r\n tostring(Identity),\r\n QueryHash=tostring(Properties.queryHash),\r\n QueryText=tostring(Properties.queryText)\r\n| summarize \r\n MaxSingleQueryMBProcessed=max(toint(BytesProcessed)/1024/1024),\r\n TotalMBProcessed=sum(toint(BytesProcessed)/1024/1024),\r\n QueryCount=count(),\r\n QueryHash=any(QueryHash) \r\n by QueryText //using queryText because queryHash doesn't seem to be different between queries\r\n| extend Approx_Accumulated_Cost=((TotalMBProcessed)*0.000476837158203125)/100 //multiply by price per mb ($5 per TB from Microsoft Docs: https://azure.microsoft.com/en-us/pricing/details/synapse-analytics/)\r\n| extend Approx_Cost_Per_Execution=((TotalMBProcessed)*0.000476837158203125)/100/QueryCount\r\n| order by TotalMBProcessed\r\n", "size": 0, "title": "Data Processed By Query", "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "table", "gridSettings": { "formatters": [ { "columnMatch": "QueryText", "formatter": 7, "formatOptions": { "linkTarget": "CellDetails", "linkIsContextBlade": true } }, { "columnMatch": "MaxSingleQueryMBProcessed", "formatter": 8, "formatOptions": { "palette": "orange" } }, { "columnMatch": "TotalMBProcessed", "formatter": 3, "formatOptions": { "palette": "blue" } }, { "columnMatch": "QueryCount", "formatter": 8, "formatOptions": { "min": 0, "palette": "turquoise" } }, { "columnMatch": "Approx_Accumulated_Cost", "formatter": 8, "formatOptions": { "palette": "yellow" }, "numberFormat": { "unit": 0, "options": { "style": "decimal", "minimumFractionDigits": 2, "maximumFractionDigits": 4 } } }, { "columnMatch": "Approx_Cost_Per_Execution", "formatter": 0, "numberFormat": { "unit": 0, "options": { "style": "decimal", "minimumFractionDigits": 2, "maximumFractionDigits": 6 } } }, { "columnMatch": "MaxSingleQueryBytesProcessed", "formatter": 8, "formatOptions": { "palette": "orange" } }, { "columnMatch": "TotalBytesProcessed", "formatter": 3, "formatOptions": { "palette": "blue", "compositeBarSettings": { "labelText": "", "columnSettings": [] }, "customColumnWidthSetting": "866.007px" } }, { "columnMatch": "I", "formatter": 3, "formatOptions": { "palette": "blue" } }, { "columnMatch": "any_QueryText", "formatter": 7, "formatOptions": { "linkTarget": "CellDetails", "linkIsContextBlade": true } } ] }, "sortBy": [] }, "name": "Data Processed By Query", "styleSettings": { "showBorder": true } }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Queries by completion type\r\nSynapseBuiltinSqlPoolRequestsEnded\r\n| where _ResourceId in~ ({Synapse})\r\n| project BytesProcessed=Properties.dataProcessedBytes,tostring(Identity)\r\n| summarize TotalMBProcessed=sum(toint(BytesProcessed)/1024/1024),QueryCount=count(),MaxSingleQueryMBProcessed=max(toint(BytesProcessed)/1024/1024) by Identity\r\n| extend Approx_Cost=((TotalMBProcessed)*0.000476837158203125)/100 //multiply by price per mb ($5 per TB from Microsoft Docs: https://azure.microsoft.com/en-us/pricing/details/synapse-analytics/)\r\n| order by TotalMBProcessed\r\n", "size": 0, "title": "Data Processed By User with $5 per TB cost", "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "exportFieldName": "Identity", "exportParameterName": "Identity", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "table", "gridSettings": { "formatters": [ { "columnMatch": "TotalMBProcessed", "formatter": 3, "formatOptions": { "palette": "blue" } }, { "columnMatch": "QueryCount", "formatter": 8, "formatOptions": { "min": 0, "palette": "turquoise" } }, { "columnMatch": "MaxSingleQueryMBProcessed", "formatter": 8, "formatOptions": { "palette": "orange" } }, { "columnMatch": "Approx_Cost", "formatter": 0, "numberFormat": { "unit": 0, "options": { "style": "decimal", "useGrouping": true, "minimumFractionDigits": 2, "maximumFractionDigits": 4 } } }, { "columnMatch": "TotalBytesProcessed", "formatter": 3, "formatOptions": { "min": 0, "palette": "blue", "compositeBarSettings": { "labelText": "", "columnSettings": [] }, "customColumnWidthSetting": "866.007px" } }, { "columnMatch": "MaxSingleQueryBytesProcessed", "formatter": 8, "formatOptions": { "min": 0, "palette": "orange" } } ] } }, "name": "Data Processed By User - With Cost", "styleSettings": { "showBorder": true } }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Query runs by user sorted by bytes processed\r\nSynapseBuiltinSqlPoolRequestsEnded\r\n| where _ResourceId in~ ({Synapse})\r\n| where Identity == '{Identity}'\r\n| project \r\n StartTime=Properties.startTime,\r\n EndTime=Properties.endTime, \r\n Identity,\r\n CommandType=Properties.command,\r\n Result=ResultType,\r\n BytesProcessed=Properties.dataProcessedBytes,\r\n QueryText=Properties.queryText\r\n| order by toint(BytesProcessed)\r\n", "size": 2, "title": "Query Summary for User by Data Processed", "noDataMessage": "Select a user to see their query history", "timeContext": { "durationMs": 86400000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "StartTime", "formatter": 6 }, { "columnMatch": "EndTime", "formatter": 6 }, { "columnMatch": "Result", "formatter": 18, "formatOptions": { "thresholdsOptions": "icons", "thresholdsGrid": [ { "operator": "Default", "thresholdValue": null, "representation": "success", "text": "{0}{1}" } ] } }, { "columnMatch": "BytesProcessed", "formatter": 8, "formatOptions": { "min": 0, "palette": "blue" } }, { "columnMatch": "QueryText", "formatter": 7, "formatOptions": { "linkTarget": "CellDetails", "linkIsContextBlade": true, "customColumnWidthSetting": "100ch" } } ] } }, "conditionalVisibility": { "parameterName": "Identity", "comparison": "isNotEqualTo" }, "name": "Query Summary for User by Data Processed" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "DataProcessed" }, "name": "DataProcessed" } ], "fallbackResourceIds": [ "azure monitor" ], "$schema": "https://github.com/Microsoft/Application-Insights-Workbooks/blob/master/schema/workbook.json" } ================================================ FILE: Monitor_Workbooks/archive/SynapseServerlessWorkbook.workbook.bak ================================================ { "version": "Notebook/1.0", "items": [ { "type": 9, "content": { "version": "KqlParameterItem/1.0", "crossComponentResources": [ "value::all" ], "parameters": [ { "id": "c4475a86-95ea-46b8-a5c0-3ee1c3f528bc", "version": "KqlParameterItem/1.0", "name": "TimeRange", "type": 4, "value": { "durationMs": 259200000 }, "typeSettings": { "selectableValues": [ { "durationMs": 300000 }, { "durationMs": 900000 }, { "durationMs": 1800000 }, { "durationMs": 3600000 }, { "durationMs": 14400000 }, { "durationMs": 43200000 }, { "durationMs": 86400000 }, { "durationMs": 172800000 }, { "durationMs": 259200000 }, { "durationMs": 604800000 }, { "durationMs": 1209600000 }, { "durationMs": 2419200000 }, { "durationMs": 2592000000 }, { "durationMs": 5184000000 }, { "durationMs": 7776000000 } ] }, "timeContext": { "durationMs": 86400000 } }, { "id": "94b22c78-91c8-47e6-8833-70d458e199c3", "version": "KqlParameterItem/1.0", "name": "Subscriptions", "type": 6, "isRequired": true, "multiSelect": true, "quote": "'", "delimiter": ",", "typeSettings": { "additionalResourceOptions": [ "value::1", "value::all" ], "includeAll": false, "showDefault": false }, "defaultValue": "value::all" }, { "id": "3dbc1029-1a17-4a4d-a133-2d47c1e7844e", "version": "KqlParameterItem/1.0", "name": "Synapse", "type": 5, "multiSelect": true, "quote": "'", "delimiter": ",", "query": "Resources\r\n| where type == 'microsoft.synapse/workspaces'\r\n| project id\r\n", "crossComponentResources": [ "{Subscriptions}" ], "typeSettings": { "additionalResourceOptions": [ "value::1", "value::all" ], "showDefault": false }, "timeContext": { "durationMs": 86400000 }, "defaultValue": "value::all", "queryType": 1, "resourceType": "microsoft.resourcegraph/resources" }, { "id": "4d1459db-354e-4019-8e86-015d946ce892", "version": "KqlParameterItem/1.0", "name": "LogAnalyticsWorkspace", "type": 5, "multiSelect": true, "quote": "'", "delimiter": ",", "query": "Resources\r\n| where type == 'microsoft.operationalinsights/workspaces'\r\n| project id\r\n", "crossComponentResources": [ "value::all" ], "value": [ "value::all" ], "typeSettings": { "additionalResourceOptions": [ "value::1", "value::all" ], "showDefault": false }, "defaultValue": "value::all", "queryType": 1, "resourceType": "microsoft.resourcegraph/resources" } ], "style": "pills", "queryType": 1, "resourceType": "microsoft.resourcegraph/resources" }, "name": "parameters - 1" }, { "type": 1, "content": { "json": "All costs listed in this workbook are approximate based on $5/TB. The cost listed here has not yet been extensively validated.", "style": "warning" }, "name": "text - 4" }, { "type": 11, "content": { "version": "LinkItem/1.0", "style": "tabs", "links": [ { "id": "4ee15681-1a46-4207-ac59-efab22cd6d9b", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Summary", "subTarget": "Summary", "style": "link" }, { "id": "82d489b0-87d6-4875-a5de-c7eb2d1c8c4f", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Data Processed", "subTarget": "DataProcessed", "style": "link" } ] }, "name": "links - 4" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 10, "content": { "chartId": "workbook9cfd0268-d682-40bb-870c-61e05013f973", "version": "MetricsItem/2.0", "size": 4, "chartType": -1, "resourceType": "microsoft.synapse/workspaces", "metricScope": 0, "resourceParameter": "Synapse", "resourceIds": [ "{Synapse}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 604800000 }, "metrics": [ { "namespace": "microsoft.synapse/workspaces", "metric": "microsoft.synapse/workspaces-Builtin SQL Pool-BuiltinSqlPoolLoginAttempts", "aggregation": 1 } ], "title": "Login Attempts", "gridFormatType": 1, "tileSettings": { "showBorder": false, "titleContent": { "columnMatch": "Name", "formatter": 13 }, "leftContent": { "columnMatch": "Value", "formatter": 12, "formatOptions": { "palette": "auto" }, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "timeBrushParameterName": "TimeRange", "gridSettings": { "rowLimit": 10000 } }, "customWidth": "33", "showPin": true, "name": "LoginAttemptsChart - Copy" }, { "type": 10, "content": { "chartId": "workbookdc90b0c5-4f40-4242-89b8-87eac7b9acaf", "version": "MetricsItem/2.0", "size": 4, "chartType": -1, "resourceType": "microsoft.synapse/workspaces", "metricScope": 0, "resourceParameter": "Synapse", "resourceIds": [ "{Synapse}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 604800000 }, "metrics": [ { "namespace": "microsoft.synapse/workspaces", "metric": "microsoft.synapse/workspaces-Builtin SQL Pool-BuiltinSqlPoolRequestsEnded", "aggregation": 1, "columnName": "Requests Completed" } ], "title": "Completed Requests", "gridFormatType": 1, "tileSettings": { "showBorder": false, "titleContent": { "columnMatch": "Name", "formatter": 13 }, "leftContent": { "columnMatch": "Value", "formatter": 12, "formatOptions": { "palette": "auto" }, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "33", "showPin": true, "name": "CompletedRequestCountTile" }, { "type": 10, "content": { "chartId": "workbook1f0054e6-9715-47bb-a7fc-e92812c07403", "version": "MetricsItem/2.0", "size": 4, "chartType": -1, "resourceType": "microsoft.synapse/workspaces", "metricScope": 0, "resourceParameter": "Synapse", "resourceIds": [ "{Synapse}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 604800000 }, "metrics": [ { "namespace": "microsoft.synapse/workspaces", "metric": "microsoft.synapse/workspaces-Builtin SQL Pool-BuiltinSqlPoolDataProcessedBytes", "aggregation": 1 } ], "title": "Data Processed", "gridFormatType": 1, "tileSettings": { "showBorder": false, "titleContent": { "columnMatch": "Name", "formatter": 13 }, "leftContent": { "columnMatch": "Value", "formatter": 12, "formatOptions": { "palette": "auto" }, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "33", "showPin": true, "name": "DataProcessed - Copy" }, { "type": 10, "content": { "chartId": "workbookdc90b0c5-4f40-4242-89b8-87eac7b9acaf", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.synapse/workspaces", "metricScope": 0, "resourceParameter": "Synapse", "resourceIds": [ "{Synapse}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 604800000 }, "metrics": [ { "namespace": "microsoft.synapse/workspaces", "metric": "microsoft.synapse/workspaces-Builtin SQL Pool-BuiltinSqlPoolRequestsEnded", "aggregation": 1, "splitBy": null, "columnName": "Requests Completed" } ], "title": "Completed Requests", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "showPin": true, "name": "CompletedRequestCount" }, { "type": 10, "content": { "chartId": "workbook1f0054e6-9715-47bb-a7fc-e92812c07403", "version": "MetricsItem/2.0", "size": 0, "chartType": 2, "resourceType": "microsoft.synapse/workspaces", "metricScope": 0, "resourceParameter": "Synapse", "resourceIds": [ "{Synapse}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 604800000 }, "metrics": [ { "namespace": "microsoft.synapse/workspaces", "metric": "microsoft.synapse/workspaces-Builtin SQL Pool-BuiltinSqlPoolDataProcessedBytes", "aggregation": 1, "splitBy": null } ], "title": "Data Processed", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "showPin": true, "name": "DataProcessed" }, { "type": 10, "content": { "chartId": "workbook9cfd0268-d682-40bb-870c-61e05013f973", "version": "MetricsItem/2.0", "size": 0, "chartType": 2, "resourceType": "microsoft.synapse/workspaces", "metricScope": 0, "resourceParameter": "Synapse", "resourceIds": [ "{Synapse}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 604800000 }, "metrics": [ { "namespace": "microsoft.synapse/workspaces", "metric": "microsoft.synapse/workspaces-Builtin SQL Pool-BuiltinSqlPoolLoginAttempts", "aggregation": 1, "splitBy": null } ], "title": "Login Attempts", "timeBrushParameterName": "TimeRange", "gridSettings": { "rowLimit": 10000 } }, "showPin": true, "name": "LoginAttemptsChart" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Queries by completion type\r\nSynapseBuiltinSqlPoolRequestsEnded\r\n| where _ResourceId in~ ({Synapse})\r\n| summarize count() by ResultType\r\n| render piechart ", "size": 3, "showAnalytics": true, "title": "Queries by Result Type", "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "sortBy": [ { "itemKey": "$gen_link_Properties_9", "sortOrder": 1 } ] }, "sortBy": [ { "itemKey": "$gen_link_Properties_9", "sortOrder": 1 } ] }, "customWidth": "33", "showPin": true, "name": "QueriesByResultType" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Queries by query type\r\nSynapseBuiltinSqlPoolRequestsEnded\r\n| where _ResourceId in~ ({Synapse})\r\n| project CommandType=tostring(Properties.command)\r\n| summarize count() by CommandType\r\n| render piechart \r\n\r\n", "size": 3, "showAnalytics": true, "title": "Queries by Query Type", "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "customWidth": "33", "showPin": true, "name": "Queries by Query Type" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Queries by completion type\r\nSynapseBuiltinSqlPoolRequestsEnded\r\n| where _ResourceId in~ ({Synapse})\r\n| project BytesProcessed=Properties.dataProcessedBytes,tostring(Identity)\r\n| summarize sum(toint(BytesProcessed)) by Identity\r\n| render piechart \r\n\r\n", "size": 3, "showAnalytics": true, "title": "Data Processed By User", "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "customWidth": "33", "showPin": true, "name": "Data Processed By User" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Most Recent Query Runs\r\nSynapseBuiltinSqlPoolRequestsEnded\r\n| order by TimeGenerated\r\n| where _ResourceId in~ ({Synapse})\r\n| project \r\n StartTime=Properties.startTime,\r\n EndTime=Properties.endTime, \r\n Identity,\r\n CommandType=Properties.command,\r\n Result=ResultType,\r\n MbProcessed=(Properties.dataProcessedBytes/1024/1024),\r\n QueryText=Properties.queryText,\r\n _ResourceId\r\n| extend elapsedTime_sec =(todatetime(EndTime) - StartTime)/1s\r\n| extend Approx_Cost=((MbProcessed)*0.000476837158203125)/100 //multiply by price per mb ($5 per TB from Microsoft Docs: https://azure.microsoft.com/en-us/pricing/details/synapse-analytics/)\r\n| project-reorder StartTime,EndTime,elapsedTime_sec,Identity,CommandType,Result,MbProcessed,Approx_Cost\r\n", "size": 2, "showAnalytics": true, "title": "Recent Queries", "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "StartTime", "formatter": 6 }, { "columnMatch": "EndTime", "formatter": 6 }, { "columnMatch": "elapsedTime_sec", "formatter": 8, "formatOptions": { "palette": "blue" } }, { "columnMatch": "Result", "formatter": 18, "formatOptions": { "thresholdsOptions": "icons", "thresholdsGrid": [ { "operator": "Default", "thresholdValue": null, "representation": "success", "text": "{0}{1}" } ] } }, { "columnMatch": "MbProcessed", "formatter": 3, "formatOptions": { "palette": "blue" } }, { "columnMatch": "Approx_Cost", "formatter": 8, "formatOptions": { "palette": "yellow" }, "numberFormat": { "unit": 0, "options": { "style": "decimal", "minimumFractionDigits": 2, "maximumFractionDigits": 6 } } }, { "columnMatch": "QueryText", "formatter": 7, "formatOptions": { "linkTarget": "CellDetails", "linkIsContextBlade": true, "customColumnWidthSetting": "100ch" } }, { "columnMatch": "BytesProcessed", "formatter": 8, "formatOptions": { "palette": "red" } } ] } }, "showPin": true, "name": "Recent Queries" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "Summary" }, "name": "SummaryGroup" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 10, "content": { "chartId": "workbook1f0054e6-9715-47bb-a7fc-e92812c07403", "version": "MetricsItem/2.0", "size": 4, "chartType": -1, "resourceType": "microsoft.synapse/workspaces", "metricScope": 0, "resourceParameter": "Synapse", "resourceIds": [ "{Synapse}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 0 }, "metrics": [ { "namespace": "microsoft.synapse/workspaces", "metric": "microsoft.synapse/workspaces-Builtin SQL Pool-BuiltinSqlPoolDataProcessedBytes", "aggregation": 1 } ], "title": "Total Data Processed", "gridFormatType": 1, "tileSettings": { "showBorder": false, "titleContent": { "columnMatch": "Name", "formatter": 13 }, "leftContent": { "columnMatch": "Value", "formatter": 12, "formatOptions": { "palette": "auto" }, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "showPin": true, "name": "DataProcessed" }, { "type": 10, "content": { "chartId": "workbook1f0054e6-9715-47bb-a7fc-e92812c07403", "version": "MetricsItem/2.0", "size": 0, "chartType": 2, "resourceType": "microsoft.synapse/workspaces", "metricScope": 0, "resourceParameter": "Synapse", "resourceIds": [ "{Synapse}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 0 }, "metrics": [ { "namespace": "microsoft.synapse/workspaces", "metric": "microsoft.synapse/workspaces-Builtin SQL Pool-BuiltinSqlPoolDataProcessedBytes", "aggregation": 1, "splitBy": null } ], "title": "Data Processed and Request Completed Count", "showOpenInMe": true, "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "showPin": true, "name": "DataProcessed - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Queries by completion type\r\nSynapseBuiltinSqlPoolRequestsEnded\r\n| where _ResourceId in~ ({Synapse})\r\n| project \r\n BytesProcessed=Properties.dataProcessedBytes,\r\n tostring(Identity),\r\n QueryHash=tostring(Properties.queryHash),\r\n QueryText=tostring(Properties.queryText)\r\n| summarize \r\n MaxSingleQueryMBProcessed=max(toint(BytesProcessed)/1024/1024),\r\n TotalMBProcessed=sum(toint(BytesProcessed)/1024/1024),\r\n QueryCount=count(),\r\n QueryHash=any(QueryHash) \r\n by QueryText //using queryText because queryHash doesn't seem to be different between queries\r\n| extend Approx_Accumulated_Cost=((TotalMBProcessed)*0.000476837158203125)/100 //multiply by price per mb ($5 per TB from Microsoft Docs: https://azure.microsoft.com/en-us/pricing/details/synapse-analytics/)\r\n| extend Approx_Cost_Per_Execution=((TotalMBProcessed)*0.000476837158203125)/100/QueryCount\r\n| order by TotalMBProcessed\r\n", "size": 0, "showAnalytics": true, "title": "Data Processed By Query", "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "table", "gridSettings": { "formatters": [ { "columnMatch": "QueryText", "formatter": 7, "formatOptions": { "linkTarget": "CellDetails", "linkIsContextBlade": true } }, { "columnMatch": "MaxSingleQueryMBProcessed", "formatter": 8, "formatOptions": { "palette": "orange" } }, { "columnMatch": "TotalMBProcessed", "formatter": 3, "formatOptions": { "palette": "blue" } }, { "columnMatch": "QueryCount", "formatter": 8, "formatOptions": { "min": 0, "palette": "turquoise" } }, { "columnMatch": "Approx_Accumulated_Cost", "formatter": 8, "formatOptions": { "palette": "yellow" }, "numberFormat": { "unit": 0, "options": { "style": "decimal", "minimumFractionDigits": 2, "maximumFractionDigits": 4 } } }, { "columnMatch": "Approx_Cost_Per_Execution", "formatter": 0, "numberFormat": { "unit": 0, "options": { "style": "decimal", "minimumFractionDigits": 2, "maximumFractionDigits": 6 } } }, { "columnMatch": "MaxSingleQueryBytesProcessed", "formatter": 8, "formatOptions": { "palette": "orange" } }, { "columnMatch": "TotalBytesProcessed", "formatter": 3, "formatOptions": { "palette": "blue", "compositeBarSettings": { "labelText": "", "columnSettings": [] }, "customColumnWidthSetting": "866.007px" } }, { "columnMatch": "I", "formatter": 3, "formatOptions": { "palette": "blue" } }, { "columnMatch": "any_QueryText", "formatter": 7, "formatOptions": { "linkTarget": "CellDetails", "linkIsContextBlade": true } } ] }, "sortBy": [] }, "showPin": true, "name": "Data Processed By Query", "styleSettings": { "showBorder": true } }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Queries by completion type\r\nSynapseBuiltinSqlPoolRequestsEnded\r\n| where _ResourceId in~ ({Synapse})\r\n| project BytesProcessed=Properties.dataProcessedBytes,tostring(Identity)\r\n| summarize TotalMBProcessed=sum(toint(BytesProcessed)/1024/1024),QueryCount=count(),MaxSingleQueryMBProcessed=max(toint(BytesProcessed)/1024/1024) by Identity\r\n| extend Approx_Cost=((TotalMBProcessed)*0.000476837158203125)/100 //multiply by price per mb ($5 per TB from Microsoft Docs: https://azure.microsoft.com/en-us/pricing/details/synapse-analytics/)\r\n| order by TotalMBProcessed\r\n", "size": 0, "showAnalytics": true, "title": "Data Processed By User with $5 per TB cost", "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "exportFieldName": "Identity", "exportParameterName": "Identity", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "table", "gridSettings": { "formatters": [ { "columnMatch": "TotalMBProcessed", "formatter": 3, "formatOptions": { "palette": "blue" } }, { "columnMatch": "QueryCount", "formatter": 8, "formatOptions": { "min": 0, "palette": "turquoise" } }, { "columnMatch": "MaxSingleQueryMBProcessed", "formatter": 8, "formatOptions": { "palette": "orange" } }, { "columnMatch": "Approx_Cost", "formatter": 0, "numberFormat": { "unit": 0, "options": { "style": "decimal", "useGrouping": true, "minimumFractionDigits": 2, "maximumFractionDigits": 4 } } }, { "columnMatch": "TotalBytesProcessed", "formatter": 3, "formatOptions": { "min": 0, "palette": "blue", "compositeBarSettings": { "labelText": "", "columnSettings": [] }, "customColumnWidthSetting": "866.007px" } }, { "columnMatch": "MaxSingleQueryBytesProcessed", "formatter": 8, "formatOptions": { "min": 0, "palette": "orange" } } ] } }, "showPin": true, "name": "Data Processed By User - With Cost", "styleSettings": { "showBorder": true } }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Query runs by user sorted by bytes processed\r\nSynapseBuiltinSqlPoolRequestsEnded\r\n| where _ResourceId in~ ({Synapse})\r\n| where Identity == '{Identity}'\r\n| project \r\n StartTime=Properties.startTime,\r\n EndTime=Properties.endTime, \r\n Identity,\r\n CommandType=Properties.command,\r\n Result=ResultType,\r\n BytesProcessed=Properties.dataProcessedBytes,\r\n QueryText=Properties.queryText\r\n| order by toint(BytesProcessed)\r\n", "size": 2, "title": "Query Summary for User by Data Processed", "noDataMessage": "Select a user to see their query history", "timeContext": { "durationMs": 1209600000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "StartTime", "formatter": 6 }, { "columnMatch": "EndTime", "formatter": 6 }, { "columnMatch": "Result", "formatter": 18, "formatOptions": { "thresholdsOptions": "icons", "thresholdsGrid": [ { "operator": "Default", "thresholdValue": null, "representation": "success", "text": "{0}{1}" } ] } }, { "columnMatch": "BytesProcessed", "formatter": 8, "formatOptions": { "min": 0, "palette": "blue" } }, { "columnMatch": "QueryText", "formatter": 7, "formatOptions": { "linkTarget": "CellDetails", "linkIsContextBlade": true, "customColumnWidthSetting": "100ch" } } ] } }, "conditionalVisibility": { "parameterName": "Identity", "comparison": "isNotEqualTo" }, "name": "Query Summary for User by Data Processed" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "DataProcessed" }, "name": "DataProcessed" } ], "fallbackResourceIds": [ "Azure Monitor" ], "$schema": "https://github.com/Microsoft/Application-Insights-Workbooks/blob/master/schema/workbook.json" } ================================================ FILE: Monitor_Workbooks/archive/SynapseWorkbook_WIP_v01.json ================================================ { "version": "Notebook/1.0", "items": [ { "type": 9, "content": { "version": "KqlParameterItem/1.0", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "parameters": [ { "id": "28da10ec-a308-47f5-9819-92ebf810b292", "version": "KqlParameterItem/1.0", "name": "LogAnalyticsSubscription", "type": 6, "value": null, "typeSettings": { "additionalResourceOptions": [], "includeAll": false, "showDefault": false }, "timeContext": { "durationMs": 86400000 } }, { "id": "e383ed24-52ae-447b-9b80-51fd3ab6b919", "version": "KqlParameterItem/1.0", "name": "LogAnalyticsWorkspace", "type": 5, "query": "Resources\r\n| where type == 'microsoft.operationalinsights/workspaces'\r\n| project id\r\n", "crossComponentResources": [ "{LogAnalyticsSubscription}" ], "value": null, "typeSettings": { "additionalResourceOptions": [], "showDefault": false }, "timeContext": { "durationMs": 86400000 }, "queryType": 1, "resourceType": "microsoft.resourcegraph/resources" }, { "id": "9b9fe566-0f52-4a75-a35b-a79c50c6a6f0", "version": "KqlParameterItem/1.0", "name": "DatabaseResourceName", "type": 5, "query": "AzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| distinct ResourceId", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "value": null, "typeSettings": { "additionalResourceOptions": [], "showDefault": false }, "timeContext": { "durationMs": 86400000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "id": "f5852627-70ca-4959-8d60-53b48864603f", "version": "KqlParameterItem/1.0", "name": "TimeRange", "type": 4, "isGlobal": true, "value": { "durationMs": 14400000 }, "typeSettings": { "selectableValues": [ { "durationMs": 300000 }, { "durationMs": 900000 }, { "durationMs": 1800000 }, { "durationMs": 3600000 }, { "durationMs": 14400000 }, { "durationMs": 43200000 }, { "durationMs": 86400000 }, { "durationMs": 172800000 }, { "durationMs": 259200000 }, { "durationMs": 604800000 }, { "durationMs": 1209600000 }, { "durationMs": 2419200000 }, { "durationMs": 2592000000 } ], "allowCustom": true }, "timeContext": { "durationMs": 86400000 } }, { "id": "6da2f63f-45a3-4b37-9108-5e8b7e358d85", "version": "KqlParameterItem/1.0", "name": "DatabaseName", "type": 1, "query": "AzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where ResourceId == '{DatabaseResourceName}'\r\n| distinct Resource ", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "id": "8bba835b-f319-43b3-8ec6-4e051fc6d446", "version": "KqlParameterItem/1.0", "name": "LogicalServerName", "type": 1, "query": "AzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where ResourceId == '{DatabaseResourceName}'\r\n| distinct LogicalServerName_s", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.resourcegraph/resources" }, "name": "parameters - 2" }, { "type": 11, "content": { "version": "LinkItem/1.0", "style": "tabs", "links": [ { "id": "202cbbc0-8d63-416d-89ed-451d6fe7c4b3", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Workload", "subTarget": "Workload", "preText": "Workload", "style": "link" }, { "id": "a7901bd0-a1f4-4491-b953-57555d764e00", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Workload Management", "subTarget": "WorkloadManagement", "style": "link" }, { "id": "45e12a14-8548-4477-aae3-c142b906dc9f", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "TempDB", "subTarget": "TempDB", "style": "link" }, { "id": "79d10d16-0696-4214-b306-c7a0e46cd64f", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Investigate Query by Query Text", "subTarget": "QueryByQueryText", "style": "link" }, { "id": "9ef8f730-d73d-432b-9b75-55095d1155f2", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Replicated Tables", "subTarget": "ReplicatedTables", "style": "link" }, { "id": "31c1cf1c-74b5-44e2-ba9a-9497834ca3dc", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Query Comparison", "subTarget": "QueryComparison", "style": "link" }, { "id": "482ccc46-8a10-4ace-bfd6-63ac73b380af", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Query Activity", "subTarget": "QueryActivity", "style": "link" } ] }, "name": "links - 0" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "title": "Workload", "items": [ { "type": 10, "content": { "chartId": "workbook90867bfc-5c33-464f-ac31-2c2e006b97f4", "version": "MetricsItem/2.0", "size": 0, "chartType": 2, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 259200000 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-dwu_consumption_percent", "aggregation": 3, "columnName": "DWU Percentage" }, { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-cpu_percent", "aggregation": 3 }, { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-physical_data_read_percent", "aggregation": 3 } ], "title": "DWU Resource Utilization", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "name": "metric - 1" }, { "type": 10, "content": { "chartId": "workbookb954d4a0-82ef-4409-88fb-837aaff80c8d", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 259200000 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-active_queries", "aggregation": 1, "splitBy": null }, { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-queued_queries", "aggregation": 1 } ], "title": "Active and Queued Queries", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "name": "metric - 1" }, { "type": 10, "content": { "chartId": "workbookb954d4a0-82ef-4409-88fb-837aaff80c8d", "version": "MetricsItem/2.0", "size": 0, "chartType": 3, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 259200000 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-local_tempdb_usage_percent", "aggregation": 3, "splitBy": null, "columnName": "TempDB Utilization Percentage" } ], "title": "TempDB Utilization", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "name": "metric - 1 - Copy" }, { "type": 10, "content": { "chartId": "workbookb954d4a0-82ef-4409-88fb-837aaff80c8d", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 0 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-WorkloadManagement-wlg_allocation_relative_to_system_percent", "aggregation": 3, "splitBy": null } ], "title": "Workload Group Utilization", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "name": "Workload Group Utilization" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databaseName = '{DatabaseName}';\r\n//Long-Running Queries - Just Actual Queries\r\n//If 'Command' is empty - you need to set a bigger time window, the older record with the command is outside of your window\r\nAzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where Resource == databaseName\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize Session_ID=any(SessionId_s),\r\n Request_ID=any(RequestId_s),\r\n Submit_Time=max(SubmitTime_t),\r\n Start_Time=max(StartTime_t),\r\n End_Time=max(EndTime_t),\r\n Command=any(Command_s),\r\n Status=min(Status_s), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType_s),\r\n Resource_class=any(ResourceClass_s)\r\n by RequestId_s\r\n| summarize ElapsedTime_min=bin(anyif(((End_Time - Start_Time)/1m),Start_Time > ago(30d)),1),\r\n Session_ID=any(Session_ID), \r\n Submit_Time=any(Submit_Time) ,\r\n Start_Time=any(Start_Time), \r\n End_Time=any(End_Time),\r\n Command=any(Command),\r\n Status=any(Status),\r\n Statement_Type=any(Statement_Type)\r\n ,Resource_class=any(Resource_class) \r\n by Request_ID\r\n| where End_Time > ago(365d)\r\n| summarize count() by Status, bin(End_Time,5m)\r\n| render timechart \r\n", "size": 0, "title": "Query Completion Count by End Time - 5m buckets", "color": "redBright", "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "chartSettings": { "seriesLabelSettings": [ { "seriesName": "Completed", "color": "green" }, { "seriesName": "Failed", "color": "red" }, { "seriesName": "Cancelled", "color": "yellow" } ] } }, "name": "query - 4" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": " AzureDiagnostics\r\n | where Category == 'SQLSecurityAuditEvents' and LogicalServerName_s == '{LogicalServerName}'\r\n //| where duration_milliseconds_d > 0\r\n | extend duration_seconds = duration_milliseconds_d /1000.0\r\n | where statement_s != 'select @@version'\r\n | where statement_s != 'SELECT @@SPID;'\r\n | summarize sum(affected_rows_d) by bin(TimeGenerated,1h)", "size": 0, "timeContext": { "durationMs": 259200000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "categoricalbar" }, "name": "query - 7" }, { "type": 10, "content": { "chartId": "workbook1afc57e6-0b32-4968-b299-db319bd21635", "version": "MetricsItem/2.0", "size": 0, "chartType": 2, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 259200000 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-connection_successful", "aggregation": 1, "splitBy": null }, { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-connection_failed", "aggregation": 1 } ], "title": "Successful and Failed Connections", "gridSettings": { "rowLimit": 10000 } }, "name": "metric - 5" }, { "type": 10, "content": { "chartId": "workbook993837ad-66d6-4cbc-ae1a-7c3f6623236b", "version": "MetricsItem/2.0", "size": 0, "chartType": 2, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 259200000 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-cache_used_percent", "aggregation": 3, "splitBy": null }, { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-cache_hit_percent", "aggregation": 3 } ], "title": "Adaptive Cache Used vs Hit Percentage", "gridSettings": { "rowLimit": 10000 } }, "name": "metric - 6" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "Workload" }, "name": "group - 1" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "title": "TempDB ", "items": [ { "type": 10, "content": { "chartId": "workbook4a9cf761-cce2-45b2-8947-8a9428ec7e1c", "version": "MetricsItem/2.0", "size": 0, "chartType": 3, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 259200000 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-local_tempdb_usage_percent", "aggregation": 3, "splitBy": null, "columnName": "TempDB Util" }, { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-local_tempdb_usage_percent", "aggregation": 4, "columnName": "TempDB Util" } ], "title": "TempDB Max and Avg Utilization", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "name": "metric - 0" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "19ee48f5-8f4e-4939-a0ef-c6bf656a93f9", "version": "KqlParameterItem/1.0", "name": "WeightParameter", "type": 1, "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 } }, { "id": "00553ec8-1a41-4dd9-a024-d607639c9bbb", "version": "KqlParameterItem/1.0", "name": "RequestID", "type": 1, "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 } } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 3" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databaseName = '{DatabaseName}';\r\n//Weighted query steps\r\nAzureDiagnostics\r\n| where Category == 'RequestSteps'\r\n| where Resource == databaseName\r\n| where RowCount_d > 0\r\n| summarize sum(RowCount_d) by RequestId_s, OperationType_s\r\n| order by sum_RowCount_d desc\r\n| limit 20\r\n| render columnchart ", "size": 0, "title": "20 Largest Query Steps by Most Rows Moved", "timeContext": { "durationMs": 259200000 }, "timeContextFromParameter": "TimeRange", "exportFieldName": "Request_ID", "exportParameterName": "RequestID", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "chartSettings": { "xAxis": "RequestId_s", "group": "OperationType_s", "createOtherGroup": 20, "showLegend": true } }, "name": "query - 1 - Copy" }, { "type": 11, "content": { "version": "LinkItem/1.0", "style": "nav", "links": [ { "id": "c98d3722-9907-43ab-9306-1957d6f7f858", "cellValue": "WeightParameter", "linkTarget": "parameter", "linkLabel": "Weighted Rowcounts", "subTarget": "Weighted", "preText": "", "postText": "", "style": "secondary" }, { "id": "a06ae99a-ad62-45e9-8c25-c219b81f59c0", "cellValue": "WeightParameter", "linkTarget": "parameter", "linkLabel": "Unweighted Rowcounts", "subTarget": "Unweighted", "preText": "", "postText": "", "style": "secondary" } ] }, "name": "links - 3" }, { "type": 1, "content": { "json": "Current Setting: {WeightParameter}", "style": "info" }, "name": "text - 4" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databaseName = '{DatabaseName}';\r\n//Weighted query steps\r\nlet RequestSteps = AzureDiagnostics\r\n| where Category == 'RequestSteps'\r\n| where Resource == databaseName\r\n| where RowCount_d > 100000000\r\n| extend Step_Elapsed_Min = round((EndTime_t - StartTime_t)/1m, 2)\r\n| extend Weighted_cnt = iff('{WeightParameter}'=='Weighted',(case(OperationType_s == 'BroadcastMoveOperation', (RowCount_d*20), RowCount_d)),RowCount_d)\r\n| project-rename StepStatus = Status_s, StepStart = StartTime_t, StepEnd = EndTime_t//, StepResource = Resource\r\n| top 100 by Weighted_cnt desc\r\n| order by Weighted_cnt desc\r\n| project Request_ID=RequestId_s,OperationType_s, RowCount_d,Weighted_cnt,Step_Elapsed_Min, StepStart, StepEnd, StepStatus, StepIndex_d,Resource;\r\nRequestSteps | join (AzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where Resource == databaseName\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize Session_ID=any(SessionId_s),\r\n Request_ID=any(RequestId_s),\r\n Submit_Time=max(SubmitTime_t),\r\n Start_Time=max(StartTime_t),\r\n End_Time=max(EndTime_t),\r\n Command=any(Command_s),\r\n Status=min(Status_s), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType_s),\r\n Resource_class=any(ResourceClass_s)\r\n by RequestId_s\r\n| summarize Session_ID=any(Session_ID), Submit_Time=any(Submit_Time) ,Start_Time=any(Start_Time), End_Time=any(End_Time),Command=any(Command),Status=any(Status),Statement_Type=any(Statement_Type),Resource_class=any(Resource_class) by Request_ID\r\n//| order by Step_Elapsed_Min desc\r\n| extend Request_Elapsed_Min = round((End_Time - Start_Time)/1m, 2)\r\n| project-rename ReqStatus = Status, ReqStart = Start_Time, ReqEnd = End_Time\r\n) on Request_ID\r\n| project-reorder Session_ID, Request_ID, Request_Elapsed_Min, ReqStart, ReqEnd, ReqStatus,StepIndex_d, OperationType_s, RowCount_d,Weighted_cnt,Step_Elapsed_Min, StepStart, StepEnd, StepStatus, Statement_Type, Command, Resource_class\r\n| order by Weighted_cnt desc\r\n| limit 20", "size": 3, "title": "20 Largest Query Steps by Most Rows Moved", "timeContext": { "durationMs": 259200000 }, "timeContextFromParameter": "TimeRange", "exportFieldName": "Request_ID1", "exportParameterName": "RequestID", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "sortBy": [ { "itemKey": "Weighted_cnt", "sortOrder": 2 } ] }, "sortBy": [ { "itemKey": "Weighted_cnt", "sortOrder": 2 } ] }, "name": "query - 1" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databaseName = '{DatabaseName}';\r\n//Long-Running Queries - Just Actual Queries\r\n//If 'Command' is empty - you need to set a bigger time window, the older record with the command is outside of your window\r\nAzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where Resource == databaseName\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize Session_ID=any(SessionId_s),\r\n Request_ID=any(RequestId_s),\r\n Submit_Time=max(SubmitTime_t),\r\n Start_Time=max(StartTime_t),\r\n End_Time=max(EndTime_t),\r\n Command=any(Command_s),\r\n Status=min(Status_s), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType_s),\r\n Resource_class=any(ResourceClass_s)\r\n by RequestId_s\r\n| summarize ElapsedTime_min=bin(anyif(((End_Time - Start_Time)/1m),Start_Time > ago(30d)),1),\r\n Session_ID=any(Session_ID), \r\n Submit_Time=any(Submit_Time) ,\r\n Start_Time=any(Start_Time), \r\n End_Time=any(End_Time),\r\n Command=any(Command),\r\n Status=any(Status),\r\n Statement_Type=any(Statement_Type)\r\n ,Resource_class=any(Resource_class) \r\n by Request_ID\r\n| where Request_ID == '{RequestID}'\r\n\r\n", "size": 4, "title": "Selected Query", "noDataMessage": "Select a query above to view details", "timeContext": { "durationMs": 259200000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "35%" } } ] } }, "name": "query - 6" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics\r\n| where Category == 'RequestSteps'\r\n| where Resource == '{DatabaseName}'\r\n| where RequestId_s == '{RequestID}' //Put your QueryID here\r\n| where Status_s != 'Running'\r\n| summarize max(StartTime_t),max(EndTime_t),max(RequestId_s),max(OperationType_s),max(RowCount_d),max(Command_s),max(Status_s) by StepIndex_d\r\n| order by StepIndex_d asc", "size": 3, "title": "Query Plan", "noDataMessage": "Select a query above to view the plan", "timeContext": { "durationMs": 259200000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 7" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "TempDB" }, "name": "group - 3" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "title": "Query By Query Text", "items": [ { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "29880874-2d41-4bd5-bf22-3e47ae8b1145", "version": "KqlParameterItem/1.0", "name": "QueryTextSnippet", "type": 1, "isRequired": true, "value": "", "timeContext": { "durationMs": 86400000 } } ], "style": "formVertical", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "customWidth": "60", "name": "parameters - 3" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics \r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize \r\n Session_ID=max(SessionId_s), \r\n Request_ID=max(RequestId_s), \r\n Submit_Time=max(SubmitTime_t), \r\n Start_Time=max(StartTime_t),\r\n End_Compile_Time=max(EndCompileTime_t), \r\n End_Time=max(EndTime_t), \r\n Command=max(Command_s), \r\n Last_Status=min(Status_s),\r\n Statement_Type=max(StatementType_s),\r\n Resource_class=max(ResourceClass_s) \r\n by RequestId_s\r\n| where Command contains '{QueryTextSnippet}'\r\n| extend elapsedTime_sec = iif(End_Time > ago(365d),(End_Time - Submit_Time)/1s,real(null)) \r\n| extend CompileTime_sec = (End_Compile_Time - Submit_Time)/1s\r\n| order by elapsedTime_sec\r\n| summarize \r\n Executions = count(),\r\n Max_Elapsed_Time_sec = bin(max(elapsedTime_sec),1),\r\n Min_Elapsed_Time_sec = bin(min(elapsedTime_sec),1),\r\n Variability_sec=bin((max(elapsedTime_sec)-min(elapsedTime_sec)),1),\r\n SampleQID = any(RequestId_s)\r\n by Command\r\n| order by Max_Elapsed_Time_sec\r\n\r\n\r\n", "size": 0, "title": "Queries Containing that text", "timeContext": { "durationMs": 259200000 }, "timeContextFromParameter": "TimeRange", "exportFieldName": "SampleQID", "exportParameterName": "SampleQID", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "50%" } } ] } }, "name": "query - 0" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics \r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s !in ('Batch','Execute')\r\n| where RequestId_s == '{SampleQID}'\r\n| summarize \r\n Session_ID=max(SessionId_s), \r\n Request_ID=max(RequestId_s), \r\n Submit_Time=max(SubmitTime_t), \r\n Start_Time=max(StartTime_t),\r\n End_Compile_Time=max(EndCompileTime_t), \r\n End_Time=max(EndTime_t), \r\n Command=max(Command_s), \r\n Last_Status=min(Status_s),\r\n Statement_Type=max(StatementType_s),\r\n Resource_class=max(ResourceClass_s) \r\n by RequestId_s\r\n| extend elapsedTime_sec = iif(End_Time > ago(365d),(End_Time - Submit_Time)/1s,real(null)) \r\n| extend CompileTime_sec = (End_Compile_Time - Submit_Time)/1s\r\n| join kind=inner\r\n (AzureDiagnostics \r\n | where Category == 'ExecRequests'\r\n | where Resource == '{DatabaseName}'\r\n | where StatementType_s !in ('Batch','Execute')\r\n | summarize \r\n Session_ID=max(SessionId_s), \r\n Request_ID=max(RequestId_s), \r\n Submit_Time=max(SubmitTime_t), \r\n Start_Time=max(StartTime_t),\r\n End_Compile_Time=max(EndCompileTime_t), \r\n End_Time=max(EndTime_t), \r\n Command=max(Command_s), \r\n Last_Status=min(Status_s),\r\n Statement_Type=max(StatementType_s),\r\n Resource_class=max(ResourceClass_s) \r\n by RequestId_s\r\n | extend elapsedTime_sec = (End_Time - Submit_Time)/1s\r\n | extend elapsedTime_sec = iif(End_Time > ago(365d),(End_Time - Submit_Time)/1s,real(null)) \r\n | extend CompileTime_sec = (End_Compile_Time - Submit_Time)/1s\r\n )\r\non Command \r\n| project Request_ID1,Session_ID1,Submit_Time1,Start_Time1,End_Compile_Time1,End_Time1,Last_Status1,Statement_Type1,Resource_class1,elapsedTime_sec1,CompileTime_sec1\r\n", "size": 0, "title": "All Executions of Selected Query", "noDataMessage": "Select a query above to see individual executions", "timeContext": { "durationMs": 259200000 }, "timeContextFromParameter": "TimeRange", "exportFieldName": "Request_ID1", "exportParameterName": "RequestId", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "sortBy": [] }, "name": "query - 0 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics\r\n| where Category == 'RequestSteps'\r\n| where Resource == '{DatabaseName}'\r\n| where RequestId_s == '{RequestId}'\r\n| where Status_s != 'Running'\r\n| summarize max(StartTime_t),max(EndTime_t),max(RequestId_s),max(OperationType_s),max(RowCount_d),max(Command_s),max(Status_s) by StepIndex_d\r\n| order by StepIndex_d asc", "size": 3, "title": "Query Plan for Selected Query", "noDataMessage": "Select a Query Above to See the Query Plan", "timeContext": { "durationMs": 259200000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 0 - Copy - Copy" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "QueryByQueryText" }, "name": "group - 4", "styleSettings": { "showBorder": true } }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "title": "Replicated Tables", "items": [ { "type": 1, "content": { "json": "All Charts on this page are based on the last 7 days of data", "style": "info" }, "name": "text - 5" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Build cache count by day\r\nAzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s == 'BuildReplicatedTableCache'\r\n| where Command_s != \"\"\r\n| where ResourceClass_s != \"\"\r\n| project Command_s,TimeGenerated,RequestId_s\r\n| summarize LastRebuild=max(TimeGenerated),RebuildCount=count(RequestId_s) by Command_s\r\n| order by RebuildCount desc\r\n| limit 15\r\n", "size": 3, "title": "Top 15 Most Rebuilds by Table", "timeContext": { "durationMs": 604800000 }, "exportFieldName": "Command_s", "exportParameterName": "QueryText", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command_s", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "40%" } } ] } }, "name": "query - 0" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Build cache count by day\r\nAzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s == 'BuildReplicatedTableCache'\r\n| where Command_s == \"{QueryText}\"\r\n| where ResourceClass_s != \"\"\r\n| project Command_s,TimeGenerated,RequestId_s\r\n| summarize count() by Command_s,bin(TimeGenerated,24h)\r\n| limit 20\r\n| render timechart", "size": 0, "title": "Rebuilds per Day for Selected Table", "noDataMessage": "Select a query above to see runs by day", "timeContext": { "durationMs": 604800000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "chartSettings": { "group": "Command_s", "createOtherGroup": 20, "ySettings": { "min": 0 } } }, "name": "query - 0 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Build cache count by day\r\nAzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s == 'BuildReplicatedTableCache'\r\n| where Command_s != \"\"\r\n| where ResourceClass_s != \"\"\r\n| project Command_s,TimeGenerated,RequestId_s\r\n| summarize count() by Command_s, bin(TimeGenerated,24h)\r\n| where count_ > 7\r\n| order by count_ desc\r\n\r\n", "size": 2, "title": "Rebuild Count by Table by Day", "timeContext": { "durationMs": 604800000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "categoricalbar", "gridSettings": { "sortBy": [ { "itemKey": "count_", "sortOrder": 1 } ] }, "sortBy": [ { "itemKey": "count_", "sortOrder": 1 } ], "tileSettings": { "showBorder": false, "titleContent": { "columnMatch": "Command_s", "formatter": 1 }, "leftContent": { "columnMatch": "count_", "formatter": 12, "formatOptions": { "palette": "auto" }, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "graphSettings": { "type": 0, "topContent": { "columnMatch": "Command_s", "formatter": 1 }, "centerContent": { "columnMatch": "count_", "formatter": 1, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "chartSettings": { "group": "Command_s", "createOtherGroup": 99, "showDataPoints": true } }, "name": "query - 0 - Copy - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Long-Running Queries - Just Actual Queries\r\nAzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize Session_ID=max(SessionId_s), Request_ID=max(RequestId_s), Submit_Time=max(SubmitTime_t), Start_Time=max(StartTime_t), End_Time=max(EndTime_t), Command=max(Command_s), Statement_Type=max(StatementType_s), Resource_class=max(ResourceClass_s) by RequestId_s\r\n| join kind= inner\r\n(\r\n AzureDiagnostics\r\n | where Category == 'ExecRequests'\r\n | where Resource == '{DatabaseName}'\r\n //| where StatementType_s !in ('Batch','Execute')\r\n | where StatementType_s == 'BuildReplicatedTableCache'\r\n | where EndTime_t > ago(7d)\r\n | where StartTime_t > ago(7d)\r\n | extend elapsedTime_min = (EndTime_t - StartTime_t)/1m\r\n //| extend elapsedTime_min = elapsedTime/1m\r\n | order by elapsedTime_min desc\r\n | project Request_ID=RequestId_s,elapsedTime_min \r\n)\r\non Request_ID\r\n| order by elapsedTime_min desc\r\n| project Request_ID,Submit_Time,Start_Time,End_Time,Elapsed_Time=round(elapsedTime_min,1) ,Command\r\n| limit 15\r\n", "size": 3, "title": "Top 15 Elapsed Time per Rebuild", "timeContext": { "durationMs": 604800000 }, "exportFieldName": "Request_ID", "exportParameterName": "RequestId", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "40%" } } ] } }, "name": "query - 3" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics\r\n| where Category == 'RequestSteps'\r\n| where Resource == '{DatabaseName}'\r\n| where RequestId_s == '{RequestId}'\r\n| where Status_s != 'Running'\r\n| summarize max(StartTime_t),max(EndTime_t),max(RequestId_s),max(OperationType_s),max(RowCount_d),max(Command_s),max(Status_s) by StepIndex_d\r\n| order by StepIndex_d asc", "size": 3, "title": "Query Plan for Selected Query", "noDataMessage": "Select a query above to view plan", "timeContext": { "durationMs": 604800000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 4" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "ReplicatedTables" }, "name": "ReplicatedTablesGroup" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 10, "content": { "chartId": "workbook72446028-6edb-4cb0-8952-e0c13bda488f", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 0 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-WorkloadManagement-wlg_allocation_relative_to_system_percent", "aggregation": 3, "splitBy": null } ], "title": "Workload Group Allocation By System Percent", "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "name": "metric - 0" }, { "type": 10, "content": { "chartId": "workbookc898119a-7381-469d-b51a-d505b4f80e73", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 0 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-WorkloadManagement-wlg_active_queries", "aggregation": 1, "splitBy": null } ], "title": "Query Count by Workload Group", "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "name": "metric - 1" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "parameters": [ { "id": "6f50577d-7b00-4e4a-acf9-d45c7a5ee813", "version": "KqlParameterItem/1.0", "name": "WorkloadGroup", "type": 10, "query": "AzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n and ResourceClass_s != \"\"\r\n| distinct ResourceClass_s", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "typeSettings": { "additionalResourceOptions": [] }, "timeContext": { "durationMs": 86400000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "value": "wg_batch_M" } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 2" }, { "type": 10, "content": { "chartId": "workbook3da1d18a-1bf5-46c5-b3b7-211f71d329cc", "version": "MetricsItem/2.0", "size": 0, "chartType": 2, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 0 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-WorkloadManagement-wlg_active_queries", "aggregation": 1, "splitBy": null }, { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-WorkloadManagement-wlg_queued_queries", "aggregation": 1 } ], "filters": [ { "id": "1", "key": "WorkloadGroupName", "operator": 0, "values": [ "WorkloadGroup" ] } ], "gridSettings": { "rowLimit": 10000 } }, "name": "metric - 3" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "WorkloadManagement" }, "name": "group - 6" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 1, "content": { "json": "## Select a Principal or Application name to filter results - leave to 'unset' to view all results" }, "name": "text - 5" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "parameters": [ { "id": "8d25c043-d1ff-4546-a1fa-f4bcbfdab8af", "version": "KqlParameterItem/1.0", "name": "User", "type": 2, "description": "User to filter subsequent queries - leave to 'unset' for all users", "query": "AzureDiagnostics\r\n| where Category == 'SQLSecurityAuditEvents' and LogicalServerName_s == '{LogicalServerName}'\r\n| summarize by server_principal_name_s", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "value": null, "typeSettings": { "additionalResourceOptions": [], "showDefault": false }, "timeContext": { "durationMs": 86400000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "id": "aa766d64-693f-4024-b4a4-b5b56b28376b", "version": "KqlParameterItem/1.0", "name": "Application", "type": 2, "query": "AzureDiagnostics\r\n| where Category == 'SQLSecurityAuditEvents' and LogicalServerName_s == '{LogicalServerName}'\r\n| summarize by application_name_s", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "value": null, "typeSettings": { "additionalResourceOptions": [] }, "timeContext": { "durationMs": 86400000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "customWidth": "30", "name": "parameters - 1" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics\r\n| where Category == 'SQLSecurityAuditEvents' and LogicalServerName_s == \"{LogicalServerName}\"\r\n| where duration_milliseconds_d > 0\r\n| extend duration_seconds = duration_milliseconds_d /1000.0\r\n| where statement_s != 'select @@version'\r\n| where statement_s != 'SELECT @@SPID;'\r\n| where server_principal_name_s has '{User}'\r\n| where application_name_s has '{Application}'\r\n| project server_principal_name_s, succeeded_s, event_time_t, LogicalServerName_s, duration_milliseconds_d, duration_seconds, affected_rows_d, statement_s, application_name_s\r\n| summarize duration_seconds = round(sum(duration_seconds)) , query_count = count(statement_s) by EventDay = bin(event_time_t,1d), UserName = server_principal_name_s, Application = application_name_s \r\n| order by EventDay, duration_seconds desc", "size": 0, "title": "Query Summary for Selected User {User} {Application}", "noDataMessage": "Select a user to see query activity", "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 0 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics\r\n| where Category == 'SQLSecurityAuditEvents' and LogicalServerName_s == \"{LogicalServerName}\"\r\n| where duration_milliseconds_d > 0\r\n| extend duration_seconds = duration_milliseconds_d /1000.0\r\n| where statement_s != 'select @@version'\r\n| where statement_s != 'SELECT @@SPID;'\r\n| where server_principal_name_s has '{User}'\r\n| where application_name_s has '{Application}'\r\n| project server_principal_name_s, succeeded_s, event_time_t, LogicalServerName_s, duration_milliseconds_d, duration_seconds, affected_rows_d, statement_s, application_name_s\r\n| summarize duration_seconds = round(sum(duration_seconds)) , query_count = count(statement_s) by EventDay = bin(event_time_t,1d), UserName = server_principal_name_s, Application = application_name_s \r\n| order by EventDay, duration_seconds desc", "size": 0, "title": "Query Summary for Selected User {User} {Application}", "noDataMessage": "Select a user to see query activity", "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "unstackedbar", "tileSettings": { "showBorder": false, "titleContent": { "columnMatch": "UserName", "formatter": 1 }, "leftContent": { "columnMatch": "duration_seconds", "formatter": 12, "formatOptions": { "palette": "auto" }, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "graphSettings": { "type": 0, "topContent": { "columnMatch": "UserName", "formatter": 1 }, "centerContent": { "columnMatch": "duration_seconds", "formatter": 1, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "chartSettings": { "xAxis": "UserName" }, "mapSettings": { "locInfo": "LatLong", "sizeSettings": "duration_seconds", "sizeAggregation": "Sum", "legendMetric": "duration_seconds", "legendAggregation": "Sum", "itemColorSettings": { "type": "heatmap", "colorAggregation": "Sum", "nodeColorField": "duration_seconds", "heatmapPalette": "greenRed" } } }, "name": "query - 0 - Copy - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databasename='{DatabaseName}';\r\nAzureDiagnostics \r\n| where Category == 'ExecRequests'\r\n| where Resource == databasename\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize Session_ID=max(SessionId_s), \r\n Query_Submit_Time=max(SubmitTime_t), \r\n Query_Start_Time=max(StartTime_t), \r\n Query_End_Time=max(EndTime_t), \r\n Query_Text=max(Command_s), \r\n Status=min(Status_s),\r\n Resource_class=max(ResourceClass_s) \r\n by RequestId_s\r\n//| where Last_Status == \"Completed\"\r\n//| where Query_Text contains \"\" //Uncomment to search by query text\r\n| join kind = inner \r\n(\r\n AzureDiagnostics\r\n | where Category == 'RequestSteps'\r\n | where Resource == databasename\r\n | summarize num_steps=max(StepIndex_d), \r\n max_step_rows=max(RowCount_d), \r\n max_step_sec=max(EndTime_t-StartTime_t)/1s,\r\n Query_ElapsedTime=(max(EndTime_t) - min(StartTime_t))/1s\r\n by RequestId_s\r\n ) on RequestId_s\r\n| order by Query_Submit_Time\r\n| project Session_ID,RequestId_s,Query_Submit_Time,Query_Start_Time,EventTime = Query_End_Time,num_steps,max_step_rows,max_step_sec,Query_ElapsedTime,Status,Query = Query_Text,Resource_class\r\n| join kind = leftouter \r\n(\r\n AzureDiagnostics\r\n | where Category == 'SQLSecurityAuditEvents' and LogicalServerName_s == \"{LogicalServerName}\"\r\n | where duration_milliseconds_d > 0\r\n | extend duration_seconds = duration_milliseconds_d /1000.0\r\n | where statement_s != 'select @@version'\r\n | where statement_s != 'SELECT @@SPID;'\r\n | where server_principal_name_s has '{User}'\r\n | where application_name_s has '{Application}'\r\n | project DatabaseName= database_name_s, UserName= server_principal_name_s, EventTime= event_time_t, Host= host_name_s, duration_seconds = round(duration_seconds), Query = statement_s, QuerySource = application_name_s , affected_rows_d\r\n | project-reorder DatabaseName, UserName, Host, EventTime, duration_seconds, Query, QuerySource\r\n) on Query,EventTime\r\n | order by affected_rows_d desc\r\n\r\n\r\n", "size": 0, "title": "All Queries {User} {Application}", "noDataMessage": "Select a user to see query activity", "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 0 - Copy - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": " AzureDiagnostics\r\n | where Category == 'SQLSecurityAuditEvents' and LogicalServerName_s == \"{LogicalServerName}\"\r\n | where duration_milliseconds_d > 0\r\n| extend Duration = round(duration_milliseconds_d /1000.0)\r\n| extend TimeBin = case (datetime_part(\"Hour\",TimeGenerated) in (6,7,8,9,10,11,12), \"Morning_6-12\", datetime_part(\"Hour\",TimeGenerated) in (13,14,15,16,17,18), \"Afternoon_12-18\", \"Overnight_18-6\")\r\n| where server_principal_name_s has '{User}'\r\n| where application_name_s has '{Application}'\r\n| summarize QueryDuration = sum(Duration) by EventTime = bin(event_time_t, 1d), TimeBin", "size": 0, "title": "Query Activity by time - sum(Duration) {User} {Application}", "noDataMessage": "Select a user to see query activity", "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "barchart" }, "name": "query - 0 - Copy" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "QueryActivity" }, "name": "QueryActivityGroup", "styleSettings": { "showBorder": true } } ], "fallbackResourceIds": [ "azure monitor" ], "$schema": "https://github.com/Microsoft/Application-Insights-Workbooks/blob/master/schema/workbook.json" } ================================================ FILE: Monitor_Workbooks/archive/SynapseWorkbook_WIP_v02.json ================================================ { "version": "Notebook/1.0", "items": [ { "type": 9, "content": { "version": "KqlParameterItem/1.0", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "parameters": [ { "id": "28da10ec-a308-47f5-9819-92ebf810b292", "version": "KqlParameterItem/1.0", "name": "LogAnalyticsSubscription", "type": 6, "value": null, "typeSettings": { "additionalResourceOptions": [], "includeAll": false, "showDefault": false }, "timeContext": { "durationMs": 86400000 } }, { "id": "e383ed24-52ae-447b-9b80-51fd3ab6b919", "version": "KqlParameterItem/1.0", "name": "LogAnalyticsWorkspace", "type": 5, "query": "Resources\r\n| where type == 'microsoft.operationalinsights/workspaces'\r\n| project id\r\n", "crossComponentResources": [ "{LogAnalyticsSubscription}" ], "value": null, "typeSettings": { "additionalResourceOptions": [], "showDefault": false }, "timeContext": { "durationMs": 86400000 }, "queryType": 1, "resourceType": "microsoft.resourcegraph/resources" }, { "id": "9b9fe566-0f52-4a75-a35b-a79c50c6a6f0", "version": "KqlParameterItem/1.0", "name": "DatabaseResourceName", "type": 5, "query": "AzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| distinct ResourceId", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "value": null, "typeSettings": { "additionalResourceOptions": [], "showDefault": false }, "timeContext": { "durationMs": 86400000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "id": "f5852627-70ca-4959-8d60-53b48864603f", "version": "KqlParameterItem/1.0", "name": "TimeRange", "type": 4, "isGlobal": true, "value": { "durationMs": 14400000 }, "typeSettings": { "selectableValues": [ { "durationMs": 300000 }, { "durationMs": 900000 }, { "durationMs": 1800000 }, { "durationMs": 3600000 }, { "durationMs": 14400000 }, { "durationMs": 43200000 }, { "durationMs": 86400000 }, { "durationMs": 172800000 }, { "durationMs": 259200000 }, { "durationMs": 604800000 }, { "durationMs": 1209600000 }, { "durationMs": 2419200000 }, { "durationMs": 2592000000 } ], "allowCustom": true }, "timeContext": { "durationMs": 86400000 } }, { "id": "6da2f63f-45a3-4b37-9108-5e8b7e358d85", "version": "KqlParameterItem/1.0", "name": "DatabaseName", "type": 1, "query": "AzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where ResourceId == '{DatabaseResourceName}'\r\n| distinct Resource ", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "id": "8bba835b-f319-43b3-8ec6-4e051fc6d446", "version": "KqlParameterItem/1.0", "name": "LogicalServerName", "type": 1, "query": "AzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where ResourceId == '{DatabaseResourceName}'\r\n| distinct LogicalServerName_s", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.resourcegraph/resources" }, "name": "parameters - 2" }, { "type": 11, "content": { "version": "LinkItem/1.0", "style": "tabs", "links": [ { "id": "202cbbc0-8d63-416d-89ed-451d6fe7c4b3", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Workload", "subTarget": "Workload", "preText": "Workload", "style": "link" }, { "id": "a7901bd0-a1f4-4491-b953-57555d764e00", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Workload Management", "subTarget": "WorkloadManagement", "style": "link" }, { "id": "45e12a14-8548-4477-aae3-c142b906dc9f", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "TempDB", "subTarget": "TempDB", "style": "link" }, { "id": "79d10d16-0696-4214-b306-c7a0e46cd64f", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Query Investigation", "subTarget": "QueryInvestigation", "style": "link" }, { "id": "9ef8f730-d73d-432b-9b75-55095d1155f2", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Replicated Tables", "subTarget": "ReplicatedTables", "style": "link" }, { "id": "31c1cf1c-74b5-44e2-ba9a-9497834ca3dc", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Query Comparison", "subTarget": "QueryComparison", "style": "link" }, { "id": "482ccc46-8a10-4ace-bfd6-63ac73b380af", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Query Activity", "subTarget": "QueryActivity", "style": "link" } ] }, "name": "links - 0" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "title": "Workload", "items": [ { "type": 10, "content": { "chartId": "workbook90867bfc-5c33-464f-ac31-2c2e006b97f4", "version": "MetricsItem/2.0", "size": 0, "chartType": 2, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 14400000 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-dwu_consumption_percent", "aggregation": 3, "columnName": "DWU Percentage" }, { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-cpu_percent", "aggregation": 3 }, { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-physical_data_read_percent", "aggregation": 3 } ], "title": "DWU Resource Utilization", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "name": "metric - 1" }, { "type": 10, "content": { "chartId": "workbookb954d4a0-82ef-4409-88fb-837aaff80c8d", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 14400000 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-active_queries", "aggregation": 1, "splitBy": null }, { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-queued_queries", "aggregation": 1 } ], "title": "Active and Queued Queries", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "name": "metric - 1" }, { "type": 10, "content": { "chartId": "workbookb954d4a0-82ef-4409-88fb-837aaff80c8d", "version": "MetricsItem/2.0", "size": 0, "chartType": 3, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 14400000 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-local_tempdb_usage_percent", "aggregation": 3, "splitBy": null, "columnName": "TempDB Utilization Percentage" } ], "title": "TempDB Utilization", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "name": "metric - 1 - Copy" }, { "type": 10, "content": { "chartId": "workbookb954d4a0-82ef-4409-88fb-837aaff80c8d", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 14400000 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-WorkloadManagement-wlg_allocation_relative_to_system_percent", "aggregation": 3, "splitBy": null } ], "title": "Workload Group Utilization", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "name": "Workload Group Utilization" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databaseName = '{DatabaseName}';\r\n//Long-Running Queries - Just Actual Queries\r\n//If 'Command' is empty - you need to set a bigger time window, the older record with the command is outside of your window\r\nAzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where Resource == databaseName\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize Session_ID=any(SessionId_s),\r\n Request_ID=any(RequestId_s),\r\n Submit_Time=max(SubmitTime_t),\r\n Start_Time=max(StartTime_t),\r\n End_Time=max(EndTime_t),\r\n Command=any(Command_s),\r\n Status=min(Status_s), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType_s),\r\n Resource_class=any(ResourceClass_s)\r\n by RequestId_s\r\n| summarize ElapsedTime_min=bin(anyif(((End_Time - Start_Time)/1m),Start_Time > ago(30d)),1),\r\n Session_ID=any(Session_ID), \r\n Submit_Time=any(Submit_Time) ,\r\n Start_Time=any(Start_Time), \r\n End_Time=any(End_Time),\r\n Command=any(Command),\r\n Status=any(Status),\r\n Statement_Type=any(Statement_Type)\r\n ,Resource_class=any(Resource_class) \r\n by Request_ID\r\n| where End_Time > ago(365d)\r\n| summarize count() by Status, bin(End_Time,5m)\r\n| render timechart \r\n", "size": 0, "title": "Query Completion Count by End Time - 5m buckets", "color": "redBright", "timeContext": { "durationMs": 14400000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "chartSettings": { "seriesLabelSettings": [ { "seriesName": "Completed", "color": "green" }, { "seriesName": "Failed", "color": "red" }, { "seriesName": "Cancelled", "color": "yellow" } ] } }, "name": "query - 4" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": " AzureDiagnostics\r\n | where Category == 'SQLSecurityAuditEvents' and LogicalServerName_s == '{LogicalServerName}'\r\n //| where duration_milliseconds_d > 0\r\n | extend duration_seconds = duration_milliseconds_d /1000.0\r\n | where statement_s != 'select @@version'\r\n | where statement_s != 'SELECT @@SPID;'\r\n | summarize sum(affected_rows_d) by bin(TimeGenerated,1h)", "size": 0, "timeContext": { "durationMs": 259200000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "categoricalbar" }, "name": "query - 7" }, { "type": 10, "content": { "chartId": "workbook1afc57e6-0b32-4968-b299-db319bd21635", "version": "MetricsItem/2.0", "size": 0, "chartType": 2, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 14400000 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-connection_successful", "aggregation": 1, "splitBy": null }, { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-connection_failed", "aggregation": 1 } ], "title": "Successful and Failed Connections", "gridSettings": { "rowLimit": 10000 } }, "name": "metric - 5" }, { "type": 10, "content": { "chartId": "workbook993837ad-66d6-4cbc-ae1a-7c3f6623236b", "version": "MetricsItem/2.0", "size": 0, "chartType": 2, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 14400000 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-cache_used_percent", "aggregation": 3, "splitBy": null }, { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-cache_hit_percent", "aggregation": 3 } ], "title": "Adaptive Cache Used vs Hit Percentage", "gridSettings": { "rowLimit": 10000 } }, "name": "metric - 6" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "Workload" }, "name": "group - 1" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "title": "TempDB ", "items": [ { "type": 10, "content": { "chartId": "workbook4a9cf761-cce2-45b2-8947-8a9428ec7e1c", "version": "MetricsItem/2.0", "size": 0, "chartType": 3, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 14400000 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-local_tempdb_usage_percent", "aggregation": 3, "splitBy": null, "columnName": "TempDB Util" }, { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-local_tempdb_usage_percent", "aggregation": 4, "columnName": "TempDB Util" } ], "title": "TempDB Max and Avg Utilization", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "name": "metric - 0" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "19ee48f5-8f4e-4939-a0ef-c6bf656a93f9", "version": "KqlParameterItem/1.0", "name": "WeightParameter", "type": 1, "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 } }, { "id": "00553ec8-1a41-4dd9-a024-d607639c9bbb", "version": "KqlParameterItem/1.0", "name": "RequestID", "type": 1, "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 } } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 3" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databaseName = '{DatabaseName}';\r\n//Weighted query steps\r\nAzureDiagnostics\r\n| where Category == 'RequestSteps'\r\n| where Resource == databaseName\r\n| where RowCount_d > 0\r\n| summarize sum(RowCount_d) by RequestId_s, OperationType_s\r\n| order by sum_RowCount_d desc\r\n| limit 20\r\n| render columnchart ", "size": 0, "title": "20 Largest Query Steps by Most Rows Moved", "timeContext": { "durationMs": 14400000 }, "timeContextFromParameter": "TimeRange", "exportFieldName": "Request_ID", "exportParameterName": "RequestID", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "chartSettings": { "xAxis": "RequestId_s", "group": "OperationType_s", "createOtherGroup": 20, "showLegend": true } }, "name": "query - 1 - Copy" }, { "type": 11, "content": { "version": "LinkItem/1.0", "style": "nav", "links": [ { "id": "c98d3722-9907-43ab-9306-1957d6f7f858", "cellValue": "WeightParameter", "linkTarget": "parameter", "linkLabel": "Weighted Rowcounts", "subTarget": "Weighted", "preText": "", "postText": "", "style": "secondary" }, { "id": "a06ae99a-ad62-45e9-8c25-c219b81f59c0", "cellValue": "WeightParameter", "linkTarget": "parameter", "linkLabel": "Unweighted Rowcounts", "subTarget": "Unweighted", "preText": "", "postText": "", "style": "secondary" } ] }, "name": "links - 3" }, { "type": 1, "content": { "json": "Current Setting: {WeightParameter}", "style": "info" }, "name": "text - 4" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databaseName = '{DatabaseName}';\r\n//Weighted query steps\r\nlet RequestSteps = AzureDiagnostics\r\n| where Category == 'RequestSteps'\r\n| where Resource == databaseName\r\n| where RowCount_d > 100000000\r\n| extend Step_Elapsed_Min = round((EndTime_t - StartTime_t)/1m, 2)\r\n| extend Weighted_cnt = iff('{WeightParameter}'=='Weighted',(case(OperationType_s == 'BroadcastMoveOperation', (RowCount_d*20), RowCount_d)),RowCount_d)\r\n| project-rename StepStatus = Status_s, StepStart = StartTime_t, StepEnd = EndTime_t//, StepResource = Resource\r\n| top 100 by Weighted_cnt desc\r\n| order by Weighted_cnt desc\r\n| project Request_ID=RequestId_s,OperationType_s, RowCount_d,Weighted_cnt,Step_Elapsed_Min, StepStart, StepEnd, StepStatus, StepIndex_d,Resource;\r\nRequestSteps | join (AzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where Resource == databaseName\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize Session_ID=any(SessionId_s),\r\n Request_ID=any(RequestId_s),\r\n Submit_Time=max(SubmitTime_t),\r\n Start_Time=max(StartTime_t),\r\n End_Time=max(EndTime_t),\r\n Command=any(Command_s),\r\n Status=min(Status_s), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType_s),\r\n Resource_class=any(ResourceClass_s)\r\n by RequestId_s\r\n| summarize Session_ID=any(Session_ID), Submit_Time=any(Submit_Time) ,Start_Time=any(Start_Time), End_Time=any(End_Time),Command=any(Command),Status=any(Status),Statement_Type=any(Statement_Type),Resource_class=any(Resource_class) by Request_ID\r\n//| order by Step_Elapsed_Min desc\r\n| extend Request_Elapsed_Min = round((End_Time - Start_Time)/1m, 2)\r\n| project-rename ReqStatus = Status, ReqStart = Start_Time, ReqEnd = End_Time\r\n) on Request_ID\r\n| project-reorder Session_ID, Request_ID, Request_Elapsed_Min, ReqStart, ReqEnd, ReqStatus,StepIndex_d, OperationType_s, RowCount_d,Weighted_cnt,Step_Elapsed_Min, StepStart, StepEnd, StepStatus, Statement_Type, Command, Resource_class\r\n| order by Weighted_cnt desc\r\n| limit 20", "size": 3, "title": "20 Largest Query Steps by Most Rows Moved", "timeContext": { "durationMs": 14400000 }, "timeContextFromParameter": "TimeRange", "exportFieldName": "Request_ID1", "exportParameterName": "RequestID", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "sortBy": [ { "itemKey": "Weighted_cnt", "sortOrder": 2 } ] }, "sortBy": [ { "itemKey": "Weighted_cnt", "sortOrder": 2 } ] }, "name": "query - 1" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databaseName = '{DatabaseName}';\r\n//Long-Running Queries - Just Actual Queries\r\n//If 'Command' is empty - you need to set a bigger time window, the older record with the command is outside of your window\r\nAzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where Resource == databaseName\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize Session_ID=any(SessionId_s),\r\n Request_ID=any(RequestId_s),\r\n Submit_Time=max(SubmitTime_t),\r\n Start_Time=max(StartTime_t),\r\n End_Time=max(EndTime_t),\r\n Command=any(Command_s),\r\n Status=min(Status_s), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType_s),\r\n Resource_class=any(ResourceClass_s)\r\n by RequestId_s\r\n| summarize ElapsedTime_min=bin(anyif(((End_Time - Start_Time)/1m),Start_Time > ago(30d)),1),\r\n Session_ID=any(Session_ID), \r\n Submit_Time=any(Submit_Time) ,\r\n Start_Time=any(Start_Time), \r\n End_Time=any(End_Time),\r\n Command=any(Command),\r\n Status=any(Status),\r\n Statement_Type=any(Statement_Type)\r\n ,Resource_class=any(Resource_class) \r\n by Request_ID\r\n| where Request_ID == '{RequestID}'\r\n\r\n", "size": 4, "title": "Selected Query", "noDataMessage": "Select a query above to view details", "timeContext": { "durationMs": 14400000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "35%" } } ] } }, "name": "query - 6" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics\r\n| where Category == 'RequestSteps'\r\n| where Resource == '{DatabaseName}'\r\n| where RequestId_s == '{RequestID}' //Put your QueryID here\r\n| where Status_s != 'Running'\r\n| summarize max(StartTime_t),max(EndTime_t),max(RequestId_s),max(OperationType_s),max(RowCount_d),max(Command_s),max(Status_s) by StepIndex_d\r\n| order by StepIndex_d asc", "size": 3, "title": "Query Plan", "noDataMessage": "Select a query above to view the plan", "timeContext": { "durationMs": 14400000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 7" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "TempDB" }, "name": "group - 3" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "title": "Query Investigation", "items": [ { "type": 1, "content": { "json": "## Use the following fields to search either using a query text snippet or using a Request ID. " }, "name": "text - 4" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "29880874-2d41-4bd5-bf22-3e47ae8b1145", "version": "KqlParameterItem/1.0", "name": "QueryTextSnippet", "type": 1, "value": "", "timeContext": { "durationMs": 86400000 } }, { "id": "0c2128d0-d979-4562-a28c-e7ceb955f126", "version": "KqlParameterItem/1.0", "name": "RequestIdSearch", "type": 1, "value": "" } ], "style": "formVertical", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "customWidth": "60", "name": "parameters - 3" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics \r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize \r\n Session_ID=max(SessionId_s), \r\n Request_ID=max(RequestId_s), \r\n Submit_Time=max(SubmitTime_t), \r\n Start_Time=max(StartTime_t),\r\n End_Compile_Time=max(EndCompileTime_t), \r\n End_Time=max(EndTime_t), \r\n Command=max(Command_s), \r\n Last_Status=min(Status_s),\r\n Statement_Type=max(StatementType_s),\r\n Resource_class=max(ResourceClass_s) \r\n by RequestId_s\r\n| where Command has '{QueryTextSnippet}'\r\nand RequestId_s has '{RequestIdSearch}'\r\n| extend elapsedTime_sec = iif(End_Time > ago(365d),(End_Time - Submit_Time)/1s,real(null)) \r\n| extend CompileTime_sec = (End_Compile_Time - Submit_Time)/1s\r\n| order by elapsedTime_sec\r\n| summarize \r\n Executions = count(),\r\n Max_Elapsed_Time_sec = bin(max(elapsedTime_sec),1),\r\n Min_Elapsed_Time_sec = bin(min(elapsedTime_sec),1),\r\n Variability_sec=bin((max(elapsedTime_sec)-min(elapsedTime_sec)),1),\r\n SampleQID = any(RequestId_s)\r\n by Command\r\n| order by Max_Elapsed_Time_sec\r\n\r\n\r\n", "size": 0, "title": "Matching Queries", "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "exportFieldName": "SampleQID", "exportParameterName": "SampleQID", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "50%" } } ] } }, "name": "query - 0" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics \r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s !in ('Batch','Execute')\r\n| where RequestId_s == '{SampleQID}'\r\n| summarize \r\n Session_ID=max(SessionId_s), \r\n Request_ID=max(RequestId_s), \r\n Submit_Time=max(SubmitTime_t), \r\n Start_Time=max(StartTime_t),\r\n End_Compile_Time=max(EndCompileTime_t), \r\n End_Time=max(EndTime_t), \r\n Command=max(Command_s), \r\n Last_Status=min(Status_s),\r\n Statement_Type=max(StatementType_s),\r\n Resource_class=max(ResourceClass_s) \r\n by RequestId_s\r\n| extend elapsedTime_sec = iif(End_Time > ago(365d),(End_Time - Submit_Time)/1s,real(null)) \r\n| extend CompileTime_sec = (End_Compile_Time - Submit_Time)/1s\r\n| join kind=inner\r\n (AzureDiagnostics \r\n | where Category == 'ExecRequests'\r\n | where Resource == '{DatabaseName}'\r\n | where StatementType_s !in ('Batch','Execute')\r\n | summarize \r\n Session_ID=max(SessionId_s), \r\n Request_ID=max(RequestId_s), \r\n Submit_Time=max(SubmitTime_t), \r\n Start_Time=max(StartTime_t),\r\n End_Compile_Time=max(EndCompileTime_t), \r\n End_Time=max(EndTime_t), \r\n Command=max(Command_s), \r\n Last_Status=min(Status_s),\r\n Statement_Type=max(StatementType_s),\r\n Resource_class=max(ResourceClass_s) \r\n by RequestId_s\r\n | extend elapsedTime_sec = (End_Time - Submit_Time)/1s\r\n | extend elapsedTime_sec = iif(End_Time > ago(365d),(End_Time - Submit_Time)/1s,real(null)) \r\n | extend CompileTime_sec = (End_Compile_Time - Submit_Time)/1s\r\n )\r\non Command \r\n| project Request_ID1,Session_ID1,Submit_Time1,Start_Time1,End_Compile_Time1,End_Time1,Last_Status1,Statement_Type1,Resource_class1,elapsedTime_sec1,CompileTime_sec1\r\n", "size": 0, "title": "All Executions of Selected Query", "noDataMessage": "Select a query above to see individual executions", "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "exportFieldName": "Request_ID1", "exportParameterName": "RequestId", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "sortBy": [] }, "name": "query - 0 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics\r\n| where Category == 'RequestSteps'\r\n| where Resource == '{DatabaseName}'\r\n| where RequestId_s == '{RequestId}'\r\n//| where Status_s != 'Running'\r\n| summarize max(StartTime_t),max(EndTime_t),max(RequestId_s),max(OperationType_s),max(RowCount_d),max(Command_s),max(Status_s) by StepIndex_d\r\n| order by StepIndex_d asc", "size": 3, "title": "Query Plan for Selected Query", "noDataMessage": "Select a Query Above to See the Query Plan", "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 0 - Copy - Copy" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "QueryInvestigation" }, "name": "group - 4", "styleSettings": { "showBorder": true } }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "title": "Replicated Tables", "items": [ { "type": 1, "content": { "json": "All Charts on this page are based on the last 7 days of data", "style": "info" }, "name": "text - 5" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Build cache count by day\r\nAzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s == 'BuildReplicatedTableCache'\r\n| where Command_s != \"\"\r\n| where ResourceClass_s != \"\"\r\n| project Command_s,TimeGenerated,RequestId_s\r\n| summarize LastRebuild=max(TimeGenerated),RebuildCount=count(RequestId_s) by Command_s\r\n| order by RebuildCount desc\r\n| limit 15\r\n", "size": 3, "title": "Top 15 Most Rebuilds by Table", "timeContext": { "durationMs": 604800000 }, "exportFieldName": "Command_s", "exportParameterName": "QueryText", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command_s", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "40%" } } ] } }, "name": "query - 0" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Build cache count by day\r\nAzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s == 'BuildReplicatedTableCache'\r\n| where Command_s == \"{QueryText}\"\r\n| where ResourceClass_s != \"\"\r\n| project Command_s,TimeGenerated,RequestId_s\r\n| summarize count() by Command_s,bin(TimeGenerated,24h)\r\n| limit 20\r\n| render timechart", "size": 0, "title": "Rebuilds per Day for Selected Table", "noDataMessage": "Select a query above to see runs by day", "timeContext": { "durationMs": 604800000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "chartSettings": { "group": "Command_s", "createOtherGroup": 20, "ySettings": { "min": 0 } } }, "name": "query - 0 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Build cache count by day\r\nAzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s == 'BuildReplicatedTableCache'\r\n| where Command_s != \"\"\r\n| where ResourceClass_s != \"\"\r\n| project Command_s,TimeGenerated,RequestId_s\r\n| summarize count() by Command_s, bin(TimeGenerated,24h)\r\n| where count_ > 7\r\n| order by count_ desc\r\n\r\n", "size": 2, "title": "Rebuild Count by Table by Day", "timeContext": { "durationMs": 604800000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "categoricalbar", "gridSettings": { "sortBy": [ { "itemKey": "count_", "sortOrder": 1 } ] }, "sortBy": [ { "itemKey": "count_", "sortOrder": 1 } ], "tileSettings": { "showBorder": false, "titleContent": { "columnMatch": "Command_s", "formatter": 1 }, "leftContent": { "columnMatch": "count_", "formatter": 12, "formatOptions": { "palette": "auto" }, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "graphSettings": { "type": 0, "topContent": { "columnMatch": "Command_s", "formatter": 1 }, "centerContent": { "columnMatch": "count_", "formatter": 1, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "chartSettings": { "group": "Command_s", "createOtherGroup": 99, "showDataPoints": true } }, "name": "query - 0 - Copy - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Long-Running Queries - Just Actual Queries\r\nAzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize Session_ID=max(SessionId_s), Request_ID=max(RequestId_s), Submit_Time=max(SubmitTime_t), Start_Time=max(StartTime_t), End_Time=max(EndTime_t), Command=max(Command_s), Statement_Type=max(StatementType_s), Resource_class=max(ResourceClass_s) by RequestId_s\r\n| join kind= inner\r\n(\r\n AzureDiagnostics\r\n | where Category == 'ExecRequests'\r\n | where Resource == '{DatabaseName}'\r\n //| where StatementType_s !in ('Batch','Execute')\r\n | where StatementType_s == 'BuildReplicatedTableCache'\r\n | where EndTime_t > ago(7d)\r\n | where StartTime_t > ago(7d)\r\n | extend elapsedTime_min = (EndTime_t - StartTime_t)/1m\r\n //| extend elapsedTime_min = elapsedTime/1m\r\n | order by elapsedTime_min desc\r\n | project Request_ID=RequestId_s,elapsedTime_min \r\n)\r\non Request_ID\r\n| order by elapsedTime_min desc\r\n| project Request_ID,Submit_Time,Start_Time,End_Time,Elapsed_Time=round(elapsedTime_min,1) ,Command\r\n| limit 15\r\n", "size": 3, "title": "Top 15 Elapsed Time per Rebuild", "timeContext": { "durationMs": 604800000 }, "exportFieldName": "Request_ID", "exportParameterName": "RequestId", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "40%" } } ] } }, "name": "query - 3" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics\r\n| where Category == 'RequestSteps'\r\n| where Resource == '{DatabaseName}'\r\n| where RequestId_s == '{RequestId}'\r\n| where Status_s != 'Running'\r\n| summarize max(StartTime_t),max(EndTime_t),max(RequestId_s),max(OperationType_s),max(RowCount_d),max(Command_s),max(Status_s) by StepIndex_d\r\n| order by StepIndex_d asc", "size": 3, "title": "Query Plan for Selected Query", "noDataMessage": "Select a query above to view plan", "timeContext": { "durationMs": 604800000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 4" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "ReplicatedTables" }, "name": "ReplicatedTablesGroup" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 10, "content": { "chartId": "workbook72446028-6edb-4cb0-8952-e0c13bda488f", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 14400000 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-WorkloadManagement-wlg_allocation_relative_to_system_percent", "aggregation": 3, "splitBy": null } ], "title": "Workload Group Allocation By System Percent", "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "name": "metric - 0" }, { "type": 10, "content": { "chartId": "workbookc898119a-7381-469d-b51a-d505b4f80e73", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 0 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-WorkloadManagement-wlg_active_queries", "aggregation": 1, "splitBy": "WorkloadGroupName" } ], "title": "Query Count by Workload Group", "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "name": "metric - 1" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "parameters": [ { "id": "6f50577d-7b00-4e4a-acf9-d45c7a5ee813", "version": "KqlParameterItem/1.0", "name": "WorkloadGroup", "type": 10, "query": "AzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n and ResourceClass_s != \"\"\r\n| distinct ResourceClass_s", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "typeSettings": { "additionalResourceOptions": [] }, "timeContext": { "durationMs": 86400000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "value": "wg_batch_M" } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 2" }, { "type": 10, "content": { "chartId": "workbook3da1d18a-1bf5-46c5-b3b7-211f71d329cc", "version": "MetricsItem/2.0", "size": 0, "chartType": 2, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 0 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-WorkloadManagement-wlg_active_queries", "aggregation": 1, "splitBy": null }, { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-WorkloadManagement-wlg_queued_queries", "aggregation": 1 } ], "filters": [ { "id": "1", "key": "WorkloadGroupName", "operator": 0, "values": [ "WorkloadGroup" ] } ], "gridSettings": { "rowLimit": 10000 } }, "name": "metric - 3" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "WorkloadManagement" }, "name": "group - 6" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 1, "content": { "json": "## Select a Principal or Application name to filter results - leave to 'unset' to view all results" }, "name": "text - 5" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "parameters": [ { "id": "8d25c043-d1ff-4546-a1fa-f4bcbfdab8af", "version": "KqlParameterItem/1.0", "name": "User", "type": 2, "description": "User to filter subsequent queries - leave to 'unset' for all users", "query": "AzureDiagnostics\r\n| where Category == 'SQLSecurityAuditEvents' and LogicalServerName_s == '{LogicalServerName}'\r\n| summarize by server_principal_name_s", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "value": null, "typeSettings": { "additionalResourceOptions": [], "showDefault": false }, "timeContext": { "durationMs": 86400000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "id": "aa766d64-693f-4024-b4a4-b5b56b28376b", "version": "KqlParameterItem/1.0", "name": "Application", "type": 2, "query": "AzureDiagnostics\r\n| where Category == 'SQLSecurityAuditEvents' and LogicalServerName_s == '{LogicalServerName}'\r\n| summarize by application_name_s", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "value": null, "typeSettings": { "additionalResourceOptions": [] }, "timeContext": { "durationMs": 86400000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "customWidth": "30", "name": "parameters - 1" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics\r\n| where Category == 'SQLSecurityAuditEvents' and LogicalServerName_s == \"{LogicalServerName}\"\r\n| where duration_milliseconds_d > 0\r\n| extend duration_seconds = duration_milliseconds_d /1000.0\r\n| where statement_s != 'select @@version'\r\n| where statement_s != 'SELECT @@SPID;'\r\n| where server_principal_name_s has '{User}'\r\n| where application_name_s has '{Application}'\r\n| project server_principal_name_s, succeeded_s, event_time_t, LogicalServerName_s, duration_milliseconds_d, duration_seconds, affected_rows_d, statement_s, application_name_s\r\n| summarize duration_seconds = round(sum(duration_seconds)) , query_count = count(statement_s) by EventDay = bin(event_time_t,1d), UserName = server_principal_name_s, Application = application_name_s \r\n| order by EventDay, duration_seconds desc", "size": 0, "title": "Query Summary for Selected User {User} {Application}", "noDataMessage": "Select a user to see query activity", "timeContext": { "durationMs": 14400000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 0 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics\r\n| where Category == 'SQLSecurityAuditEvents' and LogicalServerName_s == \"{LogicalServerName}\"\r\n| where duration_milliseconds_d > 0\r\n| extend duration_seconds = duration_milliseconds_d /1000.0\r\n| where statement_s != 'select @@version'\r\n| where statement_s != 'SELECT @@SPID;'\r\n| where server_principal_name_s has '{User}'\r\n| where application_name_s has '{Application}'\r\n| project server_principal_name_s, succeeded_s, event_time_t, LogicalServerName_s, duration_milliseconds_d, duration_seconds, affected_rows_d, statement_s, application_name_s\r\n| summarize duration_seconds = round(sum(duration_seconds)) , query_count = count(statement_s) by EventDay = bin(event_time_t,1d), UserName = server_principal_name_s, Application = application_name_s \r\n| order by EventDay, duration_seconds desc", "size": 0, "title": "Query Summary for Selected User {User} {Application}", "noDataMessage": "Select a user to see query activity", "timeContext": { "durationMs": 14400000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "unstackedbar", "tileSettings": { "showBorder": false, "titleContent": { "columnMatch": "UserName", "formatter": 1 }, "leftContent": { "columnMatch": "duration_seconds", "formatter": 12, "formatOptions": { "palette": "auto" }, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "graphSettings": { "type": 0, "topContent": { "columnMatch": "UserName", "formatter": 1 }, "centerContent": { "columnMatch": "duration_seconds", "formatter": 1, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "chartSettings": { "xAxis": "UserName" }, "mapSettings": { "locInfo": "LatLong", "sizeSettings": "duration_seconds", "sizeAggregation": "Sum", "legendMetric": "duration_seconds", "legendAggregation": "Sum", "itemColorSettings": { "type": "heatmap", "colorAggregation": "Sum", "nodeColorField": "duration_seconds", "heatmapPalette": "greenRed" } } }, "name": "query - 0 - Copy - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databasename='{DatabaseName}';\r\nAzureDiagnostics \r\n| where Category == 'ExecRequests'\r\n| where Resource == databasename\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize Session_ID=max(SessionId_s), \r\n Query_Submit_Time=max(SubmitTime_t), \r\n Query_Start_Time=max(StartTime_t), \r\n Query_End_Time=max(EndTime_t), \r\n Query_Text=max(Command_s), \r\n Status=min(Status_s),\r\n Resource_class=max(ResourceClass_s) \r\n by RequestId_s\r\n//| where Last_Status == \"Completed\"\r\n//| where Query_Text contains \"\" //Uncomment to search by query text\r\n| join kind = inner \r\n(\r\n AzureDiagnostics\r\n | where Category == 'RequestSteps'\r\n | where Resource == databasename\r\n | summarize num_steps=max(StepIndex_d), \r\n max_step_rows=max(RowCount_d), \r\n max_step_sec=max(EndTime_t-StartTime_t)/1s,\r\n Query_ElapsedTime=(max(EndTime_t) - min(StartTime_t))/1s\r\n by RequestId_s\r\n ) on RequestId_s\r\n| order by Query_Submit_Time\r\n| project Session_ID,RequestId_s,Query_Submit_Time,Query_Start_Time,EventTime = Query_End_Time,num_steps,max_step_rows,max_step_sec,Query_ElapsedTime,Status,Query = Query_Text,Resource_class\r\n| join kind = leftouter \r\n(\r\n AzureDiagnostics\r\n | where Category == 'SQLSecurityAuditEvents' and LogicalServerName_s == \"{LogicalServerName}\"\r\n | where duration_milliseconds_d > 0\r\n | extend duration_seconds = duration_milliseconds_d /1000.0\r\n | where statement_s != 'select @@version'\r\n | where statement_s != 'SELECT @@SPID;'\r\n | where server_principal_name_s has '{User}'\r\n | where application_name_s has '{Application}'\r\n | project DatabaseName= database_name_s, UserName= server_principal_name_s, EventTime= event_time_t, Host= host_name_s, duration_seconds = round(duration_seconds), Query = statement_s, QuerySource = application_name_s , affected_rows_d\r\n | project-reorder DatabaseName, UserName, Host, EventTime, duration_seconds, Query, QuerySource\r\n) on Query,EventTime\r\n | order by affected_rows_d desc\r\n\r\n\r\n", "size": 0, "title": "All Queries {User} {Application}", "noDataMessage": "Select a user to see query activity", "timeContext": { "durationMs": 14400000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 0 - Copy - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": " AzureDiagnostics\r\n | where Category == 'SQLSecurityAuditEvents' and LogicalServerName_s == \"{LogicalServerName}\"\r\n | where duration_milliseconds_d > 0\r\n| extend Duration = round(duration_milliseconds_d /1000.0)\r\n| extend TimeBin = case (datetime_part(\"Hour\",TimeGenerated) in (6,7,8,9,10,11,12), \"Morning_6-12\", datetime_part(\"Hour\",TimeGenerated) in (13,14,15,16,17,18), \"Afternoon_12-18\", \"Overnight_18-6\")\r\n| where server_principal_name_s has '{User}'\r\n| where application_name_s has '{Application}'\r\n| summarize QueryDuration = sum(Duration) by EventTime = bin(event_time_t, 1d), TimeBin", "size": 0, "title": "Query Activity by time - sum(Duration) {User} {Application}", "noDataMessage": "Select a user to see query activity", "timeContext": { "durationMs": 14400000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "barchart" }, "name": "query - 0 - Copy" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "QueryActivity" }, "name": "QueryActivityGroup", "styleSettings": { "showBorder": true } } ], "fallbackResourceIds": [ "azure monitor" ], "$schema": "https://github.com/Microsoft/Application-Insights-Workbooks/blob/master/schema/workbook.json" } ================================================ FILE: Monitor_Workbooks/archive/SynapseWorkbook_v1.00.json ================================================ { "version": "Notebook/1.0", "items": [ { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "28da10ec-a308-47f5-9819-92ebf810b292", "version": "KqlParameterItem/1.0", "name": "LogAnalyticsSubscription", "type": 6, "value": null, "typeSettings": { "additionalResourceOptions": [], "includeAll": true, "showDefault": false }, "timeContext": { "durationMs": 86400000 } }, { "id": "e383ed24-52ae-447b-9b80-51fd3ab6b919", "version": "KqlParameterItem/1.0", "name": "LogAnalyticsWorkspace", "type": 5, "query": "Resources\r\n| where type == 'microsoft.operationalinsights/workspaces'\r\n| project id\r\n", "crossComponentResources": [ "{LogAnalyticsSubscription}" ], "value": null, "typeSettings": { "additionalResourceOptions": [], "showDefault": false }, "timeContext": { "durationMs": 86400000 }, "queryType": 1, "resourceType": "microsoft.resourcegraph/resources" }, { "id": "9b9fe566-0f52-4a75-a35b-a79c50c6a6f0", "version": "KqlParameterItem/1.0", "name": "DatabaseResourceName", "type": 5, "query": "AzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| distinct ResourceId", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "value": null, "typeSettings": { "additionalResourceOptions": [], "showDefault": false }, "timeContext": { "durationMs": 86400000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "id": "f5852627-70ca-4959-8d60-53b48864603f", "version": "KqlParameterItem/1.0", "name": "TimeRange", "type": 4, "isGlobal": true, "value": { "durationMs": 14400000 }, "typeSettings": { "selectableValues": [ { "durationMs": 300000 }, { "durationMs": 900000 }, { "durationMs": 1800000 }, { "durationMs": 3600000 }, { "durationMs": 14400000 }, { "durationMs": 43200000 }, { "durationMs": 86400000 }, { "durationMs": 172800000 }, { "durationMs": 259200000 }, { "durationMs": 604800000 }, { "durationMs": 1209600000 }, { "durationMs": 2419200000 }, { "durationMs": 2592000000 } ], "allowCustom": true }, "timeContext": { "durationMs": 86400000 } }, { "id": "6da2f63f-45a3-4b37-9108-5e8b7e358d85", "version": "KqlParameterItem/1.0", "name": "DatabaseName", "type": 1, "query": "AzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where ResourceId == '{DatabaseResourceName}'\r\n| distinct Resource ", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "id": "8bba835b-f319-43b3-8ec6-4e051fc6d446", "version": "KqlParameterItem/1.0", "name": "LogicalServerName", "type": 1, "query": "AzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where ResourceId == '{DatabaseResourceName}'\r\n| distinct LogicalServerName_s", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 2" }, { "type": 11, "content": { "version": "LinkItem/1.0", "style": "tabs", "links": [ { "id": "202cbbc0-8d63-416d-89ed-451d6fe7c4b3", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Workload", "subTarget": "Workload", "preText": "Workload", "style": "link" }, { "id": "a7901bd0-a1f4-4491-b953-57555d764e00", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Workload Management", "subTarget": "WorkloadManagement", "style": "link" }, { "id": "45e12a14-8548-4477-aae3-c142b906dc9f", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "TempDB", "subTarget": "TempDB", "style": "link" }, { "id": "9ef8f730-d73d-432b-9b75-55095d1155f2", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Replicated Tables", "subTarget": "ReplicatedTables", "style": "link" }, { "id": "79d10d16-0696-4214-b306-c7a0e46cd64f", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Query Investigation", "subTarget": "QueryInvestigation", "style": "link" }, { "id": "31c1cf1c-74b5-44e2-ba9a-9497834ca3dc", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Query Comparison", "subTarget": "QueryComparison", "style": "link" }, { "id": "482ccc46-8a10-4ace-bfd6-63ac73b380af", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Query Activity", "subTarget": "QueryActivity", "style": "link" }, { "id": "5ff681ee-e005-481f-b743-b66ab1b9d71d", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Session Investigation", "subTarget": "SessionInvestigation", "style": "link" } ] }, "name": "links - 0" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "title": "Workload", "items": [ { "type": 10, "content": { "chartId": "workbook90867bfc-5c33-464f-ac31-2c2e006b97f4", "version": "MetricsItem/2.0", "size": 0, "chartType": 2, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 0 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-dwu_consumption_percent", "aggregation": 3, "splitBy": null, "columnName": "DWU Percentage" }, { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-cpu_percent", "aggregation": 3 }, { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-physical_data_read_percent", "aggregation": 3 } ], "title": "DWU Resource Utilization", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "name": "metric - 1" }, { "type": 10, "content": { "chartId": "workbookb954d4a0-82ef-4409-88fb-837aaff80c8d", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 43200000 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-active_queries", "aggregation": 1, "splitBy": null }, { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-queued_queries", "aggregation": 1 } ], "title": "Active and Queued Queries", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "name": "metric - 1" }, { "type": 10, "content": { "chartId": "workbookb954d4a0-82ef-4409-88fb-837aaff80c8d", "version": "MetricsItem/2.0", "size": 0, "chartType": 3, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 43200000 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-local_tempdb_usage_percent", "aggregation": 3, "splitBy": null, "columnName": "TempDB Utilization Percentage" } ], "title": "TempDB Utilization", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "name": "metric - 1 - Copy" }, { "type": 10, "content": { "chartId": "workbookb954d4a0-82ef-4409-88fb-837aaff80c8d", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 43200000 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-WorkloadManagement-wlg_allocation_relative_to_system_percent", "aggregation": 3, "splitBy": "WorkloadGroupName" } ], "title": "Workload Group Utilization", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "name": "Workload Group Utilization" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databaseName = '{DatabaseName}';\r\n//Long-Running Queries - Just Actual Queries\r\n//If 'Command' is empty - you need to set a bigger time window, the older record with the command is outside of your window\r\nAzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where Resource == databaseName\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize Session_ID=any(SessionId_s),\r\n Request_ID=any(RequestId_s),\r\n Submit_Time=max(SubmitTime_t),\r\n Start_Time=max(StartTime_t),\r\n End_Time=max(EndTime_t),\r\n Command=any(Command_s),\r\n Status=min(Status_s), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType_s),\r\n Resource_class=any(ResourceClass_s)\r\n by RequestId_s\r\n| summarize ElapsedTime_min=bin(anyif(((End_Time - Start_Time)/1m),Start_Time > ago(30d)),1),\r\n Session_ID=any(Session_ID), \r\n Submit_Time=any(Submit_Time) ,\r\n Start_Time=any(Start_Time), \r\n End_Time=any(End_Time),\r\n Command=any(Command),\r\n Status=any(Status),\r\n Statement_Type=any(Statement_Type)\r\n ,Resource_class=any(Resource_class) \r\n by Request_ID\r\n| where End_Time > ago(365d)\r\n| summarize count() by Status, bin(End_Time,5m)\r\n| render timechart \r\n", "size": 0, "title": "Query Completion Count by End Time - 5m buckets", "color": "redBright", "timeContext": { "durationMs": 43200000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "chartSettings": { "seriesLabelSettings": [ { "seriesName": "Completed", "color": "green" }, { "seriesName": "Failed", "color": "red" }, { "seriesName": "Cancelled", "color": "yellow" } ] } }, "name": "query - 4" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": " AzureDiagnostics\r\n | where Category == 'SQLSecurityAuditEvents' and LogicalServerName_s == '{LogicalServerName}'\r\n //| where duration_milliseconds_d > 0\r\n | extend duration_seconds = duration_milliseconds_d /1000.0\r\n | where statement_s != 'select @@version'\r\n | where statement_s != 'SELECT @@SPID;'\r\n | summarize sum(affected_rows_d) by bin(TimeGenerated,1h)", "size": 0, "title": "Rows Processed by End Time - 1h buckets", "timeContext": { "durationMs": 259200000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "categoricalbar" }, "name": "query - 7" }, { "type": 10, "content": { "chartId": "workbook1afc57e6-0b32-4968-b299-db319bd21635", "version": "MetricsItem/2.0", "size": 0, "chartType": 2, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 43200000 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-connection_successful", "aggregation": 1, "splitBy": null }, { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-connection_failed", "aggregation": 1 } ], "title": "Successful and Failed Connections", "gridSettings": { "rowLimit": 10000 } }, "name": "metric - 5" }, { "type": 10, "content": { "chartId": "workbook993837ad-66d6-4cbc-ae1a-7c3f6623236b", "version": "MetricsItem/2.0", "size": 0, "chartType": 2, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 43200000 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-cache_used_percent", "aggregation": 3, "splitBy": null }, { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-cache_hit_percent", "aggregation": 3 } ], "title": "Adaptive Cache Used vs Hit Percentage", "gridSettings": { "rowLimit": 10000 } }, "name": "metric - 6" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "Workload" }, "name": "group - 1" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "title": "TempDB ", "items": [ { "type": 10, "content": { "chartId": "workbook4a9cf761-cce2-45b2-8947-8a9428ec7e1c", "version": "MetricsItem/2.0", "size": 0, "chartType": 3, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 604800000 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-local_tempdb_usage_percent", "aggregation": 3, "splitBy": null, "columnName": "TempDB Util" } ], "title": "TempDB Max and Avg Utilization", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "name": "metric - 0" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "19ee48f5-8f4e-4939-a0ef-c6bf656a93f9", "version": "KqlParameterItem/1.0", "name": "WeightParameter", "type": 1, "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 } }, { "id": "00553ec8-1a41-4dd9-a024-d607639c9bbb", "version": "KqlParameterItem/1.0", "name": "RequestID", "type": 1, "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 } } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 3" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databaseName = '{DatabaseName}';\r\n//Weighted query steps\r\nAzureDiagnostics\r\n| where Category == 'RequestSteps'\r\n| where Resource == databaseName\r\n| where RowCount_d > 0\r\n| summarize sum(RowCount_d) by RequestId_s, OperationType_s\r\n| order by sum_RowCount_d desc\r\n| limit 20\r\n| render columnchart ", "size": 0, "title": "20 Largest Query Steps by Most Rows Moved", "timeContext": { "durationMs": 604800000 }, "timeContextFromParameter": "TimeRange", "exportFieldName": "Request_ID", "exportParameterName": "RequestID", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "chartSettings": { "xAxis": "RequestId_s", "group": "OperationType_s", "createOtherGroup": 20, "showLegend": true } }, "name": "query - 1 - Copy" }, { "type": 11, "content": { "version": "LinkItem/1.0", "style": "nav", "links": [ { "id": "c98d3722-9907-43ab-9306-1957d6f7f858", "cellValue": "WeightParameter", "linkTarget": "parameter", "linkLabel": "Weighted Rowcounts", "subTarget": "Weighted", "preText": "", "postText": "", "style": "secondary" }, { "id": "a06ae99a-ad62-45e9-8c25-c219b81f59c0", "cellValue": "WeightParameter", "linkTarget": "parameter", "linkLabel": "Unweighted Rowcounts", "subTarget": "Unweighted", "preText": "", "postText": "", "style": "secondary" } ] }, "name": "links - 3" }, { "type": 1, "content": { "json": "Current Setting: {WeightParameter}", "style": "info" }, "name": "text - 4" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databaseName = '{DatabaseName}';\r\n//Weighted query steps\r\nlet RequestSteps = AzureDiagnostics\r\n| where Category == 'RequestSteps'\r\n| where Resource == databaseName\r\n| where RowCount_d > 100000000\r\n| extend Step_Elapsed_Min = round((EndTime_t - StartTime_t)/1m, 2)\r\n| extend Weighted_cnt = iff('{WeightParameter}'=='Weighted',(case(OperationType_s == 'BroadcastMoveOperation', (RowCount_d*20), RowCount_d)),RowCount_d)\r\n| project-rename StepStatus = Status_s, StepStart = StartTime_t, StepEnd = EndTime_t//, StepResource = Resource\r\n| top 100 by Weighted_cnt desc\r\n| order by Weighted_cnt desc\r\n| project Request_ID=RequestId_s,OperationType_s, RowCount_d,Weighted_cnt,Step_Elapsed_Min, StepStart, StepEnd, StepStatus, StepIndex_d,Resource;\r\nRequestSteps | join (AzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where Resource == databaseName\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize Session_ID=any(SessionId_s),\r\n Request_ID=any(RequestId_s),\r\n Submit_Time=max(SubmitTime_t),\r\n Start_Time=max(StartTime_t),\r\n End_Time=max(EndTime_t),\r\n Command=any(Command_s),\r\n Status=min(Status_s), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType_s),\r\n Resource_class=any(ResourceClass_s)\r\n by RequestId_s\r\n| summarize Session_ID=any(Session_ID), Submit_Time=any(Submit_Time) ,Start_Time=any(Start_Time), End_Time=any(End_Time),Command=any(Command),Status=any(Status),Statement_Type=any(Statement_Type),Resource_class=any(Resource_class) by Request_ID\r\n//| order by Step_Elapsed_Min desc\r\n| extend Request_Elapsed_Min = round((End_Time - Start_Time)/1m, 2)\r\n| project-rename ReqStatus = Status, ReqStart = Start_Time, ReqEnd = End_Time\r\n) on Request_ID\r\n| project-reorder Session_ID, Request_ID, Request_Elapsed_Min, ReqStart, ReqEnd, ReqStatus,StepIndex_d, OperationType_s, RowCount_d,Weighted_cnt,Step_Elapsed_Min, StepStart, StepEnd, StepStatus, Statement_Type, Command, Resource_class\r\n| order by Weighted_cnt desc\r\n| limit 20", "size": 3, "title": "20 Largest Query Steps by Most Rows Moved", "timeContext": { "durationMs": 604800000 }, "timeContextFromParameter": "TimeRange", "exportFieldName": "Request_ID1", "exportParameterName": "RequestID", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "sortBy": [ { "itemKey": "Weighted_cnt", "sortOrder": 2 } ] }, "sortBy": [ { "itemKey": "Weighted_cnt", "sortOrder": 2 } ] }, "name": "query - 1" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databaseName = '{DatabaseName}';\r\n//Long-Running Queries - Just Actual Queries\r\n//If 'Command' is empty - you need to set a bigger time window, the older record with the command is outside of your window\r\nAzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where Resource == databaseName\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize Session_ID=any(SessionId_s),\r\n Request_ID=any(RequestId_s),\r\n Submit_Time=max(SubmitTime_t),\r\n Start_Time=max(StartTime_t),\r\n End_Time=max(EndTime_t),\r\n Command=any(Command_s),\r\n Status=min(Status_s), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType_s),\r\n Resource_class=any(ResourceClass_s)\r\n by RequestId_s\r\n| summarize ElapsedTime_min=bin(anyif(((End_Time - Start_Time)/1m),Start_Time > ago(30d)),1),\r\n Session_ID=any(Session_ID), \r\n Submit_Time=any(Submit_Time) ,\r\n Start_Time=any(Start_Time), \r\n End_Time=any(End_Time),\r\n Command=any(Command),\r\n Status=any(Status),\r\n Statement_Type=any(Statement_Type)\r\n ,Resource_class=any(Resource_class) \r\n by Request_ID\r\n| where Request_ID == '{RequestID}'\r\n\r\n", "size": 4, "title": "Selected Query", "noDataMessage": "Select a query above to view details", "timeContext": { "durationMs": 604800000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "35%" } } ] } }, "name": "query - 6" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics\r\n| where Category == 'RequestSteps'\r\n| where Resource == '{DatabaseName}'\r\n| where RequestId_s == '{RequestID}' //Put your QueryID here\r\n| where Status_s != 'Running'\r\n| summarize max(StartTime_t),max(EndTime_t),max(RequestId_s),max(OperationType_s),max(RowCount_d),max(Command_s),max(Status_s) by StepIndex_d\r\n| order by StepIndex_d asc", "size": 3, "title": "Query Plan", "noDataMessage": "Select a query above to view the plan", "timeContext": { "durationMs": 604800000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 7" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "TempDB" }, "name": "group - 3" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "title": "Query Investigation", "items": [ { "type": 1, "content": { "json": "## Search Criteria\r\nUse the following fields to search either using a query text snippet or using a Request ID. If using a query text snippet, try to keep it as simple as possible becuase minor changes in formatting may cause your queries not to show up in the results. It's best to pick something like a table name, then choose the proper query from the list that will populate. " }, "customWidth": "50", "name": "text - 4" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "0c2128d0-d979-4562-a28c-e7ceb955f126", "version": "KqlParameterItem/1.0", "name": "RequestIdSearch", "type": 1, "value": "" }, { "id": "29880874-2d41-4bd5-bf22-3e47ae8b1145", "version": "KqlParameterItem/1.0", "name": "QueryTextSnippet", "type": 1, "value": "", "timeContext": { "durationMs": 86400000 } } ], "style": "formVertical", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "customWidth": "60", "name": "parameters - 3" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics \r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize \r\n Session_ID=max(SessionId_s), \r\n Request_ID=max(RequestId_s), \r\n Submit_Time=max(SubmitTime_t), \r\n Start_Time=max(StartTime_t),\r\n End_Compile_Time=max(EndCompileTime_t), \r\n End_Time=max(EndTime_t), \r\n Command=max(Command_s), \r\n Last_Status=min(Status_s),\r\n Statement_Type=max(StatementType_s),\r\n Resource_class=max(ResourceClass_s) \r\n by RequestId_s\r\n| where Command has '{QueryTextSnippet}'\r\nand RequestId_s has '{RequestIdSearch}'\r\n| extend elapsedTime_sec = iif(End_Time > ago(365d),(End_Time - Submit_Time)/1s,real(null)) \r\n| extend CompileTime_sec = (End_Compile_Time - Submit_Time)/1s\r\n| order by elapsedTime_sec\r\n| summarize \r\n Executions = count(),\r\n Max_Elapsed_Time_sec = bin(max(elapsedTime_sec),1),\r\n Min_Elapsed_Time_sec = bin(min(elapsedTime_sec),1),\r\n Variability_sec=bin((max(elapsedTime_sec)-min(elapsedTime_sec)),1),\r\n SampleQID = any(RequestId_s),\r\n SampleSessionID = any(Session_ID)\r\n by Command\r\n| order by Max_Elapsed_Time_sec\r\n\r\n\r\n", "size": 0, "title": "Matching Queries", "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "exportedParameters": [ { "fieldName": "SampleQID", "parameterName": "SampleQID" }, { "fieldName": "SampleSessionID", "parameterName": "Samp", "parameterType": 1 } ], "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "50%" } } ] } }, "name": "query - 0" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics \r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s !in ('Batch','Execute')\r\n| where RequestId_s == '{SampleQID}'\r\n| summarize \r\n Session_ID=max(SessionId_s), \r\n Request_ID=max(RequestId_s), \r\n Submit_Time=max(SubmitTime_t), \r\n Start_Time=max(StartTime_t),\r\n End_Compile_Time=max(EndCompileTime_t), \r\n End_Time=max(EndTime_t), \r\n Command=max(Command_s), \r\n Last_Status=min(Status_s),\r\n Statement_Type=max(StatementType_s),\r\n Resource_class=max(ResourceClass_s) \r\n by RequestId_s\r\n| extend elapsedTime_sec = iif(End_Time > ago(365d),(End_Time - Submit_Time)/1s,real(null)) \r\n| extend CompileTime_sec = (End_Compile_Time - Submit_Time)/1s\r\n| join kind=inner\r\n (AzureDiagnostics \r\n | where Category == 'ExecRequests'\r\n | where Resource == '{DatabaseName}'\r\n | where StatementType_s !in ('Batch','Execute')\r\n | summarize \r\n Session_ID=max(SessionId_s), \r\n Request_ID=max(RequestId_s), \r\n Submit_Time=max(SubmitTime_t), \r\n Start_Time=max(StartTime_t),\r\n End_Compile_Time=max(EndCompileTime_t), \r\n End_Time=max(EndTime_t), \r\n Command=max(Command_s), \r\n Last_Status=min(Status_s),\r\n Statement_Type=max(StatementType_s),\r\n Resource_class=max(ResourceClass_s) \r\n by RequestId_s\r\n | extend elapsedTime_sec = (End_Time - Submit_Time)/1s\r\n | extend elapsedTime_sec = iif(End_Time > ago(365d),(End_Time - Submit_Time)/1s,real(null)) \r\n | extend CompileTime_sec = (End_Compile_Time - Submit_Time)/1s\r\n )\r\non Command \r\n| project Request_ID1,Session_ID1,Submit_Time1,Start_Time1,End_Compile_Time1,End_Time1,Last_Status1,Statement_Type1,Resource_class1,elapsedTime_sec1,CompileTime_sec1\r\n", "size": 0, "title": "All Executions of Selected Query", "noDataMessage": "Select a query above to see individual executions", "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "exportFieldName": "Request_ID1", "exportParameterName": "RequestId", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "sortBy": [] }, "name": "query - 0 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics\r\n| where Category == 'RequestSteps'\r\n| where Resource == '{DatabaseName}'\r\n| where RequestId_s == '{RequestId}'\r\n//| where Status_s != 'Running'\r\n| summarize max(StartTime_t),max(EndTime_t),max(RequestId_s),max(OperationType_s),max(RowCount_d),max(Command_s),max(Status_s) by StepIndex_d\r\n| order by StepIndex_d asc", "size": 3, "title": "Query Plan for Selected Query", "noDataMessage": "Select a Query Above to See the Query Plan", "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 0 - Copy - Copy" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "QueryInvestigation" }, "name": "group - 4", "styleSettings": { "showBorder": true } }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "title": "Replicated Tables", "items": [ { "type": 1, "content": { "json": "All Charts on this page are based on the last 7 days of data", "style": "info" }, "name": "text - 5" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Build cache count by day\r\nAzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s == 'BuildReplicatedTableCache'\r\n| where Command_s != \"\"\r\n| where ResourceClass_s != \"\"\r\n| project Command_s,TimeGenerated,RequestId_s\r\n| summarize LastRebuild=max(TimeGenerated),RebuildCount=count(RequestId_s) by Command_s\r\n| order by RebuildCount desc\r\n| limit 15\r\n", "size": 3, "title": "Top 15 Most Rebuilds by Table", "timeContext": { "durationMs": 604800000 }, "exportFieldName": "Command_s", "exportParameterName": "QueryText", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command_s", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "40%" } } ] } }, "name": "query - 0" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Build cache count by day\r\nAzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s == 'BuildReplicatedTableCache'\r\n| where Command_s == \"{QueryText}\"\r\n| where ResourceClass_s != \"\"\r\n| project Command_s,TimeGenerated,RequestId_s\r\n| summarize count() by Command_s,bin(TimeGenerated,24h)\r\n| limit 20\r\n| render timechart", "size": 0, "title": "Rebuilds per Day for Selected Table", "noDataMessage": "Select a query above to see runs by day", "timeContext": { "durationMs": 604800000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "chartSettings": { "group": "Command_s", "createOtherGroup": 20, "ySettings": { "min": 0 } } }, "name": "query - 0 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Build cache count by day\r\nAzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s == 'BuildReplicatedTableCache'\r\n| where Command_s != \"\"\r\n| where ResourceClass_s != \"\"\r\n| project Command_s,TimeGenerated,RequestId_s\r\n| summarize count() by Command_s, bin(TimeGenerated,24h)\r\n| where count_ > 7\r\n| order by count_ desc\r\n\r\n", "size": 2, "title": "Rebuild Count by Table by Day", "timeContext": { "durationMs": 604800000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "categoricalbar", "gridSettings": { "sortBy": [ { "itemKey": "count_", "sortOrder": 1 } ] }, "sortBy": [ { "itemKey": "count_", "sortOrder": 1 } ], "tileSettings": { "showBorder": false, "titleContent": { "columnMatch": "Command_s", "formatter": 1 }, "leftContent": { "columnMatch": "count_", "formatter": 12, "formatOptions": { "palette": "auto" }, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "graphSettings": { "type": 0, "topContent": { "columnMatch": "Command_s", "formatter": 1 }, "centerContent": { "columnMatch": "count_", "formatter": 1, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "chartSettings": { "group": "Command_s", "createOtherGroup": 99, "showDataPoints": true } }, "name": "query - 0 - Copy - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Long-Running Queries - Just Actual Queries\r\nAzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize Session_ID=max(SessionId_s), Request_ID=max(RequestId_s), Submit_Time=max(SubmitTime_t), Start_Time=max(StartTime_t), End_Time=max(EndTime_t), Command=max(Command_s), Statement_Type=max(StatementType_s), Resource_class=max(ResourceClass_s) by RequestId_s\r\n| join kind= inner\r\n(\r\n AzureDiagnostics\r\n | where Category == 'ExecRequests'\r\n | where Resource == '{DatabaseName}'\r\n //| where StatementType_s !in ('Batch','Execute')\r\n | where StatementType_s == 'BuildReplicatedTableCache'\r\n | where EndTime_t > ago(7d)\r\n | where StartTime_t > ago(7d)\r\n | extend elapsedTime_min = (EndTime_t - StartTime_t)/1m\r\n //| extend elapsedTime_min = elapsedTime/1m\r\n | order by elapsedTime_min desc\r\n | project Request_ID=RequestId_s,elapsedTime_min \r\n)\r\non Request_ID\r\n| order by elapsedTime_min desc\r\n| project Request_ID,Submit_Time,Start_Time,End_Time,Elapsed_Time=round(elapsedTime_min,1) ,Command\r\n| limit 15\r\n", "size": 3, "title": "Top 15 Elapsed Time per Rebuild", "timeContext": { "durationMs": 604800000 }, "exportFieldName": "Request_ID", "exportParameterName": "RequestId", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "40%" } } ] } }, "name": "query - 3" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics\r\n| where Category == 'RequestSteps'\r\n| where Resource == '{DatabaseName}'\r\n| where RequestId_s == '{RequestId}'\r\n| where Status_s != 'Running'\r\n| summarize max(StartTime_t),max(EndTime_t),max(RequestId_s),max(OperationType_s),max(RowCount_d),max(Command_s),max(Status_s) by StepIndex_d\r\n| order by StepIndex_d asc", "size": 3, "title": "Query Plan for Selected Query", "noDataMessage": "Select a query above to view plan", "timeContext": { "durationMs": 604800000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 4" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "ReplicatedTables" }, "name": "ReplicatedTablesGroup" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "title": "Workload Management", "items": [ { "type": 10, "content": { "chartId": "workbook72446028-6edb-4cb0-8952-e0c13bda488f", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 0 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-WorkloadManagement-wlg_allocation_relative_to_system_percent", "aggregation": 3, "splitBy": null } ], "title": "Workload Group Allocation By System Percent", "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "name": "metric - 0" }, { "type": 10, "content": { "chartId": "workbookc898119a-7381-469d-b51a-d505b4f80e73", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 14400000 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-WorkloadManagement-wlg_active_queries", "aggregation": 1, "splitBy": null } ], "title": "Query Count by Workload Group", "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "name": "metric - 1" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "parameters": [ { "id": "6f50577d-7b00-4e4a-acf9-d45c7a5ee813", "version": "KqlParameterItem/1.0", "name": "WorkloadGroupName", "type": 2, "query": "AzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n and ResourceClass_s != \"\"\r\n| distinct ResourceClass_s", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "value": null, "typeSettings": { "additionalResourceOptions": [], "showDefault": false }, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 2" }, { "type": 10, "content": { "chartId": "workbook3da1d18a-1bf5-46c5-b3b7-211f71d329cc", "version": "MetricsItem/2.0", "size": 0, "chartType": 2, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 14400000 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-WorkloadManagement-wlg_active_queries", "aggregation": 1, "splitBy": null }, { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-WorkloadManagement-wlg_queued_queries", "aggregation": 1 }, { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-WorkloadManagement-wlg_allocation_relative_to_system_percent", "aggregation": 3 } ], "filters": [ { "id": "3", "key": "WorkloadGroupName", "operator": 0, "valueParam": "WorkloadGroupName" } ], "gridSettings": { "rowLimit": 10000 } }, "name": "metric - 3" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "WorkloadManagement" }, "name": "group - 6" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "title": "Query Activity", "items": [ { "type": 1, "content": { "json": "## Select a Principal or Application name to filter results - leave to 'unset' to view all results\r\nSQL Auditing must be enabled and sending to the same Log Analytics Workspace for this page to work. " }, "name": "text - 5" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "parameters": [ { "id": "8d25c043-d1ff-4546-a1fa-f4bcbfdab8af", "version": "KqlParameterItem/1.0", "name": "User", "type": 2, "description": "User to filter subsequent queries - leave to 'unset' for all users", "query": "AzureDiagnostics\r\n| where Category == 'SQLSecurityAuditEvents' and LogicalServerName_s == '{LogicalServerName}'\r\n| summarize by server_principal_name_s", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "value": null, "typeSettings": { "additionalResourceOptions": [], "showDefault": false }, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "id": "aa766d64-693f-4024-b4a4-b5b56b28376b", "version": "KqlParameterItem/1.0", "name": "Application", "type": 2, "query": "AzureDiagnostics\r\n| where Category == 'SQLSecurityAuditEvents' and LogicalServerName_s == '{LogicalServerName}'\r\n| summarize by application_name_s", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "value": null, "typeSettings": { "additionalResourceOptions": [], "showDefault": false }, "timeContext": { "durationMs": 86400000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "customWidth": "30", "name": "parameters - 1" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics\r\n| where Category == 'SQLSecurityAuditEvents' and LogicalServerName_s == \"{LogicalServerName}\"\r\n| where duration_milliseconds_d > 0\r\n| extend duration_seconds = duration_milliseconds_d /1000.0\r\n| where statement_s != 'select @@version'\r\n| where statement_s != 'SELECT @@SPID;'\r\n| where server_principal_name_s has '{User}'\r\n| where application_name_s has '{Application}'\r\n| project server_principal_name_s, succeeded_s, event_time_t, LogicalServerName_s, duration_milliseconds_d, duration_seconds, affected_rows_d, statement_s, application_name_s\r\n| summarize duration_seconds = round(sum(duration_seconds)) , query_count = count(statement_s) by EventDay = bin(event_time_t,1d), UserName = server_principal_name_s, Application = application_name_s \r\n| order by EventDay, duration_seconds desc", "size": 0, "title": "Query Summary for Selected User {User} {Application}", "noDataMessage": "Select a user to see query activity", "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 0 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics\r\n| where Category == 'SQLSecurityAuditEvents' and LogicalServerName_s == \"{LogicalServerName}\"\r\n| where duration_milliseconds_d > 0\r\n| extend duration_seconds = duration_milliseconds_d /1000.0\r\n| where statement_s != 'select @@version'\r\n| where statement_s != 'SELECT @@SPID;'\r\n| where server_principal_name_s has '{User}'\r\n| where application_name_s has '{Application}'\r\n| project server_principal_name_s, succeeded_s, event_time_t, LogicalServerName_s, duration_milliseconds_d, duration_seconds, affected_rows_d, statement_s, application_name_s\r\n| summarize duration_seconds = round(sum(duration_seconds)) , query_count = count(statement_s) by EventDay = bin(event_time_t,1d), UserName = server_principal_name_s, Application = application_name_s \r\n| order by EventDay, duration_seconds desc", "size": 0, "title": "Query Summary for Selected User {User} {Application}", "noDataMessage": "Select a user to see query activity", "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "unstackedbar", "tileSettings": { "showBorder": false, "titleContent": { "columnMatch": "UserName", "formatter": 1 }, "leftContent": { "columnMatch": "duration_seconds", "formatter": 12, "formatOptions": { "palette": "auto" }, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "graphSettings": { "type": 0, "topContent": { "columnMatch": "UserName", "formatter": 1 }, "centerContent": { "columnMatch": "duration_seconds", "formatter": 1, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "chartSettings": { "xAxis": "UserName" }, "mapSettings": { "locInfo": "LatLong", "sizeSettings": "duration_seconds", "sizeAggregation": "Sum", "legendMetric": "duration_seconds", "legendAggregation": "Sum", "itemColorSettings": { "type": "heatmap", "colorAggregation": "Sum", "nodeColorField": "duration_seconds", "heatmapPalette": "greenRed" } } }, "name": "query - 0 - Copy - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databasename='{DatabaseName}';\r\nAzureDiagnostics \r\n| where Category == 'ExecRequests'\r\n| where Resource == databasename\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize Session_ID=max(SessionId_s), \r\n Query_Submit_Time=max(SubmitTime_t), \r\n Query_Start_Time=max(StartTime_t), \r\n Query_End_Time=max(EndTime_t), \r\n Query_Text=max(Command_s), \r\n Status=min(Status_s),\r\n Resource_class=max(ResourceClass_s) ,\r\n Query_ElapsedTime_s=round((max(EndTime_t) - max(StartTime_t))/1s)\r\n by RequestId_s\r\n| join kind = leftouter \r\n(\r\n AzureDiagnostics\r\n | where Category == 'RequestSteps'\r\n | where Resource == databasename\r\n | summarize num_steps=max(StepIndex_d), \r\n max_step_rows=max(RowCount_d), \r\n max_step_sec=max(EndTime_t-StartTime_t)/1s\r\n by RequestId_s\r\n ) on RequestId_s\r\n| order by Query_Submit_Time\r\n| project Session_ID,RequestId_s,Query_Submit_Time,Query_Start_Time,EventTime = Query_End_Time,num_steps,max_step_rows,max_step_sec,Query_ElapsedTime_s,Status,Query = Query_Text,Resource_class\r\n| join kind = rightouter \r\n(\r\n AzureDiagnostics\r\n | where Category == 'SQLSecurityAuditEvents' and LogicalServerName_s == \"{LogicalServerName}\"\r\n | where duration_milliseconds_d > 0\r\n | extend duration_seconds = duration_milliseconds_d /1000.0\r\n | where statement_s != 'select @@version'\r\n | where statement_s != 'SELECT @@SPID;'\r\n | where server_principal_name_s has '{User}'\r\n // | where application_name_s has '{Application}'\r\n | project DatabaseName= database_name_s, UserName= server_principal_name_s, EventTime= event_time_t, Host= host_name_s, duration_seconds = round(duration_seconds), statement_s, QuerySource = application_name_s , affected_rows_d\r\n | project-reorder DatabaseName, UserName, Host, EventTime, duration_seconds, statement_s, QuerySource\r\n) on EventTime\r\n | order by affected_rows_d desc\r\n| project Session_ID,RequestID=RequestId_s,Submit_time=Query_Submit_Time,Start_Time=Query_Start_Time,End_Time=EventTime,Status,Resource_class,UserName,Query_text=statement_s,Host,QuerySource,Affected_rows=affected_rows_d,num_steps,max_step_rows,max_step_sec,Total_Duration_s=duration_seconds\r\n\r\n\r\n\r\n\r\n", "size": 0, "title": "Queries {User} {Application}", "noDataMessage": "Select a user to see query activity", "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 0 - Copy - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": " AzureDiagnostics\r\n | where Category == 'SQLSecurityAuditEvents' and LogicalServerName_s == \"{LogicalServerName}\"\r\n | where duration_milliseconds_d > 0\r\n| extend Duration = round(duration_milliseconds_d /1000.0)\r\n| extend TimeBin = case (datetime_part(\"Hour\",TimeGenerated) in (6,7,8,9,10,11,12), \"Morning_6-12\", datetime_part(\"Hour\",TimeGenerated) in (13,14,15,16,17,18), \"Afternoon_12-18\", \"Overnight_18-6\")\r\n| where server_principal_name_s has '{User}'\r\n| where application_name_s has '{Application}'\r\n| summarize QueryDuration = sum(Duration) by EventTime = bin(event_time_t, 1d), TimeBin", "size": 0, "title": "Query Activity by time - sum(Duration) {User} {Application}", "noDataMessage": "Select a user to see query activity", "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "barchart" }, "name": "query - 0 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databasename='{DatabaseName}';\r\nAzureDiagnostics \r\n| where Category == 'ExecRequests'\r\n| where Resource == databasename\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize Session_ID=max(SessionId_s), \r\n Query_Submit_Time=max(SubmitTime_t), \r\n Query_Start_Time=max(StartTime_t), \r\n Query_End_Time=max(EndTime_t), \r\n Query_Text=max(Command_s), \r\n Status=min(Status_s),\r\n Resource_class=max(ResourceClass_s) ,\r\n Query_ElapsedTime_s=round((max(EndTime_t) - max(StartTime_t))/1s)\r\n by RequestId_s\r\n| join kind = leftouter \r\n(\r\n AzureDiagnostics\r\n | where Category == 'RequestSteps'\r\n | where Resource == databasename\r\n | summarize num_steps=max(StepIndex_d), \r\n max_step_rows=max(RowCount_d), \r\n max_step_sec=max(EndTime_t-StartTime_t)/1s\r\n by RequestId_s\r\n ) on RequestId_s\r\n| order by Query_Submit_Time\r\n| project Session_ID,RequestId_s,Query_Submit_Time,Query_Start_Time,EventTime = Query_End_Time,num_steps,max_step_rows,max_step_sec,Query_ElapsedTime_s,Status,Query = Query_Text,Resource_class\r\n| join kind = rightouter \r\n(\r\n AzureDiagnostics\r\n | where Category == 'SQLSecurityAuditEvents' and LogicalServerName_s == \"{LogicalServerName}\"\r\n | where duration_milliseconds_d > 0\r\n | extend duration_seconds = duration_milliseconds_d /1000.0\r\n | where statement_s != 'select @@version'\r\n | where statement_s != 'SELECT @@SPID;'\r\n | where server_principal_name_s has '{User}'\r\n // | where application_name_s has '{Application}'\r\n | project DatabaseName= database_name_s, UserName= server_principal_name_s, EventTime= event_time_t, Host= host_name_s, duration_seconds = round(duration_seconds), statement_s, QuerySource = application_name_s , affected_rows_d\r\n | project-reorder DatabaseName, UserName, Host, EventTime, duration_seconds, statement_s, QuerySource\r\n) on EventTime\r\n | order by affected_rows_d desc\r\n| project Session_ID,RequestID=RequestId_s,Submit_time=Query_Submit_Time,Start_Time=Query_Start_Time,End_Time=EventTime,Status,Resource_class,UserName,Query_text=statement_s,Host,QuerySource,Affected_rows=affected_rows_d,num_steps,max_step_rows,max_step_sec,Total_Duration_s=duration_seconds\r\n\r\n\r\n\r\n\r\n", "size": 0, "title": "Affected Rows By Session ID", "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "linechart", "chartSettings": { "xAxis": "RequestID", "yAxis": [ "Affected_rows" ] } }, "name": "query - 6" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "QueryActivity" }, "name": "QueryActivityGroup", "styleSettings": { "showBorder": true } }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "title": "Query Comparison", "items": [ { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "7fa3187e-9225-4faa-8f80-dc1bc40c5aab", "version": "KqlParameterItem/1.0", "name": "RequestId1", "type": 1, "value": "" } ], "style": "above", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "customWidth": "50", "name": "parameters - 3 - Copy" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "315fc476-469a-4d8d-b421-028d1113ab06", "version": "KqlParameterItem/1.0", "name": "RequestId2", "type": 1, "value": "", "timeContext": { "durationMs": 86400000 } } ], "style": "above", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "customWidth": "50", "name": "parameters - 2" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s !in ('Batch','Execute') and RequestId_s == '{RequestId1}'\r\n| summarize Session_ID=any(SessionId_s),\r\n Request_ID=any(RequestId_s),\r\n Submit_Time=max(SubmitTime_t),\r\n Start_Time=max(StartTime_t),\r\n End_Time=max(EndTime_t),\r\n Command=any(Command_s),\r\n Status=min(Status_s), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType_s),\r\n Resource_class=any(ResourceClass_s)\r\n by RequestId_s\r\n| summarize Session_ID=any(Session_ID), Submit_Time=any(Submit_Time) ,Start_Time=any(Start_Time), End_Time=any(End_Time),ElapsedTime_min=anyif((End_Time - Start_Time)/1m,Start_Time > ago(30d)),Command=any(Command),Status=any(Status),Statement_Type=any(Statement_Type),Resource_class=any(Resource_class) by Request_ID\r\n| project Session_ID,Request_ID,ElapsedTime_min,Command,Resource_class,Submit_Time,Start_Time,End_Time,Statement_Type,Status\r\n", "size": 4, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "customWidth": "50", "name": "query - 2" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s !in ('Batch','Execute') and RequestId_s == '{RequestId2}'\r\n| summarize Session_ID=any(SessionId_s),\r\n Request_ID=any(RequestId_s),\r\n Submit_Time=max(SubmitTime_t),\r\n Start_Time=max(StartTime_t),\r\n End_Time=max(EndTime_t),\r\n Command=any(Command_s),\r\n Status=min(Status_s), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType_s),\r\n Resource_class=any(ResourceClass_s)\r\n by RequestId_s\r\n| summarize Session_ID=any(Session_ID), Submit_Time=any(Submit_Time) ,Start_Time=any(Start_Time), End_Time=any(End_Time),ElapsedTime_min=anyif((End_Time - Start_Time)/1m,Start_Time > ago(30d)),Command=any(Command),Status=any(Status),Statement_Type=any(Statement_Type),Resource_class=any(Resource_class) by Request_ID\r\n| project Session_ID,Request_ID,ElapsedTime_min,Command,Resource_class,Submit_Time,Start_Time,End_Time,Statement_Type,Status\r\n", "size": 4, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "customWidth": "50", "name": "query - 2 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics\r\n| where Category == 'RequestSteps'\r\n| where Resource == '{DatabaseName}'\r\n| where RequestId_s == '{RequestId1}'\r\n| summarize StartTime=max(StartTime_t)\r\n ,EndTime=max(EndTime_t)\r\n ,RequestID=max(RequestId_s)\r\n ,Operation=max(OperationType_s)\r\n ,RowCount=max(RowCount_d)\r\n ,Command=max(Command_s)\r\n ,Status=max(Status_s)\r\n by StepIndex_d\r\n| order by StepIndex_d asc\r\n| project StartTime,EndTime,RequestID,Operation,RowCount,Command,Status,StepIndex_d", "size": 3, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "customWidth": "50", "name": "query - 4", "styleSettings": { "margin": "0", "padding": "10px" } }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics\r\n| where Category == 'RequestSteps'\r\n| where Resource == '{DatabaseName}'\r\n| where RequestId_s == '{RequestId2}'\r\n| summarize StartTime=max(StartTime_t)\r\n ,EndTime=max(EndTime_t)\r\n ,RequestID=max(RequestId_s)\r\n ,Operation=max(OperationType_s)\r\n ,RowCount=max(RowCount_d)\r\n ,Command=max(Command_s)\r\n ,Status=max(Status_s)\r\n by StepIndex_d\r\n| order by StepIndex_d asc\r\n| project StartTime,EndTime,RequestID,Operation,RowCount,Command,Status,StepIndex_d", "size": 3, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "customWidth": "50", "name": "query - 4 - Copy", "styleSettings": { "padding": "10px" } } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "QueryComparison" }, "name": "QueryComparison" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "title": "Session Investigation", "items": [ { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "feb2ac70-2555-456e-bfa6-6ad4a2dcad0f", "version": "KqlParameterItem/1.0", "name": "SessionID", "type": 1, "value": "", "timeContext": { "durationMs": 86400000 } } ], "style": "above", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 0" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databasename='{DatabaseName}';\r\nAzureDiagnostics \r\n| where Category == 'ExecRequests'\r\n| where Resource == databasename\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize Query_End_Time = max(EndTime_t ) by SessionId_s\r\n| where SessionId_s == '{SessionID}'\r\n| join kind = rightouter \r\n( \r\n AzureDiagnostics\r\n | where Category == 'SQLSecurityAuditEvents' \r\n | where duration_milliseconds_d > 0\r\n | extend duration_seconds = duration_milliseconds_d /1000.0\r\n | where statement_s != 'select @@version' and statement_s != 'SELECT @@SPID;' and server_principal_name_s != '##MS_InstanceCertificate##'\r\n) on $left.Query_End_Time==$right.event_time_t \r\n| summarize DatabaseName= max(database_name_s)\r\n , UserName= any(server_principal_name_s)\r\n , Host= max(host_name_s)\r\n , Application=max(application_name_s)\r\n by SessionId_s\r\n\r\n\r\n\r\n", "size": 4, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "tiles", "tileSettings": { "titleContent": { "columnMatch": "UserName" }, "subtitleContent": { "columnMatch": "SessionId_s" }, "leftContent": { "columnMatch": "Application" }, "rightContent": { "columnMatch": "Host" }, "secondaryContent": { "columnMatch": "DatabaseName" }, "showBorder": false, "size": "full" }, "graphSettings": { "type": 0 } }, "name": "query - 3" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics \r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize \r\n Session_ID=max(SessionId_s), \r\n Submit_Time=max(SubmitTime_t), \r\n Start_Time=max(StartTime_t),\r\n End_Compile_Time=max(EndCompileTime_t), \r\n End_Time=max(EndTime_t), \r\n Command=max(Command_s), \r\n Last_Status=min(Status_s),\r\n Statement_Type=max(StatementType_s),\r\n Resource_class=max(ResourceClass_s) \r\n by RequestId_s\r\n| where Session_ID has '{SessionID}'\r\n| extend elapsedTime_sec = iif(End_Time > ago(365d),(End_Time - Submit_Time)/1s,real(null)) \r\n| order by Submit_Time asc\r\n\r\n\r\n\r\n\r\n", "size": 0, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "exportFieldName": "RequestId_s", "exportParameterName": "RequestID", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 1" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics\r\n| where Category == 'RequestSteps'\r\n| where Resource == '{DatabaseName}'\r\n| where RequestId_s == '{RequestID}'\r\n//| where Status_s != 'Running'\r\n| summarize max(StartTime_t),max(EndTime_t),max(RequestId_s),max(OperationType_s),max(RowCount_d),max(Command_s),max(Status_s) by StepIndex_d\r\n| order by StepIndex_d asc", "size": 3, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 2" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "SessionInvestigation" }, "name": "group - 9" } ], "fallbackResourceIds": [ "azure monitor" ], "$schema": "https://github.com/Microsoft/Application-Insights-Workbooks/blob/master/schema/workbook.json" } ================================================ FILE: Monitor_Workbooks/archive/SynapseWorkbook_v1.01.json ================================================ { "version": "Notebook/1.0", "items": [ { "type": 9, "content": { "version": "KqlParameterItem/1.0", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "parameters": [ { "id": "28da10ec-a308-47f5-9819-92ebf810b292", "version": "KqlParameterItem/1.0", "name": "LogAnalyticsSubscription", "type": 6, "value": null, "typeSettings": { "additionalResourceOptions": [], "includeAll": true, "showDefault": false }, "timeContext": { "durationMs": 86400000 } }, { "id": "e383ed24-52ae-447b-9b80-51fd3ab6b919", "version": "KqlParameterItem/1.0", "name": "LogAnalyticsWorkspace", "type": 5, "query": "Resources\r\n| where type == 'microsoft.operationalinsights/workspaces'\r\n| project id\r\n", "crossComponentResources": [ "{LogAnalyticsSubscription}" ], "value": null, "typeSettings": { "additionalResourceOptions": [], "showDefault": false }, "timeContext": { "durationMs": 86400000 }, "queryType": 1, "resourceType": "microsoft.resourcegraph/resources" }, { "id": "9b9fe566-0f52-4a75-a35b-a79c50c6a6f0", "version": "KqlParameterItem/1.0", "name": "DatabaseResourceName", "type": 5, "query": "AzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| distinct ResourceId", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "value": null, "typeSettings": { "additionalResourceOptions": [], "showDefault": false }, "timeContext": { "durationMs": 604800000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "id": "f5852627-70ca-4959-8d60-53b48864603f", "version": "KqlParameterItem/1.0", "name": "TimeRange", "type": 4, "isGlobal": true, "value": { "durationMs": 14400000 }, "typeSettings": { "selectableValues": [ { "durationMs": 300000 }, { "durationMs": 900000 }, { "durationMs": 1800000 }, { "durationMs": 3600000 }, { "durationMs": 14400000 }, { "durationMs": 43200000 }, { "durationMs": 86400000 }, { "durationMs": 172800000 }, { "durationMs": 259200000 }, { "durationMs": 604800000 }, { "durationMs": 1209600000 }, { "durationMs": 2419200000 }, { "durationMs": 2592000000 } ], "allowCustom": true }, "timeContext": { "durationMs": 86400000 } }, { "id": "6da2f63f-45a3-4b37-9108-5e8b7e358d85", "version": "KqlParameterItem/1.0", "name": "DatabaseName", "type": 1, "query": "AzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where ResourceId == '{DatabaseResourceName}'\r\n| distinct Resource ", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 604800000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "id": "8bba835b-f319-43b3-8ec6-4e051fc6d446", "version": "KqlParameterItem/1.0", "name": "LogicalServerName", "type": 1, "query": "AzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where ResourceId == '{DatabaseResourceName}'\r\n| distinct LogicalServerName_s", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 2" }, { "type": 11, "content": { "version": "LinkItem/1.0", "style": "tabs", "links": [ { "id": "202cbbc0-8d63-416d-89ed-451d6fe7c4b3", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Workload", "subTarget": "Workload", "preText": "Workload", "style": "link" }, { "id": "a7901bd0-a1f4-4491-b953-57555d764e00", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Workload Management", "subTarget": "WorkloadManagement", "style": "link" }, { "id": "45e12a14-8548-4477-aae3-c142b906dc9f", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "TempDB", "subTarget": "TempDB", "style": "link" }, { "id": "9ef8f730-d73d-432b-9b75-55095d1155f2", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Replicated Tables", "subTarget": "ReplicatedTables", "style": "link" }, { "id": "79d10d16-0696-4214-b306-c7a0e46cd64f", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Query Investigation", "subTarget": "QueryInvestigation", "style": "link" }, { "id": "31c1cf1c-74b5-44e2-ba9a-9497834ca3dc", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Query Comparison", "subTarget": "QueryComparison", "style": "link" }, { "id": "5ff681ee-e005-481f-b743-b66ab1b9d71d", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Session Investigation", "subTarget": "SessionInvestigation", "style": "link" }, { "id": "482ccc46-8a10-4ace-bfd6-63ac73b380af", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Query Audit", "subTarget": "QueryAudit", "style": "link" } ] }, "name": "links - 0" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "title": "Workload", "items": [ { "type": 10, "content": { "chartId": "workbook90867bfc-5c33-464f-ac31-2c2e006b97f4", "version": "MetricsItem/2.0", "size": 0, "chartType": 2, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 14400000 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-dwu_consumption_percent", "aggregation": 3, "splitBy": null, "columnName": "DWU Percentage" }, { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-cpu_percent", "aggregation": 3 }, { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-physical_data_read_percent", "aggregation": 3 } ], "title": "DWU Resource Utilization", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "name": "metric - 1" }, { "type": 10, "content": { "chartId": "workbookb954d4a0-82ef-4409-88fb-837aaff80c8d", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 14400000 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-active_queries", "aggregation": 1, "splitBy": null }, { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-queued_queries", "aggregation": 1 } ], "title": "Active and Queued Queries", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "name": "metric - 1" }, { "type": 10, "content": { "chartId": "workbookb954d4a0-82ef-4409-88fb-837aaff80c8d", "version": "MetricsItem/2.0", "size": 0, "chartType": 3, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 14400000 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-local_tempdb_usage_percent", "aggregation": 3, "splitBy": null, "columnName": "TempDB Utilization Percentage" } ], "title": "TempDB Utilization", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "name": "metric - 1 - Copy" }, { "type": 10, "content": { "chartId": "workbookb954d4a0-82ef-4409-88fb-837aaff80c8d", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 14400000 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-WorkloadManagement-wlg_allocation_relative_to_system_percent", "aggregation": 3, "splitBy": "WorkloadGroupName" } ], "title": "Workload Group Utilization", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "name": "Workload Group Utilization" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databaseName = '{DatabaseName}';\r\n//Long-Running Queries - Just Actual Queries\r\n//If 'Command' is empty - you need to set a bigger time window, the older record with the command is outside of your window\r\nAzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where Resource == databaseName\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize Session_ID=any(SessionId_s),\r\n Request_ID=any(RequestId_s),\r\n Submit_Time=max(SubmitTime_t),\r\n Start_Time=max(StartTime_t),\r\n End_Time=max(EndTime_t),\r\n Command=any(Command_s),\r\n Status=min(Status_s), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType_s),\r\n Resource_class=any(ResourceClass_s)\r\n by RequestId_s\r\n| summarize ElapsedTime_min=bin(anyif(((End_Time - Start_Time)/1m),Start_Time > ago(30d)),1),\r\n Session_ID=any(Session_ID), \r\n Submit_Time=any(Submit_Time) ,\r\n Start_Time=any(Start_Time), \r\n End_Time=any(End_Time),\r\n Command=any(Command),\r\n Status=any(Status),\r\n Statement_Type=any(Statement_Type)\r\n ,Resource_class=any(Resource_class) \r\n by Request_ID\r\n| where End_Time > ago(365d)\r\n| summarize count() by Status, bin(End_Time,5m)\r\n| render timechart \r\n", "size": 0, "title": "Query Completion Count by End Time - 5m buckets", "color": "redBright", "timeContext": { "durationMs": 14400000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "chartSettings": { "seriesLabelSettings": [ { "seriesName": "Completed", "color": "green" }, { "seriesName": "Failed", "color": "red" }, { "seriesName": "Cancelled", "color": "yellow" } ] } }, "name": "query - 4" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": " AzureDiagnostics\r\n | where Category == 'SQLSecurityAuditEvents' and LogicalServerName_s == '{LogicalServerName}'\r\n //| where duration_milliseconds_d > 0\r\n | extend duration_seconds = duration_milliseconds_d /1000.0\r\n | where statement_s != 'select @@version'\r\n | where statement_s != 'SELECT @@SPID;'\r\n | summarize sum(affected_rows_d) by bin(TimeGenerated,1h)", "size": 0, "title": "Rows Processed by End Time - 1h buckets", "timeContext": { "durationMs": 259200000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "categoricalbar" }, "name": "query - 7" }, { "type": 10, "content": { "chartId": "workbook1afc57e6-0b32-4968-b299-db319bd21635", "version": "MetricsItem/2.0", "size": 0, "chartType": 2, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 14400000 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-connection_successful", "aggregation": 1, "splitBy": null }, { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-connection_failed", "aggregation": 1 } ], "title": "Successful and Failed Connections", "gridSettings": { "rowLimit": 10000 } }, "name": "metric - 5" }, { "type": 10, "content": { "chartId": "workbook993837ad-66d6-4cbc-ae1a-7c3f6623236b", "version": "MetricsItem/2.0", "size": 0, "chartType": 2, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 14400000 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-cache_used_percent", "aggregation": 3, "splitBy": null }, { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-cache_hit_percent", "aggregation": 3 } ], "title": "Adaptive Cache Used vs Hit Percentage", "gridSettings": { "rowLimit": 10000 } }, "name": "metric - 6" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "Workload" }, "name": "group - 1" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "title": "TempDB ", "items": [ { "type": 10, "content": { "chartId": "workbook4a9cf761-cce2-45b2-8947-8a9428ec7e1c", "version": "MetricsItem/2.0", "size": 0, "chartType": 3, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 604800000 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-local_tempdb_usage_percent", "aggregation": 3, "splitBy": null, "columnName": "TempDB Util" } ], "title": "TempDB Max and Avg Utilization", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "name": "metric - 0" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "19ee48f5-8f4e-4939-a0ef-c6bf656a93f9", "version": "KqlParameterItem/1.0", "name": "WeightParameter", "type": 1, "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 } }, { "id": "00553ec8-1a41-4dd9-a024-d607639c9bbb", "version": "KqlParameterItem/1.0", "name": "RequestID", "type": 1, "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 } } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 3" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databaseName = '{DatabaseName}';\r\n//Weighted query steps\r\nAzureDiagnostics\r\n| where Category == 'RequestSteps'\r\n| where Resource == databaseName\r\n| where RowCount_d > 0\r\n| summarize sum(RowCount_d) by RequestId_s, OperationType_s\r\n| order by sum_RowCount_d desc\r\n| limit 20\r\n| render columnchart ", "size": 0, "title": "20 Largest Query Steps by Most Rows Moved", "timeContext": { "durationMs": 604800000 }, "timeContextFromParameter": "TimeRange", "exportFieldName": "Request_ID", "exportParameterName": "RequestID", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "chartSettings": { "xAxis": "RequestId_s", "group": "OperationType_s", "createOtherGroup": 20, "showLegend": true } }, "name": "query - 1 - Copy" }, { "type": 11, "content": { "version": "LinkItem/1.0", "style": "nav", "links": [ { "id": "c98d3722-9907-43ab-9306-1957d6f7f858", "cellValue": "WeightParameter", "linkTarget": "parameter", "linkLabel": "Weighted Rowcounts", "subTarget": "Weighted", "preText": "", "postText": "", "style": "secondary" }, { "id": "a06ae99a-ad62-45e9-8c25-c219b81f59c0", "cellValue": "WeightParameter", "linkTarget": "parameter", "linkLabel": "Unweighted Rowcounts", "subTarget": "Unweighted", "preText": "", "postText": "", "style": "secondary" } ] }, "name": "links - 3" }, { "type": 1, "content": { "json": "Current Setting: {WeightParameter}", "style": "info" }, "name": "text - 4" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databaseName = '{DatabaseName}';\r\n//Weighted query steps\r\nlet RequestSteps = AzureDiagnostics\r\n| where Category == 'RequestSteps'\r\n| where Resource == databaseName\r\n| where RowCount_d > 100000000\r\n| extend Step_Elapsed_Min = round((EndTime_t - StartTime_t)/1m, 2)\r\n| extend Weighted_cnt = iff('{WeightParameter}'=='Weighted',(case(OperationType_s == 'BroadcastMoveOperation', (RowCount_d*20), RowCount_d)),RowCount_d)\r\n| project-rename StepStatus = Status_s, StepStart = StartTime_t, StepEnd = EndTime_t//, StepResource = Resource\r\n| top 100 by Weighted_cnt desc\r\n| order by Weighted_cnt desc\r\n| project Request_ID=RequestId_s,OperationType_s, RowCount_d,Weighted_cnt,Step_Elapsed_Min, StepStart, StepEnd, StepStatus, StepIndex_d,Resource;\r\nRequestSteps | join (AzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where Resource == databaseName\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize Session_ID=any(SessionId_s),\r\n Request_ID=any(RequestId_s),\r\n Submit_Time=max(SubmitTime_t),\r\n Start_Time=max(StartTime_t),\r\n End_Time=max(EndTime_t),\r\n Command=any(Command_s),\r\n Status=min(Status_s), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType_s),\r\n Resource_class=any(ResourceClass_s)\r\n by RequestId_s\r\n| summarize Session_ID=any(Session_ID), Submit_Time=any(Submit_Time) ,Start_Time=any(Start_Time), End_Time=any(End_Time),Command=any(Command),Status=any(Status),Statement_Type=any(Statement_Type),Resource_class=any(Resource_class) by Request_ID\r\n//| order by Step_Elapsed_Min desc\r\n| extend Request_Elapsed_Min = round((End_Time - Start_Time)/1m, 2)\r\n| project-rename ReqStatus = Status, ReqStart = Start_Time, ReqEnd = End_Time\r\n) on Request_ID\r\n| project-reorder Session_ID, Request_ID, Request_Elapsed_Min, ReqStart, ReqEnd, ReqStatus,StepIndex_d, OperationType_s, RowCount_d,Weighted_cnt,Step_Elapsed_Min, StepStart, StepEnd, StepStatus, Statement_Type, Command, Resource_class\r\n| order by Weighted_cnt desc\r\n| limit 20", "size": 3, "title": "20 Largest Query Steps by Most Rows Moved", "timeContext": { "durationMs": 604800000 }, "timeContextFromParameter": "TimeRange", "exportFieldName": "Request_ID1", "exportParameterName": "RequestID", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "sortBy": [ { "itemKey": "Weighted_cnt", "sortOrder": 2 } ] }, "sortBy": [ { "itemKey": "Weighted_cnt", "sortOrder": 2 } ] }, "name": "query - 1" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databaseName = '{DatabaseName}';\r\n//Long-Running Queries - Just Actual Queries\r\n//If 'Command' is empty - you need to set a bigger time window, the older record with the command is outside of your window\r\nAzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where Resource == databaseName\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize Session_ID=any(SessionId_s),\r\n Request_ID=any(RequestId_s),\r\n Submit_Time=max(SubmitTime_t),\r\n Start_Time=max(StartTime_t),\r\n End_Time=max(EndTime_t),\r\n Command=any(Command_s),\r\n Status=min(Status_s), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType_s),\r\n Resource_class=any(ResourceClass_s)\r\n by RequestId_s\r\n| summarize ElapsedTime_min=bin(anyif(((End_Time - Start_Time)/1m),Start_Time > ago(30d)),1),\r\n Session_ID=any(Session_ID), \r\n Submit_Time=any(Submit_Time) ,\r\n Start_Time=any(Start_Time), \r\n End_Time=any(End_Time),\r\n Command=any(Command),\r\n Status=any(Status),\r\n Statement_Type=any(Statement_Type)\r\n ,Resource_class=any(Resource_class) \r\n by Request_ID\r\n| where Request_ID == '{RequestID}'\r\n\r\n", "size": 4, "title": "Selected Query", "noDataMessage": "Select a query above to view details", "timeContext": { "durationMs": 604800000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "35%" } } ] } }, "name": "query - 6" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics\r\n| where Category == 'RequestSteps'\r\n| where Resource == '{DatabaseName}'\r\n| where RequestId_s == '{RequestID}' //Put your QueryID here\r\n| where Status_s != 'Running'\r\n| summarize max(StartTime_t),max(EndTime_t),max(RequestId_s),max(OperationType_s),max(RowCount_d),max(Command_s),max(Status_s) by StepIndex_d\r\n| order by StepIndex_d asc", "size": 3, "title": "Query Plan", "noDataMessage": "Select a query above to view the plan", "timeContext": { "durationMs": 604800000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 7" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "TempDB" }, "name": "group - 3" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "title": "Query Investigation", "items": [ { "type": 1, "content": { "json": "## Search Criteria\r\nUse the following fields to search either using a query text snippet or using a Request ID. If using a query text snippet, try to keep it as simple as possible becuase minor changes in formatting may cause your queries not to show up in the results. It's best to pick something like a table name, then choose the proper query from the list that will populate. " }, "customWidth": "50", "name": "text - 4" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "0c2128d0-d979-4562-a28c-e7ceb955f126", "version": "KqlParameterItem/1.0", "name": "RequestIdSearch", "type": 1, "value": "" }, { "id": "29880874-2d41-4bd5-bf22-3e47ae8b1145", "version": "KqlParameterItem/1.0", "name": "QueryTextSnippet", "type": 1, "value": "", "timeContext": { "durationMs": 86400000 } } ], "style": "formVertical", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "customWidth": "60", "name": "parameters - 3" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics \r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize \r\n Session_ID=max(SessionId_s), \r\n Request_ID=max(RequestId_s), \r\n Submit_Time=max(SubmitTime_t), \r\n Start_Time=max(StartTime_t),\r\n End_Compile_Time=max(EndCompileTime_t), \r\n End_Time=max(EndTime_t), \r\n Command=max(Command_s), \r\n Last_Status=min(Status_s),\r\n Statement_Type=max(StatementType_s),\r\n Resource_class=max(ResourceClass_s) \r\n by RequestId_s\r\n| where Command has '{QueryTextSnippet}'\r\nand RequestId_s has '{RequestIdSearch}'\r\n| extend elapsedTime_sec = iif(End_Time > ago(365d),(End_Time - Submit_Time)/1s,real(null)) \r\n| extend CompileTime_sec = (End_Compile_Time - Submit_Time)/1s\r\n| order by elapsedTime_sec\r\n| summarize \r\n Executions = count(),\r\n Max_Elapsed_Time_sec = bin(max(elapsedTime_sec),1),\r\n Min_Elapsed_Time_sec = bin(min(elapsedTime_sec),1),\r\n Variability_sec=bin((max(elapsedTime_sec)-min(elapsedTime_sec)),1),\r\n SampleQID = any(RequestId_s),\r\n SampleSessionID = any(Session_ID)\r\n by Command\r\n| order by Max_Elapsed_Time_sec\r\n\r\n\r\n", "size": 0, "title": "Matching Queries", "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "exportedParameters": [ { "fieldName": "SampleQID", "parameterName": "SampleQID" }, { "fieldName": "SampleSessionID", "parameterName": "Samp", "parameterType": 1 } ], "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "50%" } } ] } }, "name": "query - 0" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics \r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s !in ('Batch','Execute')\r\n| where RequestId_s == '{SampleQID}'\r\n| summarize \r\n Session_ID=max(SessionId_s), \r\n Request_ID=max(RequestId_s), \r\n Submit_Time=max(SubmitTime_t), \r\n Start_Time=max(StartTime_t),\r\n End_Compile_Time=max(EndCompileTime_t), \r\n End_Time=max(EndTime_t), \r\n Command=max(Command_s), \r\n Last_Status=min(Status_s),\r\n Statement_Type=max(StatementType_s),\r\n Resource_class=max(ResourceClass_s) \r\n by RequestId_s\r\n| extend elapsedTime_sec = iif(End_Time > ago(365d),(End_Time - Submit_Time)/1s,real(null)) \r\n| extend CompileTime_sec = (End_Compile_Time - Submit_Time)/1s\r\n| join kind=inner\r\n (AzureDiagnostics \r\n | where Category == 'ExecRequests'\r\n | where Resource == '{DatabaseName}'\r\n | where StatementType_s !in ('Batch','Execute')\r\n | summarize \r\n Session_ID=max(SessionId_s), \r\n Request_ID=max(RequestId_s), \r\n Submit_Time=max(SubmitTime_t), \r\n Start_Time=max(StartTime_t),\r\n End_Compile_Time=max(EndCompileTime_t), \r\n End_Time=max(EndTime_t), \r\n Command=max(Command_s), \r\n Last_Status=min(Status_s),\r\n Statement_Type=max(StatementType_s),\r\n Resource_class=max(ResourceClass_s) \r\n by RequestId_s\r\n | extend elapsedTime_sec = (End_Time - Submit_Time)/1s\r\n | extend elapsedTime_sec = iif(End_Time > ago(365d),(End_Time - Submit_Time)/1s,real(null)) \r\n | extend CompileTime_sec = (End_Compile_Time - Submit_Time)/1s\r\n )\r\non Command \r\n| project Request_ID1,Session_ID1,Submit_Time1,Start_Time1,End_Compile_Time1,End_Time1,Last_Status1,Statement_Type1,Resource_class1,elapsedTime_sec1,CompileTime_sec1\r\n", "size": 0, "title": "All Executions of Selected Query", "noDataMessage": "Select a query above to see individual executions", "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "exportFieldName": "Request_ID1", "exportParameterName": "RequestId", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "sortBy": [] }, "name": "query - 0 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics\r\n| where Category == 'RequestSteps'\r\n| where Resource == '{DatabaseName}'\r\n| where RequestId_s == '{RequestId}'\r\n//| where Status_s != 'Running'\r\n| summarize max(StartTime_t),max(EndTime_t),max(RequestId_s),max(OperationType_s),max(RowCount_d),max(Command_s),max(Status_s) by StepIndex_d\r\n| order by StepIndex_d asc", "size": 3, "title": "Query Plan for Selected Query", "noDataMessage": "Select a Query Above to See the Query Plan", "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 0 - Copy - Copy" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "QueryInvestigation" }, "name": "group - 4", "styleSettings": { "showBorder": true } }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "title": "Replicated Tables", "items": [ { "type": 1, "content": { "json": "All Charts on this page are based on the last 7 days of data", "style": "info" }, "name": "text - 5" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Build cache count by day\r\nAzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s == 'BuildReplicatedTableCache'\r\n| where Command_s != \"\"\r\n| where ResourceClass_s != \"\"\r\n| project Command_s,TimeGenerated,RequestId_s\r\n| summarize LastRebuild=max(TimeGenerated),RebuildCount=count(RequestId_s) by Command_s\r\n| order by RebuildCount desc\r\n| limit 15\r\n", "size": 3, "title": "Top 15 Most Rebuilds by Table", "timeContext": { "durationMs": 604800000 }, "exportFieldName": "Command_s", "exportParameterName": "QueryText", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command_s", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "40%" } } ] } }, "name": "query - 0" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Build cache count by day\r\nAzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s == 'BuildReplicatedTableCache'\r\n| where Command_s == \"{QueryText}\"\r\n| where ResourceClass_s != \"\"\r\n| project Command_s,TimeGenerated,RequestId_s\r\n| summarize count() by Command_s,bin(TimeGenerated,24h)\r\n| limit 20\r\n| render timechart", "size": 0, "title": "Rebuilds per Day for Selected Table", "noDataMessage": "Select a query above to see runs by day", "timeContext": { "durationMs": 604800000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "chartSettings": { "group": "Command_s", "createOtherGroup": 20, "ySettings": { "min": 0 } } }, "name": "query - 0 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Build cache count by day\r\nAzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s == 'BuildReplicatedTableCache'\r\n| where Command_s != \"\"\r\n| where ResourceClass_s != \"\"\r\n| project Command_s,TimeGenerated,RequestId_s\r\n| summarize count() by Command_s, bin(TimeGenerated,24h)\r\n| where count_ > 7\r\n| order by count_ desc\r\n\r\n", "size": 2, "title": "Rebuild Count by Table by Day", "timeContext": { "durationMs": 604800000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "categoricalbar", "gridSettings": { "sortBy": [ { "itemKey": "count_", "sortOrder": 1 } ] }, "sortBy": [ { "itemKey": "count_", "sortOrder": 1 } ], "tileSettings": { "showBorder": false, "titleContent": { "columnMatch": "Command_s", "formatter": 1 }, "leftContent": { "columnMatch": "count_", "formatter": 12, "formatOptions": { "palette": "auto" }, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "graphSettings": { "type": 0, "topContent": { "columnMatch": "Command_s", "formatter": 1 }, "centerContent": { "columnMatch": "count_", "formatter": 1, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "chartSettings": { "group": "Command_s", "createOtherGroup": 99, "showDataPoints": true } }, "name": "query - 0 - Copy - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Long-Running Queries - Just Actual Queries\r\nAzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize Session_ID=max(SessionId_s), Request_ID=max(RequestId_s), Submit_Time=max(SubmitTime_t), Start_Time=max(StartTime_t), End_Time=max(EndTime_t), Command=max(Command_s), Statement_Type=max(StatementType_s), Resource_class=max(ResourceClass_s) by RequestId_s\r\n| join kind= inner\r\n(\r\n AzureDiagnostics\r\n | where Category == 'ExecRequests'\r\n | where Resource == '{DatabaseName}'\r\n //| where StatementType_s !in ('Batch','Execute')\r\n | where StatementType_s == 'BuildReplicatedTableCache'\r\n | where EndTime_t > ago(7d)\r\n | where StartTime_t > ago(7d)\r\n | extend elapsedTime_min = (EndTime_t - StartTime_t)/1m\r\n //| extend elapsedTime_min = elapsedTime/1m\r\n | order by elapsedTime_min desc\r\n | project Request_ID=RequestId_s,elapsedTime_min \r\n)\r\non Request_ID\r\n| order by elapsedTime_min desc\r\n| project Request_ID,Submit_Time,Start_Time,End_Time,Elapsed_Time=round(elapsedTime_min,1) ,Command\r\n| limit 15\r\n", "size": 3, "title": "Top 15 Elapsed Time per Rebuild", "timeContext": { "durationMs": 604800000 }, "exportFieldName": "Request_ID", "exportParameterName": "RequestId", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "40%" } } ] } }, "name": "query - 3" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics\r\n| where Category == 'RequestSteps'\r\n| where Resource == '{DatabaseName}'\r\n| where RequestId_s == '{RequestId}'\r\n| where Status_s != 'Running'\r\n| summarize max(StartTime_t),max(EndTime_t),max(RequestId_s),max(OperationType_s),max(RowCount_d),max(Command_s),max(Status_s) by StepIndex_d\r\n| order by StepIndex_d asc", "size": 3, "title": "Query Plan for Selected Query", "noDataMessage": "Select a query above to view plan", "timeContext": { "durationMs": 604800000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 4" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "ReplicatedTables" }, "name": "ReplicatedTablesGroup" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "title": "Workload Management", "items": [ { "type": 10, "content": { "chartId": "workbook72446028-6edb-4cb0-8952-e0c13bda488f", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 14400000 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-WorkloadManagement-wlg_allocation_relative_to_system_percent", "aggregation": 3, "splitBy": null } ], "title": "Workload Group Allocation By System Percent", "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "name": "metric - 0" }, { "type": 10, "content": { "chartId": "workbookc898119a-7381-469d-b51a-d505b4f80e73", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 14400000 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-WorkloadManagement-wlg_active_queries", "aggregation": 1, "splitBy": null } ], "title": "Query Count by Workload Group", "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "name": "metric - 1" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "parameters": [ { "id": "6f50577d-7b00-4e4a-acf9-d45c7a5ee813", "version": "KqlParameterItem/1.0", "name": "WorkloadGroupName", "type": 2, "query": "AzureDiagnostics\r\n| where Category == 'ExecRequests'\r\nand Resource == '{DatabaseName}'\r\n and ResourceClass_s != \"\"\r\n| distinct ResourceClass_s", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "value": null, "typeSettings": { "additionalResourceOptions": [], "showDefault": false }, "timeContext": { "durationMs": 604800000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 2" }, { "type": 10, "content": { "chartId": "workbook3da1d18a-1bf5-46c5-b3b7-211f71d329cc", "version": "MetricsItem/2.0", "size": 0, "chartType": 2, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 14400000 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-WorkloadManagement-wlg_active_queries", "aggregation": 1, "splitBy": null }, { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-WorkloadManagement-wlg_queued_queries", "aggregation": 1 }, { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-WorkloadManagement-wlg_allocation_relative_to_system_percent", "aggregation": 3 } ], "filters": [ { "id": "3", "key": "WorkloadGroupName", "operator": 0, "valueParam": "WorkloadGroupName" } ], "gridSettings": { "rowLimit": 10000 } }, "name": "metric - 3" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "WorkloadManagement" }, "name": "group - 6" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "title": "Query Audit", "items": [ { "type": 1, "content": { "json": "## Select a Principal or Application name to filter results - leave to 'unset' to view all results\r\nSQL Auditing must be enabled and sending to the same Log Analytics Workspace for this page to work. " }, "name": "text - 5" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "parameters": [ { "id": "8d25c043-d1ff-4546-a1fa-f4bcbfdab8af", "version": "KqlParameterItem/1.0", "name": "User", "type": 2, "description": "User to filter subsequent queries - leave to 'unset' for all users", "query": "AzureDiagnostics\r\n| where Category == 'SQLSecurityAuditEvents' and LogicalServerName_s == '{LogicalServerName}'\r\n| summarize by server_principal_name_s", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "value": null, "typeSettings": { "additionalResourceOptions": [], "showDefault": false }, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "id": "aa766d64-693f-4024-b4a4-b5b56b28376b", "version": "KqlParameterItem/1.0", "name": "Application", "type": 2, "query": "AzureDiagnostics\r\n| where Category == 'SQLSecurityAuditEvents' and LogicalServerName_s == '{LogicalServerName}'\r\n| summarize by application_name_s", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "value": null, "typeSettings": { "additionalResourceOptions": [], "showDefault": false }, "timeContext": { "durationMs": 86400000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "customWidth": "30", "name": "parameters - 1" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics\r\n| where Category == 'SQLSecurityAuditEvents' and LogicalServerName_s == \"{LogicalServerName}\"\r\n| where duration_milliseconds_d > 0\r\n| extend duration_seconds = duration_milliseconds_d /1000.0\r\n| where statement_s != 'select @@version'\r\n| where statement_s != 'SELECT @@SPID;'\r\n| where server_principal_name_s has '{User}'\r\n| where application_name_s has '{Application}'\r\n| project server_principal_name_s, succeeded_s, event_time_t, LogicalServerName_s, duration_milliseconds_d, duration_seconds, affected_rows_d, statement_s, application_name_s\r\n| summarize duration_seconds = round(sum(duration_seconds)) , query_count = count(statement_s) by EventDay = bin(event_time_t,1d), UserName = server_principal_name_s, Application = application_name_s \r\n| order by EventDay, duration_seconds desc", "size": 0, "title": "Query Summary for Selected User {User} {Application}", "noDataMessage": "Select a user to see query activity", "timeContext": { "durationMs": 604800000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 0 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics\r\n| where Category == 'SQLSecurityAuditEvents' and LogicalServerName_s == \"{LogicalServerName}\"\r\n| where duration_milliseconds_d > 0\r\n| extend duration_seconds = duration_milliseconds_d /1000.0\r\n| where statement_s != 'select @@version'\r\n| where statement_s != 'SELECT @@SPID;'\r\n| where server_principal_name_s has '{User}'\r\n| where application_name_s has '{Application}'\r\n| project server_principal_name_s, succeeded_s, event_time_t, LogicalServerName_s, duration_milliseconds_d, duration_seconds, affected_rows_d, statement_s, application_name_s\r\n| summarize duration_seconds = round(sum(duration_seconds)) , query_count = count(statement_s) by EventDay = bin(event_time_t,1d), UserName = server_principal_name_s, Application = application_name_s \r\n| order by EventDay, duration_seconds desc", "size": 0, "title": "Query Summary for Selected User {User} {Application}", "noDataMessage": "Select a user to see query activity", "timeContext": { "durationMs": 604800000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "unstackedbar", "tileSettings": { "showBorder": false, "titleContent": { "columnMatch": "UserName", "formatter": 1 }, "leftContent": { "columnMatch": "duration_seconds", "formatter": 12, "formatOptions": { "palette": "auto" }, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "graphSettings": { "type": 0, "topContent": { "columnMatch": "UserName", "formatter": 1 }, "centerContent": { "columnMatch": "duration_seconds", "formatter": 1, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "chartSettings": { "xAxis": "UserName" }, "mapSettings": { "locInfo": "LatLong", "sizeSettings": "duration_seconds", "sizeAggregation": "Sum", "legendMetric": "duration_seconds", "legendAggregation": "Sum", "itemColorSettings": { "type": "heatmap", "colorAggregation": "Sum", "nodeColorField": "duration_seconds", "heatmapPalette": "greenRed" } } }, "name": "query - 0 - Copy - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databasename='{DatabaseName}';\r\nAzureDiagnostics \r\n| where Category == 'ExecRequests'\r\n| where Resource == databasename\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize Session_ID=max(SessionId_s), \r\n Query_Submit_Time=max(SubmitTime_t), \r\n Query_Start_Time=max(StartTime_t), \r\n Query_End_Time=max(EndTime_t), \r\n Query_Text=max(Command_s), \r\n Status=min(Status_s),\r\n Resource_class=max(ResourceClass_s) ,\r\n Query_ElapsedTime_s=round((max(EndTime_t) - max(StartTime_t))/1s)\r\n by RequestId_s\r\n| join kind = leftouter \r\n(\r\n AzureDiagnostics\r\n | where Category == 'RequestSteps'\r\n | where Resource == databasename\r\n | summarize num_steps=max(StepIndex_d), \r\n max_step_rows=max(RowCount_d), \r\n max_step_sec=max(EndTime_t-StartTime_t)/1s\r\n by RequestId_s\r\n ) on RequestId_s\r\n| order by Query_Submit_Time\r\n| project Session_ID,RequestId_s,Query_Submit_Time,Query_Start_Time,EventTime = Query_End_Time,num_steps,max_step_rows,max_step_sec,Query_ElapsedTime_s,Status,Query = Query_Text,Resource_class\r\n| join kind = rightouter \r\n(\r\n AzureDiagnostics\r\n | where Category == 'SQLSecurityAuditEvents' and LogicalServerName_s == \"{LogicalServerName}\"\r\n | where duration_milliseconds_d > 0\r\n | extend duration_seconds = duration_milliseconds_d /1000.0\r\n | where statement_s != 'select @@version'\r\n | where statement_s != 'SELECT @@SPID;'\r\n | where server_principal_name_s has '{User}'\r\n // | where application_name_s has '{Application}'\r\n | project DatabaseName= database_name_s, UserName= server_principal_name_s, EventTime= event_time_t, Host= host_name_s, duration_seconds = round(duration_seconds), statement_s, QuerySource = application_name_s , affected_rows_d\r\n | project-reorder DatabaseName, UserName, Host, EventTime, duration_seconds, statement_s, QuerySource\r\n) on EventTime\r\n | order by affected_rows_d desc\r\n| project Session_ID,RequestID=RequestId_s,Submit_time=Query_Submit_Time,Start_Time=Query_Start_Time,End_Time=EventTime,Status,Resource_class,UserName,Query_text=statement_s,Host,QuerySource,Affected_rows=affected_rows_d,num_steps,max_step_rows,max_step_sec,Total_Duration_s=duration_seconds\r\n\r\n\r\n\r\n\r\n", "size": 0, "title": "Queries {User} {Application}", "noDataMessage": "Select a user to see query activity", "timeContext": { "durationMs": 604800000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 0 - Copy - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": " AzureDiagnostics\r\n | where Category == 'SQLSecurityAuditEvents' and LogicalServerName_s == \"{LogicalServerName}\"\r\n | where duration_milliseconds_d > 0\r\n| extend Duration = round(duration_milliseconds_d /1000.0)\r\n| extend TimeBin = case (datetime_part(\"Hour\",TimeGenerated) in (6,7,8,9,10,11,12), \"Morning_6-12\", datetime_part(\"Hour\",TimeGenerated) in (13,14,15,16,17,18), \"Afternoon_12-18\", \"Overnight_18-6\")\r\n| where server_principal_name_s has '{User}'\r\n| where application_name_s has '{Application}'\r\n| summarize QueryDuration = sum(Duration) by EventTime = bin(event_time_t, 1d), TimeBin", "size": 0, "title": "Query Activity by time - sum(Duration) {User} {Application}", "noDataMessage": "Select a user to see query activity", "timeContext": { "durationMs": 604800000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "barchart" }, "name": "query - 0 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databasename='{DatabaseName}';\r\nAzureDiagnostics \r\n| where Category == 'ExecRequests'\r\n| where Resource == databasename\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize Session_ID=max(SessionId_s), \r\n Query_Submit_Time=max(SubmitTime_t), \r\n Query_Start_Time=max(StartTime_t), \r\n Query_End_Time=max(EndTime_t), \r\n Query_Text=max(Command_s), \r\n Status=min(Status_s),\r\n Resource_class=max(ResourceClass_s) ,\r\n Query_ElapsedTime_s=round((max(EndTime_t) - max(StartTime_t))/1s)\r\n by RequestId_s\r\n| join kind = leftouter \r\n(\r\n AzureDiagnostics\r\n | where Category == 'RequestSteps'\r\n | where Resource == databasename\r\n | summarize num_steps=max(StepIndex_d), \r\n max_step_rows=max(RowCount_d), \r\n max_step_sec=max(EndTime_t-StartTime_t)/1s\r\n by RequestId_s\r\n ) on RequestId_s\r\n| order by Query_Submit_Time\r\n| project Session_ID,RequestId_s,Query_Submit_Time,Query_Start_Time,EventTime = Query_End_Time,num_steps,max_step_rows,max_step_sec,Query_ElapsedTime_s,Status,Query = Query_Text,Resource_class\r\n| join kind = rightouter \r\n(\r\n AzureDiagnostics\r\n | where Category == 'SQLSecurityAuditEvents' and LogicalServerName_s == \"{LogicalServerName}\"\r\n | where duration_milliseconds_d > 0\r\n | extend duration_seconds = duration_milliseconds_d /1000.0\r\n | where statement_s != 'select @@version'\r\n | where statement_s != 'SELECT @@SPID;'\r\n | where server_principal_name_s has '{User}'\r\n // | where application_name_s has '{Application}'\r\n | project DatabaseName= database_name_s, UserName= server_principal_name_s, EventTime= event_time_t, Host= host_name_s, duration_seconds = round(duration_seconds), statement_s, QuerySource = application_name_s , affected_rows_d\r\n | project-reorder DatabaseName, UserName, Host, EventTime, duration_seconds, statement_s, QuerySource\r\n) on EventTime\r\n | order by affected_rows_d desc\r\n| project Session_ID,RequestID=RequestId_s,Submit_time=Query_Submit_Time,Start_Time=Query_Start_Time,End_Time=EventTime,Status,Resource_class,UserName,Query_text=statement_s,Host,QuerySource,Affected_rows=affected_rows_d,num_steps,max_step_rows,max_step_sec,Total_Duration_s=duration_seconds\r\n\r\n\r\n\r\n\r\n", "size": 0, "title": "Affected Rows By Session ID", "timeContext": { "durationMs": 604800000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "linechart", "chartSettings": { "xAxis": "RequestID", "yAxis": [ "Affected_rows" ] } }, "name": "query - 6" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "QueryAudit" }, "name": "QueryAuditGroup", "styleSettings": { "showBorder": true } }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "title": "Query Comparison", "items": [ { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "7fa3187e-9225-4faa-8f80-dc1bc40c5aab", "version": "KqlParameterItem/1.0", "name": "RequestId1", "type": 1, "value": "" } ], "style": "above", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "customWidth": "50", "name": "parameters - 3 - Copy" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "315fc476-469a-4d8d-b421-028d1113ab06", "version": "KqlParameterItem/1.0", "name": "RequestId2", "type": 1, "value": "", "timeContext": { "durationMs": 86400000 } } ], "style": "above", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "customWidth": "50", "name": "parameters - 2" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s !in ('Batch','Execute') and RequestId_s == '{RequestId1}'\r\n| summarize Session_ID=any(SessionId_s),\r\n Request_ID=any(RequestId_s),\r\n Submit_Time=max(SubmitTime_t),\r\n Start_Time=max(StartTime_t),\r\n End_Time=max(EndTime_t),\r\n Command=any(Command_s),\r\n Status=min(Status_s), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType_s),\r\n Resource_class=any(ResourceClass_s)\r\n by RequestId_s\r\n| summarize Session_ID=any(Session_ID), Submit_Time=any(Submit_Time) ,Start_Time=any(Start_Time), End_Time=any(End_Time),ElapsedTime_min=anyif((End_Time - Start_Time)/1m,Start_Time > ago(30d)),Command=any(Command),Status=any(Status),Statement_Type=any(Statement_Type),Resource_class=any(Resource_class) by Request_ID\r\n| project Session_ID,Request_ID,ElapsedTime_min,Command,Resource_class,Submit_Time,Start_Time,End_Time,Statement_Type,Status\r\n", "size": 4, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "customWidth": "50", "name": "query - 2" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s !in ('Batch','Execute') and RequestId_s == '{RequestId2}'\r\n| summarize Session_ID=any(SessionId_s),\r\n Request_ID=any(RequestId_s),\r\n Submit_Time=max(SubmitTime_t),\r\n Start_Time=max(StartTime_t),\r\n End_Time=max(EndTime_t),\r\n Command=any(Command_s),\r\n Status=min(Status_s), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType_s),\r\n Resource_class=any(ResourceClass_s)\r\n by RequestId_s\r\n| summarize Session_ID=any(Session_ID), Submit_Time=any(Submit_Time) ,Start_Time=any(Start_Time), End_Time=any(End_Time),ElapsedTime_min=anyif((End_Time - Start_Time)/1m,Start_Time > ago(30d)),Command=any(Command),Status=any(Status),Statement_Type=any(Statement_Type),Resource_class=any(Resource_class) by Request_ID\r\n| project Session_ID,Request_ID,ElapsedTime_min,Command,Resource_class,Submit_Time,Start_Time,End_Time,Statement_Type,Status\r\n", "size": 4, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "customWidth": "50", "name": "query - 2 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics\r\n| where Category == 'RequestSteps'\r\n| where Resource == '{DatabaseName}'\r\n| where RequestId_s == '{RequestId1}'\r\n| summarize StartTime=max(StartTime_t)\r\n ,EndTime=max(EndTime_t)\r\n ,RequestID=max(RequestId_s)\r\n ,Operation=max(OperationType_s)\r\n ,RowCount=max(RowCount_d)\r\n ,Command=max(Command_s)\r\n ,Status=max(Status_s)\r\n by StepIndex_d\r\n| order by StepIndex_d asc\r\n| project StartTime,EndTime,RequestID,Operation,RowCount,Command,Status,StepIndex_d", "size": 3, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "customWidth": "50", "name": "query - 4", "styleSettings": { "margin": "0", "padding": "10px" } }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics\r\n| where Category == 'RequestSteps'\r\n| where Resource == '{DatabaseName}'\r\n| where RequestId_s == '{RequestId2}'\r\n| summarize StartTime=max(StartTime_t)\r\n ,EndTime=max(EndTime_t)\r\n ,RequestID=max(RequestId_s)\r\n ,Operation=max(OperationType_s)\r\n ,RowCount=max(RowCount_d)\r\n ,Command=max(Command_s)\r\n ,Status=max(Status_s)\r\n by StepIndex_d\r\n| order by StepIndex_d asc\r\n| project StartTime,EndTime,RequestID,Operation,RowCount,Command,Status,StepIndex_d", "size": 3, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "customWidth": "50", "name": "query - 4 - Copy", "styleSettings": { "padding": "10px" } } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "QueryComparison" }, "name": "QueryComparison" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "title": "Session Investigation", "items": [ { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "feb2ac70-2555-456e-bfa6-6ad4a2dcad0f", "version": "KqlParameterItem/1.0", "name": "SessionID", "type": 1, "value": "", "timeContext": { "durationMs": 86400000 } } ], "style": "above", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 0" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databasename='{DatabaseName}';\r\nAzureDiagnostics \r\n| where Category == 'ExecRequests'\r\n| where Resource == databasename\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize Query_End_Time = max(EndTime_t ) by SessionId_s\r\n| where SessionId_s == '{SessionID}'\r\n| join kind = rightouter \r\n( \r\n AzureDiagnostics\r\n | where Category == 'SQLSecurityAuditEvents' \r\n | where duration_milliseconds_d > 0\r\n | extend duration_seconds = duration_milliseconds_d /1000.0\r\n | where statement_s != 'select @@version' and statement_s != 'SELECT @@SPID;' and server_principal_name_s != '##MS_InstanceCertificate##'\r\n) on $left.Query_End_Time==$right.event_time_t \r\n| summarize DatabaseName= max(database_name_s)\r\n , UserName= any(server_principal_name_s)\r\n , Host= max(host_name_s)\r\n , Application=max(application_name_s)\r\n by SessionId_s\r\n\r\n\r\n\r\n", "size": 4, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "tiles", "tileSettings": { "titleContent": { "columnMatch": "UserName" }, "subtitleContent": { "columnMatch": "SessionId_s" }, "leftContent": { "columnMatch": "Application" }, "rightContent": { "columnMatch": "Host" }, "secondaryContent": { "columnMatch": "DatabaseName" }, "showBorder": false, "size": "full" }, "graphSettings": { "type": 0 } }, "name": "query - 3" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics \r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize \r\n Session_ID=max(SessionId_s), \r\n Submit_Time=max(SubmitTime_t), \r\n Start_Time=max(StartTime_t),\r\n End_Compile_Time=max(EndCompileTime_t), \r\n End_Time=max(EndTime_t), \r\n Command=max(Command_s), \r\n Last_Status=min(Status_s),\r\n Statement_Type=max(StatementType_s),\r\n Resource_class=max(ResourceClass_s) \r\n by RequestId_s\r\n| where Session_ID has '{SessionID}'\r\n| extend elapsedTime_sec = iif(End_Time > ago(365d),(End_Time - Submit_Time)/1s,real(null)) \r\n| order by Submit_Time asc\r\n\r\n\r\n\r\n\r\n", "size": 0, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "exportFieldName": "RequestId_s", "exportParameterName": "RequestID", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 1" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics\r\n| where Category == 'RequestSteps'\r\n| where Resource == '{DatabaseName}'\r\n| where RequestId_s == '{RequestID}'\r\n//| where Status_s != 'Running'\r\n| summarize max(StartTime_t),max(EndTime_t),max(RequestId_s),max(OperationType_s),max(RowCount_d),max(Command_s),max(Status_s) by StepIndex_d\r\n| order by StepIndex_d asc", "size": 3, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 2" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "SessionInvestigation" }, "name": "group - 9" } ], "fallbackResourceIds": [ "azure monitor" ], "$schema": "https://github.com/Microsoft/Application-Insights-Workbooks/blob/master/schema/workbook.json" } ================================================ FILE: Monitor_Workbooks/archive/SynapseWorkbook_v1.1.json ================================================ { "version": "Notebook/1.0", "items": [ { "type": 9, "content": { "version": "KqlParameterItem/1.0", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "parameters": [ { "id": "28da10ec-a308-47f5-9819-92ebf810b292", "version": "KqlParameterItem/1.0", "name": "LogAnalyticsSubscription", "type": 6, "value": null, "typeSettings": { "additionalResourceOptions": [], "includeAll": true, "showDefault": false }, "timeContext": { "durationMs": 86400000 } }, { "id": "e383ed24-52ae-447b-9b80-51fd3ab6b919", "version": "KqlParameterItem/1.0", "name": "LogAnalyticsWorkspace", "type": 5, "query": "Resources\r\n| where type == 'microsoft.operationalinsights/workspaces'\r\n| project id\r\n", "crossComponentResources": [ "{LogAnalyticsSubscription}" ], "value": null, "typeSettings": { "additionalResourceOptions": [], "showDefault": false }, "timeContext": { "durationMs": 86400000 }, "queryType": 1, "resourceType": "microsoft.resourcegraph/resources" }, { "id": "9b9fe566-0f52-4a75-a35b-a79c50c6a6f0", "version": "KqlParameterItem/1.0", "name": "DatabaseResourceName", "type": 5, "query": "AzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| distinct ResourceId", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "value": null, "typeSettings": { "additionalResourceOptions": [], "showDefault": false }, "timeContext": { "durationMs": 604800000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "id": "f5852627-70ca-4959-8d60-53b48864603f", "version": "KqlParameterItem/1.0", "name": "TimeRange", "type": 4, "isGlobal": true, "value": { "durationMs": 14400000 }, "typeSettings": { "selectableValues": [ { "durationMs": 300000 }, { "durationMs": 900000 }, { "durationMs": 1800000 }, { "durationMs": 3600000 }, { "durationMs": 14400000 }, { "durationMs": 43200000 }, { "durationMs": 86400000 }, { "durationMs": 172800000 }, { "durationMs": 259200000 }, { "durationMs": 604800000 }, { "durationMs": 1209600000 }, { "durationMs": 2419200000 }, { "durationMs": 2592000000 } ], "allowCustom": true }, "timeContext": { "durationMs": 86400000 } }, { "id": "6da2f63f-45a3-4b37-9108-5e8b7e358d85", "version": "KqlParameterItem/1.0", "name": "DatabaseName", "type": 1, "query": "AzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where ResourceId == '{DatabaseResourceName}'\r\n| distinct Resource ", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 604800000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "id": "8bba835b-f319-43b3-8ec6-4e051fc6d446", "version": "KqlParameterItem/1.0", "name": "LogicalServerName", "type": 1, "query": "AzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where ResourceId == '{DatabaseResourceName}'\r\n| distinct LogicalServerName_s", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 2" }, { "type": 11, "content": { "version": "LinkItem/1.0", "style": "tabs", "links": [ { "id": "202cbbc0-8d63-416d-89ed-451d6fe7c4b3", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Workload", "subTarget": "Workload", "preText": "Workload", "style": "link" }, { "id": "a7901bd0-a1f4-4491-b953-57555d764e00", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Workload Management", "subTarget": "WorkloadManagement", "style": "link" }, { "id": "45e12a14-8548-4477-aae3-c142b906dc9f", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "TempDB", "subTarget": "TempDB", "style": "link" }, { "id": "9ef8f730-d73d-432b-9b75-55095d1155f2", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Replicated Tables", "subTarget": "ReplicatedTables", "style": "link" }, { "id": "79d10d16-0696-4214-b306-c7a0e46cd64f", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Query Investigation", "subTarget": "QueryInvestigation", "style": "link" }, { "id": "31c1cf1c-74b5-44e2-ba9a-9497834ca3dc", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Query Comparison", "subTarget": "QueryComparison", "style": "link" }, { "id": "5ff681ee-e005-481f-b743-b66ab1b9d71d", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Session Investigation", "subTarget": "SessionInvestigation", "style": "link" }, { "id": "482ccc46-8a10-4ace-bfd6-63ac73b380af", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Query Audit", "subTarget": "QueryAudit", "style": "link" }, { "id": "db43bb45-1611-47ce-a2ad-517943f2aa1a", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "AutoStats", "subTarget": "Statistics", "style": "link" } ] }, "name": "links - 0" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "title": "Workload", "items": [ { "type": 10, "content": { "chartId": "workbook90867bfc-5c33-464f-ac31-2c2e006b97f4", "version": "MetricsItem/2.0", "size": 0, "chartType": 2, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 14400000 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-dwu_consumption_percent", "aggregation": 3, "splitBy": null, "columnName": "DWU Percentage" }, { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-cpu_percent", "aggregation": 3 }, { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-physical_data_read_percent", "aggregation": 3 } ], "title": "DWU Resource Utilization", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "name": "metric - 1" }, { "type": 10, "content": { "chartId": "workbookb954d4a0-82ef-4409-88fb-837aaff80c8d", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 14400000 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-active_queries", "aggregation": 1, "splitBy": null }, { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-queued_queries", "aggregation": 1 } ], "title": "Active and Queued Queries", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "name": "metric - 1" }, { "type": 10, "content": { "chartId": "workbookb954d4a0-82ef-4409-88fb-837aaff80c8d", "version": "MetricsItem/2.0", "size": 0, "chartType": 3, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 14400000 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-local_tempdb_usage_percent", "aggregation": 3, "splitBy": null, "columnName": "TempDB Utilization Percentage" } ], "title": "TempDB Utilization", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "name": "metric - 1 - Copy" }, { "type": 10, "content": { "chartId": "workbookb954d4a0-82ef-4409-88fb-837aaff80c8d", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 14400000 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-WorkloadManagement-wlg_allocation_relative_to_system_percent", "aggregation": 3, "splitBy": "WorkloadGroupName" } ], "title": "Workload Group Utilization", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "name": "Workload Group Utilization" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databaseName = '{DatabaseName}';\r\n//Long-Running Queries - Just Actual Queries\r\n//If 'Command' is empty - you need to set a bigger time window, the older record with the command is outside of your window\r\nAzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where Resource == databaseName\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize Session_ID=any(SessionId_s),\r\n Request_ID=any(RequestId_s),\r\n Submit_Time=max(SubmitTime_t),\r\n Start_Time=max(StartTime_t),\r\n End_Time=max(EndTime_t),\r\n Command=any(Command_s),\r\n Status=min(Status_s), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType_s),\r\n Resource_class=any(ResourceClass_s)\r\n by RequestId_s\r\n| summarize ElapsedTime_min=bin(anyif(((End_Time - Start_Time)/1m),Start_Time > ago(30d)),1),\r\n Session_ID=any(Session_ID), \r\n Submit_Time=any(Submit_Time) ,\r\n Start_Time=any(Start_Time), \r\n End_Time=any(End_Time),\r\n Command=any(Command),\r\n Status=any(Status),\r\n Statement_Type=any(Statement_Type)\r\n ,Resource_class=any(Resource_class) \r\n by Request_ID\r\n| where End_Time > ago(365d)\r\n| summarize count() by Status, bin(End_Time,5m)\r\n| render timechart \r\n", "size": 0, "title": "Query Completion Count by End Time - 5m buckets", "color": "redBright", "timeContext": { "durationMs": 14400000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "chartSettings": { "seriesLabelSettings": [ { "seriesName": "Completed", "color": "green" }, { "seriesName": "Failed", "color": "red" }, { "seriesName": "Cancelled", "color": "yellow" } ] } }, "name": "query - 4" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": " AzureDiagnostics\r\n | where Category == 'SQLSecurityAuditEvents' and LogicalServerName_s == '{LogicalServerName}'\r\n //| where duration_milliseconds_d > 0\r\n | extend duration_seconds = duration_milliseconds_d /1000.0\r\n | where statement_s != 'select @@version'\r\n | where statement_s != 'SELECT @@SPID;'\r\n | summarize sum(affected_rows_d) by bin(TimeGenerated,1h)", "size": 0, "title": "Rows Processed by End Time - 1h buckets", "timeContext": { "durationMs": 259200000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "categoricalbar" }, "name": "query - 7" }, { "type": 10, "content": { "chartId": "workbook1afc57e6-0b32-4968-b299-db319bd21635", "version": "MetricsItem/2.0", "size": 0, "chartType": 2, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 14400000 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-connection_successful", "aggregation": 1, "splitBy": null }, { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-connection_failed", "aggregation": 1 } ], "title": "Successful and Failed Connections", "gridSettings": { "rowLimit": 10000 } }, "name": "metric - 5" }, { "type": 10, "content": { "chartId": "workbook993837ad-66d6-4cbc-ae1a-7c3f6623236b", "version": "MetricsItem/2.0", "size": 0, "chartType": 2, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 14400000 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-cache_used_percent", "aggregation": 3, "splitBy": null }, { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-cache_hit_percent", "aggregation": 3 } ], "title": "Adaptive Cache Used vs Hit Percentage", "gridSettings": { "rowLimit": 10000 } }, "name": "metric - 6" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "Workload" }, "name": "group - 1" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "title": "TempDB ", "items": [ { "type": 10, "content": { "chartId": "workbook4a9cf761-cce2-45b2-8947-8a9428ec7e1c", "version": "MetricsItem/2.0", "size": 0, "chartType": 3, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 14400000 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-local_tempdb_usage_percent", "aggregation": 3, "splitBy": null, "columnName": "TempDB Util" } ], "title": "TempDB Max and Avg Utilization", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "name": "metric - 0" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "19ee48f5-8f4e-4939-a0ef-c6bf656a93f9", "version": "KqlParameterItem/1.0", "name": "WeightParameter", "type": 1, "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 } }, { "id": "00553ec8-1a41-4dd9-a024-d607639c9bbb", "version": "KqlParameterItem/1.0", "name": "RequestID", "type": 1, "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 } } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 3" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databaseName = '{DatabaseName}';\r\n//Weighted query steps\r\nAzureDiagnostics\r\n| where Category == 'RequestSteps'\r\n| where Resource == databaseName\r\n| where RowCount_d > 0\r\n| summarize sum(RowCount_d) by RequestId_s, OperationType_s\r\n| order by sum_RowCount_d desc\r\n| limit 20\r\n| render columnchart ", "size": 0, "title": "20 Largest Query Steps by Most Rows Moved", "timeContext": { "durationMs": 14400000 }, "timeContextFromParameter": "TimeRange", "exportFieldName": "Request_ID", "exportParameterName": "RequestID", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "chartSettings": { "xAxis": "RequestId_s", "group": "OperationType_s", "createOtherGroup": 20, "showLegend": true } }, "name": "query - 1 - Copy" }, { "type": 11, "content": { "version": "LinkItem/1.0", "style": "nav", "links": [ { "id": "c98d3722-9907-43ab-9306-1957d6f7f858", "cellValue": "WeightParameter", "linkTarget": "parameter", "linkLabel": "Weighted Rowcounts", "subTarget": "Weighted", "preText": "", "postText": "", "style": "secondary" }, { "id": "a06ae99a-ad62-45e9-8c25-c219b81f59c0", "cellValue": "WeightParameter", "linkTarget": "parameter", "linkLabel": "Unweighted Rowcounts", "subTarget": "Unweighted", "preText": "", "postText": "", "style": "secondary" } ] }, "name": "links - 3" }, { "type": 1, "content": { "json": "Current Setting: {WeightParameter}", "style": "info" }, "name": "text - 4" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databaseName = '{DatabaseName}';\r\n//Weighted query steps\r\nlet RequestSteps = AzureDiagnostics\r\n| where Category == 'RequestSteps'\r\n| where Resource == databaseName\r\n| where RowCount_d > 100000000\r\n| extend Step_Elapsed_Min = round((EndTime_t - StartTime_t)/1m, 2)\r\n| extend Weighted_cnt = iff('{WeightParameter}'=='Weighted',(case(OperationType_s == 'BroadcastMoveOperation', (RowCount_d*20), RowCount_d)),RowCount_d)\r\n| project-rename StepStatus = Status_s, StepStart = StartTime_t, StepEnd = EndTime_t//, StepResource = Resource\r\n| top 100 by Weighted_cnt desc\r\n| order by Weighted_cnt desc\r\n| project Request_ID=RequestId_s,OperationType_s, RowCount_d,Weighted_cnt,Step_Elapsed_Min, StepStart, StepEnd, StepStatus, StepIndex_d,Resource;\r\nRequestSteps | join (AzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where Resource == databaseName\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize Session_ID=any(SessionId_s),\r\n Request_ID=any(RequestId_s),\r\n Submit_Time=max(SubmitTime_t),\r\n Start_Time=max(StartTime_t),\r\n End_Time=max(EndTime_t),\r\n Command=any(Command_s),\r\n Status=min(Status_s), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType_s),\r\n Resource_class=any(ResourceClass_s)\r\n by RequestId_s\r\n| summarize Session_ID=any(Session_ID), Submit_Time=any(Submit_Time) ,Start_Time=any(Start_Time), End_Time=any(End_Time),Command=any(Command),Status=any(Status),Statement_Type=any(Statement_Type),Resource_class=any(Resource_class) by Request_ID\r\n//| order by Step_Elapsed_Min desc\r\n| extend Request_Elapsed_Min = round((End_Time - Start_Time)/1m, 2)\r\n| project-rename ReqStatus = Status, ReqStart = Start_Time, ReqEnd = End_Time\r\n) on Request_ID\r\n| project-reorder Session_ID, Request_ID, Request_Elapsed_Min, ReqStart, ReqEnd, ReqStatus,StepIndex_d, OperationType_s, RowCount_d,Weighted_cnt,Step_Elapsed_Min, StepStart, StepEnd, StepStatus, Statement_Type, Command, Resource_class\r\n| order by Weighted_cnt desc\r\n| limit 20", "size": 3, "title": "20 Largest Query Steps by Most Rows Moved", "timeContext": { "durationMs": 14400000 }, "timeContextFromParameter": "TimeRange", "exportFieldName": "Request_ID1", "exportParameterName": "RequestID", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "sortBy": [ { "itemKey": "Weighted_cnt", "sortOrder": 2 } ] }, "sortBy": [ { "itemKey": "Weighted_cnt", "sortOrder": 2 } ] }, "name": "query - 1" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databaseName = '{DatabaseName}';\r\n//Long-Running Queries - Just Actual Queries\r\n//If 'Command' is empty - you need to set a bigger time window, the older record with the command is outside of your window\r\nAzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where Resource == databaseName\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize Session_ID=any(SessionId_s),\r\n Request_ID=any(RequestId_s),\r\n Submit_Time=max(SubmitTime_t),\r\n Start_Time=max(StartTime_t),\r\n End_Time=max(EndTime_t),\r\n Command=any(Command_s),\r\n Status=min(Status_s), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType_s),\r\n Resource_class=any(ResourceClass_s)\r\n by RequestId_s\r\n| summarize ElapsedTime_min=bin(anyif(((End_Time - Start_Time)/1m),Start_Time > ago(30d)),1),\r\n Session_ID=any(Session_ID), \r\n Submit_Time=any(Submit_Time) ,\r\n Start_Time=any(Start_Time), \r\n End_Time=any(End_Time),\r\n Command=any(Command),\r\n Status=any(Status),\r\n Statement_Type=any(Statement_Type)\r\n ,Resource_class=any(Resource_class) \r\n by Request_ID\r\n| where Request_ID == '{RequestID}'\r\n\r\n", "size": 4, "title": "Selected Query", "noDataMessage": "Select a query above to view details", "timeContext": { "durationMs": 14400000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "35%" } } ] } }, "name": "query - 6" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics\r\n| where Category == 'RequestSteps'\r\n| where Resource == '{DatabaseName}'\r\n| where RequestId_s == '{RequestID}' //Put your QueryID here\r\n| where Status_s != 'Running'\r\n| summarize max(StartTime_t),max(EndTime_t),max(RequestId_s),max(OperationType_s),max(RowCount_d),max(Command_s),max(Status_s) by StepIndex_d\r\n| order by StepIndex_d asc", "size": 3, "title": "Query Plan", "noDataMessage": "Select a query above to view the plan", "timeContext": { "durationMs": 14400000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 7" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "TempDB" }, "name": "group - 3" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "title": "Query Investigation", "items": [ { "type": 1, "content": { "json": "## Search Criteria\r\nUse the following fields to search either using a query text snippet or using a Request ID. If using a query text snippet, try to keep it as simple as possible becuase minor changes in formatting may cause your queries not to show up in the results. It's best to pick something like a table name, then choose the proper query from the list that will populate. " }, "customWidth": "50", "name": "text - 4" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "0c2128d0-d979-4562-a28c-e7ceb955f126", "version": "KqlParameterItem/1.0", "name": "RequestIdSearch", "type": 1, "value": "" }, { "id": "29880874-2d41-4bd5-bf22-3e47ae8b1145", "version": "KqlParameterItem/1.0", "name": "QueryTextSnippet", "type": 1, "value": "", "timeContext": { "durationMs": 86400000 } } ], "style": "formVertical", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "customWidth": "60", "name": "parameters - 3" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics \r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize \r\n Session_ID=max(SessionId_s), \r\n Request_ID=max(RequestId_s), \r\n Submit_Time=max(SubmitTime_t), \r\n Start_Time=max(StartTime_t),\r\n End_Compile_Time=max(EndCompileTime_t), \r\n End_Time=max(EndTime_t), \r\n Command=max(Command_s), \r\n Last_Status=min(Status_s),\r\n Statement_Type=max(StatementType_s),\r\n Resource_class=max(ResourceClass_s) \r\n by RequestId_s\r\n| where Command has '{QueryTextSnippet}'\r\nand RequestId_s has '{RequestIdSearch}'\r\n| extend elapsedTime_sec = iif(End_Time > ago(365d),(End_Time - Submit_Time)/1s,real(null)) \r\n| extend CompileTime_sec = (End_Compile_Time - Submit_Time)/1s\r\n| order by elapsedTime_sec\r\n| summarize \r\n Executions = count(),\r\n Max_Elapsed_Time_sec = bin(max(elapsedTime_sec),1),\r\n Min_Elapsed_Time_sec = bin(min(elapsedTime_sec),1),\r\n Variability_sec=bin((max(elapsedTime_sec)-min(elapsedTime_sec)),1),\r\n SampleQID = any(RequestId_s),\r\n SampleSessionID = any(Session_ID)\r\n by Command\r\n| order by Max_Elapsed_Time_sec\r\n\r\n\r\n", "size": 0, "title": "Matching Queries", "timeContext": { "durationMs": 14400000 }, "timeContextFromParameter": "TimeRange", "exportedParameters": [ { "fieldName": "SampleQID", "parameterName": "SampleQID" }, { "fieldName": "SampleSessionID", "parameterName": "Samp", "parameterType": 1 } ], "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "50%" } } ], "sortBy": [ { "itemKey": "Command", "sortOrder": 1 } ] }, "sortBy": [ { "itemKey": "Command", "sortOrder": 1 } ] }, "name": "query - 0" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics \r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s !in ('Batch','Execute')\r\n| where RequestId_s == '{SampleQID}'\r\n| summarize \r\n Session_ID=max(SessionId_s), \r\n Request_ID=max(RequestId_s), \r\n Submit_Time=min(SubmitTime_t), \r\n Start_Time=max(StartTime_t),\r\n End_Compile_Time=max(EndCompileTime_t), \r\n End_Time=max(EndTime_t), \r\n Command=max(Command_s), \r\n Last_Status=min(Status_s),\r\n Statement_Type=max(StatementType_s),\r\n Resource_class=max(ResourceClass_s) \r\n by RequestId_s\r\n| extend elapsedTime_sec = iif(End_Time > ago(365d),(End_Time - Submit_Time)/1s,real(null)) \r\n| extend CompileTime_sec = (End_Compile_Time - Submit_Time)/1s\r\n| join kind=inner\r\n (AzureDiagnostics \r\n | where Category == 'ExecRequests'\r\n | where Resource == '{DatabaseName}'\r\n | where StatementType_s !in ('Batch','Execute')\r\n | summarize \r\n Session_ID=max(SessionId_s), \r\n Request_ID=max(RequestId_s), \r\n Submit_Time=min(SubmitTime_t), \r\n Start_Time=max(StartTime_t),\r\n End_Compile_Time=max(EndCompileTime_t), \r\n End_Time=max(EndTime_t), \r\n Command=max(Command_s), \r\n Last_Status=min(Status_s),\r\n Statement_Type=max(StatementType_s),\r\n Resource_class=max(ResourceClass_s) \r\n by RequestId_s\r\n | extend elapsedTime_sec = (End_Time - Submit_Time)/1s\r\n | extend elapsedTime_sec = iif(End_Time > ago(365d),(End_Time - Submit_Time)/1s,real(null)) \r\n | extend CompileTime_sec = (End_Compile_Time - Submit_Time)/1s\r\n )\r\non Command \r\n| project Request_ID1,Session_ID1,Submit_Time1,Start_Time1,End_Compile_Time1,End_Time1,Last_Status1,Statement_Type1,Resource_class1,elapsedTime_sec1,CompileTime_sec1\r\n", "size": 0, "title": "All Executions of Selected Query", "noDataMessage": "Select a query above to see individual executions", "timeContext": { "durationMs": 14400000 }, "timeContextFromParameter": "TimeRange", "exportFieldName": "Request_ID1", "exportParameterName": "RequestId", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "sortBy": [] }, "name": "query - 0 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics\r\n| where Category == 'RequestSteps'\r\n| where Resource == '{DatabaseName}'\r\n| where RequestId_s == '{RequestId}'\r\n//| where Status_s != 'Running'\r\n| summarize max(StartTime_t),max(EndTime_t),max(RequestId_s),max(OperationType_s),max(RowCount_d),max(Command_s),min(Status_s) by StepIndex_d\r\n| order by StepIndex_d asc", "size": 3, "title": "Query Plan for Selected Query", "noDataMessage": "Select a Query Above to See the Query Plan", "timeContext": { "durationMs": 14400000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 0 - Copy - Copy" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "QueryInvestigation" }, "name": "group - 4", "styleSettings": { "showBorder": true } }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "title": "Replicated Tables", "items": [ { "type": 1, "content": { "json": "All Charts on this page are based on the last 7 days of data", "style": "info" }, "name": "text - 5" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Build cache count by day\r\nAzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s == 'BuildReplicatedTableCache'\r\n| where Command_s != \"\"\r\n| where ResourceClass_s != \"\"\r\n| project Command_s,TimeGenerated,RequestId_s\r\n| summarize LastRebuild=max(TimeGenerated),RebuildCount=count(RequestId_s) by Command_s\r\n| order by RebuildCount desc\r\n| limit 15\r\n", "size": 3, "title": "Top 15 Most Rebuilds by Table", "timeContext": { "durationMs": 604800000 }, "exportFieldName": "Command_s", "exportParameterName": "QueryText", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command_s", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "40%" } } ] } }, "name": "query - 0" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Build cache count by day\r\nAzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s == 'BuildReplicatedTableCache'\r\n| where Command_s == \"{QueryText}\"\r\n| where ResourceClass_s != \"\"\r\n| project Command_s,TimeGenerated,RequestId_s\r\n| summarize count() by Command_s,bin(TimeGenerated,24h)\r\n| limit 20\r\n| render timechart", "size": 0, "title": "Rebuilds per Day for Selected Table", "noDataMessage": "Select a query above to see runs by day", "timeContext": { "durationMs": 604800000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "chartSettings": { "group": "Command_s", "createOtherGroup": 20, "ySettings": { "min": 0 } } }, "name": "query - 0 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Build cache count by day\r\nAzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s == 'BuildReplicatedTableCache'\r\n| where Command_s != \"\"\r\n| where ResourceClass_s != \"\"\r\n| project Command_s,TimeGenerated,RequestId_s\r\n| summarize count() by Command_s, bin(TimeGenerated,24h)\r\n| where count_ > 7\r\n| order by count_ desc\r\n\r\n", "size": 2, "title": "Rebuild Count by Table by Day", "timeContext": { "durationMs": 604800000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "categoricalbar", "gridSettings": { "sortBy": [ { "itemKey": "count_", "sortOrder": 1 } ] }, "sortBy": [ { "itemKey": "count_", "sortOrder": 1 } ], "tileSettings": { "showBorder": false, "titleContent": { "columnMatch": "Command_s", "formatter": 1 }, "leftContent": { "columnMatch": "count_", "formatter": 12, "formatOptions": { "palette": "auto" }, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "graphSettings": { "type": 0, "topContent": { "columnMatch": "Command_s", "formatter": 1 }, "centerContent": { "columnMatch": "count_", "formatter": 1, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "chartSettings": { "group": "Command_s", "createOtherGroup": 99, "showDataPoints": true } }, "name": "query - 0 - Copy - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Long-Running Queries - Just Actual Queries\r\nAzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize Session_ID=max(SessionId_s), Request_ID=max(RequestId_s), Submit_Time=max(SubmitTime_t), Start_Time=max(StartTime_t), End_Time=max(EndTime_t), Command=max(Command_s), Statement_Type=max(StatementType_s), Resource_class=max(ResourceClass_s) by RequestId_s\r\n| join kind= inner\r\n(\r\n AzureDiagnostics\r\n | where Category == 'ExecRequests'\r\n | where Resource == '{DatabaseName}'\r\n //| where StatementType_s !in ('Batch','Execute')\r\n | where StatementType_s == 'BuildReplicatedTableCache'\r\n | where EndTime_t > ago(7d)\r\n | where StartTime_t > ago(7d)\r\n | extend elapsedTime_min = (EndTime_t - StartTime_t)/1m\r\n //| extend elapsedTime_min = elapsedTime/1m\r\n | order by elapsedTime_min desc\r\n | project Request_ID=RequestId_s,elapsedTime_min \r\n)\r\non Request_ID\r\n| order by elapsedTime_min desc\r\n| project Request_ID,Submit_Time,Start_Time,End_Time,Elapsed_Time=round(elapsedTime_min,1) ,Command\r\n| limit 15\r\n", "size": 3, "title": "Top 15 Elapsed Time per Rebuild", "timeContext": { "durationMs": 604800000 }, "exportFieldName": "Request_ID", "exportParameterName": "RequestId", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "40%" } } ] } }, "name": "query - 3" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics\r\n| where Category == 'RequestSteps'\r\n| where Resource == '{DatabaseName}'\r\n| where RequestId_s == '{RequestId}'\r\n| where Status_s != 'Running'\r\n| summarize max(StartTime_t),max(EndTime_t),max(RequestId_s),max(OperationType_s),max(RowCount_d),max(Command_s),max(Status_s) by StepIndex_d\r\n| order by StepIndex_d asc", "size": 3, "title": "Query Plan for Selected Query", "noDataMessage": "Select a query above to view plan", "timeContext": { "durationMs": 604800000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 4" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "ReplicatedTables" }, "name": "ReplicatedTablesGroup" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "title": "Workload Management", "items": [ { "type": 10, "content": { "chartId": "workbook72446028-6edb-4cb0-8952-e0c13bda488f", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 14400000 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-WorkloadManagement-wlg_allocation_relative_to_system_percent", "aggregation": 3, "splitBy": null } ], "title": "Workload Group Allocation By System Percent", "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "name": "metric - 0" }, { "type": 10, "content": { "chartId": "workbookc898119a-7381-469d-b51a-d505b4f80e73", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 14400000 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-WorkloadManagement-wlg_active_queries", "aggregation": 1, "splitBy": null } ], "title": "Query Count by Workload Group", "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "name": "metric - 1" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "parameters": [ { "id": "6f50577d-7b00-4e4a-acf9-d45c7a5ee813", "version": "KqlParameterItem/1.0", "name": "WorkloadGroupName", "type": 2, "query": "AzureDiagnostics\r\n| where Category == 'ExecRequests'\r\nand Resource == '{DatabaseName}'\r\n and ResourceClass_s != \"\"\r\n| distinct ResourceClass_s", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "value": null, "typeSettings": { "additionalResourceOptions": [], "showDefault": false }, "timeContext": { "durationMs": 604800000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 2" }, { "type": 10, "content": { "chartId": "workbook3da1d18a-1bf5-46c5-b3b7-211f71d329cc", "version": "MetricsItem/2.0", "size": 0, "chartType": 2, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 14400000 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-WorkloadManagement-wlg_active_queries", "aggregation": 1, "splitBy": null }, { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-WorkloadManagement-wlg_queued_queries", "aggregation": 1 }, { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-WorkloadManagement-wlg_allocation_relative_to_system_percent", "aggregation": 3 } ], "filters": [ { "id": "3", "key": "WorkloadGroupName", "operator": 0, "valueParam": "WorkloadGroupName" } ], "gridSettings": { "rowLimit": 10000 } }, "name": "metric - 3" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "WorkloadManagement" }, "name": "group - 6" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "title": "Query Audit", "items": [ { "type": 1, "content": { "json": "## Select a Principal or Application name to filter results - leave to 'unset' to view all results\r\nSQL Auditing must be enabled and sending to the same Log Analytics Workspace for this page to work. " }, "name": "text - 5" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "parameters": [ { "id": "8d25c043-d1ff-4546-a1fa-f4bcbfdab8af", "version": "KqlParameterItem/1.0", "name": "User", "type": 2, "description": "User to filter subsequent queries - leave to 'unset' for all users", "query": "AzureDiagnostics\r\n| where Category == 'SQLSecurityAuditEvents' and LogicalServerName_s == '{LogicalServerName}'\r\n| summarize by server_principal_name_s", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "value": null, "typeSettings": { "additionalResourceOptions": [], "showDefault": false }, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "id": "aa766d64-693f-4024-b4a4-b5b56b28376b", "version": "KqlParameterItem/1.0", "name": "Application", "type": 2, "query": "AzureDiagnostics\r\n| where Category == 'SQLSecurityAuditEvents' and LogicalServerName_s == '{LogicalServerName}'\r\n| summarize by application_name_s", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "value": null, "typeSettings": { "additionalResourceOptions": [], "showDefault": false }, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "customWidth": "30", "name": "parameters - 1" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics\r\n| where Category == 'SQLSecurityAuditEvents' and LogicalServerName_s == \"{LogicalServerName}\"\r\n| where duration_milliseconds_d > 0\r\n| extend duration_seconds = duration_milliseconds_d /1000.0\r\n| where statement_s != 'select @@version'\r\n| where statement_s != 'SELECT @@SPID;'\r\n| where server_principal_name_s has '{User}'\r\n| where application_name_s has '{Application}'\r\n| project server_principal_name_s, succeeded_s, event_time_t, LogicalServerName_s, duration_milliseconds_d, duration_seconds, affected_rows_d, statement_s, application_name_s\r\n| summarize duration_seconds = round(sum(duration_seconds)) , query_count = count(statement_s) by EventDay = bin(event_time_t,1d), UserName = server_principal_name_s, Application = application_name_s \r\n| order by EventDay, duration_seconds desc", "size": 0, "title": "Query Summary for Selected User {User} {Application}", "noDataMessage": "Select a user to see query activity", "timeContext": { "durationMs": 14400000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 0 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics\r\n| where Category == 'SQLSecurityAuditEvents' and LogicalServerName_s == \"{LogicalServerName}\"\r\n| where duration_milliseconds_d > 0\r\n| extend duration_seconds = duration_milliseconds_d /1000.0\r\n| where statement_s != 'select @@version'\r\n| where statement_s != 'SELECT @@SPID;'\r\n| where server_principal_name_s has '{User}'\r\n| where application_name_s has '{Application}'\r\n| project server_principal_name_s, succeeded_s, event_time_t, LogicalServerName_s, duration_milliseconds_d, duration_seconds, affected_rows_d, statement_s, application_name_s\r\n| summarize duration_seconds = round(sum(duration_seconds)) , query_count = count(statement_s) by EventDay = bin(event_time_t,1d), UserName = server_principal_name_s, Application = application_name_s \r\n| order by EventDay, duration_seconds desc", "size": 0, "title": "Query Summary for Selected User {User} {Application}", "noDataMessage": "Select a user to see query activity", "timeContext": { "durationMs": 14400000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "unstackedbar", "tileSettings": { "showBorder": false, "titleContent": { "columnMatch": "UserName", "formatter": 1 }, "leftContent": { "columnMatch": "duration_seconds", "formatter": 12, "formatOptions": { "palette": "auto" }, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "graphSettings": { "type": 0, "topContent": { "columnMatch": "UserName", "formatter": 1 }, "centerContent": { "columnMatch": "duration_seconds", "formatter": 1, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "chartSettings": { "xAxis": "UserName" }, "mapSettings": { "locInfo": "LatLong", "sizeSettings": "duration_seconds", "sizeAggregation": "Sum", "legendMetric": "duration_seconds", "legendAggregation": "Sum", "itemColorSettings": { "type": "heatmap", "colorAggregation": "Sum", "nodeColorField": "duration_seconds", "heatmapPalette": "greenRed" } } }, "name": "query - 0 - Copy - Copy" }, { "type": 1, "content": { "json": "## This next chart is a work in progress\r\nThe next chart uses an approximate join based on end time. If the Exec Requests Query Text and the Audit Log Query text don't match up, then it is likely not a real match and the data in teh row shoudl not be trusted. ", "style": "warning" }, "name": "text - 7" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databasename='{DatabaseName}';\r\nAzureDiagnostics \r\n| where Category == 'ExecRequests'\r\n| where Resource == databasename\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize Session_ID=max(SessionId_s), \r\n Query_Submit_Time=max(SubmitTime_t), \r\n Query_Start_Time=max(StartTime_t), \r\n Query_End_Time=max(EndTime_t), \r\n Query_Text=max(Command_s), \r\n Status=min(Status_s),\r\n Resource_class=max(ResourceClass_s) ,\r\n Query_ElapsedTime_s=round((max(EndTime_t) - max(StartTime_t))/1s)\r\n by RequestId_s\r\n| join kind = leftouter \r\n(\r\n AzureDiagnostics\r\n | where Category == 'RequestSteps'\r\n | where Resource == databasename\r\n | summarize num_steps=max(StepIndex_d), \r\n max_step_rows=max(RowCount_d), \r\n max_step_sec=max(EndTime_t-StartTime_t)/1s\r\n by RequestId_s\r\n ) on RequestId_s\r\n| order by Query_Submit_Time\r\n| project Session_ID,RequestId_s,Query_Submit_Time,Query_Start_Time,EventTime = Query_End_Time,num_steps,max_step_rows,max_step_sec,Query_ElapsedTime_s,Status,Query = Query_Text,Resource_class\r\n| join kind = rightouter \r\n(\r\n AzureDiagnostics\r\n | where Category == 'SQLSecurityAuditEvents' and LogicalServerName_s == \"{LogicalServerName}\"\r\n | where duration_milliseconds_d > 0\r\n | extend duration_seconds = duration_milliseconds_d /1000.0\r\n | where statement_s != 'select @@version'\r\n | where statement_s != 'SELECT @@SPID;'\r\n | where server_principal_name_s has '{User}'\r\n // | where application_name_s has '{Application}'\r\n | project DatabaseName= database_name_s, UserName= server_principal_name_s, EventTime= event_time_t, Host= host_name_s, duration_seconds = round(duration_seconds), statement_s, QuerySource = application_name_s , affected_rows_d\r\n | project-reorder DatabaseName, UserName, Host, EventTime, duration_seconds, statement_s, QuerySource\r\n) on EventTime\r\n | order by affected_rows_d desc\r\n| project Session_ID,RequestID=RequestId_s,Submit_time=Query_Submit_Time,Start_Time=Query_Start_Time,End_Time=EventTime,Status,Resource_class,UserName,Exec_request_text=Query,Audit_Query_text=statement_s,Host,QuerySource,Affected_rows=affected_rows_d,num_steps,max_step_rows,max_step_sec,Total_Duration_s=duration_seconds\r\n\r\n\r\n\r\n\r\n", "size": 0, "title": "Queries {User} {Application}", "noDataMessage": "Select a user to see query activity", "timeContext": { "durationMs": 14400000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 0 - Copy - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": " AzureDiagnostics\r\n | where Category == 'SQLSecurityAuditEvents' and LogicalServerName_s == \"{LogicalServerName}\"\r\n | where duration_milliseconds_d > 0\r\n| extend Duration = round(duration_milliseconds_d /1000.0)\r\n| extend TimeBin = case (datetime_part(\"Hour\",TimeGenerated) in (6,7,8,9,10,11,12), \"Morning_6-12\", datetime_part(\"Hour\",TimeGenerated) in (13,14,15,16,17,18), \"Afternoon_12-18\", \"Overnight_18-6\")\r\n| where server_principal_name_s has '{User}'\r\n| where application_name_s has '{Application}'\r\n| summarize QueryDuration = sum(Duration) by EventTime = bin(event_time_t, 1d), TimeBin", "size": 0, "title": "Query Activity by time - sum(Duration) {User} {Application}", "noDataMessage": "Select a user to see query activity", "timeContext": { "durationMs": 14400000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "barchart" }, "name": "query - 0 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databasename='{DatabaseName}';\r\nAzureDiagnostics \r\n| where Category == 'ExecRequests'\r\n| where Resource == databasename\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize Session_ID=max(SessionId_s), \r\n Query_Submit_Time=max(SubmitTime_t), \r\n Query_Start_Time=max(StartTime_t), \r\n Query_End_Time=max(EndTime_t), \r\n Query_Text=max(Command_s), \r\n Status=min(Status_s),\r\n Resource_class=max(ResourceClass_s) ,\r\n Query_ElapsedTime_s=round((max(EndTime_t) - max(StartTime_t))/1s)\r\n by RequestId_s\r\n| join kind = leftouter \r\n(\r\n AzureDiagnostics\r\n | where Category == 'RequestSteps'\r\n | where Resource == databasename\r\n | summarize num_steps=max(StepIndex_d), \r\n max_step_rows=max(RowCount_d), \r\n max_step_sec=max(EndTime_t-StartTime_t)/1s\r\n by RequestId_s\r\n ) on RequestId_s\r\n| order by Query_Submit_Time\r\n| project Session_ID,RequestId_s,Query_Submit_Time,Query_Start_Time,EventTime = Query_End_Time,num_steps,max_step_rows,max_step_sec,Query_ElapsedTime_s,Status,Query = Query_Text,Resource_class\r\n| join kind = rightouter \r\n(\r\n AzureDiagnostics\r\n | where Category == 'SQLSecurityAuditEvents' and LogicalServerName_s == \"{LogicalServerName}\"\r\n | where duration_milliseconds_d > 0\r\n | extend duration_seconds = duration_milliseconds_d /1000.0\r\n | where statement_s != 'select @@version'\r\n | where statement_s != 'SELECT @@SPID;'\r\n | where server_principal_name_s has '{User}'\r\n // | where application_name_s has '{Application}'\r\n | project DatabaseName= database_name_s, UserName= server_principal_name_s, EventTime= event_time_t, Host= host_name_s, duration_seconds = round(duration_seconds), statement_s, QuerySource = application_name_s , affected_rows_d\r\n | project-reorder DatabaseName, UserName, Host, EventTime, duration_seconds, statement_s, QuerySource\r\n) on EventTime\r\n | order by affected_rows_d desc\r\n| project Session_ID,RequestID=RequestId_s,Submit_time=Query_Submit_Time,Start_Time=Query_Start_Time,End_Time=EventTime,Status,Resource_class,UserName,Query_text=statement_s,Host,QuerySource,Affected_rows=affected_rows_d,num_steps,max_step_rows,max_step_sec,Total_Duration_s=duration_seconds\r\n\r\n\r\n\r\n\r\n", "size": 0, "title": "Affected Rows By Session ID", "timeContext": { "durationMs": 14400000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "linechart", "chartSettings": { "xAxis": "RequestID", "yAxis": [ "Affected_rows" ] } }, "name": "query - 6" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "QueryAudit" }, "name": "QueryAuditGroup", "styleSettings": { "showBorder": true } }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "title": "Query Comparison", "items": [ { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "7fa3187e-9225-4faa-8f80-dc1bc40c5aab", "version": "KqlParameterItem/1.0", "name": "RequestId1", "type": 1, "value": "" } ], "style": "above", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "customWidth": "50", "name": "parameters - 3 - Copy" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "315fc476-469a-4d8d-b421-028d1113ab06", "version": "KqlParameterItem/1.0", "name": "RequestId2", "type": 1, "value": "", "timeContext": { "durationMs": 86400000 } } ], "style": "above", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "customWidth": "50", "name": "parameters - 2" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s !in ('Batch','Execute') and RequestId_s == '{RequestId1}'\r\n| summarize Session_ID=any(SessionId_s),\r\n Request_ID=any(RequestId_s),\r\n Submit_Time=max(SubmitTime_t),\r\n Start_Time=max(StartTime_t),\r\n End_Time=max(EndTime_t),\r\n Command=any(Command_s),\r\n Status=min(Status_s), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType_s),\r\n Resource_class=any(ResourceClass_s)\r\n by RequestId_s\r\n| summarize Session_ID=any(Session_ID), Submit_Time=any(Submit_Time) ,Start_Time=any(Start_Time), End_Time=any(End_Time),ElapsedTime_min=anyif((End_Time - Start_Time)/1m,Start_Time > ago(30d)),Command=any(Command),Status=any(Status),Statement_Type=any(Statement_Type),Resource_class=any(Resource_class) by Request_ID\r\n| project Session_ID,Request_ID,ElapsedTime_min,Command,Resource_class,Submit_Time,Start_Time,End_Time,Statement_Type,Status\r\n", "size": 4, "timeContext": { "durationMs": 14400000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "customWidth": "50", "name": "query - 2" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s !in ('Batch','Execute') and RequestId_s == '{RequestId2}'\r\n| summarize Session_ID=any(SessionId_s),\r\n Request_ID=any(RequestId_s),\r\n Submit_Time=max(SubmitTime_t),\r\n Start_Time=max(StartTime_t),\r\n End_Time=max(EndTime_t),\r\n Command=any(Command_s),\r\n Status=min(Status_s), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType_s),\r\n Resource_class=any(ResourceClass_s)\r\n by RequestId_s\r\n| summarize Session_ID=any(Session_ID), Submit_Time=any(Submit_Time) ,Start_Time=any(Start_Time), End_Time=any(End_Time),ElapsedTime_min=anyif((End_Time - Start_Time)/1m,Start_Time > ago(30d)),Command=any(Command),Status=any(Status),Statement_Type=any(Statement_Type),Resource_class=any(Resource_class) by Request_ID\r\n| project Session_ID,Request_ID,ElapsedTime_min,Command,Resource_class,Submit_Time,Start_Time,End_Time,Statement_Type,Status\r\n", "size": 4, "timeContext": { "durationMs": 14400000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "customWidth": "50", "name": "query - 2 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics\r\n| where Category == 'RequestSteps'\r\n| where Resource == '{DatabaseName}'\r\n| where RequestId_s == '{RequestId1}'\r\n| summarize StartTime=max(StartTime_t)\r\n ,EndTime=max(EndTime_t)\r\n ,RequestID=max(RequestId_s)\r\n ,Operation=max(OperationType_s)\r\n ,RowCount=max(RowCount_d)\r\n ,Command=max(Command_s)\r\n ,Status=max(Status_s)\r\n by StepIndex_d\r\n| order by StepIndex_d asc\r\n| project StartTime,EndTime,RequestID,Operation,RowCount,Command,Status,StepIndex_d", "size": 3, "timeContext": { "durationMs": 14400000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "customWidth": "50", "name": "query - 4", "styleSettings": { "margin": "0", "padding": "10px" } }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics\r\n| where Category == 'RequestSteps'\r\n| where Resource == '{DatabaseName}'\r\n| where RequestId_s == '{RequestId2}'\r\n| summarize StartTime=max(StartTime_t)\r\n ,EndTime=max(EndTime_t)\r\n ,RequestID=max(RequestId_s)\r\n ,Operation=max(OperationType_s)\r\n ,RowCount=max(RowCount_d)\r\n ,Command=max(Command_s)\r\n ,Status=max(Status_s)\r\n by StepIndex_d\r\n| order by StepIndex_d asc\r\n| project StartTime,EndTime,RequestID,Operation,RowCount,Command,Status,StepIndex_d", "size": 3, "timeContext": { "durationMs": 14400000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "customWidth": "50", "name": "query - 4 - Copy", "styleSettings": { "padding": "10px" } } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "QueryComparison" }, "name": "QueryComparison" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "title": "Session Investigation", "items": [ { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "feb2ac70-2555-456e-bfa6-6ad4a2dcad0f", "version": "KqlParameterItem/1.0", "name": "SessionID", "type": 1, "value": "", "timeContext": { "durationMs": 86400000 } } ], "style": "above", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 0" }, { "type": 1, "content": { "json": "The matching of the user information in the next chart is approximate. This information is a work in progress", "style": "warning" }, "name": "text - 4" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databasename='{DatabaseName}';\r\nAzureDiagnostics \r\n| where Category == 'ExecRequests'\r\n| where Resource == databasename\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize Query_End_Time = max(EndTime_t ) by SessionId_s\r\n| where SessionId_s == '{SessionID}'\r\n| join kind = rightouter \r\n( \r\n AzureDiagnostics\r\n | where Category == 'SQLSecurityAuditEvents' \r\n | where duration_milliseconds_d > 0\r\n | extend duration_seconds = duration_milliseconds_d /1000.0\r\n | where statement_s != 'select @@version' and statement_s != 'SELECT @@SPID;' and server_principal_name_s != '##MS_InstanceCertificate##'\r\n) on $left.Query_End_Time==$right.event_time_t \r\n| summarize DatabaseName= max(database_name_s)\r\n , UserName= any(server_principal_name_s)\r\n , Host= max(host_name_s)\r\n , Application=max(application_name_s)\r\n by SessionId_s\r\n\r\n\r\n\r\n", "size": 4, "timeContext": { "durationMs": 14400000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "table", "tileSettings": { "titleContent": { "columnMatch": "UserName" }, "subtitleContent": { "columnMatch": "SessionId_s" }, "leftContent": { "columnMatch": "Application" }, "rightContent": { "columnMatch": "Host" }, "secondaryContent": { "columnMatch": "DatabaseName" }, "showBorder": false, "size": "full" }, "graphSettings": { "type": 0 } }, "name": "query - 3" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics \r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize \r\n Session_ID=max(SessionId_s), \r\n Submit_Time=max(SubmitTime_t), \r\n Start_Time=max(StartTime_t),\r\n End_Compile_Time=max(EndCompileTime_t), \r\n End_Time=max(EndTime_t), \r\n Command=max(Command_s), \r\n Last_Status=min(Status_s),\r\n Statement_Type=max(StatementType_s),\r\n Resource_class=max(ResourceClass_s) \r\n by RequestId_s\r\n| where Session_ID has '{SessionID}'\r\n| extend elapsedTime_sec = iif(End_Time > ago(365d),(End_Time - Submit_Time)/1s,real(null)) \r\n| order by Submit_Time asc\r\n\r\n\r\n\r\n\r\n", "size": 0, "timeContext": { "durationMs": 14400000 }, "timeContextFromParameter": "TimeRange", "exportFieldName": "RequestId_s", "exportParameterName": "RequestID", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 1" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics\r\n| where Category == 'RequestSteps'\r\n| where Resource == '{DatabaseName}'\r\n| where RequestId_s == '{RequestID}'\r\n//| where Status_s != 'Running'\r\n| summarize max(StartTime_t),max(EndTime_t),max(RequestId_s),max(OperationType_s),max(RowCount_d),max(Command_s),max(Status_s) by StepIndex_d\r\n| order by StepIndex_d asc", "size": 3, "timeContext": { "durationMs": 14400000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 2" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "SessionInvestigation" }, "name": "group - 9" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 1, "content": { "json": "## This tab is used to determine what statements triggerred autostats creation jobs. \r\nThe flow of autostats creation is as follows\r\n1. Query Submit Time\r\n2. \tCreate Statistics submit Time\r\n3. \tCreate Statistics end Time\r\n4. Query end_compile_time\r\n5. Query Start_Time\r\n6. Query End_Time\r\n\r\nFurther, if multiple stats are created, then the creation of all stats for this query will fall between query submit_time and end_compile_time. \r\n\r\nThe charts on this page allow you to search for an autostats job by requestID or my snippet of the autostats statement text, which can just be the schema, table, or column name. Then it will show you all commands that include that request ID or text. It will then show you all statements in the create stat statement because the query we are trying to identify will wait for all of those stats creations to complete before proceeding. \r\n\r\nThe last chart will list out all statements that could possibly have triggerred the stats creation job based on their submite/end_compile_time. " }, "name": "text - 6" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "0911bd4b-d471-480b-bdf4-1a2d4ba1ea6e", "version": "KqlParameterItem/1.0", "name": "RequestIdSearch", "type": 1, "value": "", "label": "RequestId for AutoStats Job" }, { "id": "c12e6495-4fd1-473c-8ffc-0bf502f54706", "version": "KqlParameterItem/1.0", "name": "QueryTextSnippet", "type": 1, "value": "", "timeContext": { "durationMs": 86400000 }, "label": "Snippet of autostats creation statement (Schema, table or column)" } ], "style": "formVertical", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "customWidth": "60", "name": "parameters - 3 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics \r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize \r\n Session_ID=max(SessionId_s), \r\n Request_ID=max(RequestId_s), \r\n Submit_Time=max(SubmitTime_t), \r\n Start_Time=max(StartTime_t),\r\n End_Compile_Time=max(EndCompileTime_t), \r\n End_Time=max(EndTime_t), \r\n Command=max(Command_s), \r\n Last_Status=min(Status_s),\r\n Statement_Type=max(StatementType_s),\r\n Resource_class=max(ResourceClass_s) \r\n by RequestId_s\r\n| where Command has 'CREATE STATISTICS _wa_sys'\r\n| where Command has '{QueryTextSnippet}'\r\nand RequestId_s has '{RequestIdSearch}'\r\n| extend elapsedTime_sec = iif(End_Time > ago(365d),(End_Time - Submit_Time)/1s,real(null)) \r\n| extend CompileTime_sec = (End_Compile_Time - Submit_Time)/1s\r\n| order by elapsedTime_sec\r\n| summarize \r\n Executions = count(),\r\n Max_Elapsed_Time_sec = bin(max(elapsedTime_sec),1),\r\n Min_Elapsed_Time_sec = bin(min(elapsedTime_sec),1),\r\n Variability_sec=bin((max(elapsedTime_sec)-min(elapsedTime_sec)),1),\r\n SampleQID = any(RequestId_s),\r\n SampleSessionID = any(Session_ID)\r\n by Command\r\n| order by Max_Elapsed_Time_sec\r\n\r\n\r\n", "size": 0, "title": "Matching Queries", "timeContext": { "durationMs": 14400000 }, "timeContextFromParameter": "TimeRange", "exportedParameters": [ { "fieldName": "SampleQID", "parameterName": "SampleQID" }, { "fieldName": "SampleSessionID", "parameterName": "Samp", "parameterType": 1 } ], "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "50%" } } ], "sortBy": [ { "itemKey": "Command", "sortOrder": 1 } ] }, "sortBy": [ { "itemKey": "Command", "sortOrder": 1 } ] }, "name": "query - 0 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics \r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s !in ('Batch','Execute')\r\n| where RequestId_s == '{SampleQID}'\r\n| summarize \r\n Session_ID=max(SessionId_s), \r\n Request_ID=max(RequestId_s), \r\n Submit_Time=min(SubmitTime_t), \r\n Start_Time=max(StartTime_t),\r\n End_Compile_Time=max(EndCompileTime_t), \r\n End_Time=max(EndTime_t), \r\n Command=max(Command_s), \r\n Last_Status=min(Status_s),\r\n Statement_Type=max(StatementType_s),\r\n Resource_class=max(ResourceClass_s) \r\n by RequestId_s\r\n| extend elapsedTime_sec = iif(End_Time > ago(365d),(End_Time - Submit_Time)/1s,real(null)) \r\n| extend CompileTime_sec = (End_Compile_Time - Submit_Time)/1s\r\n| join kind=inner\r\n (AzureDiagnostics \r\n | where Category == 'ExecRequests'\r\n | where Resource == '{DatabaseName}'\r\n | where StatementType_s !in ('Batch','Execute')\r\n | summarize \r\n Session_ID=max(SessionId_s), \r\n Request_ID=max(RequestId_s), \r\n Submit_Time=min(SubmitTime_t), \r\n Start_Time=max(StartTime_t),\r\n End_Compile_Time=max(EndCompileTime_t), \r\n End_Time=max(EndTime_t), \r\n Command=max(Command_s), \r\n Last_Status=min(Status_s),\r\n Statement_Type=max(StatementType_s),\r\n Resource_class=max(ResourceClass_s) \r\n by RequestId_s\r\n | extend elapsedTime_sec = (End_Time - Submit_Time)/1s\r\n | extend elapsedTime_sec = iif(End_Time > ago(365d),(End_Time - Submit_Time)/1s,real(null)) \r\n | extend CompileTime_sec = (End_Compile_Time - Submit_Time)/1s\r\n )\r\non Command \r\n| project Request_ID1,Session_ID1,Submit_Time1,Start_Time1,End_Compile_Time1,End_Time1,Last_Status1,Statement_Type1,elapsedTime_sec1,CompileTime_sec1\r\n", "size": 0, "title": "All Executions of Selected Query", "noDataMessage": "Select a query above to see individual executions", "timeContext": { "durationMs": 14400000 }, "timeContextFromParameter": "TimeRange", "exportedParameters": [ { "fieldName": "Request_ID1", "parameterName": "RequestId" }, { "fieldName": "End_Time1", "parameterName": "StatEndTime", "parameterType": 1 }, { "fieldName": "Submit_Time1", "parameterName": "StatSubmitTime", "parameterType": 1 }, { "fieldName": "Session_ID1", "parameterName": "SessionId", "parameterType": 1 } ], "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "sortBy": [ { "itemKey": "End_Time1", "sortOrder": 1 } ] }, "sortBy": [ { "itemKey": "End_Time1", "sortOrder": 1 } ] }, "name": "query - 0 - Copy - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": " AzureDiagnostics \r\n | where Category == 'ExecRequests'\r\n | where Resource == '{DatabaseName}'\r\n | where StatementType_s !in ('Batch','Execute')\r\n | where SessionId_s == '{SessionId}'\r\n | summarize \r\n Session_ID=max(SessionId_s), \r\n Request_ID=max(RequestId_s), \r\n Submit_Time=min(SubmitTime_t), \r\n Start_Time=max(StartTime_t),\r\n End_Compile_Time=max(EndCompileTime_t), \r\n End_Time=max(EndTime_t), \r\n Command=max(Command_s), \r\n Last_Status=min(Status_s),\r\n Statement_Type=max(StatementType_s),\r\n Resource_class=max(ResourceClass_s) \r\n by RequestId_s\r\n| project Session_ID,Request_ID,Submit_Time,End_Compile_Time,Start_Time,End_Time,Last_Status,Statement_Type,Command\r\n\r\n\r\n", "size": 0, "title": "All Statements in Stats Statement Session", "noDataMessage": "Select a query above to see individual executions", "timeContext": { "durationMs": 14400000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "150ch" } } ], "sortBy": [ { "itemKey": "Command", "sortOrder": 1 } ] }, "sortBy": [ { "itemKey": "Command", "sortOrder": 1 } ] }, "name": "query - 0 - Copy - Copy - Copy - Copy" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "parameters": [ { "id": "4e005821-785a-4246-aae8-de00987cba18", "version": "KqlParameterItem/1.0", "name": "Session_Submit_Time", "type": 1, "query": "AzureDiagnostics \r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s !in ('Batch','Execute')\r\n| where SessionId_s == '{SessionId}'\r\n| summarize \r\n Session_Submit_Time=min(SubmitTime_t) \r\n by SessionId_s\r\n| project Session_Submit_Time\r\n\r\n\r\n", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 259200000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "id": "b046db56-e6b3-4f3d-afb3-9687240c21f1", "version": "KqlParameterItem/1.0", "name": "Session_End_Time", "type": 1, "query": "AzureDiagnostics \r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s !in ('Batch','Execute')\r\n| where SessionId_s == '{SessionId}'\r\n| summarize \r\n Session_End_Time=max(EndTime_t) \r\n by SessionId_s\r\n| project Session_End_Time", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 259200000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 7" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics \r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s !in ('Batch','Execute')\r\n| where SubmitTime_t < datetime('{Session_Submit_Time}') and EndCompileTime_t > datetime('{Session_End_Time}') or RequestId_s == '{RequestId}'\r\n| summarize by RequestId_s\r\n| join kind=inner\r\n (\r\n AzureDiagnostics \r\n | where Category == 'ExecRequests'\r\n | where Resource == '{DatabaseName}'\r\n | where StatementType_s !in ('Batch','Execute')\r\n | summarize \r\n Session_ID=max(SessionId_s), \r\n Request_ID=max(RequestId_s), \r\n Submit_Time=min(SubmitTime_t), \r\n Start_Time=max(StartTime_t),\r\n End_Compile_Time=max(EndCompileTime_t), \r\n End_Time=max(EndTime_t), \r\n Command=max(Command_s), \r\n Last_Status=min(Status_s),\r\n Statement_Type=max(StatementType_s),\r\n Resource_class=max(ResourceClass_s) \r\n by RequestId_s\r\n ) on RequestId_s\r\n| order by End_Compile_Time\r\n| project Session_ID,Request_ID,Submit_Time,End_Compile_Time,Start_Time,End_Time,Last_Status,Statement_Type,Command\r\n\r\n", "size": 0, "title": "Query Executions that could have triggered Stats Statement based on Time of total session", "noDataMessage": "Select a query above to see individual executions", "timeContext": { "durationMs": 14400000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "150ch" } } ], "sortBy": [ { "itemKey": "Command", "sortOrder": 1 } ] }, "sortBy": [ { "itemKey": "Command", "sortOrder": 1 } ] }, "name": "query - 0 - Copy - Copy - Copy - Copy" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "Statistics" }, "name": "statistics" } ], "fallbackResourceIds": [ "azure monitor" ], "$schema": "https://github.com/Microsoft/Application-Insights-Workbooks/blob/master/schema/workbook.json" } ================================================ FILE: Monitor_Workbooks/archive/SynapseWorkbook_v1.3.json ================================================ { "version": "Notebook/1.0", "items": [ { "type": 9, "content": { "version": "KqlParameterItem/1.0", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "parameters": [ { "id": "28da10ec-a308-47f5-9819-92ebf810b292", "version": "KqlParameterItem/1.0", "name": "LogAnalyticsSubscription", "type": 6, "value": null, "typeSettings": { "additionalResourceOptions": [], "includeAll": true, "showDefault": false }, "timeContext": { "durationMs": 86400000 } }, { "id": "e383ed24-52ae-447b-9b80-51fd3ab6b919", "version": "KqlParameterItem/1.0", "name": "LogAnalyticsWorkspace", "type": 5, "query": "Resources\r\n| where type == 'microsoft.operationalinsights/workspaces'\r\n| project id\r\n", "crossComponentResources": [ "{LogAnalyticsSubscription}" ], "value": null, "typeSettings": { "additionalResourceOptions": [], "showDefault": false }, "timeContext": { "durationMs": 86400000 }, "queryType": 1, "resourceType": "microsoft.resourcegraph/resources" }, { "id": "9b9fe566-0f52-4a75-a35b-a79c50c6a6f0", "version": "KqlParameterItem/1.0", "name": "DatabaseResourceName", "type": 5, "query": "AzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| distinct ResourceId", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "value": null, "typeSettings": { "additionalResourceOptions": [], "showDefault": false }, "timeContext": { "durationMs": 604800000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "id": "f5852627-70ca-4959-8d60-53b48864603f", "version": "KqlParameterItem/1.0", "name": "TimeRange", "type": 4, "isGlobal": true, "value": { "durationMs": 14400000 }, "typeSettings": { "selectableValues": [ { "durationMs": 300000 }, { "durationMs": 900000 }, { "durationMs": 1800000 }, { "durationMs": 3600000 }, { "durationMs": 14400000 }, { "durationMs": 43200000 }, { "durationMs": 86400000 }, { "durationMs": 172800000 }, { "durationMs": 259200000 }, { "durationMs": 604800000 }, { "durationMs": 1209600000 }, { "durationMs": 2419200000 }, { "durationMs": 2592000000 } ], "allowCustom": true }, "timeContext": { "durationMs": 86400000 } }, { "id": "6da2f63f-45a3-4b37-9108-5e8b7e358d85", "version": "KqlParameterItem/1.0", "name": "DatabaseName", "type": 1, "query": "AzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where ResourceId == '{DatabaseResourceName}'\r\n| distinct Resource ", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 604800000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "id": "8bba835b-f319-43b3-8ec6-4e051fc6d446", "version": "KqlParameterItem/1.0", "name": "LogicalServerName", "type": 1, "query": "AzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where ResourceId == '{DatabaseResourceName}'\r\n| distinct LogicalServerName_s", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 2" }, { "type": 11, "content": { "version": "LinkItem/1.0", "style": "tabs", "links": [ { "id": "202cbbc0-8d63-416d-89ed-451d6fe7c4b3", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Workload", "subTarget": "Workload", "preText": "Workload", "style": "link" }, { "id": "a7901bd0-a1f4-4491-b953-57555d764e00", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Workload Management", "subTarget": "WorkloadManagement", "style": "link" }, { "id": "45e12a14-8548-4477-aae3-c142b906dc9f", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "TempDB", "subTarget": "TempDB", "style": "link" }, { "id": "9ef8f730-d73d-432b-9b75-55095d1155f2", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Replicated Tables", "subTarget": "ReplicatedTables", "style": "link" }, { "id": "79d10d16-0696-4214-b306-c7a0e46cd64f", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Query Investigation", "subTarget": "QueryInvestigation", "style": "link" }, { "id": "31c1cf1c-74b5-44e2-ba9a-9497834ca3dc", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Query Comparison", "subTarget": "QueryComparison", "style": "link" }, { "id": "5ff681ee-e005-481f-b743-b66ab1b9d71d", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Session Investigation", "subTarget": "SessionInvestigation", "style": "link" }, { "id": "482ccc46-8a10-4ace-bfd6-63ac73b380af", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Query Audit", "subTarget": "QueryAudit", "style": "link" }, { "id": "db43bb45-1611-47ce-a2ad-517943f2aa1a", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "AutoStats", "subTarget": "Statistics", "style": "link" } ] }, "name": "links - 0" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "title": "Workload", "items": [ { "type": 10, "content": { "chartId": "workbook90867bfc-5c33-464f-ac31-2c2e006b97f4", "version": "MetricsItem/2.0", "size": 0, "chartType": 2, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 0 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-dwu_consumption_percent", "aggregation": 3, "splitBy": null, "columnName": "DWU Percentage" }, { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-cpu_percent", "aggregation": 3 }, { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-physical_data_read_percent", "aggregation": 3 } ], "title": "DWU Resource Utilization", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "name": "metric - 1" }, { "type": 10, "content": { "chartId": "workbookb954d4a0-82ef-4409-88fb-837aaff80c8d", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 0 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-active_queries", "aggregation": 1, "splitBy": null }, { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-queued_queries", "aggregation": 1 } ], "title": "Active and Queued Queries", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "name": "metric - 1" }, { "type": 10, "content": { "chartId": "workbookb954d4a0-82ef-4409-88fb-837aaff80c8d", "version": "MetricsItem/2.0", "size": 0, "chartType": 3, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 14400000 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-local_tempdb_usage_percent", "aggregation": 3, "splitBy": null, "columnName": "TempDB Utilization Percentage" } ], "title": "TempDB Utilization", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "name": "metric - 1 - Copy" }, { "type": 10, "content": { "chartId": "workbookb954d4a0-82ef-4409-88fb-837aaff80c8d", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 14400000 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-WorkloadManagement-wlg_allocation_relative_to_system_percent", "aggregation": 3, "splitBy": "WorkloadGroupName" } ], "title": "Workload Group Utilization", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "name": "Workload Group Utilization" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databaseName = '{DatabaseName}';\r\n//Long-Running Queries - Just Actual Queries\r\n//If 'Command' is empty - you need to set a bigger time window, the older record with the command is outside of your window\r\nAzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where Resource == databaseName\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize Session_ID=any(SessionId_s),\r\n Request_ID=any(RequestId_s),\r\n Submit_Time=max(SubmitTime_t),\r\n Start_Time=max(StartTime_t),\r\n End_Time=max(EndTime_t),\r\n Command=any(Command_s),\r\n Status=min(Status_s), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType_s),\r\n Resource_class=any(ResourceClass_s)\r\n by RequestId_s\r\n| summarize ElapsedTime_min=bin(anyif(((End_Time - Start_Time)/1m),Start_Time > ago(30d)),1),\r\n Session_ID=any(Session_ID), \r\n Submit_Time=any(Submit_Time) ,\r\n Start_Time=any(Start_Time), \r\n End_Time=any(End_Time),\r\n Command=any(Command),\r\n Status=any(Status),\r\n Statement_Type=any(Statement_Type)\r\n ,Resource_class=any(Resource_class) \r\n by Request_ID\r\n| where End_Time > ago(365d)\r\n| summarize count() by Status, bin(End_Time,5m)\r\n| render barchart \r\n", "size": 0, "title": "Query Completion Count by End Time - 5m buckets", "color": "redBright", "timeContext": { "durationMs": 43200000 }, "timeContextFromParameter": "TimeRange", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "chartSettings": { "seriesLabelSettings": [ { "seriesName": "Completed", "color": "green" }, { "seriesName": "Failed", "color": "red" }, { "seriesName": "Cancelled", "color": "yellow" } ] } }, "name": "query - 4" }, { "type": 1, "content": { "json": "Use the buttons below to filter the next chart for Success or Failed queries. In many cases a failed query may not have a 'Command' column populated depending on what stage the query failed in. ", "style": "info" }, "name": "text - 3" }, { "type": 11, "content": { "version": "LinkItem/1.0", "style": "nav", "links": [ { "id": "8e89112f-c67f-42c0-9622-02fa306fb7a5", "cellValue": "QueryCompletionType", "linkTarget": "parameter", "linkLabel": "All Queries", "subTarget": "''", "style": "primary" }, { "id": "6abe39c7-4d4e-4c45-aa54-dc9a4c5e876e", "cellValue": "QueryCompletionType", "linkTarget": "parameter", "linkLabel": "Success Only", "subTarget": "Completed", "preText": "", "style": "secondary" }, { "id": "e41b4a0b-8464-491e-92be-a57217d6dcac", "cellValue": "QueryCompletionType", "linkTarget": "parameter", "linkLabel": "Failures Only", "subTarget": "Failed", "preText": "", "style": "secondary" } ] }, "name": "links - 11" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databaseName = '{DatabaseName}';\r\n//Long-Running Queries - Just Actual Queries\r\n//If 'Command' is empty - you need to set a bigger time window, the older record with the command is outside of your window\r\nAzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where Resource == databaseName\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize Session_ID=any(SessionId_s),\r\n Request_ID=any(RequestId_s),\r\n Submit_Time=max(SubmitTime_t),\r\n Start_Time=max(StartTime_t),\r\n End_Time=max(EndTime_t),\r\n Command=max(Command_s),\r\n Status=min(Status_s), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType_s),\r\n Resource_class=any(ResourceClass_s)\r\n by RequestId_s\r\n| summarize ElapsedTime_min=bin(anyif(((End_Time - Start_Time)/1m),Start_Time > ago(30d)),1),\r\n Session_ID=any(Session_ID), \r\n Submit_Time=min(Submit_Time) ,\r\n Start_Time=any(Start_Time), \r\n End_Time=any(End_Time),\r\n Command=any(Command),\r\n Status=any(Status),\r\n Statement_Type=any(Statement_Type)\r\n ,Resource_class=any(Resource_class) \r\n by Request_ID\r\n//| where End_Time > ago(365d)\r\n| where Status has '{QueryCompletionType}'\r\n| order by Submit_Time\r\n\r\n", "size": 0, "title": "Query Completions - use above buttons to filter", "color": "redBright", "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "rowLimit": 100 }, "chartSettings": { "seriesLabelSettings": [ { "seriesName": "Completed", "color": "green" }, { "seriesName": "Failed", "color": "red" }, { "seriesName": "Cancelled", "color": "yellow" } ] } }, "name": "query - 4 - Copy" } ] }, "name": "Query Completions", "styleSettings": { "showBorder": true } }, { "type": 10, "content": { "chartId": "workbook1afc57e6-0b32-4968-b299-db319bd21635", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 0 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-connection_successful", "aggregation": 1, "splitBy": null }, { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-connection_failed", "aggregation": 1 } ], "title": "Successful and Failed Connections", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "name": "metric - 5" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 3, "content": { "version": "KqlItem/1.0", "query": " AzureDiagnostics\r\n | where Category == 'SQLSecurityAuditEvents' and LogicalServerName_s == 'lasr-sqldwdb-eastus2-prd'\r\n | where action_name_s in ('DATABASE AUTHENTICATION SUCCEEDED','DATABASE AUTHENTICATION FAILED')\r\n | project SourceSystem,client_tls_version_d,succeeded_s,session_id_d,client_ip_s,session_server_principal_name_s,server_principal_name_s,database_principal_name_s,application_name_s,host_name_s,TimeGenerated\r\n | summarize count() by succeeded_s,bin(TimeGenerated,1m)\r\n | render barchart\r\n\r\n\r\n\r\n", "size": 0, "title": "Database Authentication success/failure rate", "timeContext": { "durationMs": 14400000 }, "timeContextFromParameter": "TimeRange", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "chartSettings": { "xAxis": "TimeGenerated", "group": "succeeded_s", "createOtherGroup": null } }, "name": "query - 8" }, { "type": 11, "content": { "version": "LinkItem/1.0", "style": "nav", "links": [ { "id": "2ed22e0a-2b53-4ed0-8f65-d2c621f34dad", "cellValue": "AuthResult", "linkTarget": "parameter", "linkLabel": "All Authentications", "subTarget": "''", "style": "primary" }, { "id": "2789ab13-ae8a-472e-bad4-9c9bdc934d4d", "cellValue": "AuthResult", "linkTarget": "parameter", "linkLabel": "Success Only", "subTarget": "true", "style": "secondary" }, { "id": "5cf4ddd4-e189-4b71-b456-0d4f1572a0a3", "cellValue": "AuthResult", "linkTarget": "parameter", "linkLabel": "Failures Only", "subTarget": "false", "style": "secondary" } ] }, "name": "links - 10" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": " AzureDiagnostics\r\n | where Category == 'SQLSecurityAuditEvents' and LogicalServerName_s == 'lasr-sqldwdb-eastus2-prd'\r\n | where action_name_s in ('DATABASE AUTHENTICATION SUCCEEDED','DATABASE AUTHENTICATION FAILED')\r\n | where succeeded_s has '{AuthResult}'\r\n | project SourceSystem,client_tls_version_d,succeeded_s,session_id_d,client_ip_s,session_server_principal_name_s,server_principal_name_s,database_principal_name_s,application_name_s,host_name_s,TimeGenerated\r\n | order by TimeGenerated\r\n\r\n\r\n\r\n\r\n", "size": 0, "title": "Database Authentication success/failure rate", "noDataMessage": "Please select a button above", "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "rowLimit": 100 }, "chartSettings": { "xAxis": "TimeGenerated", "group": "succeeded_s", "createOtherGroup": null, "showLegend": true } }, "name": "query - 8 - Copy" } ] }, "name": "Database Authentication Group", "styleSettings": { "showBorder": true } }, { "type": 10, "content": { "chartId": "workbook993837ad-66d6-4cbc-ae1a-7c3f6623236b", "version": "MetricsItem/2.0", "size": 0, "chartType": 2, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 14400000 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-cache_used_percent", "aggregation": 3, "splitBy": null }, { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-cache_hit_percent", "aggregation": 3 } ], "title": "Adaptive Cache Used vs Hit Percentage", "gridSettings": { "rowLimit": 10000 } }, "name": "metric - 6" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "Workload" }, "name": "group - 1" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "title": "TempDB ", "items": [ { "type": 10, "content": { "chartId": "workbook4a9cf761-cce2-45b2-8947-8a9428ec7e1c", "version": "MetricsItem/2.0", "size": 0, "chartType": 3, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 14400000 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-Basic-local_tempdb_usage_percent", "aggregation": 3, "splitBy": null, "columnName": "TempDB Util" } ], "title": "TempDB Max and Avg Utilization", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "name": "metric - 0" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "19ee48f5-8f4e-4939-a0ef-c6bf656a93f9", "version": "KqlParameterItem/1.0", "name": "WeightParameter", "type": 1, "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 } }, { "id": "00553ec8-1a41-4dd9-a024-d607639c9bbb", "version": "KqlParameterItem/1.0", "name": "RequestID", "type": 1, "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 } } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 3" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databaseName = '{DatabaseName}';\r\n//Weighted query steps\r\nAzureDiagnostics\r\n| where Category == 'RequestSteps'\r\n| where Resource == databaseName\r\n| where RowCount_d > 0\r\n| summarize sum(RowCount_d) by RequestId_s, OperationType_s\r\n| order by sum_RowCount_d desc\r\n| limit 20\r\n| render columnchart ", "size": 0, "title": "20 Largest Query Steps by Most Rows Moved", "timeContext": { "durationMs": 14400000 }, "timeContextFromParameter": "TimeRange", "exportFieldName": "Request_ID", "exportParameterName": "RequestID", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "chartSettings": { "xAxis": "RequestId_s", "group": "OperationType_s", "createOtherGroup": 20, "showLegend": true } }, "name": "query - 1 - Copy" }, { "type": 11, "content": { "version": "LinkItem/1.0", "style": "nav", "links": [ { "id": "c98d3722-9907-43ab-9306-1957d6f7f858", "cellValue": "WeightParameter", "linkTarget": "parameter", "linkLabel": "Weighted Rowcounts", "subTarget": "Weighted", "preText": "", "postText": "", "style": "secondary" }, { "id": "a06ae99a-ad62-45e9-8c25-c219b81f59c0", "cellValue": "WeightParameter", "linkTarget": "parameter", "linkLabel": "Unweighted Rowcounts", "subTarget": "Unweighted", "preText": "", "postText": "", "style": "secondary" } ] }, "name": "links - 3" }, { "type": 1, "content": { "json": "Current Setting: {WeightParameter}", "style": "info" }, "name": "text - 4" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databaseName = '{DatabaseName}';\r\n//Weighted query steps\r\nlet RequestSteps = AzureDiagnostics\r\n| where Category == 'RequestSteps'\r\n| where Resource == databaseName\r\n| where RowCount_d > 100000000\r\n| extend Step_Elapsed_Min = round((EndTime_t - StartTime_t)/1m, 2)\r\n| extend Weighted_cnt = iff('{WeightParameter}'=='Weighted',(case(OperationType_s == 'BroadcastMoveOperation', (RowCount_d*20), RowCount_d)),RowCount_d)\r\n| project-rename StepStatus = Status_s, StepStart = StartTime_t, StepEnd = EndTime_t//, StepResource = Resource\r\n| top 100 by Weighted_cnt desc\r\n| order by Weighted_cnt desc\r\n| project Request_ID=RequestId_s,OperationType_s, RowCount_d,Weighted_cnt,Step_Elapsed_Min, StepStart, StepEnd, StepStatus, StepIndex_d,Resource;\r\nRequestSteps | join (AzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where Resource == databaseName\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize Session_ID=any(SessionId_s),\r\n Request_ID=any(RequestId_s),\r\n Submit_Time=max(SubmitTime_t),\r\n Start_Time=max(StartTime_t),\r\n End_Time=max(EndTime_t),\r\n Command=any(Command_s),\r\n Status=min(Status_s), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType_s),\r\n Resource_class=any(ResourceClass_s)\r\n by RequestId_s\r\n| summarize Session_ID=any(Session_ID), Submit_Time=any(Submit_Time) ,Start_Time=any(Start_Time), End_Time=any(End_Time),Command=any(Command),Status=any(Status),Statement_Type=any(Statement_Type),Resource_class=any(Resource_class) by Request_ID\r\n//| order by Step_Elapsed_Min desc\r\n| extend Request_Elapsed_Min = round((End_Time - Start_Time)/1m, 2)\r\n| project-rename ReqStatus = Status, ReqStart = Start_Time, ReqEnd = End_Time\r\n) on Request_ID\r\n| project-reorder Session_ID, Request_ID, Request_Elapsed_Min, ReqStart, ReqEnd, ReqStatus,StepIndex_d, OperationType_s, RowCount_d,Weighted_cnt,Step_Elapsed_Min, StepStart, StepEnd, StepStatus, Statement_Type, Command, Resource_class\r\n| order by Weighted_cnt desc\r\n| limit 20", "size": 3, "title": "20 Largest Query Steps by Most Rows Moved", "timeContext": { "durationMs": 14400000 }, "timeContextFromParameter": "TimeRange", "exportFieldName": "Request_ID1", "exportParameterName": "RequestID", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "sortBy": [ { "itemKey": "Weighted_cnt", "sortOrder": 2 } ] }, "sortBy": [ { "itemKey": "Weighted_cnt", "sortOrder": 2 } ] }, "name": "query - 1" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databaseName = '{DatabaseName}';\r\n//Long-Running Queries - Just Actual Queries\r\n//If 'Command' is empty - you need to set a bigger time window, the older record with the command is outside of your window\r\nAzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where Resource == databaseName\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize Session_ID=any(SessionId_s),\r\n Request_ID=any(RequestId_s),\r\n Submit_Time=max(SubmitTime_t),\r\n Start_Time=max(StartTime_t),\r\n End_Time=max(EndTime_t),\r\n Command=any(Command_s),\r\n Status=min(Status_s), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType_s),\r\n Resource_class=any(ResourceClass_s)\r\n by RequestId_s\r\n| summarize ElapsedTime_min=bin(anyif(((End_Time - Start_Time)/1m),Start_Time > ago(30d)),1),\r\n Session_ID=any(Session_ID), \r\n Submit_Time=any(Submit_Time) ,\r\n Start_Time=any(Start_Time), \r\n End_Time=any(End_Time),\r\n Command=any(Command),\r\n Status=any(Status),\r\n Statement_Type=any(Statement_Type)\r\n ,Resource_class=any(Resource_class) \r\n by Request_ID\r\n| where Request_ID == '{RequestID}'\r\n\r\n", "size": 4, "title": "Selected Query", "noDataMessage": "Select a query above to view details", "timeContext": { "durationMs": 14400000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "35%" } } ] } }, "name": "query - 6" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics\r\n| where Category == 'RequestSteps'\r\n| where Resource == '{DatabaseName}'\r\n| where RequestId_s == '{RequestID}' //Put your QueryID here\r\n| where Status_s != 'Running'\r\n| summarize max(StartTime_t),max(EndTime_t),max(RequestId_s),max(OperationType_s),max(RowCount_d),max(Command_s),max(Status_s) by StepIndex_d\r\n| order by StepIndex_d asc", "size": 3, "title": "Query Plan", "noDataMessage": "Select a query above to view the plan", "timeContext": { "durationMs": 14400000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 7" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "TempDB" }, "name": "group - 3" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "title": "Query Investigation", "items": [ { "type": 1, "content": { "json": "## Search Criteria\r\nUse the following fields to search either using a query text snippet or using a Request ID. If using a query text snippet, try to keep it as simple as possible becuase minor changes in formatting may cause your queries not to show up in the results. It's best to pick something like a table name, then choose the proper query from the list that will populate. " }, "customWidth": "50", "name": "text - 4" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "0c2128d0-d979-4562-a28c-e7ceb955f126", "version": "KqlParameterItem/1.0", "name": "RequestIdSearch", "type": 1, "value": "" }, { "id": "29880874-2d41-4bd5-bf22-3e47ae8b1145", "version": "KqlParameterItem/1.0", "name": "QueryTextSnippet", "type": 1, "value": "", "timeContext": { "durationMs": 86400000 } } ], "style": "formVertical", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "customWidth": "60", "name": "parameters - 3" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics \r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize \r\n Session_ID=max(SessionId_s), \r\n Request_ID=max(RequestId_s), \r\n Submit_Time=max(SubmitTime_t), \r\n Start_Time=max(StartTime_t),\r\n End_Compile_Time=max(EndCompileTime_t), \r\n End_Time=max(EndTime_t), \r\n Command=max(Command_s), \r\n Last_Status=min(Status_s),\r\n Statement_Type=max(StatementType_s),\r\n Resource_class=max(ResourceClass_s) \r\n by RequestId_s\r\n| where Command has '{QueryTextSnippet}'\r\nand RequestId_s has '{RequestIdSearch}'\r\n| extend elapsedTime_sec = iif(End_Time > ago(365d),(End_Time - Submit_Time)/1s,real(null)) \r\n| extend CompileTime_sec = (End_Compile_Time - Submit_Time)/1s\r\n| order by elapsedTime_sec\r\n| summarize \r\n Executions = count(),\r\n Max_Elapsed_Time_sec = bin(max(elapsedTime_sec),1),\r\n Min_Elapsed_Time_sec = bin(min(elapsedTime_sec),1),\r\n Variability_sec=bin((max(elapsedTime_sec)-min(elapsedTime_sec)),1),\r\n SampleQID = any(RequestId_s),\r\n SampleSessionID = any(Session_ID)\r\n by Command\r\n| order by Max_Elapsed_Time_sec\r\n\r\n\r\n", "size": 0, "title": "Matching Queries", "timeContext": { "durationMs": 14400000 }, "timeContextFromParameter": "TimeRange", "exportedParameters": [ { "fieldName": "SampleQID", "parameterName": "SampleQID" }, { "fieldName": "SampleSessionID", "parameterName": "Samp", "parameterType": 1 } ], "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "50%" } } ], "sortBy": [ { "itemKey": "Command", "sortOrder": 1 } ] }, "sortBy": [ { "itemKey": "Command", "sortOrder": 1 } ] }, "name": "query - 0" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics \r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s !in ('Batch','Execute')\r\n| where RequestId_s == '{SampleQID}'\r\n| summarize \r\n Session_ID=max(SessionId_s), \r\n Request_ID=max(RequestId_s), \r\n Submit_Time=min(SubmitTime_t), \r\n Start_Time=max(StartTime_t),\r\n End_Compile_Time=max(EndCompileTime_t), \r\n End_Time=max(EndTime_t), \r\n Command=max(Command_s), \r\n Last_Status=min(Status_s),\r\n Statement_Type=max(StatementType_s),\r\n Resource_class=max(ResourceClass_s) \r\n by RequestId_s\r\n| extend elapsedTime_sec = iif(End_Time > ago(365d),(End_Time - Submit_Time)/1s,real(null)) \r\n| extend CompileTime_sec = (End_Compile_Time - Submit_Time)/1s\r\n| join kind=inner\r\n (AzureDiagnostics \r\n | where Category == 'ExecRequests'\r\n | where Resource == '{DatabaseName}'\r\n | where StatementType_s !in ('Batch','Execute')\r\n | summarize \r\n Session_ID=max(SessionId_s), \r\n Request_ID=max(RequestId_s), \r\n Submit_Time=min(SubmitTime_t), \r\n Start_Time=max(StartTime_t),\r\n End_Compile_Time=max(EndCompileTime_t), \r\n End_Time=max(EndTime_t), \r\n Command=max(Command_s), \r\n Last_Status=min(Status_s),\r\n Statement_Type=max(StatementType_s),\r\n Resource_class=max(ResourceClass_s) \r\n by RequestId_s\r\n | extend elapsedTime_sec = (End_Time - Submit_Time)/1s\r\n | extend elapsedTime_sec = iif(End_Time > ago(365d),(End_Time - Submit_Time)/1s,real(null)) \r\n | extend CompileTime_sec = (End_Compile_Time - Submit_Time)/1s\r\n )\r\non Command \r\n| project Request_ID1,Session_ID1,Submit_Time1,Start_Time1,End_Compile_Time1,End_Time1,Last_Status1,Statement_Type1,Resource_class1,elapsedTime_sec1,CompileTime_sec1\r\n", "size": 0, "title": "All Executions of Selected Query", "noDataMessage": "Select a query above to see individual executions", "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "exportFieldName": "Request_ID1", "exportParameterName": "RequestId", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "sortBy": [] }, "name": "query - 0 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics\r\n| where Category == 'RequestSteps'\r\n| where Resource == '{DatabaseName}'\r\n| where RequestId_s == '{RequestId}'\r\n//| where Status_s != 'Running'\r\n| summarize max(StartTime_t),max(EndTime_t),max(RequestId_s),max(OperationType_s),max(RowCount_d),max(Command_s),min(Status_s) by StepIndex_d\r\n| order by StepIndex_d asc", "size": 3, "title": "Query Plan for Selected Query", "noDataMessage": "Select a Query Above to See the Query Plan", "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 0 - Copy - Copy" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "parameters": [ { "id": "1191e58a-c1f9-4853-b36b-4be8eecbb48f", "version": "KqlParameterItem/1.0", "name": "Query_Submit_Time", "type": 1, "query": " AzureDiagnostics \r\n | where Category == 'ExecRequests'\r\n | where Resource == '{DatabaseName}'\r\n | where StatementType_s !in ('Batch','Execute')\r\n | where RequestId_s =='{RequestId}'\r\n | summarize \r\n Submit_Time=min(SubmitTime_t)\r\n by RequestId_s\r\n | project Submit_Time", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "id": "f6bcb2a4-3356-4110-ba13-99c7d13a26f0", "version": "KqlParameterItem/1.0", "name": "Query_End_Compile_Time", "type": 1, "query": " AzureDiagnostics \r\n | where Category == 'ExecRequests'\r\n | where Resource == '{DatabaseName}'\r\n | where StatementType_s !in ('Batch','Execute')\r\n | where RequestId_s =='{RequestId}'\r\n | summarize \r\n End_Compile_Time=max(EndCompileTime_t) \r\n by RequestId_s\r\n | project End_Compile_Time", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 6" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": " AzureDiagnostics \r\n | where Category == 'ExecRequests'\r\n | where Resource == 'LASR-SQLDWDB-PRD'\r\n | where StatementType_s =='CreateStatistics'\r\n | summarize \r\n Session_ID=max(SessionId_s), \r\n Request_ID=max(RequestId_s), \r\n Submit_Time=min(SubmitTime_t), \r\n Start_Time=max(StartTime_t),\r\n End_Compile_Time=max(EndCompileTime_t), \r\n End_Time=max(EndTime_t), \r\n Command=max(Command_s), \r\n Last_Status=min(Status_s),\r\n Statement_Type=max(StatementType_s),\r\n Resource_class=max(ResourceClass_s) \r\n by RequestId_s\r\n | where Submit_Time > datetime('{Query_Submit_Time}') and End_Time < datetime('{Query_End_Compile_Time}')// or RequestId_s == '{RequestId}'\r\n", "size": 0, "title": "All possibly related auto-stats statements based on time", "noDataMessage": "no auto stats statements found that could be related", "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Submit_Time", "formatter": 0, "numberFormat": { "unit": 0, "options": { "style": "decimal" } } }, { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "100ch" } } ] } }, "name": "All possibly related auto-stats statements" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "QueryInvestigation" }, "name": "group - 4", "styleSettings": { "showBorder": true } }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "title": "Replicated Tables", "items": [ { "type": 1, "content": { "json": "All Charts on this page are based on the last 7 days of data", "style": "info" }, "name": "text - 5" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Build cache count by day\r\nAzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s == 'BuildReplicatedTableCache'\r\n| where Command_s != \"\"\r\n| where ResourceClass_s != \"\"\r\n| project Command_s,TimeGenerated,RequestId_s\r\n| summarize LastRebuild=max(TimeGenerated),RebuildCount=count(RequestId_s) by Command_s\r\n| order by RebuildCount desc\r\n| limit 15\r\n", "size": 3, "title": "Top 15 Most Rebuilds by Table", "timeContext": { "durationMs": 604800000 }, "exportFieldName": "Command_s", "exportParameterName": "QueryText", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command_s", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "40%" } } ] } }, "name": "query - 0" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Build cache count by day\r\nAzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s == 'BuildReplicatedTableCache'\r\n| where Command_s == \"{QueryText}\"\r\n| where ResourceClass_s != \"\"\r\n| project Command_s,TimeGenerated,RequestId_s\r\n| summarize count() by Command_s,bin(TimeGenerated,24h)\r\n| limit 20\r\n| render timechart", "size": 0, "title": "Rebuilds per Day for Selected Table", "noDataMessage": "Select a query above to see runs by day", "timeContext": { "durationMs": 604800000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "chartSettings": { "group": "Command_s", "createOtherGroup": 20, "ySettings": { "min": 0 } } }, "name": "query - 0 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Build cache count by day\r\nAzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s == 'BuildReplicatedTableCache'\r\n| where Command_s != \"\"\r\n| where ResourceClass_s != \"\"\r\n| project Command_s,TimeGenerated,RequestId_s\r\n| summarize count() by Command_s, bin(TimeGenerated,24h)\r\n| where count_ > 7\r\n| order by count_ desc\r\n\r\n", "size": 2, "title": "Rebuild Count by Table by Day", "noDataMessage": " Only tables with more than 7 total rebuilds will show up. If no talbes with that many rebuilds are found this chart will be empty", "timeContext": { "durationMs": 604800000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "categoricalbar", "gridSettings": { "sortBy": [ { "itemKey": "count_", "sortOrder": 1 } ] }, "sortBy": [ { "itemKey": "count_", "sortOrder": 1 } ], "tileSettings": { "showBorder": false, "titleContent": { "columnMatch": "Command_s", "formatter": 1 }, "leftContent": { "columnMatch": "count_", "formatter": 12, "formatOptions": { "palette": "auto" }, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "graphSettings": { "type": 0, "topContent": { "columnMatch": "Command_s", "formatter": 1 }, "centerContent": { "columnMatch": "count_", "formatter": 1, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "chartSettings": { "group": "Command_s", "createOtherGroup": 99, "showDataPoints": true } }, "name": "query - 0 - Copy - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Long-Running Queries - Just Actual Queries\r\nAzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize Session_ID=max(SessionId_s), Request_ID=max(RequestId_s), Submit_Time=max(SubmitTime_t), Start_Time=max(StartTime_t), End_Time=max(EndTime_t), Command=max(Command_s), Statement_Type=max(StatementType_s), Resource_class=max(ResourceClass_s) by RequestId_s\r\n| join kind= inner\r\n(\r\n AzureDiagnostics\r\n | where Category == 'ExecRequests'\r\n | where Resource == '{DatabaseName}'\r\n //| where StatementType_s !in ('Batch','Execute')\r\n | where StatementType_s == 'BuildReplicatedTableCache'\r\n | where EndTime_t > ago(7d)\r\n | where StartTime_t > ago(7d)\r\n | extend elapsedTime_min = (EndTime_t - StartTime_t)/1m\r\n //| extend elapsedTime_min = elapsedTime/1m\r\n | order by elapsedTime_min desc\r\n | project Request_ID=RequestId_s,elapsedTime_min \r\n)\r\non Request_ID\r\n| order by elapsedTime_min desc\r\n| project Request_ID,Submit_Time,Start_Time,End_Time,Elapsed_Time=round(elapsedTime_min,1) ,Command\r\n| limit 15\r\n", "size": 3, "title": "Top 15 Elapsed Time per Rebuild", "timeContext": { "durationMs": 604800000 }, "exportFieldName": "Request_ID", "exportParameterName": "RequestId", "exportDefaultValue": "999999", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "40%" } } ] } }, "name": "query - 3" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics\r\n| where Category == 'RequestSteps'\r\n| where Resource == '{DatabaseName}'\r\n| where RequestId_s == '{RequestId}'\r\n| where Status_s != 'Running'\r\n| summarize max(StartTime_t),max(EndTime_t),max(RequestId_s),max(OperationType_s),max(RowCount_d),max(Command_s),max(Status_s) by StepIndex_d\r\n| order by StepIndex_d asc", "size": 3, "title": "Query Plan for Selected Query", "noDataMessage": "Select a query above to view plan", "timeContext": { "durationMs": 604800000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 4" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "ReplicatedTables" }, "name": "ReplicatedTablesGroup" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "title": "Workload Management", "items": [ { "type": 10, "content": { "chartId": "workbook72446028-6edb-4cb0-8952-e0c13bda488f", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 0 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-WorkloadManagement-wlg_allocation_relative_to_system_percent", "aggregation": 3, "splitBy": null } ], "title": "Workload Group Allocation By System Percent", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "name": "metric - 0" }, { "type": 10, "content": { "chartId": "workbookc898119a-7381-469d-b51a-d505b4f80e73", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 0 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-WorkloadManagement-wlg_active_queries", "aggregation": 1, "splitBy": null } ], "title": "Query Count by Workload Group", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "name": "metric - 1" }, { "type": 10, "content": { "chartId": "workbook8d175f6c-427b-47fc-85ea-37edd0be707c", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 0 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-WorkloadManagement-wlg_queued_queries", "aggregation": 1, "splitBy": null } ], "title": "Queued Queries by Workload Group", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "name": "Queued Queries by Workload Group" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "parameters": [ { "id": "6f50577d-7b00-4e4a-acf9-d45c7a5ee813", "version": "KqlParameterItem/1.0", "name": "WorkloadGroupName", "type": 2, "query": "AzureDiagnostics\r\n| where Category == 'ExecRequests'\r\nand Resource == '{DatabaseName}'\r\n and ResourceClass_s != \"\"\r\n| distinct ResourceClass_s", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "value": null, "typeSettings": { "additionalResourceOptions": [], "showDefault": false }, "timeContext": { "durationMs": 604800000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 2" }, { "type": 10, "content": { "chartId": "workbook3da1d18a-1bf5-46c5-b3b7-211f71d329cc", "version": "MetricsItem/2.0", "size": 0, "chartType": 2, "resourceType": "microsoft.sql/servers/databases", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 0 }, "metrics": [ { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-WorkloadManagement-wlg_active_queries", "aggregation": 1, "splitBy": null }, { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-WorkloadManagement-wlg_queued_queries", "aggregation": 1 }, { "namespace": "microsoft.sql/servers/databases", "metric": "microsoft.sql/servers/databases-WorkloadManagement-wlg_allocation_relative_to_system_percent", "aggregation": 3 } ], "filters": [ { "id": "3", "key": "WorkloadGroupName", "operator": 0, "valueParam": "WorkloadGroupName" } ], "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "name": "metric - 3" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "WorkloadManagement" }, "name": "group - 6" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "title": "Query Audit", "items": [ { "type": 1, "content": { "json": "## Select a Principal or Application name to filter results - leave to 'unset' to view all results\r\nSQL Auditing must be enabled and sending to the same Log Analytics Workspace for this page to work. " }, "name": "text - 5" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "parameters": [ { "id": "8d25c043-d1ff-4546-a1fa-f4bcbfdab8af", "version": "KqlParameterItem/1.0", "name": "User", "type": 2, "description": "User to filter subsequent queries - leave to 'unset' for all users", "query": "AzureDiagnostics\r\n| where Category == 'SQLSecurityAuditEvents' and LogicalServerName_s == '{LogicalServerName}'\r\n| summarize by server_principal_name_s", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "value": null, "typeSettings": { "additionalResourceOptions": [], "showDefault": false }, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "id": "aa766d64-693f-4024-b4a4-b5b56b28376b", "version": "KqlParameterItem/1.0", "name": "Application", "type": 2, "query": "AzureDiagnostics\r\n| where Category == 'SQLSecurityAuditEvents' and LogicalServerName_s == '{LogicalServerName}'\r\n| summarize by application_name_s", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "value": null, "typeSettings": { "additionalResourceOptions": [], "showDefault": false }, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "customWidth": "30", "name": "parameters - 1" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics\r\n| where Category == 'SQLSecurityAuditEvents' and LogicalServerName_s == \"{LogicalServerName}\"\r\n| where duration_milliseconds_d > 0\r\n| extend duration_seconds = duration_milliseconds_d /1000.0\r\n| where statement_s != 'select @@version'\r\n| where statement_s != 'SELECT @@SPID;'\r\n| where server_principal_name_s has '{User}'\r\n| where application_name_s has '{Application}'\r\n| project server_principal_name_s, succeeded_s, event_time_t, LogicalServerName_s, duration_milliseconds_d, duration_seconds, affected_rows_d, statement_s, application_name_s\r\n| summarize duration_seconds = round(sum(duration_seconds)) , query_count = count(statement_s) by EventDay = bin(event_time_t,1d), UserName = server_principal_name_s, Application = application_name_s \r\n| order by EventDay, duration_seconds desc", "size": 0, "title": "Query Summary for Selected User {User} {Application}", "noDataMessage": "Select a user to see query activity", "timeContext": { "durationMs": 14400000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 0 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics\r\n| where Category == 'SQLSecurityAuditEvents' and LogicalServerName_s == \"{LogicalServerName}\"\r\n| where duration_milliseconds_d > 0\r\n| extend duration_seconds = duration_milliseconds_d /1000.0\r\n| where statement_s != 'select @@version'\r\n| where statement_s != 'SELECT @@SPID;'\r\n| where server_principal_name_s has '{User}'\r\n| where application_name_s has '{Application}'\r\n| project server_principal_name_s, succeeded_s, event_time_t, LogicalServerName_s, duration_milliseconds_d, duration_seconds, affected_rows_d, statement_s, application_name_s\r\n| summarize duration_seconds = round(sum(duration_seconds)) , query_count = count(statement_s) by EventDay = bin(event_time_t,1d), UserName = server_principal_name_s, Application = application_name_s \r\n| order by EventDay, duration_seconds desc", "size": 0, "title": "Query Summary for Selected User {User} {Application}", "noDataMessage": "Select a user to see query activity", "timeContext": { "durationMs": 14400000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "unstackedbar", "tileSettings": { "showBorder": false, "titleContent": { "columnMatch": "UserName", "formatter": 1 }, "leftContent": { "columnMatch": "duration_seconds", "formatter": 12, "formatOptions": { "palette": "auto" }, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "graphSettings": { "type": 0, "topContent": { "columnMatch": "UserName", "formatter": 1 }, "centerContent": { "columnMatch": "duration_seconds", "formatter": 1, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "chartSettings": { "xAxis": "UserName" }, "mapSettings": { "locInfo": "LatLong", "sizeSettings": "duration_seconds", "sizeAggregation": "Sum", "legendMetric": "duration_seconds", "legendAggregation": "Sum", "itemColorSettings": { "type": "heatmap", "colorAggregation": "Sum", "nodeColorField": "duration_seconds", "heatmapPalette": "greenRed" } } }, "name": "query - 0 - Copy - Copy" }, { "type": 1, "content": { "json": "## This next chart is a work in progress\r\nThe next chart uses an approximate join based on end time. If the Exec Requests Query Text and the Audit Log Query text don't match up, then it is likely not a real match and the data in teh row shoudl not be trusted. ", "style": "warning" }, "name": "text - 7" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databasename='{DatabaseName}';\r\nAzureDiagnostics \r\n| where Category == 'ExecRequests'\r\n| where Resource == databasename\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize Session_ID=max(SessionId_s), \r\n Query_Submit_Time=max(SubmitTime_t), \r\n Query_Start_Time=max(StartTime_t), \r\n Query_End_Time=max(EndTime_t), \r\n Query_Text=max(Command_s), \r\n Status=min(Status_s),\r\n Resource_class=max(ResourceClass_s) ,\r\n Query_ElapsedTime_s=round((max(EndTime_t) - max(StartTime_t))/1s)\r\n by RequestId_s\r\n| join kind = leftouter \r\n(\r\n AzureDiagnostics\r\n | where Category == 'RequestSteps'\r\n | where Resource == databasename\r\n | summarize num_steps=max(StepIndex_d), \r\n max_step_rows=max(RowCount_d), \r\n max_step_sec=max(EndTime_t-StartTime_t)/1s\r\n by RequestId_s\r\n ) on RequestId_s\r\n| order by Query_Submit_Time\r\n| project Session_ID,RequestId_s,Query_Submit_Time,Query_Start_Time,EventTime = Query_End_Time,num_steps,max_step_rows,max_step_sec,Query_ElapsedTime_s,Status,Query = Query_Text,Resource_class\r\n| join kind = rightouter \r\n(\r\n AzureDiagnostics\r\n | where Category == 'SQLSecurityAuditEvents' and LogicalServerName_s == \"{LogicalServerName}\"\r\n | where duration_milliseconds_d > 0\r\n | extend duration_seconds = duration_milliseconds_d /1000.0\r\n | where statement_s != 'select @@version'\r\n | where statement_s != 'SELECT @@SPID;'\r\n | where server_principal_name_s has '{User}'\r\n // | where application_name_s has '{Application}'\r\n | project DatabaseName= database_name_s, UserName= server_principal_name_s, EventTime= event_time_t, Host= host_name_s, duration_seconds = round(duration_seconds), statement_s, QuerySource = application_name_s , affected_rows_d\r\n | project-reorder DatabaseName, UserName, Host, EventTime, duration_seconds, statement_s, QuerySource\r\n) on EventTime\r\n | order by affected_rows_d desc\r\n| project Session_ID,RequestID=RequestId_s,Submit_time=Query_Submit_Time,Start_Time=Query_Start_Time,End_Time=EventTime,Status,Resource_class,UserName,Exec_request_text=Query,Audit_Query_text=statement_s,Host,QuerySource,Affected_rows=affected_rows_d,num_steps,max_step_rows,max_step_sec,Total_Duration_s=duration_seconds\r\n\r\n\r\n\r\n\r\n", "size": 0, "title": "Queries {User} {Application}", "noDataMessage": "Select a user to see query activity", "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 0 - Copy - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": " AzureDiagnostics\r\n | where Category == 'SQLSecurityAuditEvents' and LogicalServerName_s == \"{LogicalServerName}\"\r\n | where duration_milliseconds_d > 0\r\n| extend Duration = round(duration_milliseconds_d /1000.0)\r\n| extend TimeBin = case (datetime_part(\"Hour\",TimeGenerated) in (6,7,8,9,10,11,12), \"Morning_6-12\", datetime_part(\"Hour\",TimeGenerated) in (13,14,15,16,17,18), \"Afternoon_12-18\", \"Overnight_18-6\")\r\n| where server_principal_name_s has '{User}'\r\n| where application_name_s has '{Application}'\r\n| summarize QueryDuration = sum(Duration) by EventTime = bin(event_time_t, 1d), TimeBin", "size": 0, "title": "Query Activity by time - sum(Duration) {User} {Application}", "noDataMessage": "Select a user to see query activity", "timeContext": { "durationMs": 14400000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "barchart" }, "name": "query - 0 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databasename='{DatabaseName}';\r\nAzureDiagnostics \r\n| where Category == 'ExecRequests'\r\n| where Resource == databasename\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize Session_ID=max(SessionId_s), \r\n Query_Submit_Time=max(SubmitTime_t), \r\n Query_Start_Time=max(StartTime_t), \r\n Query_End_Time=max(EndTime_t), \r\n Query_Text=max(Command_s), \r\n Status=min(Status_s),\r\n Resource_class=max(ResourceClass_s) ,\r\n Query_ElapsedTime_s=round((max(EndTime_t) - max(StartTime_t))/1s)\r\n by RequestId_s\r\n| join kind = leftouter \r\n(\r\n AzureDiagnostics\r\n | where Category == 'RequestSteps'\r\n | where Resource == databasename\r\n | summarize num_steps=max(StepIndex_d), \r\n max_step_rows=max(RowCount_d), \r\n max_step_sec=max(EndTime_t-StartTime_t)/1s\r\n by RequestId_s\r\n ) on RequestId_s\r\n| order by Query_Submit_Time\r\n| project Session_ID,RequestId_s,Query_Submit_Time,Query_Start_Time,EventTime = Query_End_Time,num_steps,max_step_rows,max_step_sec,Query_ElapsedTime_s,Status,Query = Query_Text,Resource_class\r\n| join kind = rightouter \r\n(\r\n AzureDiagnostics\r\n | where Category == 'SQLSecurityAuditEvents' and LogicalServerName_s == \"{LogicalServerName}\"\r\n | where duration_milliseconds_d > 0\r\n | extend duration_seconds = duration_milliseconds_d /1000.0\r\n | where statement_s != 'select @@version'\r\n | where statement_s != 'SELECT @@SPID;'\r\n | where server_principal_name_s has '{User}'\r\n // | where application_name_s has '{Application}'\r\n | project DatabaseName= database_name_s, UserName= server_principal_name_s, EventTime= event_time_t, Host= host_name_s, duration_seconds = round(duration_seconds), statement_s, QuerySource = application_name_s , affected_rows_d\r\n | project-reorder DatabaseName, UserName, Host, EventTime, duration_seconds, statement_s, QuerySource\r\n) on EventTime\r\n | order by affected_rows_d desc\r\n| project Session_ID,RequestID=RequestId_s,Submit_time=Query_Submit_Time,Start_Time=Query_Start_Time,End_Time=EventTime,Status,Resource_class,UserName,Query_text=statement_s,Host,QuerySource,Affected_rows=affected_rows_d,num_steps,max_step_rows,max_step_sec,Total_Duration_s=duration_seconds\r\n\r\n\r\n\r\n\r\n", "size": 0, "title": "Affected Rows By Session ID", "timeContext": { "durationMs": 14400000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "linechart", "chartSettings": { "xAxis": "RequestID", "yAxis": [ "Affected_rows" ] } }, "name": "query - 6" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "QueryAudit" }, "name": "QueryAuditGroup", "styleSettings": { "showBorder": true } }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "title": "Query Comparison", "items": [ { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "7fa3187e-9225-4faa-8f80-dc1bc40c5aab", "version": "KqlParameterItem/1.0", "name": "RequestId1", "type": 1, "value": "" } ], "style": "above", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "customWidth": "50", "name": "parameters - 3 - Copy" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "315fc476-469a-4d8d-b421-028d1113ab06", "version": "KqlParameterItem/1.0", "name": "RequestId2", "type": 1, "value": "", "timeContext": { "durationMs": 86400000 } } ], "style": "above", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "customWidth": "50", "name": "parameters - 2" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s !in ('Batch','Execute') and RequestId_s == '{RequestId1}'\r\n| summarize Session_ID=any(SessionId_s),\r\n Request_ID=any(RequestId_s),\r\n Submit_Time=min(SubmitTime_t),\r\n Start_Time=max(StartTime_t),\r\n End_Time=max(EndTime_t),\r\n Command=any(Command_s),\r\n Status=min(Status_s), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType_s),\r\n Resource_class=any(ResourceClass_s)\r\n by RequestId_s\r\n| summarize Session_ID=any(Session_ID), Submit_Time=any(Submit_Time) ,Start_Time=any(Start_Time), End_Time=any(End_Time),ElapsedTime_min=anyif((End_Time - Start_Time)/1m,Start_Time > ago(30d)),Command=any(Command),Status=any(Status),Statement_Type=any(Statement_Type),Resource_class=any(Resource_class) by Request_ID\r\n| project Session_ID,Request_ID,ElapsedTime_min,Command,Resource_class,Submit_Time,Start_Time,End_Time,Statement_Type,Status\r\n", "size": 4, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "customWidth": "50", "name": "query - 2" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics\r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s !in ('Batch','Execute') and RequestId_s == '{RequestId2}'\r\n| summarize Session_ID=any(SessionId_s),\r\n Request_ID=any(RequestId_s),\r\n Submit_Time=min(SubmitTime_t),\r\n Start_Time=max(StartTime_t),\r\n End_Time=max(EndTime_t),\r\n Command=any(Command_s),\r\n Status=min(Status_s), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType_s),\r\n Resource_class=any(ResourceClass_s)\r\n by RequestId_s\r\n| summarize Session_ID=any(Session_ID), Submit_Time=any(Submit_Time) ,Start_Time=any(Start_Time), End_Time=any(End_Time),ElapsedTime_min=anyif((End_Time - Start_Time)/1m,Start_Time > ago(30d)),Command=any(Command),Status=any(Status),Statement_Type=any(Statement_Type),Resource_class=any(Resource_class) by Request_ID\r\n| project Session_ID,Request_ID,ElapsedTime_min,Command,Resource_class,Submit_Time,Start_Time,End_Time,Statement_Type,Status\r\n", "size": 4, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "customWidth": "50", "name": "query - 2 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics\r\n| where Category == 'RequestSteps'\r\n| where Resource == '{DatabaseName}'\r\n| where RequestId_s == '{RequestId1}'\r\n| summarize StartTime=max(StartTime_t)\r\n ,EndTime=max(EndTime_t)\r\n ,RequestID=max(RequestId_s)\r\n ,Operation=max(OperationType_s)\r\n ,RowCount=max(RowCount_d)\r\n ,Command=max(Command_s)\r\n ,Status=max(Status_s)\r\n by StepIndex_d\r\n| order by StepIndex_d asc\r\n| project StartTime,EndTime,RequestID,Operation,RowCount,Command,Status,StepIndex_d", "size": 3, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "customWidth": "50", "name": "query - 4", "styleSettings": { "margin": "0", "padding": "10px" } }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics\r\n| where Category == 'RequestSteps'\r\n| where Resource == '{DatabaseName}'\r\n| where RequestId_s == '{RequestId2}'\r\n| summarize StartTime=max(StartTime_t)\r\n ,EndTime=max(EndTime_t)\r\n ,RequestID=max(RequestId_s)\r\n ,Operation=max(OperationType_s)\r\n ,RowCount=max(RowCount_d)\r\n ,Command=max(Command_s)\r\n ,Status=max(Status_s)\r\n by StepIndex_d\r\n| order by StepIndex_d asc\r\n| project StartTime,EndTime,RequestID,Operation,RowCount,Command,Status,StepIndex_d", "size": 3, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "customWidth": "50", "name": "query - 4 - Copy", "styleSettings": { "padding": "10px" } }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "parameters": [ { "id": "03d1c3ba-0d28-4584-bb63-388f8477034a", "version": "KqlParameterItem/1.0", "name": "Query_Submit_Time1", "type": 1, "query": " AzureDiagnostics \r\n | where Category == 'ExecRequests'\r\n | where Resource == '{DatabaseName}'\r\n | where StatementType_s !in ('Batch','Execute')\r\n | where RequestId_s =='{RequestId1}'\r\n | summarize \r\n Submit_Time=min(SubmitTime_t)\r\n by RequestId_s\r\n | project Submit_Time", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "id": "af36efd7-c5a0-429e-8908-a24e22ee6087", "version": "KqlParameterItem/1.0", "name": "Query_End_Compile_Time1", "type": 1, "query": " AzureDiagnostics \r\n | where Category == 'ExecRequests'\r\n | where Resource == '{DatabaseName}'\r\n | where StatementType_s !in ('Batch','Execute')\r\n | where RequestId_s =='{RequestId1}'\r\n | summarize \r\n End_Compile_Time=max(EndCompileTime_t) \r\n by RequestId_s\r\n | project End_Compile_Time", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "id": "03d1c3ba-0d28-4584-bb63-388f8477034a", "version": "KqlParameterItem/1.0", "name": "Query_Submit_Time2", "type": 1, "query": " AzureDiagnostics \r\n | where Category == 'ExecRequests'\r\n | where Resource == '{DatabaseName}'\r\n | where StatementType_s !in ('Batch','Execute')\r\n | where RequestId_s =='{RequestId2}'\r\n | summarize \r\n Submit_Time=min(SubmitTime_t)\r\n by RequestId_s\r\n | project Submit_Time", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "id": "af36efd7-c5a0-429e-8908-a24e22ee6087", "version": "KqlParameterItem/1.0", "name": "Query_End_Compile_Time2", "type": 1, "query": " AzureDiagnostics \r\n | where Category == 'ExecRequests'\r\n | where Resource == '{DatabaseName}'\r\n | where StatementType_s !in ('Batch','Execute')\r\n | where RequestId_s =='{RequestId2}'\r\n | summarize \r\n End_Compile_Time=max(EndCompileTime_t) \r\n by RequestId_s\r\n | project End_Compile_Time", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 6 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": " AzureDiagnostics \r\n | where Category == 'ExecRequests'\r\n | where Resource == '{DatabaseName}'\r\n | where StatementType_s =='CreateStatistics'\r\n | summarize \r\n Session_ID=max(SessionId_s), \r\n //Request_ID=max(RequestId_s), \r\n Submit_Time=min(SubmitTime_t), \r\n //Start_Time=max(StartTime_t),\r\n //End_Compile_Time=max(EndCompileTime_t), \r\n End_Time=max(EndTime_t), \r\n Command=max(Command_s), \r\n Last_Status=min(Status_s),\r\n Statement_Type=max(StatementType_s),\r\n Resource_class=max(ResourceClass_s) \r\n by RequestId_s\r\n | where Submit_Time > datetime('{Query_Submit_Time1}') and End_Time < datetime('{Query_End_Compile_Time1}') and End_Time > ago(30d)\r\n| project Command, Status=Last_Status ,Submit_Time,End_Time,Session_ID,Request_ID=RequestId_s,Statement_Type\r\n", "size": 0, "title": "All possibly related auto-stats statements based on time", "noDataMessage": "no auto stats statements found that could be related", "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Submit_Time", "formatter": 0, "numberFormat": { "unit": 0, "options": { "style": "decimal" } } }, { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "100ch" } } ], "sortBy": [ { "itemKey": "End_Time", "sortOrder": 2 } ] }, "sortBy": [ { "itemKey": "End_Time", "sortOrder": 2 } ] }, "customWidth": "50", "name": "All possibly related auto-stats statements - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": " AzureDiagnostics \r\n | where Category == 'ExecRequests'\r\n | where Resource == '{DatabaseName}'\r\n | where StatementType_s =='CreateStatistics'\r\n | summarize \r\n Session_ID=max(SessionId_s), \r\n //Request_ID=max(RequestId_s), \r\n Submit_Time=min(SubmitTime_t), \r\n //Start_Time=max(StartTime_t),\r\n //End_Compile_Time=max(EndCompileTime_t), \r\n End_Time=max(EndTime_t), \r\n Command=max(Command_s), \r\n Last_Status=min(Status_s),\r\n Statement_Type=max(StatementType_s),\r\n Resource_class=max(ResourceClass_s) \r\n by RequestId_s\r\n | where Submit_Time > datetime('{Query_Submit_Time2}') and End_Time < datetime('{Query_End_Compile_Time2}') and End_Time > ago(30d)\r\n| project Command, Status=Last_Status ,Submit_Time,End_Time,Session_ID,Request_ID=RequestId_s,Statement_Type\r\n", "size": 0, "title": "All possibly related auto-stats statements based on time", "noDataMessage": "no auto stats statements found that could be related", "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Submit_Time", "formatter": 0, "numberFormat": { "unit": 0, "options": { "style": "decimal" } } }, { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "100ch" } } ] } }, "customWidth": "50", "name": "All possibly related auto-stats statements - Copy - Copy" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "QueryComparison" }, "name": "QueryComparison" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "title": "Session Investigation", "items": [ { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "feb2ac70-2555-456e-bfa6-6ad4a2dcad0f", "version": "KqlParameterItem/1.0", "name": "SessionID", "type": 1, "value": "", "timeContext": { "durationMs": 86400000 } } ], "style": "above", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 0" }, { "type": 1, "content": { "json": "The matching of the user information in the next chart is approximate. This information is a work in progress", "style": "warning" }, "name": "text - 4" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databasename='{DatabaseName}';\r\nAzureDiagnostics \r\n| where Category == 'ExecRequests'\r\n| where Resource == databasename\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize Query_End_Time = max(EndTime_t ) by SessionId_s\r\n| where SessionId_s == '{SessionID}'\r\n| join kind = rightouter \r\n( \r\n AzureDiagnostics\r\n | where Category == 'SQLSecurityAuditEvents' \r\n | where duration_milliseconds_d > 0\r\n | extend duration_seconds = duration_milliseconds_d /1000.0\r\n | where statement_s != 'select @@version' and statement_s != 'SELECT @@SPID;' and server_principal_name_s != '##MS_InstanceCertificate##'\r\n) on $left.Query_End_Time==$right.event_time_t \r\n| summarize DatabaseName= max(database_name_s)\r\n , UserName= any(server_principal_name_s)\r\n , Host= max(host_name_s)\r\n , Application=max(application_name_s)\r\n by SessionId_s\r\n\r\n\r\n\r\n", "size": 4, "timeContext": { "durationMs": 14400000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "table", "tileSettings": { "titleContent": { "columnMatch": "UserName" }, "subtitleContent": { "columnMatch": "SessionId_s" }, "leftContent": { "columnMatch": "Application" }, "rightContent": { "columnMatch": "Host" }, "secondaryContent": { "columnMatch": "DatabaseName" }, "showBorder": false, "size": "full" }, "graphSettings": { "type": 0 } }, "name": "query - 3" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics \r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize \r\n Session_ID=max(SessionId_s), \r\n Submit_Time=max(SubmitTime_t), \r\n Start_Time=max(StartTime_t),\r\n End_Compile_Time=max(EndCompileTime_t), \r\n End_Time=max(EndTime_t), \r\n Command=max(Command_s), \r\n Last_Status=min(Status_s),\r\n Statement_Type=max(StatementType_s),\r\n Resource_class=max(ResourceClass_s) \r\n by RequestId_s\r\n| where Session_ID has '{SessionID}'\r\n| extend elapsedTime_sec = iif(End_Time > ago(365d),(End_Time - Submit_Time)/1s,real(null)) \r\n| order by Submit_Time asc\r\n\r\n\r\n\r\n\r\n", "size": 0, "timeContext": { "durationMs": 14400000 }, "timeContextFromParameter": "TimeRange", "exportFieldName": "RequestId_s", "exportParameterName": "RequestID", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 1" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics\r\n| where Category == 'RequestSteps'\r\n| where Resource == '{DatabaseName}'\r\n| where RequestId_s == '{RequestID}'\r\n//| where Status_s != 'Running'\r\n| summarize Start_Time=max(StartTime_t),End_Time=max(EndTime_t),Request_ID=max(RequestId_s),Operation_Type=max(OperationType_s),Row_Count=max(RowCount_d),Statement=max(Command_s),Status=min(Status_s) by StepIndex_d\r\n| order by StepIndex_d asc", "size": 3, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 2" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "SessionInvestigation" }, "name": "group - 9" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 1, "content": { "json": "## This tab is used to determine what statements triggerred autostats creation jobs. \r\nThe flow of autostats creation is as follows\r\n1. Query Submit Time\r\n2. \tCreate Statistics submit Time\r\n3. \tCreate Statistics end Time\r\n4. Query end_compile_time\r\n5. Query Start_Time\r\n6. Query End_Time\r\n\r\nFurther, if multiple stats are created, then the creation of all stats for this query will fall between query submit_time and end_compile_time. \r\n\r\nThe charts on this page allow you to search for an autostats job by requestID or my snippet of the autostats statement text, which can just be the schema, table, or column name. Then it will show you all commands that include that request ID or text. It will then show you all statements in the create stat statement because the query we are trying to identify will wait for all of those stats creations to complete before proceeding. \r\n\r\nThe last chart will list out all statements that could possibly have triggerred the stats creation job based on their submite/end_compile_time. " }, "name": "text - 6" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "0911bd4b-d471-480b-bdf4-1a2d4ba1ea6e", "version": "KqlParameterItem/1.0", "name": "RequestIdSearch", "type": 1, "value": "", "label": "RequestId for AutoStats Job" }, { "id": "c12e6495-4fd1-473c-8ffc-0bf502f54706", "version": "KqlParameterItem/1.0", "name": "QueryTextSnippet", "type": 1, "value": "", "timeContext": { "durationMs": 86400000 }, "label": "Snippet of autostats creation statement (Schema, table or column)" } ], "style": "formVertical", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "customWidth": "60", "name": "parameters - 3 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics \r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize \r\n Session_ID=max(SessionId_s), \r\n Request_ID=max(RequestId_s), \r\n Submit_Time=max(SubmitTime_t), \r\n Start_Time=max(StartTime_t),\r\n End_Compile_Time=max(EndCompileTime_t), \r\n End_Time=max(EndTime_t), \r\n Command=max(Command_s), \r\n Last_Status=min(Status_s),\r\n Statement_Type=max(StatementType_s),\r\n Resource_class=max(ResourceClass_s) \r\n by RequestId_s\r\n| where Command has 'CREATE STATISTICS _wa_sys'\r\n| where Command has '{QueryTextSnippet}'\r\nand RequestId_s has '{RequestIdSearch}'\r\n| extend elapsedTime_sec = iif(End_Time > ago(365d),(End_Time - Submit_Time)/1s,real(null)) \r\n| extend CompileTime_sec = (End_Compile_Time - Submit_Time)/1s\r\n| order by elapsedTime_sec\r\n| summarize \r\n Executions = count(),\r\n Max_Elapsed_Time_sec = bin(max(elapsedTime_sec),1),\r\n Min_Elapsed_Time_sec = bin(min(elapsedTime_sec),1),\r\n Variability_sec=bin((max(elapsedTime_sec)-min(elapsedTime_sec)),1),\r\n SampleQID = any(RequestId_s),\r\n SampleSessionID = any(Session_ID)\r\n by Command\r\n| order by Max_Elapsed_Time_sec\r\n\r\n\r\n", "size": 0, "title": "Matching Queries", "timeContext": { "durationMs": 14400000 }, "timeContextFromParameter": "TimeRange", "exportedParameters": [ { "fieldName": "SampleQID", "parameterName": "SampleQID" }, { "fieldName": "SampleSessionID", "parameterName": "Samp", "parameterType": 1 } ], "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "50%" } } ], "sortBy": [ { "itemKey": "Command", "sortOrder": 1 } ] }, "sortBy": [ { "itemKey": "Command", "sortOrder": 1 } ] }, "name": "query - 0 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics \r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s !in ('Batch','Execute')\r\n| where RequestId_s == '{SampleQID}'\r\n| summarize \r\n Session_ID=max(SessionId_s), \r\n Request_ID=max(RequestId_s), \r\n Submit_Time=min(SubmitTime_t), \r\n Start_Time=max(StartTime_t),\r\n End_Compile_Time=max(EndCompileTime_t), \r\n End_Time=max(EndTime_t), \r\n Command=max(Command_s), \r\n Last_Status=min(Status_s),\r\n Statement_Type=max(StatementType_s),\r\n Resource_class=max(ResourceClass_s) \r\n by RequestId_s\r\n| extend elapsedTime_sec = iif(End_Time > ago(365d),(End_Time - Submit_Time)/1s,real(null)) \r\n| extend CompileTime_sec = (End_Compile_Time - Submit_Time)/1s\r\n| join kind=inner\r\n (AzureDiagnostics \r\n | where Category == 'ExecRequests'\r\n | where Resource == '{DatabaseName}'\r\n | where StatementType_s !in ('Batch','Execute')\r\n | summarize \r\n Session_ID=max(SessionId_s), \r\n Request_ID=max(RequestId_s), \r\n Submit_Time=min(SubmitTime_t), \r\n Start_Time=max(StartTime_t),\r\n End_Compile_Time=max(EndCompileTime_t), \r\n End_Time=max(EndTime_t), \r\n Command=max(Command_s), \r\n Last_Status=min(Status_s),\r\n Statement_Type=max(StatementType_s),\r\n Resource_class=max(ResourceClass_s) \r\n by RequestId_s\r\n | extend elapsedTime_sec = (End_Time - Submit_Time)/1s\r\n | extend elapsedTime_sec = iif(End_Time > ago(365d),(End_Time - Submit_Time)/1s,real(null)) \r\n | extend CompileTime_sec = (End_Compile_Time - Submit_Time)/1s\r\n )\r\non Command \r\n| project Request_ID1,Session_ID1,Submit_Time1,Start_Time1,End_Compile_Time1,End_Time1,Last_Status1,Statement_Type1,elapsedTime_sec1,CompileTime_sec1\r\n", "size": 0, "title": "All Executions of Selected Query", "noDataMessage": "Select a query above to see individual executions", "timeContext": { "durationMs": 14400000 }, "timeContextFromParameter": "TimeRange", "exportedParameters": [ { "fieldName": "Request_ID1", "parameterName": "RequestId" }, { "fieldName": "End_Time1", "parameterName": "StatEndTime", "parameterType": 1 }, { "fieldName": "Submit_Time1", "parameterName": "StatSubmitTime", "parameterType": 1 }, { "fieldName": "Session_ID1", "parameterName": "SessionId", "parameterType": 1 } ], "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "sortBy": [ { "itemKey": "End_Time1", "sortOrder": 1 } ] }, "sortBy": [ { "itemKey": "End_Time1", "sortOrder": 1 } ] }, "name": "query - 0 - Copy - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": " AzureDiagnostics \r\n | where Category == 'ExecRequests'\r\n | where Resource == '{DatabaseName}'\r\n | where StatementType_s !in ('Batch','Execute')\r\n | where SessionId_s == '{SessionId}'\r\n | summarize \r\n Session_ID=max(SessionId_s), \r\n Request_ID=max(RequestId_s), \r\n Submit_Time=min(SubmitTime_t), \r\n Start_Time=max(StartTime_t),\r\n End_Compile_Time=max(EndCompileTime_t), \r\n End_Time=max(EndTime_t), \r\n Command=max(Command_s), \r\n Last_Status=min(Status_s),\r\n Statement_Type=max(StatementType_s),\r\n Resource_class=max(ResourceClass_s) \r\n by RequestId_s\r\n| project Session_ID,Request_ID,Submit_Time,End_Compile_Time,Start_Time,End_Time,Last_Status,Statement_Type,Command\r\n\r\n\r\n", "size": 0, "title": "All Statements in Stats Statement Session", "noDataMessage": "Select a query above to see individual executions", "timeContext": { "durationMs": 14400000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "150ch" } } ], "sortBy": [ { "itemKey": "Command", "sortOrder": 1 } ] }, "sortBy": [ { "itemKey": "Command", "sortOrder": 1 } ] }, "name": "query - 0 - Copy - Copy - Copy - Copy" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "parameters": [ { "id": "4e005821-785a-4246-aae8-de00987cba18", "version": "KqlParameterItem/1.0", "name": "Session_Submit_Time", "type": 1, "query": "AzureDiagnostics \r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s !in ('Batch','Execute')\r\n| where SessionId_s == '{SessionId}'\r\n| summarize \r\n Session_Submit_Time=min(SubmitTime_t) \r\n by SessionId_s\r\n| project Session_Submit_Time\r\n\r\n\r\n", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 259200000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "id": "b046db56-e6b3-4f3d-afb3-9687240c21f1", "version": "KqlParameterItem/1.0", "name": "Session_End_Time", "type": 1, "query": "AzureDiagnostics \r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s !in ('Batch','Execute')\r\n| where SessionId_s == '{SessionId}'\r\n| summarize \r\n Session_End_Time=max(EndTime_t) \r\n by SessionId_s\r\n| project Session_End_Time", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 259200000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 7" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics \r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s !in ('Batch','Execute')\r\n| where SubmitTime_t < datetime('{Session_Submit_Time}') and EndCompileTime_t > datetime('{Session_End_Time}') or RequestId_s == '{RequestId}'\r\n| summarize by RequestId_s\r\n| join kind=inner\r\n (\r\n AzureDiagnostics \r\n | where Category == 'ExecRequests'\r\n | where Resource == '{DatabaseName}'\r\n | where StatementType_s !in ('Batch','Execute')\r\n | summarize \r\n Session_ID=max(SessionId_s), \r\n Request_ID=max(RequestId_s), \r\n Submit_Time=min(SubmitTime_t), \r\n Start_Time=max(StartTime_t),\r\n End_Compile_Time=max(EndCompileTime_t), \r\n End_Time=max(EndTime_t), \r\n Command=max(Command_s), \r\n Last_Status=min(Status_s),\r\n Statement_Type=max(StatementType_s),\r\n Resource_class=max(ResourceClass_s) \r\n by RequestId_s\r\n ) on RequestId_s\r\n| order by End_Compile_Time\r\n| project Session_ID,Request_ID,Submit_Time,End_Compile_Time,Start_Time,End_Time,Last_Status,Statement_Type,Command\r\n\r\n", "size": 0, "title": "Query Executions that could have triggered Stats Statement based on Time of total session", "noDataMessage": "Select a query above to see individual executions", "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "150ch" } } ], "sortBy": [ { "itemKey": "Command", "sortOrder": 1 } ] }, "sortBy": [ { "itemKey": "Command", "sortOrder": 1 } ] }, "name": "query - 0 - Copy - Copy - Copy - Copy" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "Statistics" }, "name": "statistics" } ], "fallbackResourceIds": [ "azure monitor" ], "$schema": "https://github.com/Microsoft/Application-Insights-Workbooks/blob/master/schema/workbook.json" } ================================================ FILE: Monitor_Workbooks/archive/WorkspaceSQLPoolWorkbook_WIP_v0.60.JSON ================================================ { "version": "Notebook/1.0", "items": [ { "type": 9, "content": { "version": "KqlParameterItem/1.0", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "parameters": [ { "id": "28da10ec-a308-47f5-9819-92ebf810b292", "version": "KqlParameterItem/1.0", "name": "LogAnalyticsSubscription", "type": 6, "value": null, "typeSettings": { "additionalResourceOptions": [], "includeAll": true, "showDefault": false }, "timeContext": { "durationMs": 86400000 } }, { "id": "e383ed24-52ae-447b-9b80-51fd3ab6b919", "version": "KqlParameterItem/1.0", "name": "LogAnalyticsWorkspace", "type": 5, "query": "Resources\r\n| where type == 'microsoft.operationalinsights/workspaces'\r\n| project id\r\n", "crossComponentResources": [ "{LogAnalyticsSubscription}" ], "value": null, "typeSettings": { "additionalResourceOptions": [], "showDefault": false }, "timeContext": { "durationMs": 86400000 }, "queryType": 1, "resourceType": "microsoft.resourcegraph/resources" }, { "id": "9b9fe566-0f52-4a75-a35b-a79c50c6a6f0", "version": "KqlParameterItem/1.0", "name": "DatabaseResourceName", "type": 5, "query": "SynapseSqlPoolExecRequests \r\n| distinct _ResourceId", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "value": null, "typeSettings": { "additionalResourceOptions": [], "showDefault": false }, "timeContext": { "durationMs": 2592000000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "id": "f5852627-70ca-4959-8d60-53b48864603f", "version": "KqlParameterItem/1.0", "name": "TimeRange", "type": 4, "isGlobal": true, "value": { "durationMs": 172800000 }, "typeSettings": { "selectableValues": [ { "durationMs": 300000 }, { "durationMs": 900000 }, { "durationMs": 1800000 }, { "durationMs": 3600000 }, { "durationMs": 14400000 }, { "durationMs": 43200000 }, { "durationMs": 86400000 }, { "durationMs": 172800000 }, { "durationMs": 259200000 }, { "durationMs": 604800000 }, { "durationMs": 1209600000 }, { "durationMs": 2419200000 }, { "durationMs": 2592000000 } ], "allowCustom": true }, "timeContext": { "durationMs": 86400000 } }, { "id": "6da2f63f-45a3-4b37-9108-5e8b7e358d85", "version": "KqlParameterItem/1.0", "name": "DatabaseName", "type": 1, "query": "print split (\"{DatabaseResourceName}\",\"/\")[-1]", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "id": "8bba835b-f319-43b3-8ec6-4e051fc6d446", "version": "KqlParameterItem/1.0", "name": "LogicalServerName", "type": 1, "query": "SynapseSqlPoolExecRequests\r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| distinct LogicalServerName", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 2" }, { "type": 11, "content": { "version": "LinkItem/1.0", "style": "tabs", "links": [ { "id": "202cbbc0-8d63-416d-89ed-451d6fe7c4b3", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Workload", "subTarget": "Workload", "preText": "Workload", "style": "link" }, { "id": "a7901bd0-a1f4-4491-b953-57555d764e00", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Workload Management", "subTarget": "WorkloadManagement", "style": "link" }, { "id": "45e12a14-8548-4477-aae3-c142b906dc9f", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "TempDB", "subTarget": "TempDB", "style": "link" }, { "id": "9ef8f730-d73d-432b-9b75-55095d1155f2", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Replicated Tables", "subTarget": "ReplicatedTables", "style": "link" }, { "id": "79d10d16-0696-4214-b306-c7a0e46cd64f", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Query Investigation", "subTarget": "QueryInvestigation", "style": "link" }, { "id": "31c1cf1c-74b5-44e2-ba9a-9497834ca3dc", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Query Comparison", "subTarget": "QueryComparison", "style": "link" }, { "id": "5ff681ee-e005-481f-b743-b66ab1b9d71d", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Session Investigation", "subTarget": "SessionInvestigation", "style": "link" }, { "id": "482ccc46-8a10-4ace-bfd6-63ac73b380af", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Query Audit", "subTarget": "QueryAudit", "style": "link" }, { "id": "db43bb45-1611-47ce-a2ad-517943f2aa1a", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "AutoStats", "subTarget": "Statistics", "style": "link" } ] }, "name": "links - 0" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "title": "Workload", "items": [ { "type": 10, "content": { "chartId": "workbook90867bfc-5c33-464f-ac31-2c2e006b97f4", "version": "MetricsItem/2.0", "size": 0, "chartType": 2, "resourceType": "microsoft.synapse/workspaces/sqlpools", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 172800000 }, "metrics": [ { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-DWUUsedPercent", "aggregation": 3, "splitBy": null, "columnName": "DWU Usaed %" }, { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-CPUPercent", "aggregation": 3, "columnName": "CPU Used %" } ], "title": "DWU Resource Utilization", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "name": "metric - 1" }, { "type": 10, "content": { "chartId": "workbookb954d4a0-82ef-4409-88fb-837aaff80c8d", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.synapse/workspaces/sqlpools", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 172800000 }, "metrics": [ { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-ActiveQueries", "aggregation": 1, "splitBy": null }, { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-QueuedQueries", "aggregation": 1 } ], "title": "Active and Queued Queries", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "name": "metric - 1" }, { "type": 10, "content": { "chartId": "workbookb954d4a0-82ef-4409-88fb-837aaff80c8d", "version": "MetricsItem/2.0", "size": 0, "chartType": 3, "resourceType": "microsoft.synapse/workspaces/sqlpools", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 172800000 }, "metrics": [ { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-LocalTempDBUsedPercent", "aggregation": 3, "splitBy": null, "columnName": "TempDB Utilization Percentage" } ], "title": "TempDB Utilization", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "name": "metric - 1 - Copy" }, { "type": 10, "content": { "chartId": "workbookb954d4a0-82ef-4409-88fb-837aaff80c8d", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.synapse/workspaces/sqlpools", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 172800000 }, "metrics": [ { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool Workload management-WLGAllocationBySystemPercent", "aggregation": 3, "splitBy": "WorkloadGroup", "columnName": "Workload Group Allocation by System %" } ], "title": "Workload Group Utilization", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "name": "Workload Group Utilization" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Long-Running Queries - Just Actual Queries\r\n//If 'Command' is empty - you need to set a bigger time window, the older record with the command is outside of your window\r\nSynapseSqlPoolExecRequests \r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where StatementType !in ('Batch','Execute')\r\n| summarize //Session_ID=any(SessionId),\r\n Request_ID=any(RequestId),\r\n //Submit_Time=max(SubmitTime),\r\n Start_Time=max(StartTime),\r\n End_Time=max(EndTime),\r\n Command=any(Command),\r\n Status=min(Status), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType),\r\n Resource_class=any(ResourceClass)\r\n by RequestId\r\n| summarize ElapsedTime_min=bin(anyif(((End_Time - Start_Time)/1m),Start_Time > ago(30d)),1),\r\n //Session_ID=any(Session_ID), \r\n // Submit_Time=any(Submit_Time) ,\r\n Start_Time=any(Start_Time), \r\n End_Time=any(End_Time),\r\n Command=any(Command),\r\n Status=any(Status),\r\n Statement_Type=any(Statement_Type)\r\n ,Resource_class=any(Resource_class) \r\n by Request_ID\r\n| where End_Time > ago(365d)\r\n| summarize count() by Status, bin(End_Time,5m)\r\n| render barchart \r\n", "size": 0, "title": "Query Completion Count by End Time - 5m buckets", "color": "redBright", "timeContext": { "durationMs": 172800000 }, "timeContextFromParameter": "TimeRange", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "chartSettings": { "seriesLabelSettings": [ { "seriesName": "Completed", "color": "green" }, { "seriesName": "Failed", "color": "red" }, { "seriesName": "Cancelled", "color": "yellow" } ] } }, "name": "query - 4" }, { "type": 1, "content": { "json": "Use the buttons below to filter the next chart for Success or Failed queries. In many cases a failed query may not have a 'Command' column populated depending on what stage the query failed in. ", "style": "info" }, "name": "text - 3" }, { "type": 11, "content": { "version": "LinkItem/1.0", "style": "nav", "links": [ { "id": "8e89112f-c67f-42c0-9622-02fa306fb7a5", "cellValue": "QueryCompletionType", "linkTarget": "parameter", "linkLabel": "All Queries", "subTarget": "''", "style": "primary" }, { "id": "6abe39c7-4d4e-4c45-aa54-dc9a4c5e876e", "cellValue": "QueryCompletionType", "linkTarget": "parameter", "linkLabel": "Success Only", "subTarget": "Completed", "preText": "", "style": "secondary" }, { "id": "e41b4a0b-8464-491e-92be-a57217d6dcac", "cellValue": "QueryCompletionType", "linkTarget": "parameter", "linkLabel": "Failures Only", "subTarget": "Failed", "preText": "", "style": "secondary" } ] }, "name": "links - 11" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Long-Running Queries - Just Actual Queries\r\n//If 'Command' is empty - you need to set a bigger time window, the older record with the command is outside of your window\r\nSynapseSqlPoolExecRequests \r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where StatementType !in ('Batch','Execute')\r\n| summarize //Session_ID=any(SessionId),\r\n Request_ID=any(RequestId),\r\n //Submit_Time=max(SubmitTime),\r\n Start_Time=max(StartTime),\r\n End_Time=max(EndTime),\r\n Command=any(Command),\r\n Status=min(Status), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType),\r\n Resource_class=any(ResourceClass)\r\n by RequestId\r\n| summarize ElapsedTime_min=bin(anyif(((End_Time - Start_Time)/1m),Start_Time > ago(30d)),1),\r\n //Session_ID=any(Session_ID), \r\n // Submit_Time=any(Submit_Time) ,\r\n Start_Time=any(Start_Time), \r\n End_Time=any(End_Time),\r\n Command=any(Command),\r\n Status=any(Status),\r\n Statement_Type=any(Statement_Type)\r\n ,Resource_class=any(Resource_class) \r\n by Request_ID\r\n| where Status has '{QueryCompletionType}'\r\n| order by Start_Time\r\n\r\n", "size": 0, "title": "Query Completions - use above buttons to filter", "color": "redBright", "timeContext": { "durationMs": 172800000 }, "timeContextFromParameter": "TimeRange", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "rowLimit": 100 }, "chartSettings": { "seriesLabelSettings": [ { "seriesName": "Completed", "color": "green" }, { "seriesName": "Failed", "color": "red" }, { "seriesName": "Cancelled", "color": "yellow" } ] } }, "name": "query - 4 - Copy" } ] }, "name": "Query Completions", "styleSettings": { "showBorder": true } }, { "type": 10, "content": { "chartId": "workbook1afc57e6-0b32-4968-b299-db319bd21635", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.synapse/workspaces/sqlpools", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 172800000 }, "metrics": [ { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-Connections", "aggregation": 1, "splitBy": null }, { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-ConnectionsBlockedByFirewall", "aggregation": 1 } ], "title": "Successful and Failed Connections", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "name": "metric - 5" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 3, "content": { "version": "KqlItem/1.0", "query": " AzureDiagnostics\r\n | where Category == 'SQLSecurityAuditEvents' and LogicalServerName_s == 'lasr-sqldwdb-eastus2-prd'\r\n | where action_name_s in ('DATABASE AUTHENTICATION SUCCEEDED','DATABASE AUTHENTICATION FAILED')\r\n | project SourceSystem,client_tls_version_d,succeeded_s,session_id_d,client_ip_s,session_server_principal_name_s,server_principal_name_s,database_principal_name_s,application_name_s,host_name_s,TimeGenerated\r\n | summarize count() by succeeded_s,bin(TimeGenerated,1m)\r\n | render barchart\r\n\r\n\r\n\r\n", "size": 0, "title": "Database Authentication success/failure rate", "timeContext": { "durationMs": 172800000 }, "timeContextFromParameter": "TimeRange", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "chartSettings": { "xAxis": "TimeGenerated", "group": "succeeded_s", "createOtherGroup": null } }, "name": "query - 8" }, { "type": 11, "content": { "version": "LinkItem/1.0", "style": "nav", "links": [ { "id": "2ed22e0a-2b53-4ed0-8f65-d2c621f34dad", "cellValue": "AuthResult", "linkTarget": "parameter", "linkLabel": "All Authentications", "subTarget": "''", "style": "primary" }, { "id": "2789ab13-ae8a-472e-bad4-9c9bdc934d4d", "cellValue": "AuthResult", "linkTarget": "parameter", "linkLabel": "Success Only", "subTarget": "true", "style": "secondary" }, { "id": "5cf4ddd4-e189-4b71-b456-0d4f1572a0a3", "cellValue": "AuthResult", "linkTarget": "parameter", "linkLabel": "Failures Only", "subTarget": "false", "style": "secondary" } ] }, "name": "links - 10" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": " AzureDiagnostics\r\n | where Category == 'SQLSecurityAuditEvents' and LogicalServerName_s == 'lasr-sqldwdb-eastus2-prd'\r\n | where action_name_s in ('DATABASE AUTHENTICATION SUCCEEDED','DATABASE AUTHENTICATION FAILED')\r\n | where succeeded_s has '{AuthResult}'\r\n | project SourceSystem,client_tls_version_d,succeeded_s,session_id_d,client_ip_s,session_server_principal_name_s,server_principal_name_s,database_principal_name_s,application_name_s,host_name_s,TimeGenerated\r\n | order by TimeGenerated\r\n\r\n\r\n\r\n\r\n", "size": 0, "title": "Database Authentication success/failure rate", "noDataMessage": "Please select a button above", "timeContext": { "durationMs": 172800000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "rowLimit": 100 }, "chartSettings": { "xAxis": "TimeGenerated", "group": "succeeded_s", "createOtherGroup": null, "showLegend": true } }, "name": "query - 8 - Copy" } ] }, "name": "Database Authentication Group", "styleSettings": { "showBorder": true } }, { "type": 10, "content": { "chartId": "workbook993837ad-66d6-4cbc-ae1a-7c3f6623236b", "version": "MetricsItem/2.0", "size": 0, "chartType": 2, "resourceType": "microsoft.synapse/workspaces/sqlpools", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 172800000 }, "metrics": [ { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-AdaptiveCacheUsedPercent", "aggregation": 3, "splitBy": null }, { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-AdaptiveCacheHitPercent", "aggregation": 3 } ], "title": "Adaptive Cache Used vs Hit Percentage", "gridSettings": { "rowLimit": 10000 } }, "name": "metric - 6" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "Workload" }, "name": "group - 1" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "title": "TempDB ", "items": [ { "type": 10, "content": { "chartId": "workbook4a9cf761-cce2-45b2-8947-8a9428ec7e1c", "version": "MetricsItem/2.0", "size": 0, "chartType": 3, "resourceType": "microsoft.synapse/workspaces/sqlpools", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 172800000 }, "metrics": [ { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-LocalTempDBUsedPercent", "aggregation": 3, "splitBy": null, "columnName": "TempDB Util" } ], "title": "TempDB Max and Avg Utilization", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "name": "metric - 0" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "19ee48f5-8f4e-4939-a0ef-c6bf656a93f9", "version": "KqlParameterItem/1.0", "name": "WeightParameter", "type": 1, "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 } }, { "id": "00553ec8-1a41-4dd9-a024-d607639c9bbb", "version": "KqlParameterItem/1.0", "name": "RequestID", "type": 1, "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 } } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 3" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databaseResourceName = '{DatabaseResourceName}';\r\n//Weighted query steps\r\nSynapseSqlPoolRequestSteps \r\n| where _ResourceId == databaseResourceName\r\n| where RowCount > 0\r\n| summarize sum(RowCount) by RequestId, OperationType\r\n| order by sum_RowCount desc\r\n| limit 20\r\n| render columnchart ", "size": 0, "title": "20 Largest Query Steps by Most Rows Moved", "timeContext": { "durationMs": 172800000 }, "timeContextFromParameter": "TimeRange", "exportFieldName": "Request_ID", "exportParameterName": "RequestID", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "chartSettings": { "xAxis": "RequestId", "group": "OperationType", "createOtherGroup": 20, "showLegend": true } }, "name": "query - 1 - Copy" }, { "type": 11, "content": { "version": "LinkItem/1.0", "style": "nav", "links": [ { "id": "c98d3722-9907-43ab-9306-1957d6f7f858", "cellValue": "WeightParameter", "linkTarget": "parameter", "linkLabel": "Weighted Rowcounts", "subTarget": "Weighted", "preText": "", "postText": "", "style": "secondary" }, { "id": "a06ae99a-ad62-45e9-8c25-c219b81f59c0", "cellValue": "WeightParameter", "linkTarget": "parameter", "linkLabel": "Unweighted Rowcounts", "subTarget": "Unweighted", "preText": "", "postText": "", "style": "secondary" } ] }, "name": "links - 3" }, { "type": 1, "content": { "json": "Current Setting: {WeightParameter}", "style": "info" }, "name": "text - 4" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//let databaseResourceName = '{DatabaseResourceName}';\r\n//Weighted query steps\r\nlet RequestSteps = SynapseSqlPoolRequestSteps\r\n//| where _ResourceId == databaseResourceName\r\n//| where RowCount > 10000000\r\n| extend Step_Elapsed_Min = round((EndTime - StartTime) /1m, 2)\r\n| extend Weighted_cnt = iff('{WeightParameter}'=='Weighted',(case(OperationType == 'BroadcastMoveOperation', (RowCount*10), RowCount)),RowCount)\r\n| project-rename StepStatus = Status, StepStart = StartTime, StepEnd = EndTime//, StepResource = Resource\r\n| top 100 by Weighted_cnt desc\r\n| order by Weighted_cnt desc\r\n| project Request_ID=RequestId,OperationType, RowCount,Weighted_cnt,Step_Elapsed_Min, StepStart, StepEnd, StepStatus, StepIndex;\r\nRequestSteps | join (\r\nSynapseSqlPoolExecRequests\r\n//| where _ResourceId == databaseResourceName\r\n| where StatementType !in ('Batch','Execute')\r\n| summarize //Session_ID=any(SessionId),\r\n Request_ID=any(RequestId),\r\n //Submit_Time=max(SubmitTime),\r\n Start_Time=max(StartTime),\r\n End_Time=max(EndTime),\r\n Command=any(Command),\r\n Status=min(Status), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType),\r\n Resource_class=any(ResourceClass)\r\n by RequestId\r\n| summarize //Session_ID=any(Session_ID), \r\n//Submit_Time=any(Submit_Time) ,\r\nStart_Time=any(Start_Time), End_Time=any(End_Time),Command=any(Command),Status=any(Status),Statement_Type=any(Statement_Type),Resource_class=any(Resource_class) by Request_ID\r\n//| order by Step_Elapsed_Min desc\r\n| extend Request_Elapsed_Min = round((End_Time - Start_Time)/1m, 2)\r\n| project-rename ReqStatus = Status, ReqStart = Start_Time, ReqEnd = End_Time\r\n) on Request_ID\r\n| project-reorder //Session_ID, \r\nRequest_ID, Request_Elapsed_Min, ReqStart, ReqEnd, ReqStatus,StepIndex, OperationType, RowCount,Weighted_cnt,Step_Elapsed_Min, StepStart, StepEnd, StepStatus, Statement_Type, Command, Resource_class\r\n| order by Weighted_cnt desc\r\n| limit 20", "size": 3, "title": "20 Largest Query Steps by Most Rows Moved", "timeContext": { "durationMs": 172800000 }, "timeContextFromParameter": "TimeRange", "exportFieldName": "Request_ID1", "exportParameterName": "RequestID", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "sortBy": [ { "itemKey": "Weighted_cnt", "sortOrder": 2 } ] }, "sortBy": [ { "itemKey": "Weighted_cnt", "sortOrder": 2 } ] }, "name": "query - 1" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databaseResourceName = '{DatabaseResourceName}';\r\n//Long-Running Queries - Just Actual Queries\r\n//If 'Command' is empty - you need to set a bigger time window, the older record with the command is outside of your window\r\nSynapseSqlPoolExecRequests\r\n| where _ResourceId == databaseResourceName\r\n| where StatementType !in ('Batch','Execute')\r\n| summarize //Session_ID=any(SessionId),\r\n Request_ID=any(RequestId),\r\n // Submit_Time=max(SubmitTime),\r\n Start_Time=max(StartTime),\r\n End_Time=max(EndTime),\r\n Command=any(Command),\r\n Status=min(Status), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType),\r\n Resource_class=any(ResourceClass)\r\n by RequestId\r\n| summarize ElapsedTime_min=bin(anyif(((End_Time - Start_Time)/1m),Start_Time > ago(30d)),1),\r\n //Session_ID=any(Session_ID), \r\n // Submit_Time=any(Submit_Time) ,\r\n Start_Time=any(Start_Time), \r\n End_Time=any(End_Time),\r\n Command=any(Command),\r\n Status=any(Status),\r\n Statement_Type=any(Statement_Type)\r\n ,Resource_class=any(Resource_class) \r\n by Request_ID\r\n| where Request_ID == '{RequestID}'\r\n\r\n", "size": 4, "title": "Selected Query", "noDataMessage": "Select a query above to view details", "timeContext": { "durationMs": 172800000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "35%" } } ] } }, "name": "query - 6" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolRequestSteps \r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where RequestId == '{RequestID}' //Put your QueryID here\r\n| where Status != 'Running'\r\n| summarize max(StartTime),max(EndTime),max(RequestId),max(OperationType),max(RowCount),max(Command),max(Status) by StepIndex\r\n| order by StepIndex asc", "size": 3, "title": "Query Plan", "noDataMessage": "Select a query above to view the plan", "timeContext": { "durationMs": 172800000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 7" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "TempDB" }, "name": "group - 3" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "title": "Query Investigation", "items": [ { "type": 1, "content": { "json": "## Search Criteria\r\nUse the following fields to search either using a query text snippet or using a Request ID. If using a query text snippet, try to keep it as simple as possible becuase minor changes in formatting may cause your queries not to show up in the results. It's best to pick something like a table name, then choose the proper query from the list that will populate. " }, "customWidth": "50", "name": "text - 4" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "0c2128d0-d979-4562-a28c-e7ceb955f126", "version": "KqlParameterItem/1.0", "name": "RequestIdSearch", "type": 1, "value": "" }, { "id": "29880874-2d41-4bd5-bf22-3e47ae8b1145", "version": "KqlParameterItem/1.0", "name": "QueryTextSnippet", "type": 1, "value": "", "timeContext": { "durationMs": 86400000 } } ], "style": "formVertical", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "customWidth": "60", "name": "parameters - 3" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolExecRequests\r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where StatementType !in ('Batch','Execute')\r\n| summarize \r\n Request_ID=max(RequestId), \r\n Start_Time=max(StartTime),\r\n End_Compile_Time=max(EndCompileTime), \r\n End_Time=max(EndTime), \r\n QueryText = any(Command), \r\n Last_Status=min(Status),\r\n Statement_Type=max(StatementType),\r\n Resource_class=max(ResourceClass) \r\n by RequestId\r\n| extend Elapsed_Time_s=(End_Time - Start_Time)/1s\r\n| where QueryText has '{QueryTextSnippet}'\r\nand RequestId has '{RequestIdSearch}'\r\n| summarize \r\n Executions = count(),\r\n SampleQID = any(RequestId),\r\n Elapsed_Time_s=max(Elapsed_Time_s)\r\n by QueryText\r\n| order by Elapsed_Time_s\r\n\r\n\r\n\r\n", "size": 0, "title": "Matching Queries", "timeContext": { "durationMs": 172800000 }, "timeContextFromParameter": "TimeRange", "exportedParameters": [ { "fieldName": "SampleQID", "parameterName": "SampleQID" }, { "fieldName": "SampleSessionID", "parameterName": "Samp", "parameterType": 1 } ], "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "50%" } } ], "sortBy": [ { "itemKey": "Elapsed_Time_s", "sortOrder": 2 } ] }, "sortBy": [ { "itemKey": "Elapsed_Time_s", "sortOrder": 2 } ] }, "name": "query - 0" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolExecRequests\r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where StatementType !in ('Batch','Execute')\r\n| where RequestId == '{SampleQID}'\r\n| summarize \r\n Request_ID=max(RequestId), \r\n Start_Time=max(StartTime),\r\n End_Compile_Time=max(EndCompileTime), \r\n End_Time=max(EndTime), \r\n Command=max(Command), \r\n Last_Status=min(Status),\r\n Statement_Type=max(StatementType),\r\n Resource_class=max(ResourceClass) \r\n by RequestId\r\n| extend elapsedTime_sec = iif(End_Time > ago(365d),(End_Time - Start_Time)/1s,real(null)) \r\n| join kind=inner\r\n (SynapseSqlPoolExecRequests\r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where StatementType !in ('Batch','Execute')\r\n | summarize \r\n Request_ID=max(RequestId), \r\n Start_Time=max(StartTime),\r\n End_Compile_Time=max(EndCompileTime), \r\n End_Time=max(EndTime), \r\n Command=max(Command), \r\n Last_Status=min(Status),\r\n Statement_Type=max(StatementType),\r\n Resource_class=max(ResourceClass) \r\n by RequestId\r\n //| extend elapsedTime_sec = (End_Time - Start_Time)/1s\r\n | extend elapsedTime_sec = iif(End_Time > ago(365d),(End_Time - Start_Time)/1s,real(null)) \r\n )\r\non Command \r\n| project Request_ID1,Start_Time1,End_Compile_Time1,End_Time1,Last_Status1,Statement_Type1,Resource_class1,elapsedTime_sec1\r\n", "size": 0, "title": "All Executions of Selected Query", "noDataMessage": "Select a query above to see individual executions", "timeContext": { "durationMs": 172800000 }, "timeContextFromParameter": "TimeRange", "exportFieldName": "Request_ID1", "exportParameterName": "RequestId", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "sortBy": [] }, "name": "query - 0 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolRequestSteps \r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where RequestId == '{RequestId}' //Put your QueryID here\r\n| where Status != 'Running'\r\n| summarize max(StartTime),max(EndTime),max(RequestId),max(OperationType),max(RowCount),max(Command),max(Status) by StepIndex\r\n| order by StepIndex asc", "size": 3, "title": "Query Plan for Selected Query", "noDataMessage": "Select a Query Above to See the Query Plan", "timeContext": { "durationMs": 172800000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 0 - Copy - Copy" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "parameters": [ { "id": "1191e58a-c1f9-4853-b36b-4be8eecbb48f", "version": "KqlParameterItem/1.0", "name": "Query_Submit_Time", "type": 1, "query": " AzureDiagnostics \r\n | where Category == 'ExecRequests'\r\n | where Resource == '{DatabaseName}'\r\n | where StatementType_s !in ('Batch','Execute')\r\n | where RequestId_s =='{RequestId}'\r\n | summarize \r\n Submit_Time=min(SubmitTime_t)\r\n by RequestId_s\r\n | project Submit_Time", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "value": null }, { "id": "f6bcb2a4-3356-4110-ba13-99c7d13a26f0", "version": "KqlParameterItem/1.0", "name": "Query_End_Compile_Time", "type": 1, "query": " AzureDiagnostics \r\n | where Category == 'ExecRequests'\r\n | where Resource == '{DatabaseName}'\r\n | where StatementType_s !in ('Batch','Execute')\r\n | where RequestId_s =='{RequestId}'\r\n | summarize \r\n End_Compile_Time=max(EndCompileTime_t) \r\n by RequestId_s\r\n | project End_Compile_Time", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "value": null } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 6" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": " AzureDiagnostics \r\n | where Category == 'ExecRequests'\r\n | where Resource == 'LASR-SQLDWDB-PRD'\r\n | where StatementType_s =='CreateStatistics'\r\n | summarize \r\n Session_ID=max(SessionId_s), \r\n Request_ID=max(RequestId_s), \r\n Submit_Time=min(SubmitTime_t), \r\n Start_Time=max(StartTime_t),\r\n End_Compile_Time=max(EndCompileTime_t), \r\n End_Time=max(EndTime_t), \r\n Command=max(Command_s), \r\n Last_Status=min(Status_s),\r\n Statement_Type=max(StatementType_s),\r\n Resource_class=max(ResourceClass_s) \r\n by RequestId_s\r\n | where Submit_Time > datetime('{Query_Submit_Time}') and End_Time < datetime('{Query_End_Compile_Time}')// or RequestId_s == '{RequestId}'\r\n", "size": 0, "title": "All possibly related auto-stats statements based on time", "noDataMessage": "no auto stats statements found that could be related", "timeContext": { "durationMs": 172800000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Submit_Time", "formatter": 0, "numberFormat": { "unit": 0, "options": { "style": "decimal" } } }, { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "100ch" } } ] } }, "name": "All possibly related auto-stats statements" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "QueryInvestigation" }, "name": "group - 4", "styleSettings": { "showBorder": true } }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "title": "Replicated Tables", "items": [ { "type": 1, "content": { "json": "All Charts on this page are based on the last 7 days of data", "style": "info" }, "name": "text - 5" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Build cache count by day\r\nlet databaseResourceName = '{DatabaseResourceName}';\r\n//Long-Running Queries - Just Actual Queries\r\n//If 'Command' is empty - you need to set a bigger time window, the older record with the command is outside of your window\r\nSynapseSqlPoolExecRequests\r\n| where _ResourceId == databaseResourceName\r\n| where StatementType == 'BuildReplicatedTableCache'\r\n| where Command != \"\"\r\n| where ResourceClass != \"\"\r\n| project Command,TimeGenerated,RequestId\r\n| summarize LastRebuild=max(TimeGenerated),RebuildCount=count(RequestId) by Command\r\n| order by RebuildCount desc\r\n| limit 15\r\n", "size": 3, "title": "Top 15 Most Rebuilds by Table", "timeContext": { "durationMs": 604800000 }, "exportFieldName": "Command", "exportParameterName": "QueryText", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command_s", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "40%" } } ] } }, "name": "query - 0" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Build cache count by day\r\nlet databaseResourceName = '{DatabaseResourceName}';\r\nSynapseSqlPoolExecRequests\r\n| where _ResourceId == databaseResourceName\r\n| where StatementType == 'BuildReplicatedTableCache'\r\n| where Command == \"{QueryText}\"\r\n| where ResourceClass != \"\"\r\n| project Command,TimeGenerated,RequestId\r\n| summarize count() by Command,bin(TimeGenerated,24h)\r\n| limit 20\r\n| render timechart", "size": 0, "title": "Rebuilds per Day for Selected Table", "noDataMessage": "Select a query above to see runs by day", "timeContext": { "durationMs": 604800000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "chartSettings": { "group": "Command_s", "createOtherGroup": 20, "ySettings": { "min": 0 } } }, "name": "query - 0 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Build cache count by day\r\nlet databaseResourceName = '{DatabaseResourceName}';\r\n//Long-Running Queries - Just Actual Queries\r\n//If 'Command' is empty - you need to set a bigger time window, the older record with the command is outside of your window\r\nSynapseSqlPoolExecRequests\r\n| where _ResourceId == databaseResourceName\r\n| where StatementType == 'BuildReplicatedTableCache'\r\n| where Command != \"\"\r\n| where ResourceClass != \"\"\r\n| project Command,TimeGenerated,RequestId\r\n| summarize count() by Command, bin(TimeGenerated,24h)\r\n//| where count_ > 7\r\n| order by count_ desc\r\n\r\n", "size": 2, "title": "Rebuild Count by Table by Day", "noDataMessage": " Only tables with more than 7 total rebuilds will show up. If no talbes with that many rebuilds are found this chart will be empty", "timeContext": { "durationMs": 604800000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "categoricalbar", "gridSettings": { "sortBy": [ { "itemKey": "count_", "sortOrder": 1 } ] }, "sortBy": [ { "itemKey": "count_", "sortOrder": 1 } ], "tileSettings": { "showBorder": false, "titleContent": { "columnMatch": "Command_s", "formatter": 1 }, "leftContent": { "columnMatch": "count_", "formatter": 12, "formatOptions": { "palette": "auto" }, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "graphSettings": { "type": 0, "topContent": { "columnMatch": "Command_s", "formatter": 1 }, "centerContent": { "columnMatch": "count_", "formatter": 1, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "chartSettings": { "group": "Command_s", "createOtherGroup": 99, "showDataPoints": true } }, "name": "query - 0 - Copy - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databaseResourceName = '{DatabaseResourceName}';\r\n//Long-Running Queries - Just Actual Queries\r\n//If 'Command' is empty - you need to set a bigger time window, the older record with the command is outside of your window\r\nSynapseSqlPoolExecRequests\r\n| where _ResourceId == databaseResourceName\r\n| where StatementType == 'BuildReplicatedTableCache'\r\n| summarize Start_Time=max(StartTime), End_Time=max(EndTime), Command=max(Command), Statement_Type=max(StatementType), Resource_class=max(ResourceClass) by RequestId\r\n| join kind= inner\r\n(\r\n SynapseSqlPoolExecRequests\r\n | where _ResourceId == databaseResourceName\r\n | where StatementType == 'BuildReplicatedTableCache'\r\n | where StatementType == 'BuildReplicatedTableCache'\r\n | where EndTime > ago(7d)\r\n | where StartTime > ago(7d)\r\n | extend elapsedTime_min = (EndTime - StartTime)/1m\r\n | order by elapsedTime_min desc\r\n | project RequestId,elapsedTime_min \r\n)\r\non RequestId\r\n| order by elapsedTime_min desc\r\n| project RequestId,Start_Time,End_Time,Elapsed_Time=round(elapsedTime_min,1) ,Command\r\n| limit 15\r\n", "size": 3, "title": "Top 15 Elapsed Time per Rebuild", "timeContext": { "durationMs": 604800000 }, "exportFieldName": "RequestId", "exportParameterName": "RequestId", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "40%" } } ] } }, "name": "query - 3" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": " let databaseResourceName = '{DatabaseResourceName}';\r\nSynapseSqlPoolRequestSteps \r\n| where _ResourceId == databaseResourceName\r\n| where RequestId == '{RequestId}'\r\n| where Status != 'Running'\r\n| summarize max(StartTime),max(EndTime),max(RequestId),max(OperationType),max(RowCount),max(Command),max(Status) by StepIndex\r\n| order by StepIndex asc", "size": 3, "title": "Query Plan for Selected Query", "noDataMessage": "Select a query above to view plan", "timeContext": { "durationMs": 604800000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 4" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "ReplicatedTables" }, "name": "ReplicatedTablesGroup" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "title": "Workload Management", "items": [ { "type": 10, "content": { "chartId": "workbook72446028-6edb-4cb0-8952-e0c13bda488f", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.synapse/workspaces/sqlpools", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 172800000 }, "metrics": [ { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool Workload management-WLGAllocationBySystemPercent", "aggregation": 3, "splitBy": "WorkloadGroup" } ], "title": "Workload Group Allocation By System Percent", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "name": "metric - 0" }, { "type": 10, "content": { "chartId": "workbookc898119a-7381-469d-b51a-d505b4f80e73", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.synapse/workspaces/sqlpools", "metricScope": 0, "resourceIds": [ "/subscriptions/9cd45dfd-d1ac-4c16-9363-150d2afcb462/resourceGroups/SynapseWorkspaceRG1_nicksalc/providers/Microsoft.Synapse/workspaces/synapseworkspace1nicksalc/sqlPools/GetStartedSQL" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 172800000 }, "metrics": [ { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-WLGActiveQueries", "aggregation": 1, "splitBy": "WorkloadGroup" } ], "title": "Query Count by Workload Group", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "name": "metric - 1" }, { "type": 10, "content": { "chartId": "workbook8d175f6c-427b-47fc-85ea-37edd0be707c", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.synapse/workspaces/sqlpools", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 172800000 }, "metrics": [ { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-WLGQueuedQueries", "aggregation": 1, "splitBy": "WorkloadGroup" } ], "title": "Queued Queries by Workload Group", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "name": "Queued Queries by Workload Group" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "parameters": [ { "id": "6f50577d-7b00-4e4a-acf9-d45c7a5ee813", "version": "KqlParameterItem/1.0", "name": "WorkloadGroupName", "type": 2, "query": "SynapseSqlPoolExecRequests \r\n| where _ResourceId == '{DatabaseResourceName}'\r\n and ResourceClass != \"\"\r\n| distinct ResourceClass", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "value": null, "typeSettings": { "additionalResourceOptions": [], "showDefault": false }, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 2" }, { "type": 10, "content": { "chartId": "workbook3da1d18a-1bf5-46c5-b3b7-211f71d329cc", "version": "MetricsItem/2.0", "size": 0, "chartType": 2, "resourceType": "microsoft.synapse/workspaces/sqlpools", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 172800000 }, "metrics": [ { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-WLGActiveQueries", "aggregation": 1, "splitBy": null }, { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-WLGQueuedQueries", "aggregation": 1 }, { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-WLGAllocationBySystemPercent", "aggregation": 3 }, { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-WLGEffectiveCapResourcePercent", "aggregation": 3 } ], "filters": [ { "id": "5", "key": "WorkloadGroup", "operator": 0, "valueParam": "WorkloadGroupName" } ], "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "name": "metric - 3" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "WorkloadManagement" }, "name": "group - 6" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "title": "Query Audit", "items": [ { "type": 1, "content": { "json": "## Select a Principal or Application name to filter results - leave to 'unset' to view all results\r\nSQL Auditing must be enabled and sending to the same Log Analytics Workspace for this page to work. " }, "name": "text - 5" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "parameters": [ { "id": "8d25c043-d1ff-4546-a1fa-f4bcbfdab8af", "version": "KqlParameterItem/1.0", "name": "User", "type": 2, "description": "User to filter subsequent queries - leave to 'unset' for all users", "query": "SQLSecurityAuditEvents \r\n| where LogicalServerName == '{LogicalServerName}'\r\n| summarize by ServerPrincipalName", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "value": null, "typeSettings": { "additionalResourceOptions": [], "showDefault": false }, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "id": "aa766d64-693f-4024-b4a4-b5b56b28376b", "version": "KqlParameterItem/1.0", "name": "Application", "type": 2, "query": "SQLSecurityAuditEvents \r\n| where LogicalServerName == '{LogicalServerName}'\r\n| summarize by ApplicationName", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "value": null, "typeSettings": { "additionalResourceOptions": [], "showDefault": false }, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "customWidth": "30", "name": "parameters - 1" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SQLSecurityAuditEvents \r\n| where LogicalServerName == '{LogicalServerName}'\r\n| where DurationMs > 0\r\n| extend duration_seconds = DurationMs /1000.0\r\n| where Statement != 'select @@version'\r\n| where Statement != 'SELECT @@SPID;'\r\n| where ServerPrincipalName has '{User}'\r\n| where ApplicationName has '{Application}'\r\n| project ServerPrincipalName, EventTime, LogicalServerName, DurationMs, duration_seconds, AffectedRows, Statement, ApplicationName\r\n| summarize duration_seconds = round(sum(duration_seconds)) , query_count = count() by EventDay = bin(EventTime,1d), UserName = ServerPrincipalName, Application = ApplicationName \r\n| order by EventDay, duration_seconds desc", "size": 0, "title": "Query Summary for Selected User {User} {Application}", "noDataMessage": "Select a user to see query activity", "timeContext": { "durationMs": 172800000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 0 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SQLSecurityAuditEvents \r\n| where LogicalServerName == '{LogicalServerName}'\r\n| where DurationMs > 0\r\n| extend duration_seconds = DurationMs /1000.0\r\n| where Statement != 'select @@version'\r\n| where Statement != 'SELECT @@SPID;'\r\n| where ServerPrincipalName has '{User}'\r\n| where ApplicationName has '{Application}'\r\n| project ServerPrincipalName, EventTime, LogicalServerName, DurationMs, duration_seconds, AffectedRows, Statement, ApplicationName\r\n| summarize duration_seconds = round(sum(duration_seconds)) , query_count = count() by EventDay = bin(EventTime,1d), UserName = ServerPrincipalName, Application = ApplicationName \r\n| order by EventDay, duration_seconds desc", "size": 0, "title": "Query Summary for Selected User {User} {Application}", "noDataMessage": "Select a user to see query activity", "timeContext": { "durationMs": 172800000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "unstackedbar", "tileSettings": { "showBorder": false, "titleContent": { "columnMatch": "UserName", "formatter": 1 }, "leftContent": { "columnMatch": "duration_seconds", "formatter": 12, "formatOptions": { "palette": "auto" }, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "graphSettings": { "type": 0, "topContent": { "columnMatch": "UserName", "formatter": 1 }, "centerContent": { "columnMatch": "duration_seconds", "formatter": 1, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "chartSettings": { "xAxis": "UserName" }, "mapSettings": { "locInfo": "LatLong", "sizeSettings": "duration_seconds", "sizeAggregation": "Sum", "legendMetric": "duration_seconds", "legendAggregation": "Sum", "itemColorSettings": { "type": "heatmap", "colorAggregation": "Sum", "nodeColorField": "duration_seconds", "heatmapPalette": "greenRed" } } }, "name": "query - 0 - Copy - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SQLSecurityAuditEvents \r\n | where LogicalServerName == \"{LogicalServerName}\"\r\n | where DurationMs > 0\r\n | extend duration_seconds = DurationMs /1000.0\r\n | where Statement != 'select @@version'\r\n | where Statement != 'SELECT @@SPID;'\r\n | where ServerPrincipalName has '{User}'\r\n | where ApplicationName has '{Application}'\r\n | project DatabaseName= DatabaseName, UserName= ServerPrincipalName, EventTime= EventTime, Host= HostName, duration_seconds = round(duration_seconds), Statement, QuerySource = ApplicationName , AffectedRows\r\n | project-reorder DatabaseName, UserName, Host, EventTime, duration_seconds, Statement, QuerySource\r\n\r\n\r\n\r\n\r\n\r\n", "size": 0, "title": "Queries {User} {Application}", "noDataMessage": "Select a user to see query activity", "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 0 - Copy - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SQLSecurityAuditEvents \r\n | where LogicalServerName == \"{LogicalServerName}\"\r\n | where DurationMs > 0\r\n | extend duration_seconds = DurationMs /1000.0\r\n | where Statement != 'select @@version'\r\n | where Statement != 'SELECT @@SPID;'\r\n | where ServerPrincipalName has '{User}'\r\n | where ApplicationName has '{Application}'\r\n | project DatabaseName= DatabaseName, UserName= ServerPrincipalName, EventTime= EventTime, Host= HostName, duration_seconds = round(duration_seconds), Statement, QuerySource = ApplicationName , AffectedRows\r\n | project-reorder AffectedRows,DatabaseName, UserName, Host, EventTime, duration_seconds, Statement, QuerySource\r\n\r\n\r\n\r\n\r\n\r\n", "size": 0, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "barchart", "chartSettings": { "xAxis": "Host", "group": "UserName", "createOtherGroup": null, "showLegend": true } }, "name": "query - 6" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SQLSecurityAuditEvents\r\n| where LogicalServerName == \"{LogicalServerName}\"\r\n | where DurationMs > 0\r\n| extend Duration = round(DurationMs /1000.0)\r\n| extend TimeBin = case (datetime_part(\"Hour\",TimeGenerated) in (6,7,8,9,10,11,12), \"Morning_6-12\", datetime_part(\"Hour\",TimeGenerated) in (13,14,15,16,17,18), \"Afternoon_12-18\", \"Overnight_18-6\")\r\n| where ServerPrincipalName has '{User}'\r\n| where ApplicationName has '{Application}'\r\n| summarize QueryDuration = sum(Duration) by EventTime = bin(EventTime, 1d), TimeBin", "size": 0, "title": "Query Activity by time - sum(Duration) {User} {Application}", "noDataMessage": "Select a user to see query activity", "timeContext": { "durationMs": 172800000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "barchart" }, "name": "query - 0 - Copy" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "QueryAudit" }, "name": "QueryAuditGroup", "styleSettings": { "showBorder": true } }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "title": "Query Comparison", "items": [ { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "7fa3187e-9225-4faa-8f80-dc1bc40c5aab", "version": "KqlParameterItem/1.0", "name": "RequestId1", "type": 1, "value": "QID57684" } ], "style": "above", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "customWidth": "50", "name": "parameters - 3 - Copy" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "315fc476-469a-4d8d-b421-028d1113ab06", "version": "KqlParameterItem/1.0", "name": "RequestId2", "type": 1, "value": "QID57621", "timeContext": { "durationMs": 86400000 } } ], "style": "above", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "customWidth": "50", "name": "parameters - 2" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolExecRequests\r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where StatementType !in ('Batch','Execute') and RequestId == '{RequestId1}'\r\n| summarize \r\n Request_ID=any(RequestId),\r\n Start_Time=max(StartTime),\r\n End_Time=max(EndTime),\r\n Command=any(Command),\r\n Status=min(Status), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType),\r\n Resource_class=any(ResourceClass)\r\n by RequestId\r\n| summarize Start_Time=any(Start_Time), End_Time=any(End_Time),ElapsedTime_min=anyif((End_Time - Start_Time)/1m,Start_Time > ago(30d)),Command=any(Command),Status=any(Status),Statement_Type=any(Statement_Type),Resource_class=any(Resource_class) by Request_ID\r\n| project Request_ID,ElapsedTime_min,Command,Resource_class,Start_Time,End_Time,Statement_Type,Status\r\n", "size": 4, "timeContext": { "durationMs": 172800000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "customWidth": "50", "name": "query - 2" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolExecRequests\r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where StatementType !in ('Batch','Execute') and RequestId == '{RequestId2}'\r\n| summarize \r\n Request_ID=any(RequestId),\r\n Start_Time=max(StartTime),\r\n End_Time=max(EndTime),\r\n Command=any(Command),\r\n Status=min(Status), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType),\r\n Resource_class=any(ResourceClass)\r\n by RequestId\r\n| summarize Start_Time=any(Start_Time), End_Time=any(End_Time),ElapsedTime_min=anyif((End_Time - Start_Time)/1m,Start_Time > ago(30d)),Command=any(Command),Status=any(Status),Statement_Type=any(Statement_Type),Resource_class=any(Resource_class) by Request_ID\r\n| project Request_ID,ElapsedTime_min,Command,Resource_class,Start_Time,End_Time,Statement_Type,Status\r\n", "size": 4, "timeContext": { "durationMs": 172800000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "customWidth": "50", "name": "query - 2 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolRequestSteps \r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where RequestId == '{RequestId1}'\r\n| summarize StartTime=max(StartTime)\r\n ,EndTime=max(EndTime)\r\n ,RequestID=max(RequestId)\r\n ,Operation=max(OperationType)\r\n ,RowCount=max(RowCount)\r\n ,Command=max(Command)\r\n ,Status=max(Status)\r\n by StepIndex\r\n| order by StepIndex asc\r\n| project StartTime,EndTime,RequestID,Operation,RowCount,Command,Status,StepIndex", "size": 3, "timeContext": { "durationMs": 172800000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "customWidth": "50", "name": "query - 4", "styleSettings": { "margin": "0", "padding": "10px" } }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolRequestSteps \r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where RequestId == '{RequestId2}'\r\n| summarize StartTime=max(StartTime)\r\n ,EndTime=max(EndTime)\r\n ,RequestID=max(RequestId)\r\n ,Operation=max(OperationType)\r\n ,RowCount=max(RowCount)\r\n ,Command=max(Command)\r\n ,Status=max(Status)\r\n by StepIndex\r\n| order by StepIndex asc\r\n| project StartTime,EndTime,RequestID,Operation,RowCount,Command,Status,StepIndex", "size": 3, "timeContext": { "durationMs": 172800000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "customWidth": "50", "name": "query - 4 - Copy", "styleSettings": { "padding": "10px" } }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "parameters": [ { "id": "03d1c3ba-0d28-4584-bb63-388f8477034a", "version": "KqlParameterItem/1.0", "name": "Query_Submit_Time1", "type": 1, "query": " AzureDiagnostics \r\n | where Category == 'ExecRequests'\r\n | where Resource == '{DatabaseName}'\r\n | where StatementType_s !in ('Batch','Execute')\r\n | where RequestId_s =='{RequestId1}'\r\n | summarize \r\n Submit_Time=min(SubmitTime_t)\r\n by RequestId_s\r\n | project Submit_Time", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "value": null }, { "id": "af36efd7-c5a0-429e-8908-a24e22ee6087", "version": "KqlParameterItem/1.0", "name": "Query_End_Compile_Time1", "type": 1, "query": " AzureDiagnostics \r\n | where Category == 'ExecRequests'\r\n | where Resource == '{DatabaseName}'\r\n | where StatementType_s !in ('Batch','Execute')\r\n | where RequestId_s =='{RequestId1}'\r\n | summarize \r\n End_Compile_Time=max(EndCompileTime_t) \r\n by RequestId_s\r\n | project End_Compile_Time", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "value": null }, { "version": "KqlParameterItem/1.0", "name": "Query_Submit_Time2", "type": 1, "query": " AzureDiagnostics \r\n | where Category == 'ExecRequests'\r\n | where Resource == '{DatabaseName}'\r\n | where StatementType_s !in ('Batch','Execute')\r\n | where RequestId_s =='{RequestId2}'\r\n | summarize \r\n Submit_Time=min(SubmitTime_t)\r\n by RequestId_s\r\n | project Submit_Time", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "id": "1931da01-18dc-449d-950a-b9483057c12d", "value": null }, { "version": "KqlParameterItem/1.0", "name": "Query_End_Compile_Time2", "type": 1, "query": " AzureDiagnostics \r\n | where Category == 'ExecRequests'\r\n | where Resource == '{DatabaseName}'\r\n | where StatementType_s !in ('Batch','Execute')\r\n | where RequestId_s =='{RequestId2}'\r\n | summarize \r\n End_Compile_Time=max(EndCompileTime_t) \r\n by RequestId_s\r\n | project End_Compile_Time", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "id": "6f447a8d-e815-4d00-87ff-7bb26b315132", "value": null } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 6 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": " AzureDiagnostics \r\n | where Category == 'ExecRequests'\r\n | where Resource == '{DatabaseName}'\r\n | where StatementType_s =='CreateStatistics'\r\n | summarize \r\n Session_ID=max(SessionId_s), \r\n //Request_ID=max(RequestId_s), \r\n Submit_Time=min(SubmitTime_t), \r\n //Start_Time=max(StartTime_t),\r\n //End_Compile_Time=max(EndCompileTime_t), \r\n End_Time=max(EndTime_t), \r\n Command=max(Command_s), \r\n Last_Status=min(Status_s),\r\n Statement_Type=max(StatementType_s),\r\n Resource_class=max(ResourceClass_s) \r\n by RequestId_s\r\n | where Submit_Time > datetime('{Query_Submit_Time1}') and End_Time < datetime('{Query_End_Compile_Time1}') and End_Time > ago(30d)\r\n| project Command, Status=Last_Status ,Submit_Time,End_Time,Session_ID,Request_ID=RequestId_s,Statement_Type\r\n", "size": 0, "title": "All possibly related auto-stats statements based on time", "noDataMessage": "no auto stats statements found that could be related", "timeContext": { "durationMs": 172800000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Submit_Time", "formatter": 0, "numberFormat": { "unit": 0, "options": { "style": "decimal" } } }, { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "100ch" } } ], "sortBy": [ { "itemKey": "End_Time", "sortOrder": 2 } ] }, "sortBy": [ { "itemKey": "End_Time", "sortOrder": 2 } ] }, "customWidth": "50", "name": "All possibly related auto-stats statements - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": " AzureDiagnostics \r\n | where Category == 'ExecRequests'\r\n | where Resource == '{DatabaseName}'\r\n | where StatementType_s =='CreateStatistics'\r\n | summarize \r\n Session_ID=max(SessionId_s), \r\n //Request_ID=max(RequestId_s), \r\n Submit_Time=min(SubmitTime_t), \r\n //Start_Time=max(StartTime_t),\r\n //End_Compile_Time=max(EndCompileTime_t), \r\n End_Time=max(EndTime_t), \r\n Command=max(Command_s), \r\n Last_Status=min(Status_s),\r\n Statement_Type=max(StatementType_s),\r\n Resource_class=max(ResourceClass_s) \r\n by RequestId_s\r\n | where Submit_Time > datetime('{Query_Submit_Time2}') and End_Time < datetime('{Query_End_Compile_Time2}') and End_Time > ago(30d)\r\n| project Command, Status=Last_Status ,Submit_Time,End_Time,Session_ID,Request_ID=RequestId_s,Statement_Type\r\n", "size": 0, "title": "All possibly related auto-stats statements based on time", "noDataMessage": "no auto stats statements found that could be related", "timeContext": { "durationMs": 172800000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Submit_Time", "formatter": 0, "numberFormat": { "unit": 0, "options": { "style": "decimal" } } }, { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "100ch" } } ] } }, "customWidth": "50", "name": "All possibly related auto-stats statements - Copy - Copy" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "QueryComparison" }, "name": "QueryComparison" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "title": "Session Investigation", "items": [ { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "feb2ac70-2555-456e-bfa6-6ad4a2dcad0f", "version": "KqlParameterItem/1.0", "name": "SessionID", "type": 1, "value": "", "timeContext": { "durationMs": 86400000 } } ], "style": "above", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 0" }, { "type": 1, "content": { "json": "The matching of the user information in the next chart is approximate. This information is a work in progress", "style": "warning" }, "name": "text - 4" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databasename='{DatabaseName}';\r\nAzureDiagnostics \r\n| where Category == 'ExecRequests'\r\n| where Resource == databasename\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize Query_End_Time = max(EndTime_t ) by SessionId_s\r\n| where SessionId_s == '{SessionID}'\r\n| join kind = rightouter \r\n( \r\n AzureDiagnostics\r\n | where Category == 'SQLSecurityAuditEvents' \r\n | where duration_milliseconds_d > 0\r\n | extend duration_seconds = duration_milliseconds_d /1000.0\r\n | where statement_s != 'select @@version' and statement_s != 'SELECT @@SPID;' and server_principal_name_s != '##MS_InstanceCertificate##'\r\n) on $left.Query_End_Time==$right.event_time_t \r\n| summarize DatabaseName= max(database_name_s)\r\n , UserName= any(server_principal_name_s)\r\n , Host= max(host_name_s)\r\n , Application=max(application_name_s)\r\n by SessionId_s\r\n\r\n\r\n\r\n", "size": 4, "timeContext": { "durationMs": 172800000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "table", "tileSettings": { "titleContent": { "columnMatch": "UserName" }, "subtitleContent": { "columnMatch": "SessionId_s" }, "leftContent": { "columnMatch": "Application" }, "rightContent": { "columnMatch": "Host" }, "secondaryContent": { "columnMatch": "DatabaseName" }, "showBorder": false, "size": "full" }, "graphSettings": { "type": 0 } }, "name": "query - 3" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics \r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize \r\n Session_ID=max(SessionId_s), \r\n Submit_Time=max(SubmitTime_t), \r\n Start_Time=max(StartTime_t),\r\n End_Compile_Time=max(EndCompileTime_t), \r\n End_Time=max(EndTime_t), \r\n Command=max(Command_s), \r\n Last_Status=min(Status_s),\r\n Statement_Type=max(StatementType_s),\r\n Resource_class=max(ResourceClass_s) \r\n by RequestId_s\r\n| where Session_ID has '{SessionID}'\r\n| extend elapsedTime_sec = iif(End_Time > ago(365d),(End_Time - Submit_Time)/1s,real(null)) \r\n| order by Submit_Time asc\r\n\r\n\r\n\r\n\r\n", "size": 0, "timeContext": { "durationMs": 172800000 }, "timeContextFromParameter": "TimeRange", "exportFieldName": "RequestId_s", "exportParameterName": "RequestID", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 1" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics\r\n| where Category == 'RequestSteps'\r\n| where Resource == '{DatabaseName}'\r\n| where RequestId_s == '{RequestID}'\r\n//| where Status_s != 'Running'\r\n| summarize Start_Time=max(StartTime_t),End_Time=max(EndTime_t),Request_ID=max(RequestId_s),Operation_Type=max(OperationType_s),Row_Count=max(RowCount_d),Statement=max(Command_s),Status=min(Status_s) by StepIndex_d\r\n| order by StepIndex_d asc", "size": 3, "timeContext": { "durationMs": 172800000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 2" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "SessionInvestigation" }, "name": "group - 9" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 1, "content": { "json": "## This tab is used to determine what statements triggerred autostats creation jobs. \r\nThe flow of autostats creation is as follows\r\n1. Query Submit Time\r\n2. \tCreate Statistics submit Time\r\n3. \tCreate Statistics end Time\r\n4. Query end_compile_time\r\n5. Query Start_Time\r\n6. Query End_Time\r\n\r\nFurther, if multiple stats are created, then the creation of all stats for this query will fall between query submit_time and end_compile_time. \r\n\r\nThe charts on this page allow you to search for an autostats job by requestID or my snippet of the autostats statement text, which can just be the schema, table, or column name. Then it will show you all commands that include that request ID or text. It will then show you all statements in the create stat statement because the query we are trying to identify will wait for all of those stats creations to complete before proceeding. \r\n\r\nThe last chart will list out all statements that could possibly have triggerred the stats creation job based on their submite/end_compile_time. " }, "name": "text - 6" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "0911bd4b-d471-480b-bdf4-1a2d4ba1ea6e", "version": "KqlParameterItem/1.0", "name": "RequestIdSearch", "type": 1, "value": "", "label": "RequestId for AutoStats Job" }, { "id": "c12e6495-4fd1-473c-8ffc-0bf502f54706", "version": "KqlParameterItem/1.0", "name": "QueryTextSnippet", "type": 1, "value": "", "timeContext": { "durationMs": 86400000 }, "label": "Snippet of autostats creation statement (Schema, table or column)" } ], "style": "formVertical", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "customWidth": "60", "name": "parameters - 3 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics \r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize \r\n Session_ID=max(SessionId_s), \r\n Request_ID=max(RequestId_s), \r\n Submit_Time=max(SubmitTime_t), \r\n Start_Time=max(StartTime_t),\r\n End_Compile_Time=max(EndCompileTime_t), \r\n End_Time=max(EndTime_t), \r\n Command=max(Command_s), \r\n Last_Status=min(Status_s),\r\n Statement_Type=max(StatementType_s),\r\n Resource_class=max(ResourceClass_s) \r\n by RequestId_s\r\n| where Command has 'CREATE STATISTICS _wa_sys'\r\n| where Command has '{QueryTextSnippet}'\r\nand RequestId_s has '{RequestIdSearch}'\r\n| extend elapsedTime_sec = iif(End_Time > ago(365d),(End_Time - Submit_Time)/1s,real(null)) \r\n| extend CompileTime_sec = (End_Compile_Time - Submit_Time)/1s\r\n| order by elapsedTime_sec\r\n| summarize \r\n Executions = count(),\r\n Max_Elapsed_Time_sec = bin(max(elapsedTime_sec),1),\r\n Min_Elapsed_Time_sec = bin(min(elapsedTime_sec),1),\r\n Variability_sec=bin((max(elapsedTime_sec)-min(elapsedTime_sec)),1),\r\n SampleQID = any(RequestId_s),\r\n SampleSessionID = any(Session_ID)\r\n by Command\r\n| order by Max_Elapsed_Time_sec\r\n\r\n\r\n", "size": 0, "title": "Matching Queries", "timeContext": { "durationMs": 14400000 }, "timeContextFromParameter": "TimeRange", "exportedParameters": [ { "fieldName": "SampleQID", "parameterName": "SampleQID" }, { "fieldName": "SampleSessionID", "parameterName": "Samp", "parameterType": 1 } ], "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "50%" } } ], "sortBy": [ { "itemKey": "Command", "sortOrder": 1 } ] }, "sortBy": [ { "itemKey": "Command", "sortOrder": 1 } ] }, "name": "query - 0 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics \r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s !in ('Batch','Execute')\r\n| where RequestId_s == '{SampleQID}'\r\n| summarize \r\n Session_ID=max(SessionId_s), \r\n Request_ID=max(RequestId_s), \r\n Submit_Time=min(SubmitTime_t), \r\n Start_Time=max(StartTime_t),\r\n End_Compile_Time=max(EndCompileTime_t), \r\n End_Time=max(EndTime_t), \r\n Command=max(Command_s), \r\n Last_Status=min(Status_s),\r\n Statement_Type=max(StatementType_s),\r\n Resource_class=max(ResourceClass_s) \r\n by RequestId_s\r\n| extend elapsedTime_sec = iif(End_Time > ago(365d),(End_Time - Submit_Time)/1s,real(null)) \r\n| extend CompileTime_sec = (End_Compile_Time - Submit_Time)/1s\r\n| join kind=inner\r\n (AzureDiagnostics \r\n | where Category == 'ExecRequests'\r\n | where Resource == '{DatabaseName}'\r\n | where StatementType_s !in ('Batch','Execute')\r\n | summarize \r\n Session_ID=max(SessionId_s), \r\n Request_ID=max(RequestId_s), \r\n Submit_Time=min(SubmitTime_t), \r\n Start_Time=max(StartTime_t),\r\n End_Compile_Time=max(EndCompileTime_t), \r\n End_Time=max(EndTime_t), \r\n Command=max(Command_s), \r\n Last_Status=min(Status_s),\r\n Statement_Type=max(StatementType_s),\r\n Resource_class=max(ResourceClass_s) \r\n by RequestId_s\r\n | extend elapsedTime_sec = (End_Time - Submit_Time)/1s\r\n | extend elapsedTime_sec = iif(End_Time > ago(365d),(End_Time - Submit_Time)/1s,real(null)) \r\n | extend CompileTime_sec = (End_Compile_Time - Submit_Time)/1s\r\n )\r\non Command \r\n| project Request_ID1,Session_ID1,Submit_Time1,Start_Time1,End_Compile_Time1,End_Time1,Last_Status1,Statement_Type1,elapsedTime_sec1,CompileTime_sec1\r\n", "size": 0, "title": "All Executions of Selected Query", "noDataMessage": "Select a query above to see individual executions", "timeContext": { "durationMs": 14400000 }, "timeContextFromParameter": "TimeRange", "exportedParameters": [ { "fieldName": "Request_ID1", "parameterName": "RequestId" }, { "fieldName": "End_Time1", "parameterName": "StatEndTime", "parameterType": 1 }, { "fieldName": "Submit_Time1", "parameterName": "StatSubmitTime", "parameterType": 1 }, { "fieldName": "Session_ID1", "parameterName": "SessionId", "parameterType": 1 } ], "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "sortBy": [ { "itemKey": "End_Time1", "sortOrder": 1 } ] }, "sortBy": [ { "itemKey": "End_Time1", "sortOrder": 1 } ] }, "name": "query - 0 - Copy - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": " AzureDiagnostics \r\n | where Category == 'ExecRequests'\r\n | where Resource == '{DatabaseName}'\r\n | where StatementType_s !in ('Batch','Execute')\r\n | where SessionId_s == '{SessionId}'\r\n | summarize \r\n Session_ID=max(SessionId_s), \r\n Request_ID=max(RequestId_s), \r\n Submit_Time=min(SubmitTime_t), \r\n Start_Time=max(StartTime_t),\r\n End_Compile_Time=max(EndCompileTime_t), \r\n End_Time=max(EndTime_t), \r\n Command=max(Command_s), \r\n Last_Status=min(Status_s),\r\n Statement_Type=max(StatementType_s),\r\n Resource_class=max(ResourceClass_s) \r\n by RequestId_s\r\n| project Session_ID,Request_ID,Submit_Time,End_Compile_Time,Start_Time,End_Time,Last_Status,Statement_Type,Command\r\n\r\n\r\n", "size": 0, "title": "All Statements in Stats Statement Session", "noDataMessage": "Select a query above to see individual executions", "timeContext": { "durationMs": 14400000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "150ch" } } ], "sortBy": [ { "itemKey": "Command", "sortOrder": 1 } ] }, "sortBy": [ { "itemKey": "Command", "sortOrder": 1 } ] }, "name": "query - 0 - Copy - Copy - Copy - Copy" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "parameters": [ { "id": "4e005821-785a-4246-aae8-de00987cba18", "version": "KqlParameterItem/1.0", "name": "Session_Submit_Time", "type": 1, "query": "AzureDiagnostics \r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s !in ('Batch','Execute')\r\n| where SessionId_s == '{SessionId}'\r\n| summarize \r\n Session_Submit_Time=min(SubmitTime_t) \r\n by SessionId_s\r\n| project Session_Submit_Time\r\n\r\n\r\n", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 259200000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "id": "b046db56-e6b3-4f3d-afb3-9687240c21f1", "version": "KqlParameterItem/1.0", "name": "Session_End_Time", "type": 1, "query": "AzureDiagnostics \r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s !in ('Batch','Execute')\r\n| where SessionId_s == '{SessionId}'\r\n| summarize \r\n Session_End_Time=max(EndTime_t) \r\n by SessionId_s\r\n| project Session_End_Time", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 259200000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 7" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics \r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s !in ('Batch','Execute')\r\n| where SubmitTime_t < datetime('{Session_Submit_Time}') and EndCompileTime_t > datetime('{Session_End_Time}') or RequestId_s == '{RequestId}'\r\n| summarize by RequestId_s\r\n| join kind=inner\r\n (\r\n AzureDiagnostics \r\n | where Category == 'ExecRequests'\r\n | where Resource == '{DatabaseName}'\r\n | where StatementType_s !in ('Batch','Execute')\r\n | summarize \r\n Session_ID=max(SessionId_s), \r\n Request_ID=max(RequestId_s), \r\n Submit_Time=min(SubmitTime_t), \r\n Start_Time=max(StartTime_t),\r\n End_Compile_Time=max(EndCompileTime_t), \r\n End_Time=max(EndTime_t), \r\n Command=max(Command_s), \r\n Last_Status=min(Status_s),\r\n Statement_Type=max(StatementType_s),\r\n Resource_class=max(ResourceClass_s) \r\n by RequestId_s\r\n ) on RequestId_s\r\n| order by End_Compile_Time\r\n| project Session_ID,Request_ID,Submit_Time,End_Compile_Time,Start_Time,End_Time,Last_Status,Statement_Type,Command\r\n\r\n", "size": 0, "title": "Query Executions that could have triggered Stats Statement based on Time of total session", "noDataMessage": "Select a query above to see individual executions", "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "150ch" } } ], "sortBy": [ { "itemKey": "Command", "sortOrder": 1 } ] }, "sortBy": [ { "itemKey": "Command", "sortOrder": 1 } ] }, "name": "query - 0 - Copy - Copy - Copy - Copy" } ] }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "Statistics" }, "name": "statistics" } ], "fallbackResourceIds": [ "azure monitor" ], "$schema": "https://github.com/Microsoft/Application-Insights-Workbooks/blob/master/schema/workbook.json" } ================================================ FILE: Monitor_Workbooks/archive/WorkspaceSQLPoolWorkbook_WIP_v0.73.JSON ================================================ { "version": "Notebook/1.0", "items": [ { "type": 9, "content": { "version": "KqlParameterItem/1.0", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "parameters": [ { "id": "f5852627-70ca-4959-8d60-53b48864603f", "version": "KqlParameterItem/1.0", "name": "TimeRange", "type": 4, "isGlobal": true, "value": { "durationMs": 1209600000 }, "typeSettings": { "selectableValues": [ { "durationMs": 300000 }, { "durationMs": 900000 }, { "durationMs": 1800000 }, { "durationMs": 3600000 }, { "durationMs": 14400000 }, { "durationMs": 43200000 }, { "durationMs": 86400000 }, { "durationMs": 172800000 }, { "durationMs": 259200000 }, { "durationMs": 604800000 }, { "durationMs": 1209600000 }, { "durationMs": 2419200000 }, { "durationMs": 2592000000 } ], "allowCustom": true }, "timeContext": { "durationMs": 86400000 } }, { "id": "28da10ec-a308-47f5-9819-92ebf810b292", "version": "KqlParameterItem/1.0", "name": "LogAnalyticsSubscription", "type": 6, "value": null, "typeSettings": { "additionalResourceOptions": [], "includeAll": true, "showDefault": false }, "timeContext": { "durationMs": 86400000 } }, { "id": "e383ed24-52ae-447b-9b80-51fd3ab6b919", "version": "KqlParameterItem/1.0", "name": "LogAnalyticsWorkspace", "type": 5, "query": "Resources\r\n| where type == 'microsoft.operationalinsights/workspaces'\r\n| project id\r\n", "crossComponentResources": [ "{LogAnalyticsSubscription}" ], "value": null, "typeSettings": { "additionalResourceOptions": [], "showDefault": false }, "timeContext": { "durationMs": 86400000 }, "queryType": 1, "resourceType": "microsoft.resourcegraph/resources" }, { "id": "9b9fe566-0f52-4a75-a35b-a79c50c6a6f0", "version": "KqlParameterItem/1.0", "name": "DatabaseResourceName", "type": 5, "query": "SynapseSqlPoolExecRequests \r\n| distinct _ResourceId", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "value": null, "typeSettings": { "additionalResourceOptions": [], "showDefault": false }, "timeContext": { "durationMs": 2592000000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "id": "6da2f63f-45a3-4b37-9108-5e8b7e358d85", "version": "KqlParameterItem/1.0", "name": "DatabaseName", "type": 1, "query": "print split (\"{DatabaseResourceName}\",\"/\")[-1]", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "id": "8bba835b-f319-43b3-8ec6-4e051fc6d446", "version": "KqlParameterItem/1.0", "name": "LogicalServerName", "type": 1, "query": "SynapseSqlPoolExecRequests\r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| distinct LogicalServerName", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "id": "b86cd4a2-2303-4288-b48c-1c119cb420ba", "version": "KqlParameterItem/1.0", "name": "AuditingState", "type": 1, "query": "let hasNonEmptyTable = (T:string) \r\n{ \r\n toscalar( \r\n union isfuzzy=true \r\n ( table(T) \r\n | where DatabaseName has '{DatabaseName}'\r\n | where TimeGenerated > ago(30d)| take 1 | count as Count ),\r\n (print Count=0) \r\n | summarize sum(Count) \r\n ) > 0\r\n};\r\nlet TableName = 'SQLSecurityAuditEvents';\r\nprint IsPresent=iif(hasNonEmptyTable(TableName ), \"enabled\", \"disabled\")", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 604800000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "id": "4025bcb8-f6d7-4e81-b805-84253835f8fb", "version": "KqlParameterItem/1.0", "name": "DiagnosticsState", "type": 1, "query": "let hasNonEmptyTable = (T:string, T2:string) \r\n{ \r\n toscalar( \r\n union isfuzzy=true \r\n ( table(T) | where TimeGenerated > ago(30d) | where _ResourceId endswith '/sqlpools/{DatabaseName}'| take 1 | count as Count ),\r\n ( table(T2) | where TimeGenerated > ago(30d) | where _ResourceId endswith '/sqlpools/{DatabaseName}'| take 1 | count as Count),\r\n (print Count=0) \r\n | summarize sum(Count) \r\n ) > 1\r\n};\r\nlet TableName = 'SynapseSqlPoolExecRequests';\r\nlet TableName2 = 'SynapseSqlPoolRequestSteps';\r\nprint IsPresent=iif(hasNonEmptyTable(TableName,TableName2 ), \"enabled\", \"disabled\")", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 2592000000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "customWidth": "90", "name": "parameters - 2" }, { "type": 1, "content": { "json": "Workbook version: v0.75", "style": "info" }, "customWidth": "10", "name": "version", "styleSettings": { "showBorder": true } }, { "type": 1, "content": { "json": "Select your Log Analytics Workspace by setting the parameters above from left to right. ", "style": "warning" }, "conditionalVisibility": { "parameterName": "DatabaseResourceName", "comparison": "isEqualTo" }, "customWidth": "30", "name": "text - 14" }, { "type": 11, "content": { "version": "LinkItem/1.0", "style": "tabs", "links": [ { "id": "202cbbc0-8d63-416d-89ed-451d6fe7c4b3", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Workload", "subTarget": "Workload", "preText": "Workload", "style": "link" }, { "id": "a7901bd0-a1f4-4491-b953-57555d764e00", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Workload Management", "subTarget": "WorkloadManagement", "style": "link" }, { "id": "45e12a14-8548-4477-aae3-c142b906dc9f", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "TempDB", "subTarget": "TempDB", "style": "link" }, { "id": "9ef8f730-d73d-432b-9b75-55095d1155f2", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Replicated Tables", "subTarget": "ReplicatedTables", "style": "link" }, { "id": "79d10d16-0696-4214-b306-c7a0e46cd64f", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Query Investigation", "subTarget": "QueryInvestigation", "style": "link" }, { "id": "31c1cf1c-74b5-44e2-ba9a-9497834ca3dc", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Query Comparison", "subTarget": "QueryComparison", "style": "link" }, { "id": "5ff681ee-e005-481f-b743-b66ab1b9d71d", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Session Investigation", "subTarget": "SessionInvestigation", "style": "link" }, { "id": "482ccc46-8a10-4ace-bfd6-63ac73b380af", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Query Audit", "subTarget": "QueryAudit", "style": "link" }, { "id": "db43bb45-1611-47ce-a2ad-517943f2aa1a", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "AutoStats", "subTarget": "Statistics", "style": "link" } ] }, "name": "links - 0" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "title": "Workload", "items": [ { "type": 10, "content": { "chartId": "workbook90867bfc-5c33-464f-ac31-2c2e006b97f4", "version": "MetricsItem/2.0", "size": 0, "chartType": 2, "resourceType": "microsoft.synapse/workspaces/sqlpools", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 0 }, "metrics": [ { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-DWUUsedPercent", "aggregation": 3, "splitBy": null, "columnName": "DWU Usaed %" }, { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-CPUPercent", "aggregation": 3, "columnName": "CPU Used %" } ], "title": "DWU Resource Utilization", "showOpenInMe": true, "showCreateAlertRule": true, "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "showPin": true, "name": "metric - 1" }, { "type": 10, "content": { "chartId": "workbookb954d4a0-82ef-4409-88fb-837aaff80c8d", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.synapse/workspaces/sqlpools", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 0 }, "metrics": [ { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-ActiveQueries", "aggregation": 1, "splitBy": null }, { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-QueuedQueries", "aggregation": 1 } ], "title": "Active and Queued Queries", "showOpenInMe": true, "showCreateAlertRule": true, "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "showPin": true, "name": "metric - 1" }, { "type": 10, "content": { "chartId": "workbookb954d4a0-82ef-4409-88fb-837aaff80c8d", "version": "MetricsItem/2.0", "size": 0, "chartType": 3, "resourceType": "microsoft.synapse/workspaces/sqlpools", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 0 }, "metrics": [ { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-LocalTempDBUsedPercent", "aggregation": 3, "splitBy": null, "columnName": "TempDB Utilization Percentage" } ], "title": "TempDB Utilization", "showOpenInMe": true, "showCreateAlertRule": true, "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "showPin": true, "name": "metric - 1 - Copy" }, { "type": 10, "content": { "chartId": "workbookb954d4a0-82ef-4409-88fb-837aaff80c8d", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.synapse/workspaces/sqlpools", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 0 }, "metrics": [ { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool Workload management-WLGAllocationBySystemPercent", "aggregation": 3, "splitBy": null, "columnName": "Workload Group Allocation by System %" } ], "title": "Workload Group Utilization", "showOpenInMe": true, "showCreateAlertRule": true, "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "showPin": true, "name": "Workload Group Utilization" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Long-Running Queries - Just Actual Queries\r\n//If 'Command' is empty - you need to set a bigger time window, the older record with the command is outside of your window\r\nSynapseSqlPoolExecRequests \r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where StatementType !in ('Batch','Execute')\r\n| summarize //Session_ID=any(SessionId),\r\n Request_ID=any(RequestId),\r\n //Submit_Time=max(SubmitTime),\r\n Start_Time=max(StartTime),\r\n End_Time=max(EndTime),\r\n Command=any(Command),\r\n Status=min(Status), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType),\r\n Resource_class=any(ResourceClass)\r\n by RequestId\r\n| summarize ElapsedTime_min=bin(anyif(((End_Time - Start_Time)/1m),Start_Time > ago(30d)),1),\r\n //Session_ID=any(Session_ID), \r\n // Submit_Time=any(Submit_Time) ,\r\n Start_Time=any(Start_Time), \r\n End_Time=any(End_Time),\r\n Command=any(Command),\r\n Status=any(Status),\r\n Statement_Type=any(Statement_Type)\r\n ,Resource_class=any(Resource_class) \r\n by Request_ID\r\n| where End_Time > ago(365d)\r\n| summarize count() by Status, bin(End_Time,5m)\r\n| render barchart \r\n", "size": 0, "title": "Query Completion Count by End Time - 5m buckets", "color": "redBright", "timeContext": { "durationMs": 2592000000 }, "timeContextFromParameter": "TimeRange", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "chartSettings": { "seriesLabelSettings": [ { "seriesName": "Completed", "color": "green" }, { "seriesName": "Failed", "color": "red" }, { "seriesName": "Cancelled", "color": "yellow" } ] } }, "name": "query - 4" }, { "type": 1, "content": { "json": "Use the buttons below to filter the next chart for Success or Failed queries. In many cases a failed query may not have a 'Command' column populated depending on what stage the query failed in. ", "style": "info" }, "customWidth": "25", "name": "text - 3" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "e2a833ac-48b4-4ccd-bbcd-33fccf1dbd75", "version": "KqlParameterItem/1.0", "name": "QueryCompletionType", "type": 1, "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 } } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 4" }, { "type": 11, "content": { "version": "LinkItem/1.0", "style": "nav", "links": [ { "id": "8e89112f-c67f-42c0-9622-02fa306fb7a5", "cellValue": "QueryCompletionType", "linkTarget": "parameter", "linkLabel": "All Queries", "subTarget": "''", "style": "primary" }, { "id": "6abe39c7-4d4e-4c45-aa54-dc9a4c5e876e", "cellValue": "QueryCompletionType", "linkTarget": "parameter", "linkLabel": "Success Only", "subTarget": "Completed", "preText": "", "style": "secondary" }, { "id": "e41b4a0b-8464-491e-92be-a57217d6dcac", "cellValue": "QueryCompletionType", "linkTarget": "parameter", "linkLabel": "Failures Only", "subTarget": "Failed", "preText": "", "style": "secondary" } ] }, "name": "links - 11" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Long-Running Queries - Just Actual Queries\r\n//If 'Command' is empty - you need to set a bigger time window, the older record with the command is outside of your window\r\nSynapseSqlPoolExecRequests \r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where StatementType !in ('Batch','Execute')\r\n| summarize //Session_ID=any(SessionId),\r\n Request_ID=any(RequestId),\r\n Start_Time=max(StartTime),\r\n End_Time=max(EndTime),\r\n Command=any(Command),\r\n Status=min(Status), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType),\r\n Resource_class=any(ResourceClass)\r\n by RequestId\r\n| summarize ElapsedTime_min=bin(anyif(((End_Time - Start_Time)/1m),Start_Time > ago(30d)),1),\r\n Start_Time=any(Start_Time), \r\n End_Time=any(End_Time),\r\n Command=any(Command),\r\n Status=any(Status),\r\n Statement_Type=any(Statement_Type)\r\n ,Resource_class=any(Resource_class) \r\n by Request_ID\r\n| where Status has '{QueryCompletionType}'\r\n| order by Start_Time\r\n\r\n", "size": 0, "title": "Query Completions - use above buttons to filter", "color": "redBright", "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "rowLimit": 100 }, "chartSettings": { "seriesLabelSettings": [ { "seriesName": "Completed", "color": "green" }, { "seriesName": "Failed", "color": "red" }, { "seriesName": "Cancelled", "color": "yellow" } ] } }, "conditionalVisibility": { "parameterName": "QueryCompletionType", "comparison": "isEqualTo" }, "name": "query - 4 - Copy" } ] }, "name": "Query Completions", "styleSettings": { "showBorder": true } }, { "type": 10, "content": { "chartId": "workbook1afc57e6-0b32-4968-b299-db319bd21635", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.synapse/workspaces/sqlpools", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 2592000000 }, "metrics": [ { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-Connections", "aggregation": 1, "splitBy": null }, { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-ConnectionsBlockedByFirewall", "aggregation": 1 } ], "title": "Successful and Failed Connections", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "name": "metric - 5" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 3, "content": { "version": "KqlItem/1.0", "query": " SQLSecurityAuditEvents\r\n | where LogicalServerName == '{LogicalServerName}'\r\n | where ActionName in ('DATABASE AUTHENTICATION SUCCEEDED','DATABASE AUTHENTICATION FAILED')\r\n | project SourceSystem,ClientTlsVersion ,Succeeded,SessionId,ClientIp,SessionServerPrincipalName,ServerPrincipalName,DatabasePrincipalName,ApplicationName,HostName,TimeGenerated\r\n | summarize count() by Succeeded,bin(TimeGenerated,1m)\r\n | render barchart\r\n\r\n\r\n\r\n", "size": 0, "title": "Database Authentication success/failure rate", "timeContext": { "durationMs": 2592000000 }, "timeContextFromParameter": "TimeRange", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "chartSettings": { "xAxis": "TimeGenerated", "group": "succeeded_s", "createOtherGroup": null } }, "name": "query - 8" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "f7485a11-48df-4b61-a70e-9f56d6a00ec6", "version": "KqlParameterItem/1.0", "name": "AuthResult", "type": 1, "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 } } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 3" }, { "type": 11, "content": { "version": "LinkItem/1.0", "style": "nav", "links": [ { "id": "2ed22e0a-2b53-4ed0-8f65-d2c621f34dad", "cellValue": "AuthResult", "linkTarget": "parameter", "linkLabel": "All Authentications", "subTarget": "''", "style": "primary" }, { "id": "2789ab13-ae8a-472e-bad4-9c9bdc934d4d", "cellValue": "AuthResult", "linkTarget": "parameter", "linkLabel": "Success Only", "subTarget": "true", "style": "secondary" }, { "id": "5cf4ddd4-e189-4b71-b456-0d4f1572a0a3", "cellValue": "AuthResult", "linkTarget": "parameter", "linkLabel": "Failures Only", "subTarget": "false", "style": "secondary" } ] }, "name": "links - 10" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": " SQLSecurityAuditEvents\r\n | where LogicalServerName == '{LogicalServerName}'\r\n | where ActionName in ('DATABASE AUTHENTICATION SUCCEEDED','DATABASE AUTHENTICATION FAILED')\r\n | where Succeeded == '{AuthResult}'\r\n | project SourceSystem,ClientTlsVersion ,Succeeded,SessionId,ClientIp,SessionServerPrincipalName,ServerPrincipalName,DatabasePrincipalName,ApplicationName,HostName,TimeGenerated\r\n | summarize count() by Succeeded,bin(TimeGenerated,1m)\r\n\r\n\r\n\r\n\r\n\r\n", "size": 0, "title": "Database Authentication success/failure rate", "noDataMessage": "Please select a button above", "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "rowLimit": 100 }, "chartSettings": { "xAxis": "TimeGenerated", "group": "succeeded_s", "createOtherGroup": null, "showLegend": true } }, "name": "query - 8 - Copy" } ] }, "conditionalVisibility": { "parameterName": "AuditingState", "comparison": "isEqualTo", "value": "enabled" }, "name": "Database Authentication Group", "styleSettings": { "showBorder": true } }, { "type": 10, "content": { "chartId": "workbook993837ad-66d6-4cbc-ae1a-7c3f6623236b", "version": "MetricsItem/2.0", "size": 0, "chartType": 2, "resourceType": "microsoft.synapse/workspaces/sqlpools", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 0 }, "metrics": [ { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-AdaptiveCacheUsedPercent", "aggregation": 3, "splitBy": null }, { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-AdaptiveCacheHitPercent", "aggregation": 3 } ], "title": "Adaptive Cache Used vs Hit Percentage", "showCreateAlertRule": true, "gridSettings": { "rowLimit": 10000 } }, "name": "metric - 6" } ] }, "conditionalVisibilities": [ { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "Workload" }, { "parameterName": "DiagnosticsState", "comparison": "isEqualTo", "value": "enabled" } ], "name": "group - 1" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "title": "TempDB ", "items": [ { "type": 10, "content": { "chartId": "workbook4a9cf761-cce2-45b2-8947-8a9428ec7e1c", "version": "MetricsItem/2.0", "size": 0, "chartType": 3, "resourceType": "microsoft.synapse/workspaces/sqlpools", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 2592000000 }, "metrics": [ { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-LocalTempDBUsedPercent", "aggregation": 3, "splitBy": null, "columnName": "TempDB Util" } ], "title": "TempDB Max and Avg Utilization", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "name": "metric - 0" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "19ee48f5-8f4e-4939-a0ef-c6bf656a93f9", "version": "KqlParameterItem/1.0", "name": "WeightParameter", "type": 1, "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 } }, { "id": "00553ec8-1a41-4dd9-a024-d607639c9bbb", "version": "KqlParameterItem/1.0", "name": "RequestID", "type": 1, "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 }, "value": "" } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 3" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databaseResourceName = '{DatabaseResourceName}';\r\n//Weighted query steps\r\nSynapseSqlPoolRequestSteps \r\n| where _ResourceId == databaseResourceName\r\n| where RowCount > 0\r\n| summarize sum(RowCount) by RequestId, OperationType\r\n| order by sum_RowCount desc\r\n| limit 20\r\n| render columnchart ", "size": 0, "title": "20 Largest Query Steps by Most Rows Moved", "timeContext": { "durationMs": 2592000000 }, "timeContextFromParameter": "TimeRange", "exportFieldName": "Request_ID", "exportParameterName": "RequestID", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "chartSettings": { "xAxis": "RequestId", "group": "OperationType", "createOtherGroup": 20, "showLegend": true } }, "name": "query - 1 - Copy" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "8afacdd5-2690-48d0-b125-fb118378e90c", "version": "KqlParameterItem/1.0", "name": "WeightParameter", "type": 1, "value": "Unweighted", "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 } } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 8" }, { "type": 11, "content": { "version": "LinkItem/1.0", "style": "nav", "links": [ { "id": "c98d3722-9907-43ab-9306-1957d6f7f858", "cellValue": "WeightParameter", "linkTarget": "parameter", "linkLabel": "Weighted Rowcounts", "subTarget": "Weighted", "preText": "", "postText": "", "style": "secondary" }, { "id": "a06ae99a-ad62-45e9-8c25-c219b81f59c0", "cellValue": "WeightParameter", "linkTarget": "parameter", "linkLabel": "Unweighted Rowcounts", "subTarget": "Unweighted", "preText": "", "postText": "", "style": "secondary" } ] }, "name": "links - 3" }, { "type": 1, "content": { "json": "Current Setting: {WeightParameter}", "style": "info" }, "customWidth": "25", "name": "text - 4" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//let databaseResourceName = '{DatabaseResourceName}';\r\n//Weighted query steps\r\nlet RequestSteps = SynapseSqlPoolRequestSteps\r\n//| where _ResourceId == databaseResourceName\r\n//| where RowCount > 10000000\r\n| extend Step_Elapsed_Min = round((EndTime - StartTime) /1m, 2)\r\n| extend Weighted_cnt = iff('{WeightParameter}'=='Weighted',(case(OperationType == 'BroadcastMoveOperation', (RowCount*10), RowCount)),RowCount)\r\n| project-rename StepStatus = Status, StepStart = StartTime, StepEnd = EndTime//, StepResource = Resource\r\n| top 100 by Weighted_cnt desc\r\n| order by Weighted_cnt desc\r\n| project Request_ID=RequestId,OperationType, RowCount,Weighted_cnt,Step_Elapsed_Min, StepStart, StepEnd, StepStatus, StepIndex;\r\nRequestSteps | join (\r\nSynapseSqlPoolExecRequests\r\n//| where _ResourceId == databaseResourceName\r\n| where StatementType !in ('Batch','Execute')\r\n| summarize //Session_ID=any(SessionId),\r\n Request_ID=any(RequestId),\r\n //Submit_Time=max(SubmitTime),\r\n Start_Time=max(StartTime),\r\n End_Time=max(EndTime),\r\n Command=any(Command),\r\n Status=min(Status), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType),\r\n Resource_class=any(ResourceClass)\r\n by RequestId\r\n| summarize //Session_ID=any(Session_ID), \r\n//Submit_Time=any(Submit_Time) ,\r\nStart_Time=any(Start_Time), End_Time=any(End_Time),Command=any(Command),Status=any(Status),Statement_Type=any(Statement_Type),Resource_class=any(Resource_class) by Request_ID\r\n//| order by Step_Elapsed_Min desc\r\n| extend Request_Elapsed_Min = round((End_Time - Start_Time)/1m, 2)\r\n| project-rename ReqStatus = Status, ReqStart = Start_Time, ReqEnd = End_Time\r\n) on Request_ID\r\n| project-reorder //Session_ID, \r\nRequest_ID, Request_Elapsed_Min, ReqStart, ReqEnd, ReqStatus,StepIndex, OperationType, RowCount,Weighted_cnt,Step_Elapsed_Min, StepStart, StepEnd, StepStatus, Statement_Type, Command, Resource_class\r\n| order by Weighted_cnt desc\r\n| limit 20", "size": 3, "title": "20 Largest Query Steps by Most Rows Moved", "timeContext": { "durationMs": 2592000000 }, "timeContextFromParameter": "TimeRange", "exportFieldName": "Request_ID1", "exportParameterName": "RequestID", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "sortBy": [ { "itemKey": "Weighted_cnt", "sortOrder": 2 } ] }, "sortBy": [ { "itemKey": "Weighted_cnt", "sortOrder": 2 } ] }, "name": "query - 1" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databaseResourceName = '{DatabaseResourceName}';\r\n//Long-Running Queries - Just Actual Queries\r\n//If 'Command' is empty - you need to set a bigger time window, the older record with the command is outside of your window\r\nSynapseSqlPoolExecRequests\r\n| where _ResourceId == databaseResourceName\r\n| where StatementType !in ('Batch','Execute')\r\n| summarize //Session_ID=any(SessionId),\r\n Request_ID=any(RequestId),\r\n Start_Time=max(StartTime),\r\n End_Time=max(EndTime),\r\n Command=any(Command),\r\n Status=min(Status), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType),\r\n Resource_class=any(ResourceClass)\r\n by RequestId\r\n| summarize ElapsedTime_min=bin(anyif(((End_Time - Start_Time)/1m),Start_Time > ago(30d)),1),\r\n Start_Time=any(Start_Time), \r\n End_Time=any(End_Time),\r\n Command=any(Command),\r\n Status=any(Status),\r\n Statement_Type=any(Statement_Type)\r\n ,Resource_class=any(Resource_class) \r\n by Request_ID\r\n| where Request_ID == '{RequestID}' and Request_ID != ''\r\n\r\n", "size": 4, "title": "Selected Query", "noDataMessage": "Select a query above to view details", "noDataMessageStyle": 4, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "35%" } } ] } }, "name": "query - 6" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolRequestSteps \r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where RequestId == '{RequestID}' and RequestId != '' //Put your QueryID here\r\n| where Status != 'Running'\r\n| summarize max(StartTime),max(EndTime),max(RequestId),max(OperationType),max(RowCount),max(Command),max(Status) by StepIndex\r\n| order by StepIndex asc", "size": 3, "title": "Query Plan", "noDataMessage": "Select a query above to view the plan", "noDataMessageStyle": 4, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 7" } ] }, "conditionalVisibilities": [ { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "TempDB" }, { "parameterName": "DiagnosticsState", "comparison": "isEqualTo", "value": "enabled" } ], "name": "group - 3" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "title": "Query Investigation", "items": [ { "type": 1, "content": { "json": "## Search Criteria\r\nUse the following fields to search either using a query text snippet or using a Request ID. If using a query text snippet, try to keep it as simple as possible becuase minor changes in formatting may cause your queries not to show up in the results. It's best to pick something like a table name, then choose the proper query from the list that will populate. " }, "customWidth": "50", "name": "text - 4" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "4b98dd26-4ccf-420e-a990-8d015f27fb76", "version": "KqlParameterItem/1.0", "name": "SampleQID", "type": 1, "value": "999", "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 } }, { "id": "d5524dd5-cf7e-41cf-beb3-474b3290289e", "version": "KqlParameterItem/1.0", "name": "RequestId", "type": 1, "value": "", "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 } } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "initializeQueryInvestigationParameters" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "0c2128d0-d979-4562-a28c-e7ceb955f126", "version": "KqlParameterItem/1.0", "name": "RequestId", "type": 1, "value": "QID72414", "label": "Request Id Search" }, { "id": "29880874-2d41-4bd5-bf22-3e47ae8b1145", "version": "KqlParameterItem/1.0", "name": "QueryTextSnippet", "type": 1, "value": "", "timeContext": { "durationMs": 86400000 } } ], "style": "formVertical", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "customWidth": "60", "name": "parameters - 3" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolExecRequests\r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where StatementType !in ('Batch','Execute')\r\n| summarize \r\n Request_ID=max(RequestId), \r\n Start_Time=max(StartTime),\r\n End_Compile_Time=max(EndCompileTime), \r\n End_Time=max(EndTime), \r\n QueryText = any(Command), \r\n Last_Status=min(Status),\r\n Statement_Type=max(StatementType),\r\n Resource_class=max(ResourceClass) \r\n by RequestId\r\n| extend Elapsed_Time_s=(End_Time - Start_Time)/1s\r\n| where QueryText has '{QueryTextSnippet}'\r\nand RequestId has '{RequestId}'\r\n| summarize \r\n Executions = count(),\r\n SampleQID = any(RequestId),\r\n Elapsed_Time_s=max(Elapsed_Time_s)\r\n by QueryText\r\n| order by Elapsed_Time_s\r\n\r\n\r\n\r\n", "size": 0, "title": "Matching Queries", "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "exportedParameters": [ { "fieldName": "SampleQID", "parameterName": "SampleQID" }, { "fieldName": "SampleSessionID", "parameterName": "Samp", "parameterType": 1 }, { "fieldName": "SampleQID", "parameterName": "RequestId", "parameterType": 1 } ], "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "50%" } } ], "sortBy": [ { "itemKey": "Elapsed_Time_s", "sortOrder": 2 } ] }, "sortBy": [ { "itemKey": "Elapsed_Time_s", "sortOrder": 2 } ] }, "name": "query - 0" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolExecRequests\r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where StatementType !in ('Batch','Execute')\r\n| where RequestId == '{SampleQID}'\r\n| summarize \r\n Request_ID=max(RequestId), \r\n Start_Time=max(StartTime),\r\n End_Compile_Time=max(EndCompileTime), \r\n End_Time=max(EndTime), \r\n Command=max(Command), \r\n Last_Status=min(Status),\r\n Statement_Type=max(StatementType),\r\n Resource_class=max(ResourceClass) \r\n by RequestId\r\n| extend elapsedTime_sec = iif(End_Time > ago(365d),(End_Time - Start_Time)/1s,real(null)) \r\n| join kind=inner\r\n (SynapseSqlPoolExecRequests\r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where StatementType !in ('Batch','Execute')\r\n | summarize \r\n Request_ID=max(RequestId), \r\n Start_Time=max(StartTime),\r\n End_Compile_Time=max(EndCompileTime), \r\n End_Time=max(EndTime), \r\n Command=max(Command), \r\n Last_Status=min(Status),\r\n Statement_Type=max(StatementType),\r\n Resource_class=max(ResourceClass) \r\n by RequestId\r\n //| extend elapsedTime_sec = (End_Time - Start_Time)/1s\r\n | extend elapsedTime_sec = iif(End_Time > ago(365d),(End_Time - Start_Time)/1s,real(null)) \r\n )\r\non Command \r\n| project Request_ID1,Start_Time1,End_Compile_Time1,End_Time1,Last_Status1,Statement_Type1,Resource_class1,elapsedTime_sec1\r\n", "size": 0, "title": "All Executions of Selected Query Text", "noDataMessage": "Select a query above to see individual executions", "noDataMessageStyle": 4, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "exportFieldName": "Request_ID1", "exportParameterName": "RequestId", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "sortBy": [] }, "name": "query - 0 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolRequestSteps \r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where RequestId == '{RequestId}' and RequestId != ''\r\n| where Status != 'Running'\r\n| summarize max(StartTime),max(EndTime),max(RequestId),max(OperationType),max(RowCount),max(Command),max(Status) by StepIndex\r\n| order by StepIndex asc", "size": 3, "title": "Query Plan for Selected Query", "noDataMessage": "Select a Query Above to See the Query Plan", "noDataMessageStyle": 4, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 0 - Copy - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolExecRequests\r\n | where StatementType =='CreateStatistics'\r\n | where _ResourceId has '{DatabaseName}'\r\n | summarize \r\n Root_Query_Id=max(RootQueryId), \r\n Start_Time=max(StartTime),\r\n End_Compile_Time=max(EndCompileTime), \r\n End_Time=max(EndTime), \r\n Command=max(Command), \r\n Last_Status=min(Status),\r\n Statement_Type=max(StatementType),\r\n Resource_class=max(ResourceClass) \r\n by RequestId\r\n | where Root_Query_Id == '{RequestId}'", "size": 0, "title": "Triggered Auto-Stats Statements", "noDataMessage": "No triggered autostats statements found", "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Submit_Time", "formatter": 0, "numberFormat": { "unit": 0, "options": { "style": "decimal" } } }, { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "100ch" } } ] } }, "name": "All triggered auto-stats statements" } ] }, "conditionalVisibilities": [ { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "QueryInvestigation" }, { "parameterName": "DiagnosticsState", "comparison": "isEqualTo", "value": "enabled" } ], "name": "group - 4", "styleSettings": { "showBorder": true } }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "title": "Replicated Tables", "items": [ { "type": 1, "content": { "json": "All Charts on this page are based on the last 7 days of data", "style": "info" }, "customWidth": "25", "name": "text - 5" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "533ff6bb-97cd-4aaa-9372-171cad378bcd", "version": "KqlParameterItem/1.0", "name": "QueryText", "type": 1, "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 } }, { "id": "99de0056-d4f3-465e-a27e-599d69b23c77", "version": "KqlParameterItem/1.0", "name": "RequestId", "type": 1, "value": "999", "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 } } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "initializeTempDBVariables" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Build cache count by day\r\nlet databaseResourceName = '{DatabaseResourceName}';\r\n//Long-Running Queries - Just Actual Queries\r\n//If 'Command' is empty - you need to set a bigger time window, the older record with the command is outside of your window\r\nSynapseSqlPoolExecRequests\r\n| where _ResourceId == databaseResourceName\r\n| where StatementType == 'BuildReplicatedTableCache'\r\n| where Command != \"\"\r\n| where ResourceClass != \"\"\r\n| project Command,TimeGenerated,RequestId\r\n| summarize LastRebuild=max(TimeGenerated),RebuildCount=count(RequestId) by Command\r\n| order by RebuildCount desc\r\n| limit 15\r\n", "size": 3, "title": "Top 15 Most Rebuilds by Table", "noDataMessage": "No replicated table rebuilds found in the last 7 days", "noDataMessageStyle": 4, "timeContext": { "durationMs": 604800000 }, "exportFieldName": "Command", "exportParameterName": "QueryText", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command_s", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "40%" } } ] } }, "name": "query - 0" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Build cache count by day\r\nlet databaseResourceName = '{DatabaseResourceName}';\r\nSynapseSqlPoolExecRequests\r\n| where _ResourceId == databaseResourceName\r\n| where StatementType == 'BuildReplicatedTableCache'\r\n| where Command == \"{QueryText}\"\r\n| where ResourceClass != \"\"\r\n| project Command,TimeGenerated,RequestId\r\n| summarize count() by Command,bin(TimeGenerated,24h)\r\n| limit 20\r\n| render timechart", "size": 0, "title": "Rebuilds per Day for Selected Table", "noDataMessage": "Select a query above to see runs by day", "noDataMessageStyle": 4, "timeContext": { "durationMs": 604800000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "chartSettings": { "group": "Command_s", "createOtherGroup": 20, "ySettings": { "min": 0 } } }, "name": "query - 0 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Build cache count by day\r\nlet databaseResourceName = '{DatabaseResourceName}';\r\n//Long-Running Queries - Just Actual Queries\r\n//If 'Command' is empty - you need to set a bigger time window, the older record with the command is outside of your window\r\nSynapseSqlPoolExecRequests\r\n| where _ResourceId == databaseResourceName\r\n| where StatementType == 'BuildReplicatedTableCache'\r\n| where Command != \"\"\r\n| where ResourceClass != \"\"\r\n| project Command,TimeGenerated,RequestId\r\n| summarize count() by Command, bin(TimeGenerated,24h)\r\n//| where count_ > 7\r\n| order by count_ desc\r\n\r\n", "size": 2, "title": "Rebuild Count by Table by Day", "noDataMessage": " Only tables with more than 7 total rebuilds will show up. If no talbes with that many rebuilds are found this chart will be empty", "noDataMessageStyle": 4, "timeContext": { "durationMs": 604800000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "categoricalbar", "gridSettings": { "sortBy": [ { "itemKey": "count_", "sortOrder": 1 } ] }, "sortBy": [ { "itemKey": "count_", "sortOrder": 1 } ], "tileSettings": { "showBorder": false, "titleContent": { "columnMatch": "Command_s", "formatter": 1 }, "leftContent": { "columnMatch": "count_", "formatter": 12, "formatOptions": { "palette": "auto" }, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "graphSettings": { "type": 0, "topContent": { "columnMatch": "Command_s", "formatter": 1 }, "centerContent": { "columnMatch": "count_", "formatter": 1, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "chartSettings": { "group": "Command_s", "createOtherGroup": 99, "showDataPoints": true } }, "name": "query - 0 - Copy - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databaseResourceName = '{DatabaseResourceName}';\r\n//Long-Running Queries - Just Actual Queries\r\n//If 'Command' is empty - you need to set a bigger time window, the older record with the command is outside of your window\r\nSynapseSqlPoolExecRequests\r\n| where _ResourceId == databaseResourceName\r\n| where StatementType == 'BuildReplicatedTableCache'\r\n| summarize Start_Time=max(StartTime), End_Time=max(EndTime), Command=max(Command), Statement_Type=max(StatementType), Resource_class=max(ResourceClass) by RequestId\r\n| join kind= inner\r\n(\r\n SynapseSqlPoolExecRequests\r\n | where _ResourceId == databaseResourceName\r\n | where StatementType == 'BuildReplicatedTableCache'\r\n | where StatementType == 'BuildReplicatedTableCache'\r\n | where EndTime > ago(7d)\r\n | where StartTime > ago(7d)\r\n | extend elapsedTime_min = (EndTime - StartTime)/1m\r\n | order by elapsedTime_min desc\r\n | project RequestId,elapsedTime_min \r\n)\r\non RequestId\r\n| order by elapsedTime_min desc\r\n| project RequestId,Start_Time,End_Time,Elapsed_Time=round(elapsedTime_min,1) ,Command\r\n| limit 15\r\n", "size": 3, "title": "Top 15 Elapsed Time per Rebuild", "noDataMessageStyle": 4, "timeContext": { "durationMs": 604800000 }, "exportFieldName": "RequestId", "exportParameterName": "RequestId", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "40%" } } ] } }, "name": "query - 3" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": " let databaseResourceName = '{DatabaseResourceName}';\r\nSynapseSqlPoolRequestSteps \r\n| where _ResourceId == databaseResourceName\r\n| where RequestId == '{RequestId}'\r\n| where Status != 'Running'\r\n| summarize max(StartTime),max(EndTime),max(RequestId),max(OperationType),max(RowCount),max(Command),max(Status) by StepIndex\r\n| order by StepIndex asc", "size": 3, "title": "Query Plan for Selected Query", "noDataMessage": "Select a query above to view plan", "noDataMessageStyle": 4, "timeContext": { "durationMs": 604800000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 4" } ] }, "conditionalVisibilities": [ { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "ReplicatedTables" }, { "parameterName": "DiagnosticsState", "comparison": "isEqualTo", "value": "enabled" } ], "name": "ReplicatedTablesGroup" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "title": "Workload Management", "items": [ { "type": 10, "content": { "chartId": "workbook72446028-6edb-4cb0-8952-e0c13bda488f", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.synapse/workspaces/sqlpools", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 2592000000 }, "metrics": [ { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool Workload management-WLGAllocationBySystemPercent", "aggregation": 3, "splitBy": "WorkloadGroup" } ], "title": "Workload Group Allocation By System Percent", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "name": "metric - 0" }, { "type": 10, "content": { "chartId": "workbookc898119a-7381-469d-b51a-d505b4f80e73", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.synapse/workspaces/sqlpools", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 2592000000 }, "metrics": [ { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool Workload management-WLGActiveQueries", "aggregation": 1, "splitBy": "WorkloadGroup" } ], "title": "Query Count by Workload Group", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "name": "metric - 1" }, { "type": 10, "content": { "chartId": "workbook8d175f6c-427b-47fc-85ea-37edd0be707c", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.synapse/workspaces/sqlpools", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 2592000000 }, "metrics": [ { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-WLGQueuedQueries", "aggregation": 1, "splitBy": "WorkloadGroup" } ], "title": "Queued Queries by Workload Group", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "name": "Queued Queries by Workload Group" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "parameters": [ { "id": "6f50577d-7b00-4e4a-acf9-d45c7a5ee813", "version": "KqlParameterItem/1.0", "name": "WorkloadGroupName", "type": 2, "query": "SynapseSqlPoolExecRequests \r\n| where _ResourceId == '{DatabaseResourceName}'\r\n and ResourceClass != \"\"\r\n| distinct ResourceClass", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "value": null, "typeSettings": { "additionalResourceOptions": [], "showDefault": false }, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 2" }, { "type": 10, "content": { "chartId": "workbook3da1d18a-1bf5-46c5-b3b7-211f71d329cc", "version": "MetricsItem/2.0", "size": 0, "chartType": 2, "resourceType": "microsoft.synapse/workspaces/sqlpools", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 2592000000 }, "metrics": [ { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-WLGActiveQueries", "aggregation": 1, "splitBy": null }, { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-WLGQueuedQueries", "aggregation": 1 }, { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-WLGAllocationBySystemPercent", "aggregation": 3 }, { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-WLGEffectiveCapResourcePercent", "aggregation": 3 } ], "filters": [ { "id": "5", "key": "WorkloadGroup", "operator": 0, "valueParam": "WorkloadGroupName" } ], "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "name": "metric - 3" } ] }, "conditionalVisibilities": [ { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "WorkloadManagement" }, { "parameterName": "DiagnosticsState", "comparison": "isEqualTo", "value": "enabled" } ], "name": "group - 6" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "title": "Query Audit", "items": [ { "type": 1, "content": { "json": "## Select a Principal or Application name to filter results - leave to 'unset' to view all results\r\nSQL Auditing must be enabled and sending to the same Log Analytics Workspace for this page to work. " }, "name": "text - 5" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "parameters": [ { "id": "8d25c043-d1ff-4546-a1fa-f4bcbfdab8af", "version": "KqlParameterItem/1.0", "name": "User", "type": 2, "description": "User to filter subsequent queries - leave to 'unset' for all users", "query": "SQLSecurityAuditEvents \r\n| where LogicalServerName == '{LogicalServerName}'\r\n| summarize by ServerPrincipalName", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "value": null, "typeSettings": { "additionalResourceOptions": [], "showDefault": false }, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "id": "aa766d64-693f-4024-b4a4-b5b56b28376b", "version": "KqlParameterItem/1.0", "name": "Application", "type": 2, "query": "SQLSecurityAuditEvents \r\n| where LogicalServerName == '{LogicalServerName}'\r\n| summarize by ApplicationName", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "value": null, "typeSettings": { "additionalResourceOptions": [], "showDefault": false }, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "customWidth": "30", "name": "parameters - 1" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SQLSecurityAuditEvents \r\n| where LogicalServerName == '{LogicalServerName}'\r\n| where DurationMs > 0\r\n| extend duration_seconds = DurationMs /1000.0\r\n| where Statement != 'select @@version'\r\n| where Statement != 'SELECT @@SPID;'\r\n| where ServerPrincipalName has '{User}'\r\n| where ApplicationName has '{Application}'\r\n| project ServerPrincipalName, EventTime, LogicalServerName, DurationMs, duration_seconds, AffectedRows, Statement, ApplicationName\r\n| summarize duration_seconds = round(sum(duration_seconds)) , query_count = count() by EventDay = bin(EventTime,1d), UserName = ServerPrincipalName, Application = ApplicationName \r\n| order by EventDay, duration_seconds desc", "size": 0, "title": "Query Summary for Selected User {User} {Application}", "noDataMessage": "Select a user to see query activity", "timeContext": { "durationMs": 604800000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 0 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SQLSecurityAuditEvents \r\n| where LogicalServerName == '{LogicalServerName}'\r\n| where DurationMs > 0\r\n| extend duration_seconds = DurationMs /1000.0\r\n| where Statement != 'select @@version'\r\n| where Statement != 'SELECT @@SPID;'\r\n| where ServerPrincipalName has '{User}'\r\n| where ApplicationName has '{Application}'\r\n| project ServerPrincipalName, EventTime, LogicalServerName, DurationMs, duration_seconds, AffectedRows, Statement, ApplicationName\r\n| summarize duration_seconds = round(sum(duration_seconds)) , query_count = count() by EventDay = bin(EventTime,1d), UserName = ServerPrincipalName, Application = ApplicationName \r\n| order by EventDay, duration_seconds desc", "size": 0, "title": "Query Summary for Selected User {User} {Application}", "noDataMessage": "Select a user to see query activity", "timeContext": { "durationMs": 604800000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "unstackedbar", "tileSettings": { "showBorder": false, "titleContent": { "columnMatch": "UserName", "formatter": 1 }, "leftContent": { "columnMatch": "duration_seconds", "formatter": 12, "formatOptions": { "palette": "auto" }, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "graphSettings": { "type": 0, "topContent": { "columnMatch": "UserName", "formatter": 1 }, "centerContent": { "columnMatch": "duration_seconds", "formatter": 1, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "chartSettings": { "xAxis": "UserName" }, "mapSettings": { "locInfo": "LatLong", "sizeSettings": "duration_seconds", "sizeAggregation": "Sum", "legendMetric": "duration_seconds", "legendAggregation": "Sum", "itemColorSettings": { "type": "heatmap", "colorAggregation": "Sum", "nodeColorField": "duration_seconds", "heatmapPalette": "greenRed" } } }, "name": "query - 0 - Copy - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SQLSecurityAuditEvents \r\n | where LogicalServerName == \"{LogicalServerName}\"\r\n | where DurationMs > 0\r\n | extend duration_seconds = DurationMs /1000.0\r\n | where Statement != 'select @@version'\r\n | where Statement != 'SELECT @@SPID;'\r\n | where ServerPrincipalName has '{User}'\r\n | where ApplicationName has '{Application}'\r\n | project DatabaseName= DatabaseName, UserName= ServerPrincipalName, EventTime= EventTime, Host= HostName, duration_seconds = round(duration_seconds), Statement, QuerySource = ApplicationName , AffectedRows\r\n | project-reorder DatabaseName, UserName, Host, EventTime, duration_seconds, Statement, QuerySource\r\n\r\n\r\n\r\n\r\n\r\n", "size": 0, "title": "Queries {User} {Application}", "noDataMessage": "Select a user to see query activity", "timeContext": { "durationMs": 604800000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 0 - Copy - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SQLSecurityAuditEvents \r\n | where LogicalServerName == \"{LogicalServerName}\"\r\n | where DurationMs > 0\r\n | extend duration_seconds = DurationMs /1000.0\r\n | where Statement != 'select @@version'\r\n | where Statement != 'SELECT @@SPID;'\r\n | where ServerPrincipalName has '{User}'\r\n | where ApplicationName has '{Application}'\r\n | project DatabaseName= DatabaseName, UserName= ServerPrincipalName, EventTime= EventTime, Host= HostName, duration_seconds = round(duration_seconds), Statement, QuerySource = ApplicationName , AffectedRows\r\n | project-reorder AffectedRows,DatabaseName, UserName, Host, EventTime, duration_seconds, Statement, QuerySource\r\n\r\n\r\n\r\n\r\n\r\n", "size": 0, "timeContext": { "durationMs": 604800000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "barchart", "chartSettings": { "xAxis": "Host", "group": "UserName", "createOtherGroup": null, "showLegend": true } }, "name": "query - 6" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SQLSecurityAuditEvents\r\n| where LogicalServerName == \"{LogicalServerName}\"\r\n | where DurationMs > 0\r\n| extend Duration = round(DurationMs /1000.0)\r\n| extend TimeBin = case (datetime_part(\"Hour\",TimeGenerated) in (6,7,8,9,10,11,12), \"Morning_6-12\", datetime_part(\"Hour\",TimeGenerated) in (13,14,15,16,17,18), \"Afternoon_12-18\", \"Overnight_18-6\")\r\n| where ServerPrincipalName has '{User}'\r\n| where ApplicationName has '{Application}'\r\n| summarize QueryDuration = sum(Duration) by EventTime = bin(EventTime, 1d), TimeBin", "size": 0, "title": "Query Activity by time - sum(Duration) {User} {Application}", "noDataMessage": "Select a user to see query activity", "timeContext": { "durationMs": 604800000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "barchart" }, "name": "query - 0 - Copy" } ] }, "conditionalVisibilities": [ { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "QueryAudit" }, { "parameterName": "AuditingState", "comparison": "isEqualTo", "value": "enabled" } ], "name": "QueryAuditGroup", "styleSettings": { "showBorder": true } }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "title": "Query Comparison", "items": [ { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "7fa3187e-9225-4faa-8f80-dc1bc40c5aab", "version": "KqlParameterItem/1.0", "name": "RequestId1", "type": 1, "value": "" } ], "style": "above", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "customWidth": "50", "name": "parameters - 3 - Copy" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "315fc476-469a-4d8d-b421-028d1113ab06", "version": "KqlParameterItem/1.0", "name": "RequestId2", "type": 1, "value": "", "timeContext": { "durationMs": 86400000 } } ], "style": "above", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "customWidth": "50", "name": "parameters - 2" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolExecRequests\r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where StatementType !in ('Batch','Execute') and RequestId == '{RequestId1}'\r\n| summarize \r\n Request_ID=any(RequestId),\r\n Start_Time=max(StartTime),\r\n End_Time=max(EndTime),\r\n Command=any(Command),\r\n Status=min(Status), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType),\r\n Resource_class=any(ResourceClass)\r\n by RequestId\r\n| summarize Start_Time=any(Start_Time), End_Time=any(End_Time),ElapsedTime_min=anyif((End_Time - Start_Time)/1m,Start_Time > ago(30d)),Command=any(Command),Status=any(Status),Statement_Type=any(Statement_Type),Resource_class=any(Resource_class) by Request_ID\r\n| project Request_ID,ElapsedTime_min,Command,Resource_class,Start_Time,End_Time,Statement_Type,Status\r\n", "size": 4, "timeContext": { "durationMs": 2592000000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "customWidth": "50", "name": "query - 2" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolExecRequests\r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where StatementType !in ('Batch','Execute') and RequestId == '{RequestId2}'\r\n| summarize \r\n Request_ID=any(RequestId),\r\n Start_Time=max(StartTime),\r\n End_Time=max(EndTime),\r\n Command=any(Command),\r\n Status=min(Status), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType),\r\n Resource_class=any(ResourceClass)\r\n by RequestId\r\n| summarize Start_Time=any(Start_Time), End_Time=any(End_Time),ElapsedTime_min=anyif((End_Time - Start_Time)/1m,Start_Time > ago(30d)),Command=any(Command),Status=any(Status),Statement_Type=any(Statement_Type),Resource_class=any(Resource_class) by Request_ID\r\n| project Request_ID,ElapsedTime_min,Command,Resource_class,Start_Time,End_Time,Statement_Type,Status\r\n", "size": 4, "timeContext": { "durationMs": 2592000000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "customWidth": "50", "name": "query - 2 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolRequestSteps \r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where RequestId == '{RequestId1}' and RequestId != ''\r\n| summarize StartTime=max(StartTime)\r\n ,EndTime=max(EndTime)\r\n ,RequestID=max(RequestId)\r\n ,Operation=max(OperationType)\r\n ,RowCount=max(RowCount)\r\n ,Command=max(Command)\r\n ,Status=max(Status)\r\n by StepIndex\r\n| order by StepIndex asc\r\n| project StartTime,EndTime,RequestID,Operation,RowCount,Command,Status,StepIndex", "size": 3, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "customWidth": "50", "name": "query - 4", "styleSettings": { "margin": "0", "padding": "10px" } }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolRequestSteps \r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where RequestId == '{RequestId2}' and RequestId != ''\r\n| summarize StartTime=max(StartTime)\r\n ,EndTime=max(EndTime)\r\n ,RequestID=max(RequestId)\r\n ,Operation=max(OperationType)\r\n ,RowCount=max(RowCount)\r\n ,Command=max(Command)\r\n ,Status=max(Status)\r\n by StepIndex\r\n| order by StepIndex asc\r\n| project StartTime,EndTime,RequestID,Operation,RowCount,Command,Status,StepIndex", "size": 3, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "customWidth": "50", "name": "query - 4 - Copy", "styleSettings": { "padding": "10px" } }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolExecRequests\r\n | where StatementType =='CreateStatistics'\r\n | where _ResourceId has '{DatabaseName}'\r\n | summarize \r\n Root_Query_Id=max(RootQueryId), \r\n Start_Time=max(StartTime),\r\n End_Compile_Time=max(EndCompileTime), \r\n End_Time=max(EndTime), \r\n Command=max(Command), \r\n Last_Status=min(Status),\r\n Statement_Type=max(StatementType),\r\n Resource_class=max(ResourceClass) \r\n by RequestId\r\n | where Root_Query_Id == '{RequestId1}'", "size": 0, "title": "Triggered Auto-Stats Statements", "noDataMessage": "No triggered autostats statements found", "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Submit_Time", "formatter": 0, "numberFormat": { "unit": 0, "options": { "style": "decimal" } } }, { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "100ch" } } ], "sortBy": [ { "itemKey": "End_Time", "sortOrder": 2 } ] }, "sortBy": [ { "itemKey": "End_Time", "sortOrder": 2 } ] }, "customWidth": "50", "name": "All triggered auto-stats statements" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolExecRequests\r\n | where StatementType =='CreateStatistics'\r\n | where _ResourceId has '{DatabaseName}'\r\n | summarize \r\n Root_Query_Id=max(RootQueryId), \r\n Start_Time=max(StartTime),\r\n End_Compile_Time=max(EndCompileTime), \r\n End_Time=max(EndTime), \r\n Command=max(Command), \r\n Last_Status=min(Status),\r\n Statement_Type=max(StatementType),\r\n Resource_class=max(ResourceClass) \r\n by RequestId\r\n | where Root_Query_Id == '{RequestId2}'", "size": 0, "title": "Triggered Auto-Stats Statements", "noDataMessage": "No triggered autostats statements found", "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Submit_Time", "formatter": 0, "numberFormat": { "unit": 0, "options": { "style": "decimal" } } }, { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "100ch" } } ] } }, "customWidth": "50", "name": "All triggered auto-stats statements" } ] }, "conditionalVisibilities": [ { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "QueryComparison" }, { "parameterName": "DiagnosticsState", "comparison": "isEqualTo", "value": "enabled" } ], "name": "QueryComparison" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "title": "Session Investigation", "items": [ { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "feb2ac70-2555-456e-bfa6-6ad4a2dcad0f", "version": "KqlParameterItem/1.0", "name": "SessionID", "type": 1, "value": "", "timeContext": { "durationMs": 86400000 } } ], "style": "above", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 0" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics \r\n| where Category == 'ExecRequests'\r\n| where Resource == '{DatabaseName}'\r\n| where StatementType_s !in ('Batch','Execute')\r\n| summarize \r\n Session_ID=max(SessionId_s), \r\n Submit_Time=max(SubmitTime_t), \r\n Start_Time=max(StartTime_t),\r\n End_Compile_Time=max(EndCompileTime_t), \r\n End_Time=max(EndTime_t), \r\n Command=max(Command_s), \r\n Last_Status=min(Status_s),\r\n Statement_Type=max(StatementType_s),\r\n Resource_class=max(ResourceClass_s) \r\n by RequestId_s\r\n| where Session_ID has '{SessionID}'\r\n| extend elapsedTime_sec = iif(End_Time > ago(365d),(End_Time - Submit_Time)/1s,real(null)) \r\n| order by Submit_Time asc\r\n\r\n\r\n\r\n\r\n", "size": 0, "timeContext": { "durationMs": 2592000000 }, "timeContextFromParameter": "TimeRange", "exportFieldName": "RequestId_s", "exportParameterName": "RequestID", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 1" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "AzureDiagnostics\r\n| where Category == 'RequestSteps'\r\n| where Resource == '{DatabaseName}'\r\n| where RequestId_s == '{RequestID}'\r\n//| where Status_s != 'Running'\r\n| summarize Start_Time=max(StartTime_t),End_Time=max(EndTime_t),Request_ID=max(RequestId_s),Operation_Type=max(OperationType_s),Row_Count=max(RowCount_d),Statement=max(Command_s),Status=min(Status_s) by StepIndex_d\r\n| order by StepIndex_d asc", "size": 3, "timeContext": { "durationMs": 2592000000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 2" } ] }, "conditionalVisibilities": [ { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "SessionInvestigation" }, { "parameterName": "DiagnosticsState", "comparison": "isEqualTo", "value": "enabled" } ], "name": "group - 9" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 1, "content": { "json": "## This tab is used to determine what statements triggerred autostats creation jobs. \r\nThe flow of autostats creation is as follows\r\n1. Query Submit Time\r\n2. \tCreate Statistics submit Time\r\n3. \tCreate Statistics end Time\r\n4. Query end_compile_time\r\n5. Query Start_Time\r\n6. Query End_Time\r\n\r\nFurther, if multiple stats are created, then the creation of all stats for this query will fall between query submit_time and end_compile_time. \r\n\r\nThe charts on this page allow you to search for an autostats job by requestID or my snippet of the autostats statement text, which can just be the schema, table, or column name. Then it will show you all commands that include that request ID or text. It will then show you all statements in the create stat statement because the query we are trying to identify will wait for all of those stats creations to complete before proceeding. \r\n\r\nThe last chart will list the statement that triggered the stats creation. " }, "name": "text - 6" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "df5b9b85-4188-4f2c-88cb-1369e09f6742", "version": "KqlParameterItem/1.0", "name": "RootQueryId", "type": 1, "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 } }, { "id": "560c9ec5-6341-4fa1-9ce6-35ff010151b1", "version": "KqlParameterItem/1.0", "name": "RequestId", "type": 1, "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 } } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 5" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "0911bd4b-d471-480b-bdf4-1a2d4ba1ea6e", "version": "KqlParameterItem/1.0", "name": "RequestIdSearch", "type": 1, "value": "", "label": "RequestId for AutoStats Job" }, { "id": "c12e6495-4fd1-473c-8ffc-0bf502f54706", "version": "KqlParameterItem/1.0", "name": "QueryTextSnippet", "type": 1, "value": "", "timeContext": { "durationMs": 86400000 }, "label": "Snippet of autostats creation statement (Schema, table or column)" } ], "style": "formVertical", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "customWidth": "60", "name": "parameters - 3 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolExecRequests\r\n | where StatementType =='CreateStatistics'\r\n | where _ResourceId has '{DatabaseName}'\r\n| summarize \r\n Root_Query_Id=max(RootQueryId), \r\n Start_Time=max(StartTime),\r\n End_Time=max(EndTime), \r\n Command=max(Command), \r\n Last_Status=min(Status),\r\n Statement_Type=max(StatementType)\r\n by RequestId\r\n| where Command has 'CREATE STATISTICS _wa_sys'\r\n| where Command has '{QueryTextSnippet}' and RequestId has '{RequestIdSearch}'\r\n//| extend elapsedTime_sec = iif(End_Time > ago(365d),(End_Time - Submit_Time)/1s,real(null)) \r\n//| extend CompileTime_sec = (End_Compile_Time - Submit_Time)/1s\r\n//| order by elapsedTime_sec\r\n//| summarize \r\n // Executions = count(),\r\n // Max_Elapsed_Time_sec = bin(max(elapsedTime_sec),1),\r\n // Min_Elapsed_Time_sec = bin(min(elapsedTime_sec),1),\r\n // Variability_sec=bin((max(elapsedTime_sec)-min(elapsedTime_sec)),1),\r\n // SampleQID = any(RequestId),\r\n // SampleSessionID = any(Session_ID)\r\n // by Command\r\n//| order by Max_Elapsed_Time_sec\r\n\r\n\r\n", "size": 0, "title": "Matching Autostats Queries", "noDataMessageStyle": 4, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "exportedParameters": [ { "fieldName": "RequestId", "parameterName": "RequestId", "parameterType": 1 }, { "fieldName": "Root_Query_Id", "parameterName": "RootQueryId", "parameterType": 1 } ], "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "50%" } } ], "sortBy": [ { "itemKey": "Command", "sortOrder": 1 } ] }, "sortBy": [ { "itemKey": "Command", "sortOrder": 1 } ] }, "name": "query - 0 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolExecRequests\r\n | where StatementType !='CreateStatistics'\r\n | where _ResourceId has '{DatabaseName}'\r\n | where RequestId == '{RootQueryId}'\r\n | summarize \r\n Start_Time=max(StartTime),\r\n End_Compile_Time=max(EndCompileTime), \r\n End_Time=max(EndTime), \r\n Command=max(Command), \r\n Last_Status=min(Status),\r\n Statement_Type=max(StatementType),\r\n Resource_class=max(ResourceClass) \r\n by RequestId", "size": 3, "title": "Statement that Triggered Selected Autostat", "noDataMessage": "Select an autostats query above to see what query triggered it", "noDataMessageStyle": 4, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "150ch" } } ], "sortBy": [ { "itemKey": "Command", "sortOrder": 1 } ] }, "sortBy": [ { "itemKey": "Command", "sortOrder": 1 } ] }, "name": "query - 0 - Copy - Copy - Copy - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolExecRequests\r\n | where StatementType =='CreateStatistics'\r\n | where _ResourceId has '{DatabaseName}'\r\n| summarize \r\n Root_Query_Id=max(RootQueryId), \r\n Start_Time=max(StartTime),\r\n End_Time=max(EndTime), \r\n Command=max(Command), \r\n Last_Status=min(Status),\r\n Statement_Type=max(StatementType)\r\n by RequestId\r\n| where Command has 'CREATE STATISTICS _wa_sys'\r\n| where Root_Query_Id == '{RootQueryId}'", "size": 3, "title": "All Stats Statements Triggered by selected Query", "noDataMessageStyle": 4, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 13" } ] }, "conditionalVisibilities": [ { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "Statistics" }, { "parameterName": "DiagnosticsState", "comparison": "isEqualTo", "value": "enabled" } ], "name": "statistics" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 1, "content": { "json": "" }, "customWidth": "60", "showPin": false, "name": "Image" }, { "type": 1, "content": { "json": "Enable SQL Auditing to get additional visibility into user activity against your SQL Pool\r\n\r\nThis section provides additional monitoring coverage that is based on SQL Audit logs.
\r\nIf you have not activated SQL Auditing for your dedeciated SQL Pool, you must enable them to go to the same Log Analytics workspace as the rest of your diagnostic settings for it to show up here. [Learn more](https://docs.microsoft.com/en-us/azure/azure-sql/database/auditing-overview)\r\n" }, "customWidth": "60", "name": "text - 2" }, { "type": 11, "content": { "version": "LinkItem/1.0", "style": "paragraph", "links": [ { "id": "f4df7a1e-2124-4620-9005-f9b66e47f550", "cellValue": "{DatabaseResourceName}", "linkTarget": "Resource", "linkLabel": "Configure Logs for Auditing >", "subTarget": "auditing", "preText": "", "postText": "", "style": "primary" } ] }, "customWidth": "70", "name": "links - 8" } ] }, "customWidth": "90", "name": "Onboarding Message - Not onboarded yet" } ] }, "conditionalVisibilities": [ { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "QueryAudit" }, { "parameterName": "AuditingState", "comparison": "isEqualTo", "value": "disabled" } ], "name": "AuditingDisabledGroup" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 1, "content": { "json": "" }, "customWidth": "60", "showPin": false, "name": "Image" }, { "type": 1, "content": { "json": "Get more visibility into the usage and performance of your Azure Synapse Dedicated SQL Pool\r\n\r\nThis section provides additional monitoring coverage that is based on diagnostic logs.
\r\n\r\nIf you have not activated monitoring in diagnostic settings, you must enable the **ExecRequests** and **RequestSteps** logs and send them to a Log Analytics workspace. You may choose to enable the **SQLSecurityAuditEvents** table at the same time to take full advantage of this monitoring workbook. [Learn more](https://docs.microsoft.com/en-us/azure/synapse-analytics/monitoring/how-to-monitor-using-azure-monitor#logs)" }, "customWidth": "60", "name": "text - 2" }, { "type": 11, "content": { "version": "LinkItem/1.0", "style": "paragraph", "links": [ { "id": "f4df7a1e-2124-4620-9005-f9b66e47f550", "cellValue": "{DatabaseResourceName}", "linkTarget": "Resource", "linkLabel": "Configure Logs for Monitoring >", "subTarget": "diagnostics", "preText": "", "postText": "", "style": "primary" } ] }, "customWidth": "70", "name": "links - 8" } ] }, "customWidth": "90", "name": "Onboarding Message - Not onboarded yet" } ] }, "conditionalVisibilities": [ { "parameterName": "GroupSelection", "comparison": "isNotEqualTo", "value": "QueryAudit" }, { "parameterName": "DiagnosticsState", "comparison": "isEqualTo", "value": "disabled" } ], "name": "DiagnosticsDisabledGroup" } ], "fallbackResourceIds": [ "Azure Monitor" ], "$schema": "https://github.com/Microsoft/Application-Insights-Workbooks/blob/master/schema/workbook.json" } ================================================ FILE: Monitor_Workbooks/archive/WorkspaceSQLPoolWorkbook_WIP_v0.77.JSON ================================================ { "version": "Notebook/1.0", "items": [ { "type": 9, "content": { "version": "KqlParameterItem/1.0", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "parameters": [ { "id": "f5852627-70ca-4959-8d60-53b48864603f", "version": "KqlParameterItem/1.0", "name": "TimeRange", "type": 4, "isGlobal": true, "value": { "durationMs": 86400000 }, "typeSettings": { "selectableValues": [ { "durationMs": 300000 }, { "durationMs": 900000 }, { "durationMs": 1800000 }, { "durationMs": 3600000 }, { "durationMs": 14400000 }, { "durationMs": 43200000 }, { "durationMs": 86400000 }, { "durationMs": 172800000 }, { "durationMs": 259200000 }, { "durationMs": 604800000 }, { "durationMs": 1209600000 }, { "durationMs": 2419200000 }, { "durationMs": 2592000000 } ], "allowCustom": true }, "timeContext": { "durationMs": 86400000 } }, { "id": "28da10ec-a308-47f5-9819-92ebf810b292", "version": "KqlParameterItem/1.0", "name": "LogAnalyticsSubscription", "type": 6, "value": null, "typeSettings": { "additionalResourceOptions": [], "includeAll": true, "showDefault": false }, "timeContext": { "durationMs": 86400000 } }, { "id": "e383ed24-52ae-447b-9b80-51fd3ab6b919", "version": "KqlParameterItem/1.0", "name": "LogAnalyticsWorkspace", "type": 5, "query": "Resources\r\n| where type == 'microsoft.operationalinsights/workspaces'\r\n| project id\r\n", "crossComponentResources": [ "{LogAnalyticsSubscription}" ], "value": null, "typeSettings": { "additionalResourceOptions": [], "showDefault": false }, "timeContext": { "durationMs": 86400000 }, "queryType": 1, "resourceType": "microsoft.resourcegraph/resources" }, { "id": "9b9fe566-0f52-4a75-a35b-a79c50c6a6f0", "version": "KqlParameterItem/1.0", "name": "DatabaseResourceName", "type": 5, "query": "SynapseSqlPoolExecRequests \r\n| distinct _ResourceId", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "value": null, "typeSettings": { "additionalResourceOptions": [], "showDefault": false }, "timeContext": { "durationMs": 2592000000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "id": "6da2f63f-45a3-4b37-9108-5e8b7e358d85", "version": "KqlParameterItem/1.0", "name": "DatabaseName", "type": 1, "query": "print split (\"{DatabaseResourceName}\",\"/\")[-1]", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "id": "8bba835b-f319-43b3-8ec6-4e051fc6d446", "version": "KqlParameterItem/1.0", "name": "LogicalServerName", "type": 1, "query": "SynapseSqlPoolExecRequests\r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| distinct LogicalServerName", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "id": "b86cd4a2-2303-4288-b48c-1c119cb420ba", "version": "KqlParameterItem/1.0", "name": "AuditingState", "type": 1, "query": "let hasNonEmptyTable = (T:string) \r\n{ \r\n toscalar( \r\n union isfuzzy=true \r\n ( table(T) \r\n | where DatabaseName has '{DatabaseName}'\r\n | where TimeGenerated > ago(30d)| take 1 | count as Count ),\r\n (print Count=0) \r\n | summarize sum(Count) \r\n ) > 0\r\n};\r\nlet TableName = 'SQLSecurityAuditEvents';\r\nprint IsPresent=iif(hasNonEmptyTable(TableName ), \"enabled\", \"disabled\")", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 604800000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "id": "4025bcb8-f6d7-4e81-b805-84253835f8fb", "version": "KqlParameterItem/1.0", "name": "DiagnosticsState", "type": 1, "query": "let hasNonEmptyTable = (T:string, T2:string) \r\n{ \r\n toscalar( \r\n union isfuzzy=true \r\n ( table(T) | where TimeGenerated > ago(30d) | where _ResourceId endswith '/sqlpools/{DatabaseName}'| take 1 | count as Count ),\r\n ( table(T2) | where TimeGenerated > ago(30d) | where _ResourceId endswith '/sqlpools/{DatabaseName}'| take 1 | count as Count),\r\n (print Count=0) \r\n | summarize sum(Count) \r\n ) > 1\r\n};\r\nlet TableName = 'SynapseSqlPoolExecRequests';\r\nlet TableName2 = 'SynapseSqlPoolRequestSteps';\r\nprint IsPresent=iif(hasNonEmptyTable(TableName,TableName2 ), \"enabled\", \"disabled\")", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 2592000000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "customWidth": "90", "name": "parameters - 2" }, { "type": 1, "content": { "json": "Select your Log Analytics Workspace by setting the parameters above from left to right. ", "style": "warning" }, "conditionalVisibility": { "parameterName": "DatabaseResourceName", "comparison": "isEqualTo" }, "customWidth": "30", "name": "text - 14" }, { "type": 11, "content": { "version": "LinkItem/1.0", "style": "tabs", "links": [ { "id": "202cbbc0-8d63-416d-89ed-451d6fe7c4b3", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Overview", "subTarget": "Overview", "preText": "Workload", "style": "link" }, { "id": "a7901bd0-a1f4-4491-b953-57555d764e00", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Workload Management", "subTarget": "WorkloadManagement", "style": "link" }, { "id": "45e12a14-8548-4477-aae3-c142b906dc9f", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "TempDB", "subTarget": "TempDB", "style": "link" }, { "id": "9ef8f730-d73d-432b-9b75-55095d1155f2", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Replicated Tables", "subTarget": "ReplicatedTables", "style": "link" }, { "id": "79d10d16-0696-4214-b306-c7a0e46cd64f", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Query Investigation", "subTarget": "QueryInvestigation", "style": "link" }, { "id": "31c1cf1c-74b5-44e2-ba9a-9497834ca3dc", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Query Comparison", "subTarget": "QueryComparison", "style": "link" }, { "id": "482ccc46-8a10-4ace-bfd6-63ac73b380af", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "Query Audit", "subTarget": "QueryAudit", "style": "link" }, { "id": "db43bb45-1611-47ce-a2ad-517943f2aa1a", "cellValue": "GroupSelection", "linkTarget": "parameter", "linkLabel": "AutoStats", "subTarget": "Statistics", "style": "link" } ] }, "name": "links - 0" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 10, "content": { "chartId": "workbook90867bfc-5c33-464f-ac31-2c2e006b97f4", "version": "MetricsItem/2.0", "size": 0, "chartType": 2, "resourceType": "microsoft.synapse/workspaces/sqlpools", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 1209600000 }, "metrics": [ { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-DWUUsedPercent", "aggregation": 3, "splitBy": null, "columnName": "DWU Usaed %" }, { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-CPUPercent", "aggregation": 3, "columnName": "CPU Used %" } ], "title": "DWU Resource Utilization", "showOpenInMe": true, "showCreateAlertRule": true, "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "showPin": true, "name": "metric - 1" }, { "type": 10, "content": { "chartId": "workbookb954d4a0-82ef-4409-88fb-837aaff80c8d", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.synapse/workspaces/sqlpools", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 0 }, "metrics": [ { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-ActiveQueries", "aggregation": 1, "splitBy": null }, { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-QueuedQueries", "aggregation": 1 } ], "title": "Active and Queued Queries", "showOpenInMe": true, "showCreateAlertRule": true, "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "showPin": true, "name": "metric - 1" }, { "type": 10, "content": { "chartId": "workbookb954d4a0-82ef-4409-88fb-837aaff80c8d", "version": "MetricsItem/2.0", "size": 0, "chartType": 3, "resourceType": "microsoft.synapse/workspaces/sqlpools", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 0 }, "metrics": [ { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-LocalTempDBUsedPercent", "aggregation": 3, "splitBy": null, "columnName": "TempDB Utilization Percentage" } ], "title": "TempDB Utilization", "showOpenInMe": true, "showCreateAlertRule": true, "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "showPin": true, "name": "metric - 1 - Copy" }, { "type": 10, "content": { "chartId": "workbookb954d4a0-82ef-4409-88fb-837aaff80c8d", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.synapse/workspaces/sqlpools", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 0 }, "metrics": [ { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool Workload management-WLGAllocationBySystemPercent", "aggregation": 3, "splitBy": null, "columnName": "Workload Group Allocation by System %" } ], "title": "Workload Group Utilization", "showOpenInMe": true, "showCreateAlertRule": true, "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "showPin": true, "name": "Workload Group Utilization" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Long-Running Queries - Just Actual Queries\r\n//If 'Command' is empty - you need to set a bigger time window, the older record with the command is outside of your window\r\nSynapseSqlPoolExecRequests \r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where StatementType !in ('Batch','Execute')\r\n| summarize //Session_ID=any(SessionId),\r\n Request_ID=any(RequestId),\r\n //Submit_Time=max(SubmitTime),\r\n Start_Time=max(StartTime),\r\n End_Time=max(EndTime),\r\n Command=any(Command),\r\n Status=min(Status), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType),\r\n Resource_class=any(ResourceClass)\r\n by RequestId\r\n| summarize ElapsedTime_min=bin(anyif(((End_Time - Start_Time)/1m),Start_Time > ago(30d)),1),\r\n //Session_ID=any(Session_ID), \r\n // Submit_Time=any(Submit_Time) ,\r\n Start_Time=any(Start_Time), \r\n End_Time=any(End_Time),\r\n Command=any(Command),\r\n Status=any(Status),\r\n Statement_Type=any(Statement_Type)\r\n ,Resource_class=any(Resource_class) \r\n by Request_ID\r\n| where End_Time > ago(365d)\r\n| summarize count() by Status, bin(End_Time,5m)\r\n| render barchart \r\n", "size": 0, "title": "Query Completion Count by End Time - 5m buckets", "color": "redBright", "timeContext": { "durationMs": 1209600000 }, "timeContextFromParameter": "TimeRange", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "chartSettings": { "seriesLabelSettings": [ { "seriesName": "Completed", "color": "green" }, { "seriesName": "Failed", "color": "red" }, { "seriesName": "Cancelled", "color": "yellow" } ] } }, "name": "query - 4" }, { "type": 1, "content": { "json": "Use the buttons below to filter the next chart for Success or Failed queries. In many cases a failed query may not have a 'Command' column populated depending on what stage the query failed in. ", "style": "info" }, "customWidth": "25", "name": "text - 3" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "e2a833ac-48b4-4ccd-bbcd-33fccf1dbd75", "version": "KqlParameterItem/1.0", "name": "QueryCompletionType", "type": 1, "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 } } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 4" }, { "type": 11, "content": { "version": "LinkItem/1.0", "style": "nav", "links": [ { "id": "8e89112f-c67f-42c0-9622-02fa306fb7a5", "cellValue": "QueryCompletionType", "linkTarget": "parameter", "linkLabel": "All Queries", "subTarget": "''", "style": "primary" }, { "id": "6abe39c7-4d4e-4c45-aa54-dc9a4c5e876e", "cellValue": "QueryCompletionType", "linkTarget": "parameter", "linkLabel": "Success Only", "subTarget": "Completed", "preText": "", "style": "secondary" }, { "id": "e41b4a0b-8464-491e-92be-a57217d6dcac", "cellValue": "QueryCompletionType", "linkTarget": "parameter", "linkLabel": "Failures Only", "subTarget": "Failed", "preText": "", "style": "secondary" } ] }, "name": "links - 11" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Long-Running Queries - Just Actual Queries\r\n//If 'Command' is empty - you need to set a bigger time window, the older record with the command is outside of your window\r\nSynapseSqlPoolExecRequests \r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where StatementType !in ('Batch','Execute')\r\n| summarize //Session_ID=any(SessionId),\r\n Request_ID=any(RequestId),\r\n Start_Time=max(StartTime),\r\n End_Time=max(EndTime),\r\n Command=any(Command),\r\n Status=min(Status), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType),\r\n Resource_class=any(ResourceClass)\r\n by RequestId\r\n| summarize ElapsedTime_min=bin(anyif(((End_Time - Start_Time)/1m),Start_Time > ago(30d)),1),\r\n Start_Time=any(Start_Time), \r\n End_Time=any(End_Time),\r\n Command=any(Command),\r\n Status=any(Status),\r\n Statement_Type=any(Statement_Type)\r\n ,Resource_class=any(Resource_class) \r\n by Request_ID\r\n| where Status has '{QueryCompletionType}'\r\n| order by Start_Time\r\n\r\n", "size": 0, "title": "Query Completions - use above buttons to filter", "color": "redBright", "timeContext": { "durationMs": 1209600000 }, "timeContextFromParameter": "TimeRange", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "rowLimit": 100 }, "chartSettings": { "seriesLabelSettings": [ { "seriesName": "Completed", "color": "green" }, { "seriesName": "Failed", "color": "red" }, { "seriesName": "Cancelled", "color": "yellow" } ] } }, "name": "query - 4 - Copy" } ] }, "name": "Query Completions", "styleSettings": { "showBorder": true } }, { "type": 10, "content": { "chartId": "workbook1afc57e6-0b32-4968-b299-db319bd21635", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.synapse/workspaces/sqlpools", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 0 }, "metrics": [ { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-Connections", "aggregation": 1, "splitBy": null }, { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-ConnectionsBlockedByFirewall", "aggregation": 1 } ], "title": "Successful and Failed Connections", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "name": "metric - 5" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 3, "content": { "version": "KqlItem/1.0", "query": " SQLSecurityAuditEvents\r\n | where LogicalServerName == '{LogicalServerName}'\r\n | where ActionName in ('DATABASE AUTHENTICATION SUCCEEDED','DATABASE AUTHENTICATION FAILED')\r\n | project SourceSystem,ClientTlsVersion ,Succeeded,SessionId,ClientIp,SessionServerPrincipalName,ServerPrincipalName,DatabasePrincipalName,ApplicationName,HostName,TimeGenerated\r\n | summarize count() by Succeeded,bin(TimeGenerated,1m)\r\n | render barchart\r\n\r\n\r\n\r\n", "size": 0, "title": "Database Authentication success/failure rate", "timeContext": { "durationMs": 2592000000 }, "timeContextFromParameter": "TimeRange", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "chartSettings": { "xAxis": "TimeGenerated", "group": "succeeded_s", "createOtherGroup": null } }, "name": "query - 8" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "f7485a11-48df-4b61-a70e-9f56d6a00ec6", "version": "KqlParameterItem/1.0", "name": "AuthResult", "type": 1, "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 } } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 3" }, { "type": 11, "content": { "version": "LinkItem/1.0", "style": "nav", "links": [ { "id": "2ed22e0a-2b53-4ed0-8f65-d2c621f34dad", "cellValue": "AuthResult", "linkTarget": "parameter", "linkLabel": "All Authentications", "subTarget": "''", "style": "primary" }, { "id": "2789ab13-ae8a-472e-bad4-9c9bdc934d4d", "cellValue": "AuthResult", "linkTarget": "parameter", "linkLabel": "Success Only", "subTarget": "true", "style": "secondary" }, { "id": "5cf4ddd4-e189-4b71-b456-0d4f1572a0a3", "cellValue": "AuthResult", "linkTarget": "parameter", "linkLabel": "Failures Only", "subTarget": "false", "style": "secondary" } ] }, "name": "links - 10" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": " SQLSecurityAuditEvents\r\n | where LogicalServerName == '{LogicalServerName}'\r\n | where ActionName in ('DATABASE AUTHENTICATION SUCCEEDED','DATABASE AUTHENTICATION FAILED')\r\n | where Succeeded == '{AuthResult}'\r\n | project SourceSystem,ClientTlsVersion ,Succeeded,SessionId,ClientIp,SessionServerPrincipalName,ServerPrincipalName,DatabasePrincipalName,ApplicationName,HostName,TimeGenerated\r\n | summarize count() by Succeeded,bin(TimeGenerated,1m)\r\n\r\n\r\n\r\n\r\n\r\n", "size": 0, "title": "Database Authentication success/failure rate", "noDataMessage": "Please select a button above", "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "rowLimit": 100 }, "chartSettings": { "xAxis": "TimeGenerated", "group": "succeeded_s", "createOtherGroup": null, "showLegend": true } }, "name": "query - 8 - Copy" } ] }, "conditionalVisibility": { "parameterName": "AuditingState", "comparison": "isEqualTo", "value": "enabled" }, "name": "Database Authentication Group", "styleSettings": { "showBorder": true } }, { "type": 10, "content": { "chartId": "workbook993837ad-66d6-4cbc-ae1a-7c3f6623236b", "version": "MetricsItem/2.0", "size": 0, "chartType": 2, "resourceType": "microsoft.synapse/workspaces/sqlpools", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 1209600000 }, "metrics": [ { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-AdaptiveCacheUsedPercent", "aggregation": 3, "splitBy": null }, { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-AdaptiveCacheHitPercent", "aggregation": 3 } ], "title": "Adaptive Cache Used vs Hit Percentage", "showCreateAlertRule": true, "gridSettings": { "rowLimit": 10000 } }, "name": "metric - 6" } ] }, "conditionalVisibilities": [ { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "Overview" }, { "parameterName": "DiagnosticsState", "comparison": "isEqualTo", "value": "enabled" } ], "name": "overviewGroup" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 10, "content": { "chartId": "workbook4a9cf761-cce2-45b2-8947-8a9428ec7e1c", "version": "MetricsItem/2.0", "size": 0, "chartType": 3, "resourceType": "microsoft.synapse/workspaces/sqlpools", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 2592000000 }, "metrics": [ { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-LocalTempDBUsedPercent", "aggregation": 3, "splitBy": null, "columnName": "TempDB Util" } ], "title": "TempDB Max and Avg Utilization", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "name": "metric - 0" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "19ee48f5-8f4e-4939-a0ef-c6bf656a93f9", "version": "KqlParameterItem/1.0", "name": "WeightParameter", "type": 1, "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 } }, { "id": "00553ec8-1a41-4dd9-a024-d607639c9bbb", "version": "KqlParameterItem/1.0", "name": "RequestID", "type": 1, "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 }, "value": "" } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 3" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databaseResourceName = '{DatabaseResourceName}';\r\n//Weighted query steps\r\nSynapseSqlPoolRequestSteps \r\n| where _ResourceId == databaseResourceName\r\n| where RowCount > 0\r\n| summarize sum(RowCount) by RequestId, OperationType\r\n| order by sum_RowCount desc\r\n| limit 20\r\n| render columnchart ", "size": 0, "title": "20 Largest Query Steps by Most Rows Moved", "timeContext": { "durationMs": 2592000000 }, "timeContextFromParameter": "TimeRange", "exportFieldName": "Request_ID", "exportParameterName": "RequestID", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "chartSettings": { "xAxis": "RequestId", "group": "OperationType", "createOtherGroup": 20, "showLegend": true } }, "name": "query - 1 - Copy" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "8afacdd5-2690-48d0-b125-fb118378e90c", "version": "KqlParameterItem/1.0", "name": "WeightParameter", "type": 1, "value": "Unweighted", "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 } } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 8" }, { "type": 11, "content": { "version": "LinkItem/1.0", "style": "nav", "links": [ { "id": "c98d3722-9907-43ab-9306-1957d6f7f858", "cellValue": "WeightParameter", "linkTarget": "parameter", "linkLabel": "Weighted Rowcounts", "subTarget": "Weighted", "preText": "", "postText": "", "style": "secondary" }, { "id": "a06ae99a-ad62-45e9-8c25-c219b81f59c0", "cellValue": "WeightParameter", "linkTarget": "parameter", "linkLabel": "Unweighted Rowcounts", "subTarget": "Unweighted", "preText": "", "postText": "", "style": "secondary" } ] }, "name": "links - 3" }, { "type": 1, "content": { "json": "Current Setting: {WeightParameter}", "style": "info" }, "customWidth": "25", "name": "text - 4" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//let databaseResourceName = '{DatabaseResourceName}';\r\n//Weighted query steps\r\nlet RequestSteps = SynapseSqlPoolRequestSteps\r\n//| where _ResourceId == databaseResourceName\r\n//| where RowCount > 10000000\r\n| extend Step_Elapsed_Min = round((EndTime - StartTime) /1m, 2)\r\n| extend Weighted_cnt = iff('{WeightParameter}'=='Weighted',(case(OperationType == 'BroadcastMoveOperation', (RowCount*10), RowCount)),RowCount)\r\n| project-rename StepStatus = Status, StepStart = StartTime, StepEnd = EndTime//, StepResource = Resource\r\n| top 100 by Weighted_cnt desc\r\n| order by Weighted_cnt desc\r\n| project Request_ID=RequestId,OperationType, RowCount,Weighted_cnt,Step_Elapsed_Min, StepStart, StepEnd, StepStatus, StepIndex;\r\nRequestSteps | join (\r\nSynapseSqlPoolExecRequests\r\n//| where _ResourceId == databaseResourceName\r\n| where StatementType !in ('Batch','Execute')\r\n| summarize //Session_ID=any(SessionId),\r\n Request_ID=any(RequestId),\r\n //Submit_Time=max(SubmitTime),\r\n Start_Time=max(StartTime),\r\n End_Time=max(EndTime),\r\n Command=any(Command),\r\n Status=min(Status), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType),\r\n Resource_class=any(ResourceClass)\r\n by RequestId\r\n| summarize //Session_ID=any(Session_ID), \r\n//Submit_Time=any(Submit_Time) ,\r\nStart_Time=any(Start_Time), End_Time=any(End_Time),Command=any(Command),Status=any(Status),Statement_Type=any(Statement_Type),Resource_class=any(Resource_class) by Request_ID\r\n//| order by Step_Elapsed_Min desc\r\n| extend Request_Elapsed_Min = round((End_Time - Start_Time)/1m, 2)\r\n| project-rename ReqStatus = Status, ReqStart = Start_Time, ReqEnd = End_Time\r\n) on Request_ID\r\n| project-reorder //Session_ID, \r\nRequest_ID, Request_Elapsed_Min, ReqStart, ReqEnd, ReqStatus,StepIndex, OperationType, RowCount,Weighted_cnt,Step_Elapsed_Min, StepStart, StepEnd, StepStatus, Statement_Type, Command, Resource_class\r\n| order by Weighted_cnt desc\r\n| limit 20", "size": 3, "title": "20 Largest Query Steps by Most Rows Moved", "timeContext": { "durationMs": 2592000000 }, "timeContextFromParameter": "TimeRange", "exportFieldName": "Request_ID1", "exportParameterName": "RequestID", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "sortBy": [ { "itemKey": "Weighted_cnt", "sortOrder": 2 } ] }, "sortBy": [ { "itemKey": "Weighted_cnt", "sortOrder": 2 } ] }, "name": "query - 1" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databaseResourceName = '{DatabaseResourceName}';\r\n//Long-Running Queries - Just Actual Queries\r\n//If 'Command' is empty - you need to set a bigger time window, the older record with the command is outside of your window\r\nSynapseSqlPoolExecRequests\r\n| where _ResourceId == databaseResourceName\r\n| where StatementType !in ('Batch','Execute')\r\n| summarize //Session_ID=any(SessionId),\r\n Request_ID=any(RequestId),\r\n Start_Time=max(StartTime),\r\n End_Time=max(EndTime),\r\n Command=any(Command),\r\n Status=min(Status), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType),\r\n Resource_class=any(ResourceClass)\r\n by RequestId\r\n| summarize ElapsedTime_min=bin(anyif(((End_Time - Start_Time)/1m),Start_Time > ago(30d)),1),\r\n Start_Time=any(Start_Time), \r\n End_Time=any(End_Time),\r\n Command=any(Command),\r\n Status=any(Status),\r\n Statement_Type=any(Statement_Type)\r\n ,Resource_class=any(Resource_class) \r\n by Request_ID\r\n| where Request_ID == '{RequestID}' and Request_ID != ''\r\n\r\n", "size": 4, "title": "Selected Query", "noDataMessage": "Select a query above to view details", "noDataMessageStyle": 4, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "35%" } } ] } }, "name": "query - 6" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolRequestSteps \r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where RequestId == '{RequestID}' and RequestId != '' //Put your QueryID here\r\n| where Status != 'Running'\r\n| summarize max(StartTime),max(EndTime),max(RequestId),max(OperationType),max(RowCount),max(Command),max(Status) by StepIndex\r\n| order by StepIndex asc", "size": 3, "title": "Query Plan", "noDataMessage": "Select a query above to view the plan", "noDataMessageStyle": 4, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 7" } ] }, "conditionalVisibilities": [ { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "TempDB" }, { "parameterName": "DiagnosticsState", "comparison": "isEqualTo", "value": "enabled" } ], "name": "TempDBGroup" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 1, "content": { "json": "## Search Criteria\r\nUse the following fields to search either using a query text snippet or using a Request ID. If using a query text snippet, try to keep it as simple as possible becuase minor changes in formatting may cause your queries not to show up in the results. It's best to pick something like a table name, then choose the proper query from the list that will populate. " }, "customWidth": "50", "name": "text - 4" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "4b98dd26-4ccf-420e-a990-8d015f27fb76", "version": "KqlParameterItem/1.0", "name": "SampleQID", "type": 1, "value": "999", "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 } }, { "id": "d5524dd5-cf7e-41cf-beb3-474b3290289e", "version": "KqlParameterItem/1.0", "name": "RequestId", "type": 1, "value": "", "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 } } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "initializeQueryInvestigationParameters" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "0c2128d0-d979-4562-a28c-e7ceb955f126", "version": "KqlParameterItem/1.0", "name": "RequestId", "type": 1, "value": "", "label": "Request Id Search" }, { "id": "29880874-2d41-4bd5-bf22-3e47ae8b1145", "version": "KqlParameterItem/1.0", "name": "QueryTextSnippet", "type": 1, "value": "", "timeContext": { "durationMs": 86400000 } } ], "style": "formVertical", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "customWidth": "60", "name": "parameters - 3" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolExecRequests\r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where StatementType !in ('Batch','Execute')\r\n| summarize \r\n Request_ID=max(RequestId), \r\n Start_Time=max(StartTime),\r\n End_Compile_Time=max(EndCompileTime), \r\n End_Time=max(EndTime), \r\n QueryText = any(Command), \r\n Last_Status=min(Status),\r\n Statement_Type=max(StatementType),\r\n Resource_class=max(ResourceClass) \r\n by RequestId\r\n| extend Elapsed_Time_s=(End_Time - Start_Time)/1s\r\n| where QueryText has '{QueryTextSnippet}'\r\nand RequestId has '{RequestId}'\r\n| summarize \r\n Executions = count(),\r\n SampleQID = any(RequestId),\r\n Elapsed_Time_s=max(Elapsed_Time_s)\r\n by QueryText\r\n| order by Elapsed_Time_s\r\n\r\n\r\n\r\n", "size": 0, "title": "Matching Queries", "timeContext": { "durationMs": 1209600000 }, "timeContextFromParameter": "TimeRange", "exportedParameters": [ { "fieldName": "SampleQID", "parameterName": "SampleQID" }, { "fieldName": "SampleQID", "parameterName": "RequestId", "parameterType": 1 }, { "fieldName": "QueryText", "parameterName": "QueryText", "parameterType": 1 } ], "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "50%" } } ], "sortBy": [ { "itemKey": "Elapsed_Time_s", "sortOrder": 2 } ] }, "sortBy": [ { "itemKey": "Elapsed_Time_s", "sortOrder": 2 } ] }, "name": "query - 0" }, { "type": 1, "content": { "json": "## DSQL Command " }, "conditionalVisibility": { "parameterName": "QueryText", "comparison": "isNotEqualTo" }, "name": "text - 8" }, { "type": 1, "content": { "json": "```{QueryText}```\r\n" }, "conditionalVisibility": { "parameterName": "QueryText", "comparison": "isNotEqualTo" }, "name": "ShowQueryText", "styleSettings": { "showBorder": true } }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolExecRequests\r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where StatementType !in ('Batch','Execute')\r\n| where RequestId == '{SampleQID}'\r\n| summarize \r\n Request_ID=max(RequestId), \r\n Start_Time=max(StartTime),\r\n End_Compile_Time=max(EndCompileTime), \r\n End_Time=max(EndTime), \r\n Command=max(Command), \r\n Last_Status=min(Status),\r\n Statement_Type=max(StatementType),\r\n Resource_class=max(ResourceClass) \r\n by RequestId\r\n| extend elapsedTime_sec = iif(End_Time > ago(365d),(End_Time - Start_Time)/1s,real(null)) \r\n| join kind=inner\r\n (SynapseSqlPoolExecRequests\r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where StatementType !in ('Batch','Execute')\r\n | summarize \r\n Request_ID=max(RequestId), \r\n Start_Time=max(StartTime),\r\n End_Compile_Time=max(EndCompileTime), \r\n End_Time=max(EndTime), \r\n Command=max(Command), \r\n Last_Status=min(Status),\r\n Statement_Type=max(StatementType),\r\n Resource_class=max(ResourceClass) \r\n by RequestId\r\n //| extend elapsedTime_sec = (End_Time - Start_Time)/1s\r\n | extend elapsedTime_sec = iif(End_Time > ago(365d),(End_Time - Start_Time)/1s,real(null)) \r\n )\r\non Command \r\n| project Request_ID1,Start_Time1,End_Compile_Time1,End_Time1,Last_Status1,Statement_Type1,Resource_class1,elapsedTime_sec1\r\n", "size": 0, "title": "All Executions of Selected Query Text", "noDataMessage": "Select a query above to see individual executions", "noDataMessageStyle": 4, "timeContext": { "durationMs": 1209600000 }, "timeContextFromParameter": "TimeRange", "exportFieldName": "Request_ID1", "exportParameterName": "RequestId", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "sortBy": [] }, "name": "query - 0 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolRequestSteps \r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where RequestId == '{RequestId}' and RequestId != ''\r\n| where Status != 'Running'\r\n| summarize max(StartTime),max(EndTime),max(RequestId),max(OperationType),max(RowCount),max(Command),max(Status) by StepIndex\r\n| order by StepIndex asc", "size": 3, "title": "Query Plan for Selected Query", "noDataMessage": "Select a Query Above to See the Query Plan", "noDataMessageStyle": 4, "timeContext": { "durationMs": 1209600000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 0 - Copy - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolExecRequests\r\n | where StatementType =='CreateStatistics'\r\n | where _ResourceId has '{DatabaseName}'\r\n | summarize \r\n Root_Query_Id=max(RootQueryId), \r\n Start_Time=max(StartTime),\r\n End_Compile_Time=max(EndCompileTime), \r\n End_Time=max(EndTime), \r\n Command=max(Command), \r\n Last_Status=min(Status),\r\n Statement_Type=max(StatementType),\r\n Resource_class=max(ResourceClass) \r\n by RequestId\r\n | where Root_Query_Id == '{RequestId}'", "size": 0, "title": "Triggered Auto-Stats Statements", "noDataMessage": "No triggered autostats statements found", "timeContext": { "durationMs": 1209600000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Submit_Time", "formatter": 0, "numberFormat": { "unit": 0, "options": { "style": "decimal" } } }, { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "100ch" } } ] } }, "name": "All triggered auto-stats statements" } ] }, "conditionalVisibilities": [ { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "QueryInvestigation" }, { "parameterName": "DiagnosticsState", "comparison": "isEqualTo", "value": "enabled" } ], "name": "QueryInvestigationGroup", "styleSettings": { "showBorder": true } }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 1, "content": { "json": "All Charts on this page are based on the last 7 days of data", "style": "info" }, "customWidth": "25", "name": "text - 5" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "533ff6bb-97cd-4aaa-9372-171cad378bcd", "version": "KqlParameterItem/1.0", "name": "QueryText", "type": 1, "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 } }, { "id": "99de0056-d4f3-465e-a27e-599d69b23c77", "version": "KqlParameterItem/1.0", "name": "RequestId", "type": 1, "value": "999", "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 } } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "initializeTempDBVariables" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Build cache count by day\r\nlet databaseResourceName = '{DatabaseResourceName}';\r\n//Long-Running Queries - Just Actual Queries\r\n//If 'Command' is empty - you need to set a bigger time window, the older record with the command is outside of your window\r\nSynapseSqlPoolExecRequests\r\n| where _ResourceId == databaseResourceName\r\n| where StatementType == 'BuildReplicatedTableCache'\r\n| where Command != \"\"\r\n| where ResourceClass != \"\"\r\n| project Command,TimeGenerated,RequestId\r\n| summarize LastRebuild=max(TimeGenerated),RebuildCount=count(RequestId) by Command\r\n| order by RebuildCount desc\r\n| limit 15\r\n", "size": 3, "title": "Top 15 Most Rebuilds by Table", "noDataMessage": "No replicated table rebuilds found in the last 7 days", "noDataMessageStyle": 4, "timeContext": { "durationMs": 604800000 }, "exportFieldName": "Command", "exportParameterName": "QueryText", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command_s", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "40%" } } ] } }, "name": "query - 0" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Build cache count by day\r\nlet databaseResourceName = '{DatabaseResourceName}';\r\nSynapseSqlPoolExecRequests\r\n| where _ResourceId == databaseResourceName\r\n| where StatementType == 'BuildReplicatedTableCache'\r\n| where Command == \"{QueryText}\"\r\n| where ResourceClass != \"\"\r\n| project Command,TimeGenerated,RequestId\r\n| summarize count() by Command,bin(TimeGenerated,24h)\r\n| limit 20\r\n| render timechart", "size": 0, "title": "Rebuilds per Day for Selected Table", "noDataMessage": "Select a query above to see runs by day", "noDataMessageStyle": 4, "timeContext": { "durationMs": 604800000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "chartSettings": { "group": "Command_s", "createOtherGroup": 20, "ySettings": { "min": 0 } } }, "name": "query - 0 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "//Build cache count by day\r\nlet databaseResourceName = '{DatabaseResourceName}';\r\n//Long-Running Queries - Just Actual Queries\r\n//If 'Command' is empty - you need to set a bigger time window, the older record with the command is outside of your window\r\nSynapseSqlPoolExecRequests\r\n| where _ResourceId == databaseResourceName\r\n| where StatementType == 'BuildReplicatedTableCache'\r\n| where Command != \"\"\r\n| where ResourceClass != \"\"\r\n| project Command,TimeGenerated,RequestId\r\n| summarize count() by Command, bin(TimeGenerated,24h)\r\n//| where count_ > 7\r\n| order by count_ desc\r\n\r\n", "size": 2, "title": "Rebuild Count by Table by Day", "noDataMessage": " Only tables with more than 7 total rebuilds will show up. If no talbes with that many rebuilds are found this chart will be empty", "noDataMessageStyle": 4, "timeContext": { "durationMs": 604800000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "categoricalbar", "gridSettings": { "sortBy": [ { "itemKey": "count_", "sortOrder": 1 } ] }, "sortBy": [ { "itemKey": "count_", "sortOrder": 1 } ], "tileSettings": { "showBorder": false, "titleContent": { "columnMatch": "Command_s", "formatter": 1 }, "leftContent": { "columnMatch": "count_", "formatter": 12, "formatOptions": { "palette": "auto" }, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "graphSettings": { "type": 0, "topContent": { "columnMatch": "Command_s", "formatter": 1 }, "centerContent": { "columnMatch": "count_", "formatter": 1, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "chartSettings": { "group": "Command_s", "createOtherGroup": 99, "showDataPoints": true } }, "name": "query - 0 - Copy - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "let databaseResourceName = '{DatabaseResourceName}';\r\n//Long-Running Queries - Just Actual Queries\r\n//If 'Command' is empty - you need to set a bigger time window, the older record with the command is outside of your window\r\nSynapseSqlPoolExecRequests\r\n| where _ResourceId == databaseResourceName\r\n| where StatementType == 'BuildReplicatedTableCache'\r\n| summarize Start_Time=max(StartTime), End_Time=max(EndTime), Command=max(Command), Statement_Type=max(StatementType), Resource_class=max(ResourceClass) by RequestId\r\n| join kind= inner\r\n(\r\n SynapseSqlPoolExecRequests\r\n | where _ResourceId == databaseResourceName\r\n | where StatementType == 'BuildReplicatedTableCache'\r\n | where StatementType == 'BuildReplicatedTableCache'\r\n | where EndTime > ago(7d)\r\n | where StartTime > ago(7d)\r\n | extend elapsedTime_min = (EndTime - StartTime)/1m\r\n | order by elapsedTime_min desc\r\n | project RequestId,elapsedTime_min \r\n)\r\non RequestId\r\n| order by elapsedTime_min desc\r\n| project RequestId,Start_Time,End_Time,Elapsed_Time=round(elapsedTime_min,1) ,Command\r\n| limit 15\r\n", "size": 3, "title": "Top 15 Elapsed Time per Rebuild", "noDataMessageStyle": 4, "timeContext": { "durationMs": 604800000 }, "exportFieldName": "RequestId", "exportParameterName": "RequestId", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "40%" } } ] } }, "name": "query - 3" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": " let databaseResourceName = '{DatabaseResourceName}';\r\nSynapseSqlPoolRequestSteps \r\n| where _ResourceId == databaseResourceName\r\n| where RequestId == '{RequestId}'\r\n| where Status != 'Running'\r\n| summarize max(StartTime),max(EndTime),max(RequestId),max(OperationType),max(RowCount),max(Command),max(Status) by StepIndex\r\n| order by StepIndex asc", "size": 3, "title": "Query Plan for Selected Query", "noDataMessage": "Select a query above to view plan", "noDataMessageStyle": 4, "timeContext": { "durationMs": 604800000 }, "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 4" } ] }, "conditionalVisibilities": [ { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "ReplicatedTables" }, { "parameterName": "DiagnosticsState", "comparison": "isEqualTo", "value": "enabled" } ], "name": "ReplicatedTablesGroup" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 10, "content": { "chartId": "workbook72446028-6edb-4cb0-8952-e0c13bda488f", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.synapse/workspaces/sqlpools", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 1209600000 }, "metrics": [ { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool Workload management-WLGAllocationBySystemPercent", "aggregation": 3, "splitBy": "WorkloadGroup" } ], "title": "Workload Group Allocation By System Percent", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "name": "metric - 0" }, { "type": 10, "content": { "chartId": "workbookc898119a-7381-469d-b51a-d505b4f80e73", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.synapse/workspaces/sqlpools", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 0 }, "metrics": [ { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool Workload management-WLGActiveQueries", "aggregation": 1, "splitBy": null } ], "title": "Query Count by Workload Group", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "customWidth": "50", "name": "metric - 1" }, { "type": 10, "content": { "chartId": "workbook8d175f6c-427b-47fc-85ea-37edd0be707c", "version": "MetricsItem/2.0", "size": 0, "chartType": 1, "resourceType": "microsoft.synapse/workspaces/sqlpools", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 1209600000 }, "metrics": [ { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-WLGQueuedQueries", "aggregation": 1, "splitBy": "WorkloadGroup" } ], "title": "Queued Queries by Workload Group", "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "name": "Queued Queries by Workload Group" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "parameters": [ { "id": "6f50577d-7b00-4e4a-acf9-d45c7a5ee813", "version": "KqlParameterItem/1.0", "name": "WorkloadGroupName", "type": 2, "query": "SynapseSqlPoolExecRequests \r\n| where _ResourceId == '{DatabaseResourceName}'\r\n and ResourceClass != \"\"\r\n| distinct ResourceClass", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "value": null, "typeSettings": { "additionalResourceOptions": [], "showDefault": false }, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 2" }, { "type": 10, "content": { "chartId": "workbook3da1d18a-1bf5-46c5-b3b7-211f71d329cc", "version": "MetricsItem/2.0", "size": 0, "chartType": 2, "resourceType": "microsoft.synapse/workspaces/sqlpools", "metricScope": 0, "resourceParameter": "DatabaseResourceName", "resourceIds": [ "{DatabaseResourceName}" ], "timeContextFromParameter": "TimeRange", "timeContext": { "durationMs": 1209600000 }, "metrics": [ { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-WLGActiveQueries", "aggregation": 1, "splitBy": null }, { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-WLGQueuedQueries", "aggregation": 1 }, { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-WLGAllocationBySystemPercent", "aggregation": 3 }, { "namespace": "microsoft.synapse/workspaces/sqlpools", "metric": "microsoft.synapse/workspaces/sqlpools-SQL dedicated pool-WLGEffectiveCapResourcePercent", "aggregation": 3 } ], "filters": [ { "id": "5", "key": "WorkloadGroup", "operator": 0, "valueParam": "WorkloadGroupName" } ], "timeBrushParameterName": "TimeRange", "timeBrushExportOnlyWhenBrushed": true, "gridSettings": { "rowLimit": 10000 } }, "name": "metric - 3" } ] }, "conditionalVisibilities": [ { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "WorkloadManagement" }, { "parameterName": "DiagnosticsState", "comparison": "isEqualTo", "value": "enabled" } ], "name": "WorkloadManagementGroup" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 1, "content": { "json": "## Select a Principal or Application name to filter results - leave to 'unset' to view all results\r\nSQL Auditing must be enabled and sending to the same Log Analytics Workspace for this page to work. " }, "name": "text - 5" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "parameters": [ { "id": "8d25c043-d1ff-4546-a1fa-f4bcbfdab8af", "version": "KqlParameterItem/1.0", "name": "User", "type": 2, "description": "User to filter subsequent queries - leave to 'unset' for all users", "query": "SQLSecurityAuditEvents \r\n| where LogicalServerName == '{LogicalServerName}'\r\n| summarize by ServerPrincipalName", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "value": null, "typeSettings": { "additionalResourceOptions": [], "showDefault": false }, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, { "id": "aa766d64-693f-4024-b4a4-b5b56b28376b", "version": "KqlParameterItem/1.0", "name": "Application", "type": 2, "query": "SQLSecurityAuditEvents \r\n| where LogicalServerName == '{LogicalServerName}'\r\n| summarize by ApplicationName", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "value": null, "typeSettings": { "additionalResourceOptions": [], "showDefault": false }, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "customWidth": "30", "name": "parameters - 1" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SQLSecurityAuditEvents \r\n| where LogicalServerName == '{LogicalServerName}'\r\n| where DurationMs > 0\r\n| extend duration_seconds = DurationMs /1000.0\r\n| where Statement != 'select @@version'\r\n| where Statement != 'SELECT @@SPID;'\r\n| where ServerPrincipalName has '{User}'\r\n| where ApplicationName has '{Application}'\r\n| project ServerPrincipalName, EventTime, LogicalServerName, DurationMs, duration_seconds, AffectedRows, Statement, ApplicationName\r\n| summarize duration_seconds = round(sum(duration_seconds)) , query_count = count() by EventDay = bin(EventTime,1d), UserName = ServerPrincipalName, Application = ApplicationName \r\n| order by EventDay, duration_seconds desc", "size": 0, "title": "Query Summary for Selected User {User} {Application}", "noDataMessage": "Select a user to see query activity", "timeContext": { "durationMs": 604800000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 0 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SQLSecurityAuditEvents \r\n| where LogicalServerName == '{LogicalServerName}'\r\n| where DurationMs > 0\r\n| extend duration_seconds = DurationMs /1000.0\r\n| where Statement != 'select @@version'\r\n| where Statement != 'SELECT @@SPID;'\r\n| where ServerPrincipalName has '{User}'\r\n| where ApplicationName has '{Application}'\r\n| project ServerPrincipalName, EventTime, LogicalServerName, DurationMs, duration_seconds, AffectedRows, Statement, ApplicationName\r\n| summarize duration_seconds = round(sum(duration_seconds)) , query_count = count() by EventDay = bin(EventTime,1d), UserName = ServerPrincipalName, Application = ApplicationName \r\n| order by EventDay, duration_seconds desc", "size": 0, "title": "Query Summary for Selected User {User} {Application}", "noDataMessage": "Select a user to see query activity", "timeContext": { "durationMs": 604800000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "unstackedbar", "tileSettings": { "showBorder": false, "titleContent": { "columnMatch": "UserName", "formatter": 1 }, "leftContent": { "columnMatch": "duration_seconds", "formatter": 12, "formatOptions": { "palette": "auto" }, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "graphSettings": { "type": 0, "topContent": { "columnMatch": "UserName", "formatter": 1 }, "centerContent": { "columnMatch": "duration_seconds", "formatter": 1, "numberFormat": { "unit": 17, "options": { "maximumSignificantDigits": 3, "maximumFractionDigits": 2 } } } }, "chartSettings": { "xAxis": "UserName" }, "mapSettings": { "locInfo": "LatLong", "sizeSettings": "duration_seconds", "sizeAggregation": "Sum", "legendMetric": "duration_seconds", "legendAggregation": "Sum", "itemColorSettings": { "type": "heatmap", "colorAggregation": "Sum", "nodeColorField": "duration_seconds", "heatmapPalette": "greenRed" } } }, "name": "query - 0 - Copy - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SQLSecurityAuditEvents \r\n | where LogicalServerName == \"{LogicalServerName}\"\r\n | where DurationMs > 0\r\n | extend duration_seconds = DurationMs /1000.0\r\n | where Statement != 'select @@version'\r\n | where Statement != 'SELECT @@SPID;'\r\n | where ServerPrincipalName has '{User}'\r\n | where ApplicationName has '{Application}'\r\n | project DatabaseName= DatabaseName, UserName= ServerPrincipalName, EventTime= EventTime, Host= HostName, duration_seconds = round(duration_seconds), Statement, QuerySource = ApplicationName , AffectedRows\r\n | project-reorder DatabaseName, UserName, Host, EventTime, duration_seconds, Statement, QuerySource\r\n\r\n\r\n\r\n\r\n\r\n", "size": 0, "title": "Queries {User} {Application}", "noDataMessage": "Select a user to see query activity", "timeContext": { "durationMs": 604800000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 0 - Copy - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SQLSecurityAuditEvents \r\n | where LogicalServerName == \"{LogicalServerName}\"\r\n | where DurationMs > 0\r\n | extend duration_seconds = DurationMs /1000.0\r\n | where Statement != 'select @@version'\r\n | where Statement != 'SELECT @@SPID;'\r\n | where ServerPrincipalName has '{User}'\r\n | where ApplicationName has '{Application}'\r\n | project DatabaseName= DatabaseName, UserName= ServerPrincipalName, EventTime= EventTime, Host= HostName, duration_seconds = round(duration_seconds), Statement, QuerySource = ApplicationName , AffectedRows\r\n | project-reorder AffectedRows,DatabaseName, UserName, Host, EventTime, duration_seconds, Statement, QuerySource\r\n\r\n\r\n\r\n\r\n\r\n", "size": 0, "timeContext": { "durationMs": 604800000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "barchart", "chartSettings": { "xAxis": "Host", "group": "UserName", "createOtherGroup": null, "showLegend": true } }, "name": "query - 6" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SQLSecurityAuditEvents\r\n| where LogicalServerName == \"{LogicalServerName}\"\r\n | where DurationMs > 0\r\n| extend Duration = round(DurationMs /1000.0)\r\n| extend TimeBin = case (datetime_part(\"Hour\",TimeGenerated) in (6,7,8,9,10,11,12), \"Morning_6-12\", datetime_part(\"Hour\",TimeGenerated) in (13,14,15,16,17,18), \"Afternoon_12-18\", \"Overnight_18-6\")\r\n| where ServerPrincipalName has '{User}'\r\n| where ApplicationName has '{Application}'\r\n| summarize QueryDuration = sum(Duration) by EventTime = bin(EventTime, 1d), TimeBin", "size": 0, "title": "Query Activity by time - sum(Duration) {User} {Application}", "noDataMessage": "Select a user to see query activity", "timeContext": { "durationMs": 604800000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "visualization": "barchart" }, "name": "query - 0 - Copy" } ] }, "conditionalVisibilities": [ { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "QueryAudit" }, { "parameterName": "AuditingState", "comparison": "isEqualTo", "value": "enabled" } ], "name": "QueryAuditGroup", "styleSettings": { "showBorder": true } }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "7fa3187e-9225-4faa-8f80-dc1bc40c5aab", "version": "KqlParameterItem/1.0", "name": "RequestId1", "type": 1, "value": "" } ], "style": "above", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "customWidth": "50", "name": "parameters - 3 - Copy" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "315fc476-469a-4d8d-b421-028d1113ab06", "version": "KqlParameterItem/1.0", "name": "RequestId2", "type": 1, "value": "", "timeContext": { "durationMs": 86400000 } } ], "style": "above", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "customWidth": "50", "name": "parameters - 2" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 9, "content": { "version": "KqlParameterItem/1.0", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "parameters": [ { "id": "1537c5b3-0b6c-4b1d-89be-946cd8268020", "version": "KqlParameterItem/1.0", "name": "QueryText1", "type": 1, "query": "SynapseSqlPoolExecRequests\r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where StatementType !in ('Batch','Execute') and RequestId == '{RequestId1}'\r\n| summarize max(Command)", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" } ], "style": "above", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 5" }, { "type": 1, "content": { "json": "#### {RequestId1} Query Text" }, "conditionalVisibility": { "parameterName": "RequestId1", "comparison": "isNotEqualTo" }, "name": "text - 5" }, { "type": 1, "content": { "json": "```{QueryText1}```" }, "conditionalVisibility": { "parameterName": "RequestId1", "comparison": "isNotEqualTo" }, "name": "text - 3" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolExecRequests\r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where StatementType !in ('Batch','Execute') and RequestId == '{RequestId1}'\r\n| summarize \r\n Request_ID=any(RequestId),\r\n Start_Time=max(StartTime),\r\n End_Time=max(EndTime),\r\n //Command=any(Command),\r\n Status=min(Status), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType),\r\n Resource_class=any(ResourceClass)\r\n by RequestId\r\n| summarize Start_Time=any(Start_Time), End_Time=any(End_Time),ElapsedTime_min=anyif((End_Time - Start_Time)/1m,Start_Time > ago(30d))\r\n//,Command=any(Command)\r\n,Status=any(Status),Statement_Type=any(Statement_Type),Resource_class=any(Resource_class) by Request_ID\r\n| project ElapsedTime_min\r\n//,Command\r\n,Resource_class,Start_Time\r\n//,End_Time\r\n,Statement_Type,Status\r\n", "size": 4, "title": "Exec Requests", "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "conditionalVisibility": { "parameterName": "RequestId1", "comparison": "isNotEqualTo" }, "name": "query - 2" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolRequestSteps \r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where RequestId == '{RequestId1}' and RequestId != ''\r\n| summarize StartTime=max(StartTime)\r\n ,EndTime=max(EndTime)\r\n ,RequestID=max(RequestId)\r\n ,Operation=max(OperationType)\r\n ,RowCount=max(RowCount)\r\n ,Command=max(Command)\r\n ,Status=min(Status)\r\n by StepIndex\r\n| order by StepIndex asc\r\n| project StartTime,EndTime,Operation,RowCount,Command,Status,StepIndex", "size": 3, "title": "Request Steps", "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "conditionalVisibility": { "parameterName": "RequestId1", "comparison": "isNotEqualTo" }, "name": "StepQueryRequest1", "styleSettings": { "margin": "0", "padding": "10px" } }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolExecRequests\r\n | where StatementType =='CreateStatistics'\r\n | where _ResourceId has '{DatabaseName}'\r\n | summarize \r\n Root_Query_Id=max(RootQueryId), \r\n Start_Time=max(StartTime),\r\n End_Compile_Time=max(EndCompileTime), \r\n End_Time=max(EndTime), \r\n Command=max(Command), \r\n Last_Status=min(Status),\r\n Statement_Type=max(StatementType),\r\n Resource_class=max(ResourceClass) \r\n by RequestId\r\n | where Root_Query_Id == '{RequestId1}'", "size": 0, "title": "Triggered Auto-Stats Statements", "noDataMessage": "No triggered autostats statements found", "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Submit_Time", "formatter": 0, "numberFormat": { "unit": 0, "options": { "style": "decimal" } } }, { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "100ch" } } ], "sortBy": [ { "itemKey": "End_Time", "sortOrder": 2 } ] }, "sortBy": [ { "itemKey": "End_Time", "sortOrder": 2 } ] }, "conditionalVisibility": { "parameterName": "RequestId1", "comparison": "isNotEqualTo" }, "name": "All triggered auto-stats statements" } ] }, "customWidth": "50", "name": "RequestId1Group", "styleSettings": { "showBorder": true } }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 9, "content": { "version": "KqlParameterItem/1.0", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "parameters": [ { "id": "1537c5b3-0b6c-4b1d-89be-946cd8268020", "version": "KqlParameterItem/1.0", "name": "QueryText2", "type": 1, "query": "SynapseSqlPoolExecRequests\r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where StatementType !in ('Batch','Execute') and RequestId == '{RequestId2}'\r\n| summarize max(Command)", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "isHiddenWhenLocked": true, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" } ], "style": "above", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 5" }, { "type": 1, "content": { "json": "#### {RequestId2} Query Text" }, "conditionalVisibility": { "parameterName": "RequestId2", "comparison": "isNotEqualTo" }, "name": "text - 5" }, { "type": 1, "content": { "json": "```{QueryText2}```" }, "conditionalVisibility": { "parameterName": "RequestId2", "comparison": "isNotEqualTo" }, "name": "text - 4" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolExecRequests\r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where StatementType !in ('Batch','Execute') and RequestId == '{RequestId2}'\r\n| summarize \r\n Request_ID=any(RequestId),\r\n Start_Time=max(StartTime),\r\n End_Time=max(EndTime),\r\n //Command=any(Command),\r\n Status=min(Status), //This works because Completed/Failed/Cancelled are all below running, below suspended. This happens to work out where the min is the current status\r\n Statement_Type=any(StatementType),\r\n Resource_class=any(ResourceClass)\r\n by RequestId\r\n| summarize Start_Time=any(Start_Time), End_Time=any(End_Time),ElapsedTime_min=anyif((End_Time - Start_Time)/1m,Start_Time > ago(30d))\r\n//,Command=any(Command)\r\n,Status=any(Status),Statement_Type=any(Statement_Type),Resource_class=any(Resource_class) by Request_ID\r\n| project ElapsedTime_min\r\n//,Command\r\n,Resource_class,Start_Time\r\n//,End_Time\r\n,Statement_Type,Status\r\n", "size": 4, "title": "Exec Requests", "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "conditionalVisibility": { "parameterName": "RequestId2", "comparison": "isNotEqualTo" }, "name": "query - 2 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolRequestSteps \r\n| where _ResourceId == '{DatabaseResourceName}'\r\n| where RequestId == '{RequestId2}' and RequestId != ''\r\n| summarize StartTime=max(StartTime)\r\n ,EndTime=max(EndTime)\r\n ,RequestID=max(RequestId)\r\n ,Operation=max(OperationType)\r\n ,RowCount=max(RowCount)\r\n ,Command=max(Command)\r\n ,Status=min(Status)\r\n by StepIndex\r\n| order by StepIndex asc\r\n| project StartTime,EndTime,Operation,RowCount,Command,Status,StepIndex", "size": 3, "title": "Request Steps", "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "conditionalVisibility": { "parameterName": "RequestId2", "comparison": "isNotEqualTo" }, "name": "query - 4 - Copy", "styleSettings": { "padding": "10px" } }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolExecRequests\r\n | where StatementType =='CreateStatistics'\r\n | where _ResourceId has '{DatabaseName}'\r\n | summarize \r\n Root_Query_Id=max(RootQueryId), \r\n Start_Time=max(StartTime),\r\n End_Compile_Time=max(EndCompileTime), \r\n End_Time=max(EndTime), \r\n Command=max(Command), \r\n Last_Status=min(Status),\r\n Statement_Type=max(StatementType),\r\n Resource_class=max(ResourceClass) \r\n by RequestId\r\n | where Root_Query_Id == '{RequestId2}'", "size": 0, "title": "Triggered Auto-Stats Statements", "noDataMessage": "No triggered autostats statements found", "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Submit_Time", "formatter": 0, "numberFormat": { "unit": 0, "options": { "style": "decimal" } } }, { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "100ch" } } ] } }, "conditionalVisibility": { "parameterName": "RequestId2", "comparison": "isNotEqualTo" }, "name": "All triggered auto-stats statements" } ] }, "customWidth": "50", "name": "RequestId2Group", "styleSettings": { "showBorder": true } } ] }, "conditionalVisibilities": [ { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "QueryComparison" }, { "parameterName": "DiagnosticsState", "comparison": "isEqualTo", "value": "enabled" } ], "name": "QueryComparison" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 1, "content": { "json": "## This tab is used to determine what statements triggerred autostats creation jobs. \r\nThe flow of autostats creation is as follows\r\n1. Query Submit Time\r\n2. \tCreate Statistics submit Time\r\n3. \tCreate Statistics end Time\r\n4. Query end_compile_time\r\n5. Query Start_Time\r\n6. Query End_Time\r\n\r\nFurther, if multiple stats are created, then the creation of all stats for this query will fall between query submit_time and end_compile_time. \r\n\r\nThe charts on this page allow you to search for an autostats job by requestID or my snippet of the autostats statement text, which can just be the schema, table, or column name. Then it will show you all commands that include that request ID or text. It will then show you all statements in the create stat statement because the query we are trying to identify will wait for all of those stats creations to complete before proceeding. \r\n\r\nThe last chart will list the statement that triggered the stats creation. " }, "name": "text - 6" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "df5b9b85-4188-4f2c-88cb-1369e09f6742", "version": "KqlParameterItem/1.0", "name": "RootQueryId", "type": 1, "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 } }, { "id": "560c9ec5-6341-4fa1-9ce6-35ff010151b1", "version": "KqlParameterItem/1.0", "name": "RequestId", "type": 1, "isHiddenWhenLocked": true, "timeContext": { "durationMs": 86400000 } } ], "style": "pills", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "name": "parameters - 5" }, { "type": 9, "content": { "version": "KqlParameterItem/1.0", "parameters": [ { "id": "0911bd4b-d471-480b-bdf4-1a2d4ba1ea6e", "version": "KqlParameterItem/1.0", "name": "RequestIdSearch", "type": 1, "value": "", "label": "RequestId for AutoStats Job" }, { "id": "c12e6495-4fd1-473c-8ffc-0bf502f54706", "version": "KqlParameterItem/1.0", "name": "QueryTextSnippet", "type": 1, "value": "", "timeContext": { "durationMs": 86400000 }, "label": "Snippet of autostats creation statement (Schema, table or column)" } ], "style": "formVertical", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces" }, "customWidth": "60", "name": "parameters - 3 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolExecRequests\r\n | where StatementType =='CreateStatistics'\r\n | where _ResourceId has '{DatabaseName}'\r\n| summarize \r\n Root_Query_Id=max(RootQueryId), \r\n Start_Time=max(StartTime),\r\n End_Time=max(EndTime), \r\n Command=max(Command), \r\n Last_Status=min(Status),\r\n Statement_Type=max(StatementType)\r\n by RequestId\r\n| where Command has 'CREATE STATISTICS _wa_sys'\r\n| where Command has '{QueryTextSnippet}' and RequestId has '{RequestIdSearch}'\r\n//| extend elapsedTime_sec = iif(End_Time > ago(365d),(End_Time - Submit_Time)/1s,real(null)) \r\n//| extend CompileTime_sec = (End_Compile_Time - Submit_Time)/1s\r\n//| order by elapsedTime_sec\r\n//| summarize \r\n // Executions = count(),\r\n // Max_Elapsed_Time_sec = bin(max(elapsedTime_sec),1),\r\n // Min_Elapsed_Time_sec = bin(min(elapsedTime_sec),1),\r\n // Variability_sec=bin((max(elapsedTime_sec)-min(elapsedTime_sec)),1),\r\n // SampleQID = any(RequestId),\r\n // SampleSessionID = any(Session_ID)\r\n // by Command\r\n//| order by Max_Elapsed_Time_sec\r\n\r\n\r\n", "size": 0, "title": "Matching Autostats Queries", "noDataMessageStyle": 4, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "exportedParameters": [ { "fieldName": "RequestId", "parameterName": "RequestId", "parameterType": 1 }, { "fieldName": "Root_Query_Id", "parameterName": "RootQueryId", "parameterType": 1 } ], "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "50%" } } ], "sortBy": [ { "itemKey": "Command", "sortOrder": 1 } ] }, "sortBy": [ { "itemKey": "Command", "sortOrder": 1 } ] }, "name": "query - 0 - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolExecRequests\r\n | where StatementType !='CreateStatistics'\r\n | where _ResourceId has '{DatabaseName}'\r\n | where RequestId == '{RootQueryId}'\r\n | summarize \r\n Start_Time=max(StartTime),\r\n End_Compile_Time=max(EndCompileTime), \r\n End_Time=max(EndTime), \r\n Command=max(Command), \r\n Last_Status=min(Status),\r\n Statement_Type=max(StatementType),\r\n Resource_class=max(ResourceClass) \r\n by RequestId", "size": 3, "title": "Statement that Triggered Selected Autostat", "noDataMessage": "Select an autostats query above to see what query triggered it", "noDataMessageStyle": 4, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ], "gridSettings": { "formatters": [ { "columnMatch": "Command", "formatter": 0, "formatOptions": { "customColumnWidthSetting": "150ch" } } ], "sortBy": [ { "itemKey": "Command", "sortOrder": 1 } ] }, "sortBy": [ { "itemKey": "Command", "sortOrder": 1 } ] }, "name": "query - 0 - Copy - Copy - Copy - Copy" }, { "type": 3, "content": { "version": "KqlItem/1.0", "query": "SynapseSqlPoolExecRequests\r\n | where StatementType =='CreateStatistics'\r\n | where _ResourceId has '{DatabaseName}'\r\n| summarize \r\n Root_Query_Id=max(RootQueryId), \r\n Start_Time=max(StartTime),\r\n End_Time=max(EndTime), \r\n Command=max(Command), \r\n Last_Status=min(Status),\r\n Statement_Type=max(StatementType)\r\n by RequestId\r\n| where Command has 'CREATE STATISTICS _wa_sys'\r\n| where Root_Query_Id == '{RootQueryId}'", "size": 3, "title": "All Stats Statements Triggered by selected Query", "noDataMessageStyle": 4, "timeContext": { "durationMs": 0 }, "timeContextFromParameter": "TimeRange", "queryType": 0, "resourceType": "microsoft.operationalinsights/workspaces", "crossComponentResources": [ "{LogAnalyticsWorkspace}" ] }, "name": "query - 13" } ] }, "conditionalVisibilities": [ { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "Statistics" }, { "parameterName": "DiagnosticsState", "comparison": "isEqualTo", "value": "enabled" } ], "name": "statistics" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 1, "content": { "json": "" }, "customWidth": "60", "showPin": false, "name": "Image" }, { "type": 1, "content": { "json": "Enable SQL Auditing to get additional visibility into user activity against your SQL Pool\r\n\r\nThis section provides additional monitoring coverage that is based on SQL Audit logs.
\r\nIf you have not activated SQL Auditing for your dedeciated SQL Pool, you must enable them to go to the same Log Analytics workspace as the rest of your diagnostic settings for it to show up here. [Learn more](https://docs.microsoft.com/en-us/azure/azure-sql/database/auditing-overview)\r\n" }, "customWidth": "60", "name": "text - 2" }, { "type": 11, "content": { "version": "LinkItem/1.0", "style": "paragraph", "links": [ { "id": "f4df7a1e-2124-4620-9005-f9b66e47f550", "cellValue": "{DatabaseResourceName}", "linkTarget": "Resource", "linkLabel": "Configure Logs for Auditing >", "subTarget": "auditing", "preText": "", "postText": "", "style": "primary" } ] }, "customWidth": "70", "name": "links - 8" } ] }, "customWidth": "90", "name": "Onboarding Message - Not onboarded yet" } ] }, "conditionalVisibilities": [ { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "QueryAudit" }, { "parameterName": "AuditingState", "comparison": "isEqualTo", "value": "disabled" } ], "name": "AuditingDisabledGroup" }, { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 12, "content": { "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ { "type": 1, "content": { "json": "" }, "customWidth": "60", "showPin": false, "name": "Image" }, { "type": 1, "content": { "json": "Get more visibility into the usage and performance of your Azure Synapse Dedicated SQL Pool\r\n\r\nThis section provides additional monitoring coverage that is based on diagnostic logs.
\r\n\r\nIf you have not activated monitoring in diagnostic settings, you must enable the **ExecRequests** and **RequestSteps** logs and send them to a Log Analytics workspace. You may choose to enable the **SQLSecurityAuditEvents** table at the same time to take full advantage of this monitoring workbook. [Learn more](https://docs.microsoft.com/en-us/azure/synapse-analytics/monitoring/how-to-monitor-using-azure-monitor#logs)" }, "customWidth": "60", "name": "text - 2" }, { "type": 11, "content": { "version": "LinkItem/1.0", "style": "paragraph", "links": [ { "id": "f4df7a1e-2124-4620-9005-f9b66e47f550", "cellValue": "{DatabaseResourceName}", "linkTarget": "Resource", "linkLabel": "Configure Logs for Monitoring >", "subTarget": "diagnostics", "preText": "", "postText": "", "style": "primary" } ] }, "customWidth": "70", "name": "links - 8" } ] }, "customWidth": "90", "name": "Onboarding Message - Not onboarded yet" } ] }, "conditionalVisibilities": [ { "parameterName": "GroupSelection", "comparison": "isNotEqualTo", "value": "QueryAudit" }, { "parameterName": "DiagnosticsState", "comparison": "isEqualTo", "value": "disabled" } ], "name": "DiagnosticsDisabledGroup" }, { "type": 1, "content": { "json": "Workbook version: v0.77", "style": "info" }, "conditionalVisibility": { "parameterName": "GroupSelection", "comparison": "isEqualTo", "value": "Overview" }, "customWidth": "15", "name": "version", "styleSettings": { "showBorder": true } } ], "fallbackResourceIds": [ "/subscriptions/9cd45dfd-d1ac-4c16-9363-150d2afcb462/resourceGroups/ContosoProd" ], "$schema": "https://github.com/Microsoft/Application-Insights-Workbooks/blob/master/schema/workbook.json" } ================================================ FILE: PowerBI/README.md ================================================ # This template is a work in progress and is not yet meant for use in production This template is a work in progress, but is in a usable state. It currently only has realtime pages from querying DMVs. It will get historical data as well as I post updates. # Pre-Requisites PowerBI Desktop installed on your machine. There are currently no other pre-requisites other than a running SQLDW Instance. In future releases there will be Log Analytics queries and the below pre-requisites will apply to that. # Variables When you open the template it will as you to fill in a number of variables. A lot of these are for future use or will be removed later. **SQLDW_Servername:** the name of the server your SQLDW resides on in the form sqldwname.database.windows.net **DatbaseName:** The name of your SQLDW Database **LogAnalyticsWorkspaceID:** Not in use, enter any text value **StorageAccountName:** Not in use, enter any text value **RangeStart:** Not in use, enter any date value in the form 4/21/2020 1:00:00 AM **RangeEnd:** Not in use, enter any date value in the form 4/21/2020 1:00:00 AM **SQLDW_Servername_short:** Not in use, enter any text value # Messages about Native Database Queries Most of the DMVs are collected using native datbase queries. You need to allow each one permissions to run by hitting 'Run' on the popup. ================================================ FILE: README.md ================================================ # Azure Synapse Toolbox ![CSELogo.png](https://github.com/microsoft/Azure_Synapse_Toolbox/blob/master/Collateral/CSELogo.png) The Azure Synapse Toolbox is a place for useful tools and scripts to help you manage and monitor Azure Synapse Analytics.

# Training Resources ### Blogs [Historical Dashboards for Dedicated Pool](https://techcommunity.microsoft.com/t5/azure-synapse-analytics-blog/historical-monitoring-dashboards-for-azure-synapse-dedicated-sql/ba-p/3725322)
[Monitoring Serverless Query History](https://techcommunity.microsoft.com/t5/azure-synapse-analytics-blog/monitoring-synapse-serverless-sql-pool-query-history/ba-p/3710423)
[Create Alerts for your Dedicated SQL Pool](https://techcommunity.microsoft.com/t5/azure-synapse-analytics-blog/create-alerts-for-your-synapse-dedicated-sql-pool/ba-p/3773256) ### Videos [Azure Synapse Analytics Youtube Channel](https://www.youtube.com/@AzureSynapse/featured)

# Overview ### Azure Resource Graph Queries The Azure Resource Graph queries assist with gathering Azure tenant inventory for Azure resources related to Azure Synapse Analytics. They are intended to aid cost optimization, general inventory needs, normalizing or standardization of configuration, and more. ### Distribution Advisor The Distribution Advisor (DA) feature of Azure Synapse SQL analyzes customer queries and recommends the best distribution strategies for tables to improve query performance. Queries to be considered by the advisor can be provided by the customer or pulled from historic queries available in DMV. See [Microsoft documentation](https://docs.microsoft.com/en-us/azure/synapse-analytics/sql/distribution-advisor) for more information ![DistributionAdvisorRecommendations.png](Collateral/Screenshots/DistributionAdvisorRecommendations.png "Distribution Advisor") ### Log Analytics Queries Helpful KQL queries for querying diagnostic data that has been sent to Log Analytics for your serverless and dedicated SQL pools. ### Monitor Workbooks In-depth, interactive workbooks for exploring monitoring data for your Serverless and Dedicated SQL Pools, Synapse Spark Pools, Synapse Pipelines, and ADLS storage. ![SynapsePipelineWorkbook1](Collateral/Screenshots/SynapsePipelineWorkbook1.png) ### PowerBI PowerBI templates to monitor your Synapse Dedicated SQL Pool. PowerBI has the ability to query the front-end of your SQL endpoint as well as the back-end Log Analytics data so you can build powerful reports. ### Synapse Analyzer The Azure Synapse Analyzer Report was created to help you identify common issues that may be present in your database that can lead to performance issues. This report focuses on known best practices that Microsoft has identified with SQL Dedicated Pools. Following these best practices will help to get the best performance out of your solution. The Azure Synapse Best Practice Analyzer Report should help give you insights into the health of your database. We will continue to update the report to call out defined best practices that Microsoft has defined. ![Tables with Issues](Synapse_Analyzer/Synapse_BPA_Report/img/Tables-with-Issues.png "Tables with Issues") ### Synapse Toolkit The Synapse Toolkit is a set of stored procedures that help investigate current activity on your Synapse Dedicated SQL Pool. sp_status is the overall summary procedure that calls various other procedures to provide a picture of current activity. Use the detail_command columns to deep dive into a particular session, query, or wait. List of SPs currently included: - sp_status - sp_concurrency - sp_requests - sp_reqeusts_detail - sp_sessions - sp_sessions_detail - sp_waits - sp_waits_detail - sp_datamovement ![sp_status_screenshot.png](Collateral/Screenshots/SynapseToolkit/sp_status_screenshot.png "Synapse Toolkit") ### TSQL Queries Helpful queries for managing and monitoring various aspects of your Dedicated SQL Pool. # Contributing This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com. When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA. This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. ================================================ FILE: SECURITY.md ================================================ ## Security Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/Microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin), and [our GitHub organizations](https://opensource.microsoft.com/). If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://aka.ms/opensource/security/definition), please report it to us as described below. ## Reporting Security Issues **Please do not report security vulnerabilities through public GitHub issues.** Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://aka.ms/opensource/security/create-report). If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://aka.ms/opensource/security/pgpkey). You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://aka.ms/opensource/security/msrc). Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue: * Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.) * Full paths of source file(s) related to the manifestation of the issue * The location of the affected source code (tag/branch/commit or direct URL) * Any special configuration required to reproduce the issue * Step-by-step instructions to reproduce the issue * Proof-of-concept or exploit code (if possible) * Impact of the issue, including how an attacker might exploit the issue This information will help us triage your report more quickly. If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://aka.ms/opensource/security/bounty) page for more details about our active programs. ## Preferred Languages We prefer all communications to be in English. ## Policy Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://aka.ms/opensource/security/cvd). ================================================ FILE: Synapse_Analyzer/README.md ================================================ # Azure Synapse Analyzer Report The Azure Synapse Analyzer Report was created to help you identify common issues that may be present in your database that can lead to performance issues. This report focuses on known best practices that Microsoft has identified with SQL Dedicated Pools. Following these best practices will help to get the best performance out of your solution. The [Azure Synapse Best Practice Analyzer Report](https://aka.ms/synapseanalyzer "Synapse BPA Report") should help give you insights into the health of your database. We will continue to update the report to call out defined best practices that Microsoft has defined. ## Contributing This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com. When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA. This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. ## Trademarks This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow [Microsoft's Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general). Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party's policies. ================================================ FILE: Synapse_Analyzer/Synapse_BPA_Report/ArchivedVersions/README.md ================================================ # Archived Folder for older versions of the report This folder is to keep older versions of Synapse Analyzer Report. Currently contains Synapse best practice analyzer_v1.0.pbit - version 1.0 ================================================ FILE: Synapse_Analyzer/Synapse_BPA_Report/ForLargeDBwithCTAS/CreateTablesForSynapseAnalyzer.sql ================================================ -- Create Separate Schema For loading all Tables CREATE SCHEMA SynapseAnalyzer GO -- All_Tables IF Exists(SELECT [name] FROM sys.tables WHERE [name] like 'All_Tables' AND schema_id = SCHEMA_ID('SynapseAnalyzer')) BEGIN DROP TABLE SynapseAnalyzer.All_Tables END GO CREATE TABLE SynapseAnalyzer.All_Tables WITH (Clustered Index([two_part_name], s_key), DISTRIBUTION = REPLICATE) AS SELECT ROW_NUMBER() OVER(ORDER BY [two_part_name] ASC) AS s_key , GETDATE() AS [execution_time] , [database_name] , [schema_name] , [table_name] , [table_object_id] , [is_external_table] , [two_part_name] , [three_part_name] FROM ( SELECT DB_NAME() AS [database_name] , sm.[name] AS [schema_name] , tb.[name] AS [table_name] , tb.object_id AS [table_object_id] , QUOTENAME(sm.[name]) + '.' + QUOTENAME(tb.[name]) AS two_part_name , QUOTENAME(DB_NAME()) + '.' + QUOTENAME(sm.[name]) + '.' + QUOTENAME(tb.[name]) AS three_part_name , CASE WHEN et.object_id IS NULL THEN 0 ELSE 1 END AS is_external_table FROM sys.tables AS tb JOIN sys.schemas AS sm ON tb.[schema_id] = sm.[schema_id] LEFT OUTER JOIN sys.external_tables et ON tb.object_id = et.object_id ) All_Tables GO -- ColumnstoreDensity IF Exists(SELECT [name] FROM sys.tables WHERE [name] like 'ColumnstoreDensity' AND schema_id = SCHEMA_ID('SynapseAnalyzer')) BEGIN DROP TABLE SynapseAnalyzer.ColumnstoreDensity END GO CREATE TABLE SynapseAnalyzer.ColumnstoreDensity WITH (Clustered Index ([TwoPartName]), DISTRIBUTION = REPLICATE) AS SELECT QUOTENAME(s.name)+'.'+QUOTENAME(t.name) AS [TwoPartName] , GETDATE() AS [execution_date] , DB_Name() AS [database_name] , s.name AS [schema_name] , t.name AS [table_name] , COUNT(DISTINCT rg.[partition_number]) AS [table_partition_count] , SUM(rg.[total_rows]) AS [row_count_total] , SUM(rg.[total_rows])/COUNT(DISTINCT rg.[distribution_id]) AS [row_count_per_distribution_MAX] , CEILING ((SUM(rg.[total_rows])*1.0/COUNT(DISTINCT rg.[distribution_id]))/1048576) AS [rowgroup_per_distribution_MAX] , SUM(CASE WHEN rg.[State] = 0 THEN 1 ELSE 0 END) AS [INVISIBLE_rowgroup_count] , SUM(CASE WHEN rg.[State] = 0 THEN rg.[total_rows] ELSE 0 END) AS [INVISIBLE_rowgroup_rows] , MIN(CASE WHEN rg.[State] = 0 THEN rg.[total_rows] ELSE NULL END) AS [INVISIBLE_rowgroup_rows_MIN] , MAX(CASE WHEN rg.[State] = 0 THEN rg.[total_rows] ELSE NULL END) AS [INVISIBLE_rowgroup_rows_MAX] , AVG(CASE WHEN rg.[State] = 0 THEN rg.[total_rows] ELSE NULL END) AS [INVISIBLE_rowgroup_rows_AVG] , SUM(CASE WHEN rg.[State] = 1 THEN 1 ELSE 0 END) AS [OPEN_rowgroup_count] , SUM(CASE WHEN rg.[State] = 1 THEN rg.[total_rows] ELSE 0 END) AS [OPEN_rowgroup_rows] , MIN(CASE WHEN rg.[State] = 1 THEN rg.[total_rows] ELSE NULL END) AS [OPEN_rowgroup_rows_MIN] , MAX(CASE WHEN rg.[State] = 1 THEN rg.[total_rows] ELSE NULL END) AS [OPEN_rowgroup_rows_MAX] , AVG(CASE WHEN rg.[State] = 1 THEN rg.[total_rows] ELSE NULL END) AS [OPEN_rowgroup_rows_AVG] , SUM(CASE WHEN rg.[State] = 2 THEN 1 ELSE 0 END) AS [CLOSED_rowgroup_count] , SUM(CASE WHEN rg.[State] = 2 THEN rg.[total_rows] ELSE 0 END) AS [CLOSED_rowgroup_rows] , MIN(CASE WHEN rg.[State] = 2 THEN rg.[total_rows] ELSE NULL END) AS [CLOSED_rowgroup_rows_MIN] , MAX(CASE WHEN rg.[State] = 2 THEN rg.[total_rows] ELSE NULL END) AS [CLOSED_rowgroup_rows_MAX] , AVG(CASE WHEN rg.[State] = 2 THEN rg.[total_rows] ELSE NULL END) AS [CLOSED_rowgroup_rows_AVG] , SUM(CASE WHEN rg.[State] = 3 THEN 1 ELSE 0 END) AS [COMPRESSED_rowgroup_count] , SUM(CASE WHEN rg.[State] = 3 THEN rg.[total_rows] ELSE 0 END) AS [COMPRESSED_rowgroup_rows] , SUM(CASE WHEN rg.[State] = 3 THEN rg.[deleted_rows] ELSE 0 END) AS [COMPRESSED_rowgroup_rows_DELETED] , MIN(CASE WHEN rg.[State] = 3 THEN rg.[total_rows] ELSE NULL END) AS [COMPRESSED_rowgroup_rows_MIN] , MAX(CASE WHEN rg.[State] = 3 THEN rg.[total_rows] ELSE NULL END) AS [COMPRESSED_rowgroup_rows_MAX] , AVG(CASE WHEN rg.[State] = 3 THEN rg.[total_rows] ELSE NULL END) AS [COMPRESSED_rowgroup_rows_AVG] , 'ALTER INDEX ALL ON ' + s.name + '.' + t.NAME + ' REBUILD;' AS [Rebuild_Index_SQL] FROM sys.[pdw_nodes_column_store_row_groups] rg JOIN sys.[pdw_nodes_tables] nt ON rg.[object_id] = nt.[object_id] AND rg.[pdw_node_id] = nt.[pdw_node_id] AND rg.[distribution_id] = nt.[distribution_id] JOIN sys.[pdw_table_mappings] mp ON nt.[name] = mp.[physical_name] JOIN sys.[tables] t ON mp.[object_id] = t.[object_id] JOIN sys.[schemas] s ON t.[schema_id] = s.[schema_id] GROUP BY s.[name] , t.[name]; -- StatsSummary IF Exists(SELECT [name] FROM sys.tables WHERE [name] like 'StatsSummary' AND schema_id = SCHEMA_ID('SynapseAnalyzer')) BEGIN DROP TABLE SynapseAnalyzer.StatsSummary END GO CREATE TABLE SynapseAnalyzer.StatsSummary WITH (Clustered Index ([two_part_name]), DISTRIBUTION = REPLICATE) AS WITH StatsColumns AS ( SELECT c.object_id , s.stats_id , s.name , STRING_AGG(QUOTENAME(c.name),',') Stat_Columns , count(1) NumberOfColumns FROM sys.stats s JOIN sys.stats_columns sc ON s.object_id = sc.object_id AND s.stats_id = sc.stats_id JOIN sys.columns c ON c.object_id = s.object_id AND c.column_id = sc.column_id WHERE (s.auto_created = 1 OR s.user_created = 1) GROUP BY c.object_id, s.stats_id, s.name ) SELECT GETDATE() AS [execution_time] , DB_NAME() AS [database_name] , s.name AS [schema_name] , t.name AS [table_name] , QUOTENAME(s.name)+'.'+QUOTENAME(t.name) AS [two_part_name] , sc.name AS [stat_name] , STATS_DATE(sc.[object_id],sc.[stats_id]) AS [stats_last_updated_date] , sc.Stat_Columns AS [stat_column_list] , sc.NumberOfColumns AS [no_of_columns] FROM sys.schemas s JOIN sys.tables t ON t.schema_id=s.schema_id JOIN sys.indexes i ON i.object_id=t.object_id AND i.index_id<2 JOIN StatsColumns sc ON sc.object_id=t.object_id -- TableSizes IF Exists(SELECT [name] FROM sys.tables WHERE [name] like 'TableSizes' AND schema_id = SCHEMA_ID('SynapseAnalyzer')) BEGIN DROP TABLE SynapseAnalyzer.TableSizes END GO CREATE TABLE SynapseAnalyzer.TableSizes WITH (Clustered Index ([two_part_name],[distribution_id]), DISTRIBUTION = HASH(distribution_id) ) AS WITH base AS ( SELECT GETDATE() AS [execution_time] , DB_NAME() AS [database_name] , s.name AS [schema_name] , t.name AS [table_name] , QUOTENAME(s.name)+'.'+QUOTENAME(t.name) AS [two_part_name] , nt.[name] AS [node_table_name] , ROW_NUMBER() OVER(PARTITION BY nt.[name] ORDER BY (SELECT NULL)) AS [node_table_name_seq] , tp.[distribution_policy_desc] AS [distribution_policy_name] , c.[name] AS [distribution_column] , nt.[distribution_id] AS [distribution_id] , i.[index_id] AS [index_id] , i.[type] AS [index_type] , i.[type_desc] AS [index_type_desc] , nt.[pdw_node_id] AS [pdw_node_id] , pn.[type] AS [pdw_node_type] , pn.[name] AS [pdw_node_name] , di.name AS [dist_name] , di.position AS [dist_position] , nps.[partition_number] AS [partition_nmbr] , nps.[reserved_page_count] AS [reserved_space_page_count] , nps.[reserved_page_count] - nps.[used_page_count] AS [unused_space_page_count] , nps.[in_row_data_page_count] + nps.[row_overflow_used_page_count] + nps.[lob_used_page_count] AS [data_space_page_count] , nps.[reserved_page_count] - (nps.[reserved_page_count] - nps.[used_page_count]) - ([in_row_data_page_count] + [row_overflow_used_page_count]+[lob_used_page_count]) AS [index_space_page_count] , nps.[row_count] AS [row_count] from sys.schemas s INNER JOIN sys.tables t ON s.[schema_id] = t.[schema_id] INNER JOIN sys.indexes i ON t.[object_id] = i.[object_id] INNER JOIN sys.pdw_table_distribution_properties tp ON t.[object_id] = tp.[object_id] INNER JOIN sys.pdw_table_mappings tm ON t.[object_id] = tm.[object_id] INNER JOIN sys.pdw_nodes_tables nt ON tm.[physical_name] = nt.[name] INNER JOIN sys.dm_pdw_nodes pn ON nt.[pdw_node_id] = pn.[pdw_node_id] INNER JOIN sys.pdw_distributions di ON nt.[distribution_id] = di.[distribution_id] INNER JOIN sys.dm_pdw_nodes_db_partition_stats nps ON nt.[object_id] = nps.[object_id] AND i.[index_id] = nps.[index_id] AND nt.[pdw_node_id] = nps.[pdw_node_id] AND nt.[distribution_id] = nps.[distribution_id] LEFT OUTER JOIN (select * from sys.pdw_column_distribution_properties where distribution_ordinal = 1) cdp ON t.[object_id] = cdp.[object_id] LEFT OUTER JOIN sys.columns c ON cdp.[object_id] = c.[object_id] AND cdp.[column_id] = c.[column_id] WHERE pn.[type] = 'COMPUTE' ) SELECT [execution_time] , [database_name] , [schema_name] , [table_name] , [two_part_name] , [node_table_name] , [node_table_name_seq] , [distribution_policy_name] , [distribution_column] , [distribution_id] , [index_id] , [index_type] , [index_type_desc] , [pdw_node_id] , [pdw_node_type] , [pdw_node_name] , [dist_name] , [dist_position] , [partition_nmbr] , [reserved_space_page_count] , [unused_space_page_count] , [data_space_page_count] , [index_space_page_count] , [row_count] , ([reserved_space_page_count] * 8.0) AS [reserved_space_KB] , ([unused_space_page_count] * 8.0) AS [unused_space_KB] , ([data_space_page_count] * 8.0) AS [data_space_KB] , ([index_space_page_count] * 8.0) AS [index_space_KB] FROM base -- StatColumns IF Exists(SELECT [name] FROM sys.tables WHERE [name] like 'StatColumns' AND schema_id = SCHEMA_ID('SynapseAnalyzer')) BEGIN DROP TABLE SynapseAnalyzer.StatColumns END GO CREATE TABLE SynapseAnalyzer.StatColumns WITH (Clustered Index ([two_part_name]), DISTRIBUTION = ROUND_ROBIN ) AS SELECT GETDATE() AS [execution_time] , DB_NAME() AS [database_name] , sm.[name] AS [schema_name] , tb.[name] AS [table_name] , st.[name] AS [stats_name] , st.[filter_definition] AS [stats_filter_definition] , st.[has_filter] AS [stats_is_filtered] , STATS_DATE(st.[object_id],st.[stats_id]) AS [stats_last_updated_date] , co.[name] AS [stats_column_name] , ty.[name] AS [column_type] , co.[max_length] AS [column_max_length] , co.[precision] AS [column_precision] , co.[scale] AS [column_scale] , co.[is_nullable] AS [column_is_nullable] , co.[collation_name] AS [column_collation_name] , QUOTENAME(sm.[name])+'.'+QUOTENAME(tb.[name]) AS two_part_name , QUOTENAME(DB_NAME())+'.'+QUOTENAME(sm.[name])+'.'+QUOTENAME(tb.[name]) AS three_part_name FROM sys.objects AS ob JOIN sys.stats AS st ON ob.[object_id] = st.[object_id] JOIN sys.stats_columns AS sc ON st.[stats_id] = sc.[stats_id] AND st.[object_id] = sc.[object_id] JOIN sys.columns AS co ON sc.[column_id] = co.[column_id] AND sc.[object_id] = co.[object_id] JOIN sys.types AS ty ON co.[user_type_id] = ty.[user_type_id] JOIN sys.tables AS tb ON co.[object_id] = tb.[object_id] JOIN sys.schemas AS sm ON tb.[schema_id] = sm.[schema_id] WHERE 1=1 AND (st.user_created = 1 OR st.auto_created = 1) -- ControlNodeRowcount IF Exists(SELECT [name] FROM sys.tables WHERE [name] like 'ControlNodeRowcount' AND schema_id = SCHEMA_ID('SynapseAnalyzer')) BEGIN DROP TABLE SynapseAnalyzer.ControlNodeRowcount END GO CREATE TABLE SynapseAnalyzer.ControlNodeRowcount WITH (Clustered Index ([two_part_name]), DISTRIBUTION = ROUND_ROBIN ) AS WITH CtlSummary AS ( SELECT p.object_id , p.index_id , p.partition_number , SUM(p.rows) rows FROM sys.partitions p WHERE p.index_id < 2 GROUP BY p.object_id, p.partition_number,p.index_id ) SELECT GETDATE() AS [execution_time] , DB_NAME() AS [database_name] , s.name AS [schema_name] , t.name AS [table_name] , QUOTENAME(s.name)+'.'+QUOTENAME(t.name) AS [two_part_name] , i.type_desc AS [table_type] , p.partition_number AS [partition_number] , p.rows AS [Stats_rowcount] FROM sys.schemas s JOIN sys.tables t ON t.schema_id=s.schema_id JOIN sys.indexes i ON i.object_id=t.object_id AND i.index_id<2 JOIN CtlSummary p ON p.object_id=t.object_id AND p.index_id=i.index_id --ColumnStoreRowGroupPhysicalStats IF Exists(SELECT [name] FROM sys.tables WHERE [name] like 'ColumnStoreRowGroupPhysicalStats' AND schema_id = SCHEMA_ID('SynapseAnalyzer')) BEGIN DROP TABLE SynapseAnalyzer.ColumnStoreRowGroupPhysicalStats END GO CREATE TABLE SynapseAnalyzer.ColumnStoreRowGroupPhysicalStats WITH (Clustered Index ([two_part_name],index_id,row_group_id), DISTRIBUTION = ROUND_ROBIN) AS SELECT tb.[name] AS [logical_table_name] , sm.[name] AS [schema_name] , QUOTENAME(sm.name)+'.'+QUOTENAME(tb.name) AS [two_part_name] , rg.[index_id] AS [index_id] , rg.[partition_number] AS [partition_number] , rg.[row_group_id] AS [row_group_id] , rg.[state] AS [state] , rg.[state_desc] AS [state_desc] , rg.[total_rows] AS [total_rows] , rg.[deleted_rows] AS [deleted_rows] , rg.[size_in_bytes] AS [size_in_bytes] , COALESCE(rg.[trim_reason_desc], rg.[state_desc])AS trim_reason_desc , mp.[physical_name] AS physical_name FROM sys.[schemas] sm JOIN sys.[tables] tb ON sm.[schema_id] = tb.[schema_id] JOIN sys.[pdw_table_mappings] mp ON tb.[object_id] = mp.[object_id] JOIN sys.[pdw_nodes_tables] nt ON nt.[name] = mp.[physical_name] JOIN sys.[dm_pdw_nodes_db_column_store_row_group_physical_stats] rg ON rg.[object_id] = nt.[object_id] AND rg.[pdw_node_id] = nt.[pdw_node_id] AND rg.[distribution_id] = nt.[distribution_id] --ExternalTables IF Exists(SELECT [name] FROM sys.tables WHERE [name] like 'ExternalTables' AND schema_id = SCHEMA_ID('SynapseAnalyzer')) BEGIN DROP TABLE SynapseAnalyzer.ExternalTables END GO CREATE TABLE SynapseAnalyzer.ExternalTables WITH (Clustered Index ([two_part_name]), DISTRIBUTION = REPLICATE ) AS SELECT GETDATE() AS [execution_time] , DB_NAME() AS [database_name] , sm.[name] AS [schema_name] , et.[name] AS [table_name] , et.object_id AS [table_object_id] , et.type_desc , et.max_column_id_used , et.uses_ansi_nulls , et.data_source_id , et.file_format_id , et.location , QUOTENAME(sm.[name]) + '.' + QUOTENAME(et.[name]) AS two_part_name FROM sys.external_tables AS et JOIN sys.schemas AS sm ON et.[schema_id] = sm.[schema_id] ================================================ FILE: Synapse_Analyzer/Synapse_BPA_Report/ForLargeDBwithCTAS/README.md ================================================ # Synapse Analyzer Report – for XL data warehouses. ## CTAS version for XL data warehouses With this update we are also bringing a parallel copy of Synapse Analyzer report specifically targeted towards scenarios where Synapse Dedicated Pool database has greater than 20K tables and the normal refresh of synapse analyzer report times out after long period (greater than 5 hours) ![Synapse Analyzer with CTAS](../img/Synapse-Analyzer-with-CTAS-Tables-About-Page.png "Synapse Analyzer with CTAS") For this version of the report the Synapse Admin has to run the Create table script on the dedicated Pool database which is being analyzed. The script will - a. Create new schema named “SynapseAnalyzer” under same database - b. Execute Create Table as Select (CTAS) statements to create tables in SynapseAnalyzer schema and prepopulate it with details from the same database. - c. These tables are then used as source for the Power BI template file “Synapse best practice analyzer_with_CTAS.pbit” - d. The PBI template will then connect to SynapseAnalyzer schema and pull all the information from the tables that are prepopulated in above steps. **Important**: You need to run the scripts in given order. 1. The “CreateTablesForSynapseAnalyzer_CTAS.sql” script creates new schema named “SynapseAnalyzer” and then creates all required tables as a part of CTAS 2. Only after step 1 above is successfully complete you can use “Synapse best practice analyzer_with_CTAS.pbit” for creating report using the PBI template file. ## Fixed error during desktop refresh For many users, running load data through Power BI desktop, the “Load Data” used to turn out into following error. All Tables Loading blocked by failures with other queries. ColumnstoreDensity Query 'ColumnstoreDensity' (step 'Expanded All Tables') references other queries or steps, so it may not directly access a data source. Please rebuild this data combination. StatsSummary Loading blocked by failures with other queries. TableSizes Query 'TableSizes' (step 'Expanded All Tables') references other queries or steps, so it may not directly access a data source. Please rebuild this data combination. … While there was a details section in Troubleshooting document on github location for troubleshooting this error, the overall first experience with tool was not optimal. With a new version of Synapse Analyzer report we have fixed this issue so you should not be getting the above error. In future we plan to continue with more features and reports. Thank you very much for using Synapse Analyzer. As always, we would be happy to receive any feedback you may have on the report. ================================================ FILE: Synapse_Analyzer/Synapse_BPA_Report/InstallationGuide.md ================================================ # Using Power BI Template (.pbit) for Synapse Best Practice Report You can install and use Power BI Desktop to access Power BI Desktop template (.pbit) file. 1. From this GitHub location, download a Power BI template (.pbit) file named [**Synapse best practice analyzer.pbit**](./Synapse%20best%20practice%20analyzer.pbit "Synapse best practice analyzer.pbit"). 2. You can use this pbit file through Power BI desktop (latest build). 3. This step by step [installation guide](./InstallationGuide.md "InstallationGuide.md") will help you on installation, configuration and refresh of the report. 4. If you face any errors in the process, the [troubleshooting guide](./TroubleshootingGuide.md "TroubleshootingGuide.md") will help you troubleshoot some of the common scenarios. Below explains steps to install and run this report using Power BI template file (.pbit) from this location. ## Prerequisite 1. Latest version of Power BI Desktop App from [Microsoft Store](https://aka.ms/pbidesktopstore "Microsoft Store") on your PC. To configure Power BI desktop using Power BI desktop template (.pbit) file you need permission on your PC to run Power BI desktop. 2. Sysadmin privileges are required to capture information from Synapse dedicated pool. The person setting up refresh, and the credentials used for refresh, should have admin rights on Synapse Dedicated pool and its databases. 3. Consumers of this Report, however, could be non-admin based on who the report is shared with. ## Installation 1. If not already done, install latest version of Power BI Desktop (Mar-2022 or greater). ![Install Power BI Desktop](./img/Install-Power-BI-Desktop.png "Install Power BI Desktop") 2. Open Power BI Desktop on your PC, 3. It will prompt you for Get Data screen. You can click on Open other reports link ![Open Other Reports](./img/Open-Other-Reports.png "Open Other Reports") 4. Change file type from pbix to pbit (1) 5. Select “Synapse Best Practice Report.pbit” template file provided (2) ![Browse select pbit file](./img/Browse-select-pbit-file.png "Browse select pbit file") 6. Click open (3) 7. Dialogue box for Synapse Best Practice report will open ![Provide connection parameters SQL endpoint database](./img/Provide-connection-parameters-SQLendpoint-database.png "Provide connection parameters SQL endpoint database") 8. Provide Synapse Dedicated Pool Endpoint (1) and Database Name (2) in the parameter text boxes 9. Click Load to open report (3) 10. If you are opening it for the first time it will pop up security warnings. This is because most of the data is collected using native database queries against DMVs. You need to allow each one permission to run by hitting 'Run' on the popup. Like an example below ![Native database query warning](./img/Native-database-query-warning.png "Native database query warning") 11. Click “Try Again” to allow it to connect to Synapse Endpoint through Native Query. 12. This should start the refresh process. ![Refresh starts](./img/Refresh-starts.png "Refresh starts") 13. Once refresh is complete click OK ================================================ FILE: Synapse_Analyzer/Synapse_BPA_Report/PublishToPowerBIService.md ================================================ # Publish Azure Synapse Analyzer Report to Power BI service While you can use Power BI desktop to refresh and view Azure Synapse Analyzer Report occasionally. You can set this report as a part of your operational procedure to review it on a regular basis in order to ensure you are having optimum Synapse practices implemented all the time. For scheduled report, and broader access to the report, we recommend publishing report to Power BI Service using Publish option in Power BI desktop. To publish pbix file to Power BI service please follow the steps outlined in [Publish from Power BI Desktop](https://docs.microsoft.com/en-us/power-bi/create-reports/desktop-upload-desktop-files "Publish from Power BI Desktop"). User publishing report may need Power BI Pro user privileges. While setting up refresh of the dataset in Power BI Service, the data source credentials used for refresh require admin rights on Synapse Dedicated pool and its databases. To configure dataset refresh in Power BI service 1. After successfully publishing PBI desktop file, go to the premium workspace where you published the file. Click more options on the dataset and go to dataset settings ![Dataset more info Settings](./img/Dataset-more-info-Settings.png "Dataset more info Settings") 2. Under the dataset settings, you will see error for data source. 3. Expand parameters under settings and provide Synapse dedicated pool endpoint and database name parameters. Click Apply ![Dataset settings input parameter values](./img/Dataset-settings-input-parameter-values.png "Dataset settings input parameter values") 4. Click on “Discover Data Sources” link after you applied parameters in above step. This will populate data source information from parameters you provided. 5. You will then see option for data source credentials and Gateway connection as shown in figure below. ![Edit Credentials option](./img/Edit-Credentials-option.png "Edit Credentials option") 6. Click Edit Credentials to provide login credentials to your Synapse Dedicated endpoint. (the credentials should have sysadmin rights on the Synapse Database) 7. If you have configured your synapse datasource to be available behind virtual private network, go to Gateway connection option and choose right gateway datasource from your gateways. For more help on how to configure data source on gateway please see [Use the data source with Scheduled refresh](https://docs.microsoft.com/en-us/power-bi/connect-data/service-gateway-enterprise-manage-sql#use-the-data-source-with-scheduled-refresh "Use the data source with Scheduled refresh"). For more details on how to create gateway data source you can refer [Add or remove a gateway data source](https://docs.microsoft.com/power-bi/connect-data/service-gateway-data-sources "Add or remove a gateway data source"). 8. After above step, now refresh dataset by clicking refresh now ![Click Refresh now](./img/Click-Refresh-now.png "Click Refresh now") ================================================ FILE: Synapse_Analyzer/Synapse_BPA_Report/README.md ================================================ # Azure Synapse Analyzer Report to monitor and improve Synapse Dedicated Pool performance The Azure Synapse Analyzer Report is created to help you identify common issues that may be present in your database that can lead to performance issues. This report focuses on known best practices that Microsoft has identified with SQL Dedicated Pools. Following these best practices will help to get the best performance out of your solution. ## Updated to Version 2.0 New version of Synapse Analyzer Report has been updated. Along with following detials, it includes reports related to **Workload Management** in Azure Synapse Analytics Dedicated SQL Pool. Please refer to [Updates to Synapse Analyzer Report](./UpdatestoSynapseAnalyzerReport.md "UpdatestoSynapseAnalyzerReport.md") document to know what is included in the new update. If you are reading it for the first time, then for overview of the overall report, please read through below before going to update section. ## Report Details This report provides key information around Table and Index storage for your Synapse Dedicated Pool (DW) database. The report has following main pages: - About - Issue Tables - All Tables - Table Details - External Table Details - Workload management ### About This page provides overall information about the report. ### Issue Tables This page provides information about Tables where we have detected possible issues. The following issues are detected currently. We do plan on expanding this list in the future. - Data Skewness - Large Replicate Tables - Missing Stats - Outdated Statistics - Too Many Partitions You can hover on the issue in "Table count by issue" tree-map visual to get a description about the issue. Clicking on the issue will filter the table visual to show you tables that are having an issue. The URL link in the table visual can provide more documentation about the issue type. You can right click on table name and drill-through to the Table details page. Row groups by trim reason bar chart provides information on the count of row groups trimmed by the reason due to which those were trimmed. To get more details on any visual you can click on the ? icon on the visual where available. ![Tables with Issues](./img/Tables-with-Issues.png "Tables with Issues") ### All Tables This page provides information on the overall landscape of the table and index metadata for your data warehouse database. Table count by distribution policy and index type provides information on how your tables are aligned to different distribution versus index strategies. Please review this matrix to ensure you are using optimal strategy for your tables and indexes. At any time you can click on ? icon on the visual to know more details on the guidance. You can right click on any table to go to Table details page. ![All Tables](./img/All-Tables.png "All Tables") ### Table Details This page provides granular details about a single table like individual table attributes. The upper green/red indicators provides information on issues that were detected for this table. The Stats by update time table provides information on the last updated date for any statistics available on that table. The column chart below provides information on distribution of rows across 60 distributions for the distributed table. Row groups by trim reason provides count of row groups by the reason due to which those were trimmed. ![Table Details](./img/Table-Details.png "Table Details") ### External Table Details This table provides metadata information on external tables present in the database like the source of external table, file format, source locations etc. ![External Table Details](./img/External-Table-Details.png "External Table Details") ## Best Practice Rules The rules created will validate Best Practices rules against the set of conditions to flag an issue. The 5 rules that have been incorporated today are: | Issue | Issue Description | | ------------ | ------------ | | **Data Skewness** | This is a scenario when data is distributed unequally among 60 distributions. A heavy skew can negatively impact queries involving that table. And in most cases, data skew can be avoided by choosing the correct distribution column. See how to [choose a distribution column](https://docs.microsoft.com/azure/synapse-analytics/sql-data-warehouse/sql-data-warehouse-tables-distribute#choose-a-distribution-column "choose a distribution column") for more information. | | **Large Replicated Tables** | Replicated tables help in avoiding the shuffle of data by maintaining a full copy of the table on each Compute Node. Due to the overhead involved in broadcasting the whole table, it is recommended to replicate a table that is < 2GB and infrequently updated. For more details, please refer [design guidance for replicated tables](https://docs.microsoft.com/azure/synapse-analytics/sql-data-warehouse/design-guidance-for-replicated-tables "design guidance for replicated tables"). | | **Missing Stats** | If statistics are missing and the database AUTO_CREATE_STATISTICS option is on, dedicated SQL pool analyzes incoming user queries for missing statistics. The query optimizer creates statistics on individual columns on the query predicate or join condition to improve cardinality estimates for the query plan. Automatic creation of statistics is done synchronously so you may incur slightly degraded query performance if your columns are missing statistics. To avoid measurable performance degradation, you should ensure stats have been created first by executing the benchmark workload before profiling the system. Check [SQL data warehouse tables statistics](https://docs.microsoft.com/azure/synapse-analytics/sql-data-warehouse/sql-data-warehouse-tables-statistics "SQL data warehouse tables statistics") to learn more. | | **Outdated Statistics** | SQL Pool uses a cost-based query optimizer which uses statistics to generate an optimal query execution plan. In the case of outdated/missing statistics, the SQL engine can choose a wrong execution plan leading to performance issues. Check [SQL data warehouse tables statistics](https://docs.microsoft.com/azure/synapse-analytics/sql-data-warehouse/sql-data-warehouse-tables-statistics "SQL data warehouse tables statistics") to learn more. | | **Too Many Partitions** | For a Columnstore table, it highly recommended to have 1 million rows per row-group for better compression & performance. SQL Pool internally divides each table into 60 child-tables ( aka distribution), and a partition further divides these child tables by partition column. It would be best if you aimed to have 1 Million or more rows per partition per distribution. Refer [Data warehouse tables partition](https://docs.microsoft.com/azure/synapse-analytics/sql-data-warehouse/sql-data-warehouse-tables-partition "Data warehouse tables partition") for details. | ## Installation You can install and use Power BI Desktop to access Power BI Desktop template (.pbit) file. 1. From this GitHub location, download a Power BI template (.pbit) file named [**Synapse best practice analyzer.pbit**](./Synapse%20best%20practice%20analyzer.pbit "Synapse best practice analyzer.pbit"). 2. You can use this pbit file through Power BI desktop (latest build). 3. The step by step [installation guide](./InstallationGuide.md "InstallationGuide.md") will help you on installation, configuration and refresh of the report. 4. If you face any errors in the process, the [troubleshooting guide](./TroubleshootingGuide.md "troubleshootingGuide.md") will help you troubleshoot some of the common scenarios. ## Required Permissions - To configure Power BI desktop using Power BI desktop template (.pbit) file you need permission on your PC to run Power BI desktop. - To connect to Azure Synapse Dedicated Pool data warehouse endpoint and refresh report you need to provide data source credentials. For those credentials Sysadmin privileges are required to capture information from Synapse dedicated pool. - Consumers of this Report, however, could be non-admin based on who the report is shared with. ## Schedule Refresh from Power BI Service (Optional) While you can use Power BI desktop report occasionally, for scheduled report and broader access to the report, we recommend publishing report to Power BI Service using Publish option in Power BI desktop. To publish pbix file to Power BI service and refresh dataset from service user need Power BI Pro user privileges. [Publish Azure Synapse Analyzer Report to Power BI service](./PublishToPowerBIService.md "PublishToPowerBIService.md") provides step-by-step instructions. Please note: While setting up refresh of dataset in Power BI Service, the credentials used for refresh, should have admin rights on Synapse Dedicated pool and its databases. ## Update to Version 2.0 New version of Synapse Analyzer Report has been uploaded. It includes reports related to Workload Management in Azure Synapse Analytics Dedicated SQL Pool. Please refer to [Updates to Synapse Analyzer Report](./UpdatestoSynapseAnalyzerReport.md "UpdatestoSynapseAnalyzerReport.md") document for more details. ## Summary The Azure Synapse Analyzer Report should help give you insights into the health of your Azure Synapse Dedicated Pool database. We will continue to update the report to call out defined best practices that Microsoft has defined. ================================================ FILE: Synapse_Analyzer/Synapse_BPA_Report/TroubleshootingGuide.md ================================================ # Troubleshooting errors when refreshing report from Power BI Desktop During the refresh you may encounter Errors. This document lists some of the common errors and possible troubleshooting steps for those errors. ## Connection Errors when refreshing report from Power BI Desktop Sometimes you may receive errors while connecting to your Synapse Dedicated Pool database. ![Connection Error Could not connect to server](./img/Connection-Error-Could-not-connect-to-server.png "Connection Error Could not connect to server") ![Database is paused](./img/Database-is-paused.png "Database is paused") If you receive any of the above connection errors, please ensure that 1. You have provided correct connection parameters for Server endpoint and database 2. The given database on the synapse workspace is online and running 3. You have provided appropriate credentials to be used to connect to the database 4. The credentials provided have admin access to the Synapse data warehouse database. You can close Power BI desktop without saving and open pbit file again from Power BI Desktop. ## Timeout errors when refreshing report from Power BI Desktop You may encounter Timeout error when refreshing Power BI report from Power BI desktop. If you click close on the error dialog you will see following on the Power BI desktop ![PBI desktop report after refresh errors](./img/PBI-desktop-report-after-refresh-errors.png "PBI desktop report after refresh errors") At this time you can try following troubleshooting steps based on situations 1. Check if the Azure Synapse Dedicated Pool database is online and accepting connections 2. Check if database is too busy with other requests. You can refresh the report towards off peak hours to ensure it pulls all the data 3. If refresh is timing out after it starts loading data, You can save the failed refresh desktop file without applying changes and upload pbix file to Power BI workspace (preferably Power BI Premium) and refresh from there. For that Save file on your desktop. While saving it will ask for applying changes, choose apply later ![Warning dialog while saving desktop file](./img/Warning-dialog-while-saving-desktop-file.png "Warning dialog while saving desktop file") Publish file to Power BI Workspace. We would prefer using Power BI Premium since Premium datasets have higher timeout value and also higher processing power to execute refresh. While publishing it may again ask you to save file and pop up the same dialog as above step. You can click “Apply later”. ![Power BI Publish successful dialog box](./img/Power-BI-Publish-successful-dialog-box.png "Power BI Publish successful dialog box") After successfully publishing PBI desktop file, go to the premium workspace where you published the file. Click more options on the dataset and go to dataset settings ![Dataset more info Settings](./img/Dataset-more-info-Settings.png "Dataset more info Settings") Under the dataset settings, you will see error for data source. Expand parameters under settings and provide Synapse dedicated pool endpoint and database name parameters. Click Apply ![Dataset settings input parameter values](./img/Dataset-settings-input-parameter-values.png "Dataset settings input parameter values") Click on “Discover Data Sources” link after you applied parameters in above step. This will populate data source information from parameters you provided. You will then see option for data source credentials and Gateway connection as shown in figure below. ![Edit Credentials option](./img/Edit-Credentials-option.png "Edit Credentials option") Click Edit Credentials to provide login credentials to your Synapse Dedicated endpoint. (the credentials should have sysadmin rights on the Synapse Database) If you have configured your synapse datasource to be available behind virtual private network, go to Gateway connection option and choose right gateway datasource from your gateways. For more help on how to configure data source on gateway please see [Use the data source with Scheduled refresh](https://docs.microsoft.com/en-us/power-bi/connect-data/service-gateway-enterprise-manage-sql#use-the-data-source-with-scheduled-refresh "Use the data source with Scheduled refresh"). For more details on how to create gateway data source you can refer [Add or remove a gateway data source](https://docs.microsoft.com/power-bi/connect-data/service-gateway-data-sources "Add or remove a gateway data source"). After above step, now refresh dataset by clicking refresh now ![Click Refresh now](./img/Click-Refresh-now.png "Click Refresh now") ## Other errors when refreshing report from Power BI Desktop Sometimes you may see following error like “Query ‘Query Name’ (step ‘step name’) reference other queries or steps… please rebuild this data combination” ![All Tables reference error](./img/All-Tables-reference-error.png "All Tables reference error") This error happens only in desktop due to some internal race condition. There are two ways to fix it. You can either publish a report to Power BI service using steps mentioned in timeout error section Alternatively, you can use following technique to “refresh all” preview from transform data screen. For this go to transform data to open Power Query editor. ![Open Power Query editor](./img/Open-Power-Query-editor.png "Open Power Query editor") In Power Query editor, under Queries pane, click on “All Tables” query. Expand “Refresh Preview” and click “Refresh All”. Wait for preview refresh to complete. ![Refresh Preview Refresh All](./img/Refresh-Preview-Refresh-All.png "Refresh Preview Refresh All") Once preview is refreshed you can click” Close & Apply” button on the left corner of navigation ribbon. This will restart the refresh. ================================================ FILE: Synapse_Analyzer/Synapse_BPA_Report/UpdatestoSynapseAnalyzerReport.md ================================================ # Updates to Synapse Analyzer Report – Workload Management and support for XL data warehouses. In May 2022 we released the first version of Synapse Analyzer Report that will help you with table, index, and statistics information and report issues on these topics. With help from Nick Salch, Fretz Nusan, and Synapse CSE team, today we have an update (v2.0) to the Synapse Analyzer report: - Addition of Workload Management Report page to the existing report - A new separate CTAS version of Synapse Analyzer Report for extra-large data warehouses - Fixed below error during desktop refresh - Query 'Query Name’ (step 'Expanded All Tables') references other queries or steps, so it may not directly access a data source. Please rebuild this data combination. ## Addition of Workload Management Report page: The new version (v2.0) contains additional reports to detect issues in configuration of Workload Management settings in Synapse Dedicated Pool. ![Workload Management](./img/Workload-Management.png "Workload Management") Following is the brief description for the Workload Management report page. ### Workload Management: This page provides information on workload management and related settings in Synapse dedicated pool. It highlights some of the common warnings admins should be aware of when setting the resource and request percentage for effective workload governance. Please review issues and warnings on this page to ensure you are using optimal strategy for your workload groups and classifiers. At any time you can click on ? icon on the visual to view more details on the guidance. ### WLM Issue Summary: This table provides summary of all issues detected in your WLM environment. You can hover on each issue to find brief description and / or click on issue to find groups affected by respective issue. You can also click on URL link to find more information about workload management. ### Group Details: The table provides details for each workload group. Groups highlighted suggest there exist one or more issues for that group. You can hover on the groups flagged to find issues identified for that group. - Flag for effective values suggests there is mismatch between config and effective value at request or resource level. - Flag on request min config suggests mismatch in request min vs request max values. - Flag on resource min config suggests deviations in resource min configurations. ### Requests / Timeouts Summary: The table provides snapshot of requests and timeouts summary at the time when data was last refreshed / updated. The table below provides details on issues that have been added for workload management. | Issue | Issue Description | | ----------- | --------------------------------- | | **Importance Mismatch** | Mismatch in workload group importance and workload classifier importance for a workload group. Importance can be set separately at the workload group or workload classifier level. Whichever importance is higher is the one that will be assigned to the query. This test is just to make the user aware that there are two different importance set to make sure there is no confusion on the classified query's importance. Refer [Workload Management](https://docs.microsoft.com/en-us/azure/synapse-analytics/sql-data-warehouse/resource-classes-for-workload-management "Workload management with resource classes in Azure Synapse Analytics") for details.| | **Request Max Mismatch** | Mismatch in configured and effective values of max request grant percentage for a workload group. The system will allow you to set any valid values for your request max and this will be your configured or desired value. The effective value is the actual value that is being used based on the configuration of other workload groups in the system. If your request max is set to 100%, but there is another workload group with a 10% minimum, then your effective request max will be lowered to 90%. Refer [Workload Management](https://docs.microsoft.com/en-us/azure/synapse-analytics/sql-data-warehouse/resource-classes-for-workload-management "Workload management with resource classes in Azure Synapse Analytics") for details.| | **Request Min Mismatch** | Mismatch in configured and effective values of min request grant percentage for a workload group. The system will allow you to set any valid values for your request minimum and this will be your configured or desired value. The effective value is the actual value that is being used based on the configuration of other workload groups in the system. If your request min is set to 50%, but there are other workload groups with combined minimums totaling 60%, then your effective request min will be lowered to 40%. Refer [Workload Management](https://docs.microsoft.com/en-us/azure/synapse-analytics/sql-data-warehouse/resource-classes-for-workload-management "Workload management with resource classes in Azure Synapse Analytics") for details.| | **Resource Max Mismatch** | Mismatch in configured and effective values of cap resource percentage for a workload group. The system will allow you to set any valid values for your resource max (workload group max) and this will be your configured or desired value. The effective value is the actual value that is being used based on the configuration of other workload groups in the system. If your resource max is set to 100%, but there is another workload group with a 10% minimum, then your effective resource max will be lowered to 90%. Refer [Workload Management](https://docs.microsoft.com/en-us/azure/synapse-analytics/sql-data-warehouse/resource-classes-for-workload-management "Workload management with resource classes in Azure Synapse Analytics") for details.| | **Resource Min Mismatch** | Mismatch in configured and effective values of min resource percentage for a workload group. The system will allow you to set any valid values for your resource minimum and this will be your configured or desired value. The effective value is the actual value that is being used based on the configuration of other workload groups in the system. If your resource minimum is set to 50%, but there are other workload groups with combined minimums totaling 60%, then your effective request min will be lowered to 40%. Refer [Workload Management](https://docs.microsoft.com/en-us/azure/synapse-analytics/sql-data-warehouse/resource-classes-for-workload-management "Workload management with resource classes in Azure Synapse Analytics") for details.| | **Resource Min NonZero** | Resource min percentage is nonzero for a workload group. You can set a workload group to have a minimum percentage allocated at all times, this is true regardless of whether or not there are queries running in this group. This test is to notify the user that there is a group that has a permanent resource grant because it will lower the concurrency resources available to all other groups and in many cases lower your overall concurrency. Refer [Workload Management](https://docs.microsoft.com/en-us/azure/synapse-analytics/sql-data-warehouse/resource-classes-for-workload-management "Workload management with resource classes in Azure Synapse Analytics") for details.| | **Resource Min Over10%** | Resource min percentage is > 10% for a workload group. When you set a workload group minimum it is allocated at all times regardless of whether or not there are queries running in this group. If this minimum is set to high then it can have a dramatic effect on the overall concurrency available to the system since queries not in this group can never tap into this granted percentage. There may be rare scenarios where this is a valid configuration such as a fairly constant workload that regularly uses more than this minimum, but you are more likely to achieve higher concurrency by removing or lowering this minimum, capping certain workloads, and allowing the shared resources to be dynamically allocated based on importance. Refer [Workload Management](https://docs.microsoft.com/en-us/azure/synapse-analytics/sql-data-warehouse/resource-classes-for-workload-management "Workload management with resource classes in Azure Synapse Analytics") for details.| | **Request Min vs Request Max mismatch** | Request min grant percentage and request max grant percentage do not match for a workload group. On a per-request basis within a workload group you can set a separate minimum and maximum resource grant. If there are enough resources available it will grant the maximum, but if there are not it will lower the allocation until it gets to the minimum at which point if there are still not enough resources the query will queue. However, in most scenarios you do not want to set a separate minimum and maximum request grant because it could result in varying query runtimes based on how large of a grant the query is given at different times. Refer [Workload Management](https://docs.microsoft.com/en-us/azure/synapse-analytics/sql-data-warehouse/resource-classes-for-workload-management "Workload management with resource classes in Azure Synapse Analytics") for details.| ## CTAS version for XL data warehouses With this update we are also bringing a parallel copy of Synapse Analyzer report specifically targeted towards scenarios where Synapse Dedicated Pool database has greater than 20K tables and the normal refresh of synapse analyzer report times out after long period (greater than 5 hours) For this version of the report the Synapse Admin has to run the Create table script on the dedicated Pool database which is being analyzed. The script will - a. Create new schema named “SynapseAnalyzer” under same database - b. Execute Create Table as Select (CTAS) statements to create tables in SynapseAnalyzer schema and prepopulate it with details from the same database. - c. These tables are then used as source for the Power BI template file “Synapse best practice analyzer_with_CTAS.pbit” - d. The PBI template will then connect to SynapseAnalyzer schema and pull all the information from the tables that are prepopulated in above steps. **Important**: You need to run the scripts in given order. 1. The “CreateTablesForSynapseAnalyzer_CTAS.sql” script creates new schema named “SynapseAnalyzer” and then creates all required tables as a part of CTAS 2. Only after step 1 above is successfully complete you can use “Synapse best practice analyzer_with_CTAS.pbit” for creating report using the PBI template file. ## Fixed error during desktop refresh For many users, running load data through Power BI desktop, the “Load Data” used to turn out into following error. All Tables Loading blocked by failures with other queries. ColumnstoreDensity Query 'ColumnstoreDensity' (step 'Expanded All Tables') references other queries or steps, so it may not directly access a data source. Please rebuild this data combination. StatsSummary Loading blocked by failures with other queries. TableSizes Query 'TableSizes' (step 'Expanded All Tables') references other queries or steps, so it may not directly access a data source. Please rebuild this data combination. … While there was a details section in Troubleshooting document on github location for troubleshooting this error, the overall first experience with tool was not optimal. With a new version of Synapse Analyzer report we have fixed this issue so you should not be getting the above error. In future we plan to continue with more features and reports. Thank you very much for using Synapse Analyzer. As always, we would be happy to receive any feedback you may have on the report. ================================================ FILE: Synapse_Toolkit/README.md ================================================ # Synapse Toolkit The Synapse Toolkit is a set of stored procedures that help investigate current activity on your Synapse Dedicated SQL Pool. sp_status is the overall summary procedure that calls various other procedures to provide a picture of current activity. Use the detail_command columns to deep dive into a particular session, query, or wait. List of SPs currently included: sp_status sp_concurrency sp_requests sp_requests_detail sp_sessions sp_sessions_detail sp_waits sp_waits_detail sp_datamovement - BETA Version includes new fields in the 'running queries' output to show cpu, IO, and cost metrics. These metrics are being tested for accuracy. ## Installation Run SynpaseToolkit.sql to create the stored procedures in dbo. If stored procedures with this name already exist they will overwrite them. ## Using the Toolkit Run **EXEC sp_status** to get an overview of system activity. Then use the comands provided in the last column(s) to dive deeper. For the best experience execute with SSMS ![sp_status_screenshot](/Collateral/Screenshots/SynapseToolkit/sp_status_screenshot.png) Sp_status runs 4 separate queries to give you an overall picture of your current workload. Some of the results provide you with the query to deep-dive further into that request’s execution. ### Workload state * **resource_allocated_percentage:** The total percentage of resources utilized by all running queries. In this case there are 4 queries running, each with a 24% allocation for a total of 96% allocation. * **active_sessions:** The number of currently active sessions * **idle_sessions:** The number of sessions that are not active, but have not been closed * **running_queries:** Total number of executing queries, this does not include suspended queries. * **queued_queries:** Total number of queries that are in the suspended state * **concurrency_waits:** Number of queued queries that are waiting on concurrency resources to free up. In this case there are 2 queued queries, 1 of them is waiting on concurrency. * **object_waits:** Number of queued queries that are waiting on objects. In this case of the 2 queued queries, one of them is queued because there is an object lock it was not able to obtain. Queries waiting on objects may later be blocked by concurrency, but they cannot proceed until they are able to get locks on the required objects. ### Running Requests This result shows all currently executing queries against your system. The result only includes queries that have an actual execution plan so it will not show parent-level queries like batches. Column-level detail for running requests can be found on the sys.dm_pdw_exec_requests documentation page. The result also provides you with two extra columns to help further investigation: * **request_detail_command:** Executing this query will allow you to deep-dive into the execution plan of this query. You will see the entire plan at the distribution-level along with row counts for each distribution. * **session_detail_command:** Executing this query will show you all queries for this session. ### Suspended requests Suspended requests shows detail about suspended queries and why they are in the suspended state. There are 4 columns added to help identify why these are queued: * **Concurrency_waits:** A non-zero value for this column means the query is suspended because there are not enough resources free to service this request. This is related to ‘resource_allocated_percentage’ in the first result. * **Object_waits:** A non-zero value in this column means the query is suspended because there is at least one object it was not able to obtain a lock on * **Waits_detail_command:** The command provided here allows you to investigate what objects are blocked and what query is blocking them. For a concurrency wait this will return no results since it is just waiting on resource percentage to free up * **Session_detail_command:** Executing this query will show you all queries for this session ### Data Movement This is perhaps the best indicator of what the heaviest queries currently executing are. Data movement can be a heavy operation, so queries that are performing a large amount of data movement are causing a lot of utilization of the service resources. If you are seeing resource issues and slowness, killing the first query in this result is most likely to free up resources. * **Step_rows_processed:** the number of rows that have been moved so far by this currently executing step of the query * **Step_GB_Processed:** how many gigabytes of data have been moved between distributions. * **Request_detail_command:** Executing this command will show the entire detailed query plan for this query including data movement for each distribution on each step. ================================================ FILE: Synapse_Toolkit/SynapseToolkit.sql ================================================ /*************************************************************************** Synapse Toolkit v1.1, 06/13/22 The Synapse Toolkit is a set of stored procedures that help investigate current activity on your Synapse Dedicated SQL Pool. sp_status is the overall summary procedure that calls various other procedures to provide a picture of current activity. Use the detail_command columns to deep dive into a particular session, query, or wait. List of SPs currently included: sp_status sp_concurrency sp_requests sp_reqeusts_detail sp_sessions sp_sessions_detail sp_waits sp_waits_detail sp_datamovement ****************************************************************************/ /*************************************************************************** Procedure name: sp_status Description: Runs a few of the included SPs to give overall system utilization. ****************************************************************************/ IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_NAME = 'sp_status') EXEC ('CREATE PROC dbo.sp_status AS SELECT ''TEMPORARY''') GO ALTER PROC [dbo].[sp_status] AS PRINT 'Synapse Toolkit v1.1, 06/13/22' EXEC sp_concurrency; EXEC sp_requests; EXEC sp_datamovement --EXEC sp_sessions GO /*************************************************************************** Procedure name: sp_requests Description: Collects running requests and suspended requests in two separate result windows. A running request provides a sp_requests_details query to see the plan for the running query. A suspended request provides the sp_waits_detail query so you can see why the query is in the suspended state. ****************************************************************************/ IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_NAME = 'sp_requests') EXEC ('CREATE PROC dbo.sp_requests AS SELECT ''TEMPORARY''') GO ALTER PROC [dbo].[sp_requests] AS SELECT 'Running Request' AS 'Running Requests' ,s.session_id ,r.request_id ,s.login_name ,r.submit_time ,r.end_compile_time ,r.total_elapsed_time ,r.[label] ,r.classifier_name ,r.group_name ,r.resource_allocation_percentage AS 'allocation_%' ,ISNULL(r.command2, r.command) AS 'query_text' ,r.result_cache_hit ,'EXEC sp_requests_detail @request_id=''' + r.request_id + '''' AS 'request_detail_command' ,'EXEC sp_sessions_detail @session_id=''' + r.session_id + '''' AS 'session_detail_command' FROM sys.dm_pdw_exec_requests r JOIN sys.dm_pdw_exec_sessions s on r.session_id = s.session_id WHERE (r.group_name is not null OR r.result_cache_hit = 1) AND r.[status] = 'Running' OPTION(LABEL='SynapseToolkit') SELECT 'Suspended Request' AS 'Suspended Requests' ,s.session_id ,r.request_id ,s.login_name ,r.submit_time ,r.total_elapsed_time AS 'wait_time' ,r.[label] ,r.classifier_name ,ISNULL(r.command2, r.command) AS 'query_text' ,w.resource_waits AS 'concurrency_waits' ,w.object_waits AS 'object_waits' ,'EXEC sp_waits_detail @request_id=''' + r.request_id + '''' AS 'waits_detail' ,'EXEC sp_sessions_detail @session_id=''' + r.session_id + '''' AS 'session_detail_command' FROM sys.dm_pdw_exec_requests r JOIN sys.dm_pdw_exec_sessions s on r.session_id = s.session_id LEFT JOIN ( SELECT request_id ,SUM(CASE WHEN object_type = 'SYSTEM' THEN 1 ELSE 0 END) AS resource_waits ,SUM(CASE WHEN object_type != 'SYSTEM' THEN 1 ELSE 0 END) AS object_waits FROM sys.dm_pdw_waits WHERE state != 'Granted' GROUP BY request_id ) w ON r.request_id = w.request_id WHERE r.[status] = 'Suspended' OPTION(LABEL='SynapseToolkit') GO /*************************************************************************** Procedure name: sp_requests_detail Description: Provides the detailed query plan for the specified requestID. This shows a results at the distribution-level. Use Step_index to determine which step you are looking at. ****************************************************************************/ IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_NAME = 'sp_requests_detail') EXEC ('CREATE PROC dbo.sp_requests_detail AS SELECT ''TEMPORARY''') GO ALTER PROC [dbo].[sp_requests_detail] @request_id [varchar](20) AS --Query Step Data SELECT 'Query Plan' AS 'Query Plan' ,rs.request_id ,rs.step_index ,rs.operation_type ,rs.[status] AS 'step_status' ,rs.estimated_rows AS 'step_estimated_rows' ,rs.row_count AS 'step_actual_rows' ,rs.total_elapsed_time AS 'step_elapsed_time' ,dist.pdw_node_id ,dist.distribution_id ,dist.[type] AS 'distribution_step_type' ,dist.[status] AS 'distribution_step_status' ,dist.total_elapsed_time AS 'distribution_elapsed_time' ,dist.bytes_per_sec ,dist.bytes_processed ,dist.row_count ,dist.start_time ,dist.end_time ,dist.spid ,rs.command ,dist.error_id FROM (--dms SELECT request_id ,step_index ,pdw_node_id ,distribution_id ,type ,status ,start_time ,end_time ,total_elapsed_time ,command ,error_id ,sql_spid AS spid ,bytes_per_sec ,bytes_processed ,rows_processed AS row_count ,command AS dist_text FROM sys.dm_pdw_dms_workers WHERE request_id = @request_id UNION ALL --sql SELECT request_id ,step_index ,pdw_node_id ,distribution_id ,'SQL' AS type ,[status] ,start_time ,end_time ,total_elapsed_time ,command ,error_id ,spid ,-1 AS bytes_per_sec ,-1 AS bytes_processed ,row_count ,command AS dist_text FROM sys.dm_pdw_sql_requests WHERE request_id = @request_id AND command not like '%DISTRIBUTED_MOVE%' ) dist RIGHT JOIN sys.dm_pdw_request_steps rs ON rs.request_id = dist.request_id AND rs.step_index = dist.step_index WHERE rs.request_id = @request_id ORDER BY rs.step_index,dist.pdw_node_id,dist.distribution_id OPTION(LABEL='SynapseToolkit') GO /*************************************************************************** Procedure name: sp_waits Description: Collects information on granted and queued object and resource (concurrency) waits. Provides statements for waits_detail queries to get more information on what is blocking what. ****************************************************************************/ IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_NAME = 'sp_waits') EXEC ('CREATE PROC dbo.sp_waits AS SELECT ''TEMPORARY''') GO ALTER PROC [dbo].[sp_waits] AS --Granted Object Locks SELECT 'Granted Object Lock' AS 'Granted Object Locks' ,w.session_id ,w.request_id ,r.[status] AS 'request_status' ,w.[state] AS 'wait_state' ,w.[type] ,w.object_type ,w.[object_name] ,r.importance ,r.classifier_name ,r.group_name ,w.priority ,w.request_time ,w.acquire_time ,r.total_elapsed_time AS 'request_elapsed_time' ,r.[label] ,ISNULL(r.command2, r.command) AS 'query_text' --,'EXEC sp_waits_detail @request_id=''' + w.request_id + '''' AS 'detail_command' FROM sys.dm_pdw_waits w JOIN sys.dm_pdw_exec_requests r ON w.request_id = r.request_id WHERE w.object_type != 'SYSTEM' AND w.[state]='Granted' AND r.[status] != 'Completed' AND w.session_id != SESSION_ID() ORDER BY r.[status],r.start_time,r.submit_time,w.priority asc OPTION(LABEL='SynapseToolkit') --Queued Locks SELECT 'Queued Object Lock' AS 'Queued Object Locks' ,w.session_id ,w.request_id ,r.[status] AS 'request_status' ,w.[state] AS 'wait_state' ,w.[type] ,w.object_type ,w.[object_name] ,r.importance ,r.classifier_name ,r.group_name ,w.priority ,w.request_time ,w.acquire_time ,r.total_elapsed_time AS 'request_elapsed_time' ,r.[label] ,ISNULL(r.command2, r.command) AS 'query_text' ,'EXEC sp_waits_detail @request_id=''' + w.request_id + '''' AS 'detail_command' FROM sys.dm_pdw_waits w JOIN sys.dm_pdw_exec_requests r ON w.request_id = r.request_id WHERE w.object_type != 'SYSTEM' AND w.[state]!='Granted' AND r.[status] != 'Completed' ORDER BY r.[status],r.start_time,r.submit_time,w.priority asc OPTION(LABEL='SynapseToolkit') --Granted concurrency waits SELECT 'Granted Concurrency Wait' AS 'Granted Concurrency Waits' ,w.session_id ,w.request_id ,r.[status] AS 'request_status' ,w.[state] AS 'wait_state' ,r.resource_allocation_percentage ,r.importance ,r.classifier_name ,r.group_name ,w.priority ,w.request_time ,w.acquire_time ,r.total_elapsed_time AS 'request_elapsed_time' ,r.[label] ,ISNULL(r.command2, r.command) AS 'query_text' FROM sys.dm_pdw_waits w JOIN sys.dm_pdw_exec_requests r on w.request_id = r.request_id WHERE object_type = 'SYSTEM' AND w.[state]='Granted' AND w.[type] NOT IN ('ConcurrencyResourceType','LocalQueriesConcurrencyResourceType') ORDER BY w.session_id,w.request_id,w.wait_id OPTION(LABEL='SynapseToolkit') --Queued concurrency waits SELECT 'Queued Concurrency Wait' AS 'Queued Concurrency Waits' ,w.session_id ,w.request_id ,r.[status] AS 'request_status' ,w.[state] AS 'wait_state' ,r.resource_allocation_percentage ,r.importance ,r.classifier_name ,r.group_name ,w.priority ,w.request_time ,w.acquire_time ,r.total_elapsed_time AS 'request_elapsed_time' ,r.[label] ,ISNULL(r.command2, r.command) AS 'query_text' FROM sys.dm_pdw_waits w JOIN sys.dm_pdw_exec_requests r on w.request_id = r.request_id WHERE object_type = 'SYSTEM' AND w.[state]!='Granted' AND w.[type] NOT IN ('ConcurrencyResourceType','LocalQueriesConcurrencyResourceType') ORDER BY w.session_id,w.request_id,w.wait_id OPTION(LABEL='SynapseToolkit') GO /*************************************************************************** Procedure name: sp_waits_detail Description: When providing a suspended requestID: This sp will return all queries that have object locks on the same objects the provided query is queued on This query returns a message if a query with no waiting object locks is provided ****************************************************************************/ IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_NAME = 'sp_waits_detail') EXEC ('CREATE PROC dbo.sp_waits_detail AS SELECT ''TEMPORARY''') GO ALTER PROC [dbo].[sp_waits_detail] @request_id [varchar](20) AS --If the provided statement is suspended, show what's blocking it IF (SELECT [status] FROM sys.dm_pdw_exec_requests WHERE request_id = @request_id) = 'Suspended' BEGIN IF (SELECT TOP 1 [object_type] FROM sys.dm_pdw_waits WHERE request_id = @request_id AND STATE != 'GRANTED' ) != 'SYSTEM' BEGIN --Queued Object Locks for provided query SELECT 'Blocked Object Lock' AS 'Blocked Object Locks' ,session_id ,request_id ,wait_id ,[state] ,[type] ,object_type ,[object_name] ,priority ,request_time ,acquire_time FROM sys.dm_pdw_waits WHERE object_type != 'SYSTEM' AND [state]!='Granted' AND request_id = @request_id ORDER BY session_id,wait_id OPTION(LABEL='SynapseToolkit') --Granted Locks on the same objects as in query SELECT 'Possible Blocker' AS 'Possible Blockers' ,w2.session_id ,w2.request_id ,w2.wait_id ,w2.[state] ,w2.[type] ,w2.object_type ,w2.[object_name] ,w2.priority ,w2.request_time ,w2.acquire_time ,'EXEC sp_requests_detail @request_id=''' + w2.request_id + '''' AS 'request_detail_command' ,'EXEC sp_sessions_detail @session_id=''' + w2.session_id + '''' AS 'session_detail_command' FROM sys.dm_pdw_waits w1 JOIN sys.dm_pdw_waits w2 ON w1.[object_name] = w2.[object_name] WHERE w1.request_id = @request_id AND w2.[state] = 'Granted' ORDER BY w2.session_id,w2.wait_id OPTION(LABEL='SynapseToolkit') END END ELSE BEGIN SELECT 'No queued object Locks found for ' + @request_id AS 'Message' END GO /*************************************************************************** Procedure name: sp_concurrency Description: Shows general information about how many queries are running/suspended and how many queued object locks or resource (concurrency) locks. Also shows the currentl percentage of resources allocated to running queries by workload group assignment ****************************************************************************/ IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_NAME = 'sp_concurrency') EXEC ('CREATE PROC dbo.sp_concurrency AS SELECT ''TEMPORARY''') GO ALTER PROC [dbo].[sp_concurrency] AS SELECT sum(case when r.status = 'Running' then r.resource_allocation_percentage else 0 end) as 'resource_allocated_percentage' --,sum(case when s.status = 'Active' then 1 else 0 end) as 'active_sessions' --sum(case when s.status = 'Idle' then 1 else 0 end) as 'idle_sessions' ,(SELECT count(1) FROM sys.dm_pdw_exec_sessions where status = 'Active') AS 'active_sessions' ,(SELECT count(1) FROM sys.dm_pdw_exec_sessions where status = 'Idle') AS 'idle_sessions' ,sum(case when r.status = 'Running' AND (r.group_name is not null OR r.result_cache_hit = 1) then 1 else 0 end) as running_queries ,sum(case when r.status = 'suspended' then 1 else 0 end) as queued_queries ,sum(case when w.queued_resource_waits > 0 then 1 else 0 end) AS concurrency_waits ,sum(case when w.queued_object_locks > 0 then 1 else 0 end) AS object_waits FROM sys.dm_pdw_exec_requests r JOIN sys.dm_pdw_exec_sessions s ON r.session_id = s.session_id LEFT JOIN ( SELECT request_id ,count(request_id) AS queued_locks ,sum(case when object_type = 'system' then 1 else 0 end) as queued_resource_waits ,sum(case when object_type != 'system' then 1 else 0 end) as queued_object_locks FROM sys.dm_pdw_waits WHERE state != 'Granted' GROUP BY request_id ) w ON w.request_id = r.request_id OPTION(LABEL='SynapseToolkit') GO /*************************************************************************** Procedure name: sp_datamovement Description: Shows all data movement currently happening in order from largest to smallest. The items at the top of this list are likely the most resource- intensive queries currently running. ****************************************************************************/ IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_NAME = 'sp_datamovement') EXEC ('CREATE PROC dbo.sp_datamovement AS SELECT ''TEMPORARY''') GO ALTER PROC sp_datamovement AS WITH step_data AS ( SELECT SUM(rows_processed) AS Step_Rows_Processed , SUM(Bytes_processed) AS Step_Bytes_Processed , max(total_elapsed_time) AS Step_elapsed_time , request_id , step_index , status --, type FROM sys.dm_pdw_dms_workers WHERE status != 'StepComplete' Group by request_id , step_index , status --, type ) SELECT 'Data Movement' AS 'Data Movements' ,s.login_name ,step_data.request_id , per.session_id , rs.operation_type , (step_data.Step_elapsed_time/1000/60) AS 'step_elapsed_time_(m)' , step_data.Step_rows_processed , step_data.step_bytes_processed , (step_data.Step_Bytes_Processed/1024/1024/1024) AS Step_GB_Processed , step_data.step_index --, step_data.type , step_data.status as Step_status --, per.status AS QID_Status , per.total_elapsed_time/1000/60 as 'QID_elapsed_time(m)' , ISNULL(per.command2, per.command) AS 'QID_Command' , per.resource_class , per.importance ,'EXEC sp_requests_detail @request_id=''' + per.request_id + '''' AS 'request_detail_command' FROM step_data LEFT JOIN sys.dm_pdw_exec_requests per ON step_data.request_id = per.request_id JOIN sys.dm_pdw_exec_sessions s ON per.session_id = s.session_id JOIN sys.dm_pdw_request_steps rs ON step_data.request_id = rs.request_id AND step_data.step_index = rs.step_index WHERE per.status = 'Running' ORDER BY step_data.Step_rows_processed DESC OPTION(LABEL='SynapseToolkit') GO /*************************************************************************** Procedure name: sp_sessions Description: status of all open sessions ****************************************************************************/ IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_NAME = 'sp_sessions') EXEC ('CREATE PROC dbo.sp_sessions AS SELECT ''TEMPORARY''') GO ALTER PROC sp_sessions AS SELECT 'Active Session' AS 'Active Sessions' ,s.session_id ,s.request_id ,s.login_name ,s.login_time ,s.query_count ,s.client_id ,s.[app_name] ,'EXEC sp_sessions_detail @session_id=''' + s.session_id + '''' AS 'detail_command' FROM sys.dm_pdw_exec_sessions s WHERE s.[status] = 'active' order by login_time asc OPTION(LABEL='SynapseToolkit') SELECT 'Idle Session' AS 'Idle Sessions' ,s.session_id ,s.request_id ,s.login_name ,s.login_time ,s.query_count ,s.client_id ,s.[app_name] ,'EXEC sp_sessions_detail @session_id=''' + s.session_id + '''' AS 'detail_command' FROM sys.dm_pdw_exec_sessions s WHERE s.[status] = 'idle' order by login_time asc OPTION(LABEL='SynapseToolkit') GO /*************************************************************************** Procedure name: sp_sessions_detail Description: ****************************************************************************/ IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_NAME = 'sp_sessions_detail') EXEC ('CREATE PROC dbo.sp_sessions_detail AS SELECT ''TEMPORARY''') GO ALTER PROC sp_sessions_detail @session_id [varchar](20) AS SELECT Session_id ,request_id ,[status] ,submit_time ,end_compile_time ,start_time ,end_time ,total_elapsed_time/1000 AS 'total_elapsed_time_s' ,[label] ,error_id ,command ,command2 ,classifier_name ,group_name ,importance ,resource_allocation_percentage ,result_cache_hit ,'EXEC sp_requests_detail @request_id=''' + request_id + '''' AS 'detail_command' FROM sys.dm_pdw_exec_requests WHERE session_id = @session_id ORDER BY submit_time ASC OPTION(LABEL='SynapseToolkit') /*************************************************************************** Procedure name: Description: ****************************************************************************/ /*IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_NAME = '') EXEC ('CREATE PROC dbo. AS SELECT ''TEMPORARY''') GO */ ================================================ FILE: Synapse_Toolkit/SynapseToolkit_beta.sql ================================================ /*************************************************************************** Synapse Toolkit The Synapse Toolkit is a set of stored procedures that help investigate current activity on your Synapse Dedicated SQL Pool. sp_status is the overall summary procedure that calls various other procedures to provide a picture of current activity. Use the detail_command columns to deep dive into a particular session, query, or wait. List of SPs currently included: sp_status sp_concurrency sp_requests sp_reqeusts_detail sp_sessions sp_sessions_detail sp_waits sp_waits_detail sp_datamovement ****************************************************************************/ /*************************************************************************** Procedure name: sp_status Description: Runs a few of the included SPs to give overall system utilization. ****************************************************************************/ IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_NAME = 'sp_status') EXEC ('CREATE PROC dbo.sp_status AS SELECT ''TEMPORARY''') GO ALTER PROC [dbo].[sp_status] AS PRINT 'Synapse Toolkit v2.1_beta, 11/15/22' EXEC sp_concurrency; EXEC sp_requests; EXEC sp_datamovement GO /*************************************************************************** Procedure name: sp_requests Description: Collects running requests and suspended requests in two separate result windows. A running request provides a sp_requests_details query to see the plan for the running query. A suspended request provides the sp_waits_detail query so you can see why the query is in the suspended state. ****************************************************************************/ IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_NAME = 'sp_requests') EXEC ('CREATE PROC dbo.sp_requests AS SELECT ''TEMPORARY''') GO ALTER PROC [dbo].[sp_requests] AS SELECT 'Running Request' AS 'Running Requests' ,s.session_id ,r.request_id --,r.status ,r.command ,r.resource_allocation_percentage AS 'resource_grant' ,s.login_name ,r.submit_time ,r.end_compile_time ,r.total_elapsed_time ,r.[label] ,r.classifier_name ,r.group_name ,ISNULL(r.command2, r.command) AS 'query_text' ,r.result_cache_hit --,psr.step_index --,prs.operation_type --,prs.status ,sum(ner.cpu_time)/1000 AS 'step_cpu_time' ,sum(ner.reads) AS 'step_reads' ,sum(ner.writes) AS 'step_writes' --,sum(ner.logical_reads) AS 'total_logical_reads'ok, i' ,max(ner.granted_query_memory) AS 'step_total_granted_memory_pages' ,round(log(sum(g.query_cost)),2) AS 'step_cost' ,'EXEC sp_requests_detail @request_id=''' + r.request_id + '''' AS 'request_detail_command' ,'EXEC sp_sessions_detail @session_id=''' + s.session_id + '''' AS 'session_detail_command' FROM sys.dm_pdw_exec_requests r JOIN sys.dm_pdw_exec_sessions s on r.session_id = s.session_id LEFT JOIN sys.dm_pdw_request_steps rs ON r.request_id = rs.request_id LEFT JOIN sys.dm_pdw_sql_requests sr ON rs.request_id = sr.request_id AND rs.step_index = sr.step_index LEFT JOIN sys.dm_pdw_nodes_exec_requests ner ON sr.spid = ner.session_id AND sr.pdw_node_id = ner.pdw_node_id LEFT JOIN sys.dm_pdw_nodes_exec_query_memory_grants g ON ner.session_id = g.session_id AND ner.pdw_node_id = g.pdw_node_id WHERE (r.group_name is not null OR r.result_cache_hit = 1) AND rs.[status] = 'Running' GROUP BY r.request_id --,r.[status] ,r.request_id ,r.status ,r.command ,r.command2 ,r.resource_allocation_percentage ,s.session_id ,s.login_name ,r.submit_time ,r.end_compile_time ,r.total_elapsed_time ,r.[label] ,r.classifier_name ,r.group_name --,ISNULL(r.command2, r.command) ,r.result_cache_hit OPTION(LABEL='SynapseToolkit') SELECT 'Suspended Request' AS 'Suspended Requests' ,s.session_id ,r.request_id ,s.login_name ,r.submit_time ,r.total_elapsed_time AS 'wait_time' ,r.[label] ,r.classifier_name ,ISNULL(r.command2, r.command) AS 'query_text' ,w.resource_waits AS 'concurrency_waits' ,w.object_waits AS 'object_waits' ,'EXEC sp_waits_detail @request_id=''' + r.request_id + '''' AS 'waits_detail' ,'EXEC sp_sessions_detail @session_id=''' + r.session_id + '''' AS 'session_detail_command' FROM sys.dm_pdw_exec_requests r JOIN sys.dm_pdw_exec_sessions s on r.session_id = s.session_id LEFT JOIN ( SELECT request_id ,SUM(CASE WHEN object_type = 'SYSTEM' THEN 1 ELSE 0 END) AS resource_waits ,SUM(CASE WHEN object_type != 'SYSTEM' THEN 1 ELSE 0 END) AS object_waits FROM sys.dm_pdw_waits WHERE state != 'Granted' GROUP BY request_id ) w ON r.request_id = w.request_id WHERE r.[status] = 'Suspended' OPTION(LABEL='SynapseToolkit') GO /*************************************************************************** Procedure name: sp_requests_detail Description: Provides the detailed query plan for the specified requestID. This shows a results at the distribution-level. Use Step_index to determine which step you are looking at. ****************************************************************************/ IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_NAME = 'sp_requests_detail') EXEC ('CREATE PROC dbo.sp_requests_detail AS SELECT ''TEMPORARY''') GO ALTER PROC [dbo].[sp_requests_detail] @request_id [varchar](20) AS --Query Step Data SELECT 'Query Plan' AS 'Query Plan' ,rs.request_id ,rs.step_index ,rs.operation_type ,rs.[status] AS 'step_status' ,rs.estimated_rows AS 'step_estimated_rows' ,rs.row_count AS 'step_actual_rows' ,rs.total_elapsed_time AS 'step_elapsed_time' ,dist.pdw_node_id ,dist.distribution_id ,dist.[type] AS 'distribution_step_type' ,dist.[status] AS 'distribution_step_status' ,dist.total_elapsed_time AS 'distribution_elapsed_time' ,dist.bytes_per_sec ,dist.bytes_processed ,dist.row_count ,dist.start_time ,dist.end_time ,dist.spid ,rs.command ,dist.source_info AS 'distribution_source_command' ,dist.error_id FROM (--dms SELECT request_id ,step_index ,pdw_node_id ,distribution_id ,type ,status ,start_time ,end_time ,total_elapsed_time ,command ,error_id ,sql_spid AS spid ,bytes_per_sec ,bytes_processed ,rows_processed AS row_count ,command AS dist_text ,source_info FROM sys.dm_pdw_dms_workers WHERE request_id = @request_id UNION ALL --sql SELECT request_id ,step_index ,pdw_node_id ,distribution_id ,'SQL' AS type ,[status] ,start_time ,end_time ,total_elapsed_time ,command ,-1 AS 'distribution_source_command' ,error_id ,spid ,-1 AS bytes_per_sec ,-1 AS bytes_processed ,row_count ,command AS dist_text FROM sys.dm_pdw_sql_requests WHERE request_id = @request_id AND command not like '%DISTRIBUTED_MOVE%' ) dist RIGHT JOIN sys.dm_pdw_request_steps rs ON rs.request_id = dist.request_id AND rs.step_index = dist.step_index WHERE rs.request_id = @request_id ORDER BY rs.step_index,dist.pdw_node_id,dist.distribution_id,dist.type OPTION(LABEL='SynapseToolkit') GO /*************************************************************************** Procedure name: sp_waits Description: Collects information on granted and queued object and resource (concurrency) waits. Provides statements for waits_detail queries to get more information on what is blocking what. ****************************************************************************/ IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_NAME = 'sp_waits') EXEC ('CREATE PROC dbo.sp_waits AS SELECT ''TEMPORARY''') GO ALTER PROC [dbo].[sp_waits] AS --Granted Object Locks SELECT 'Granted Object Lock' AS 'Granted Object Locks' ,w.session_id ,w.request_id ,r.[status] AS 'request_status' ,w.[state] AS 'wait_state' ,w.[type] ,w.object_type ,w.[object_name] ,r.importance ,r.classifier_name ,r.group_name ,w.priority ,w.request_time ,w.acquire_time ,r.total_elapsed_time AS 'request_elapsed_time' ,r.[label] ,ISNULL(r.command2, r.command) AS 'query_text' --,'EXEC sp_waits_detail @request_id=''' + w.request_id + '''' AS 'detail_command' FROM sys.dm_pdw_waits w JOIN sys.dm_pdw_exec_requests r ON w.request_id = r.request_id WHERE w.object_type != 'SYSTEM' AND w.[state]='Granted' AND r.[status] != 'Completed' AND w.session_id != SESSION_ID() ORDER BY r.[status],r.start_time,r.submit_time,w.priority asc OPTION(LABEL='SynapseToolkit') --Queued Locks SELECT 'Queued Object Lock' AS 'Queued Object Locks' ,w.session_id ,w.request_id ,r.[status] AS 'request_status' ,w.[state] AS 'wait_state' ,w.[type] ,w.object_type ,w.[object_name] ,r.importance ,r.classifier_name ,r.group_name ,w.priority ,w.request_time ,w.acquire_time ,r.total_elapsed_time AS 'request_elapsed_time' ,r.[label] ,ISNULL(r.command2, r.command) AS 'query_text' ,'EXEC sp_waits_detail @request_id=''' + w.request_id + '''' AS 'detail_command' FROM sys.dm_pdw_waits w JOIN sys.dm_pdw_exec_requests r ON w.request_id = r.request_id WHERE w.object_type != 'SYSTEM' AND w.[state]!='Granted' AND r.[status] != 'Completed' ORDER BY r.[status],r.start_time,r.submit_time,w.priority asc OPTION(LABEL='SynapseToolkit') --Granted concurrency waits SELECT 'Granted Concurrency Wait' AS 'Granted Concurrency Waits' ,w.session_id ,w.request_id ,r.[status] AS 'request_status' ,w.[state] AS 'wait_state' ,r.resource_allocation_percentage ,r.importance ,r.classifier_name ,r.group_name ,w.priority ,w.request_time ,w.acquire_time ,r.total_elapsed_time AS 'request_elapsed_time' ,r.[label] ,ISNULL(r.command2, r.command) AS 'query_text' FROM sys.dm_pdw_waits w JOIN sys.dm_pdw_exec_requests r on w.request_id = r.request_id WHERE object_type = 'SYSTEM' AND w.[state]='Granted' AND w.[type] NOT IN ('ConcurrencyResourceType','LocalQueriesConcurrencyResourceType') ORDER BY w.session_id,w.request_id,w.wait_id OPTION(LABEL='SynapseToolkit') --Queued concurrency waits SELECT 'Queued Concurrency Wait' AS 'Queued Concurrency Waits' ,w.session_id ,w.request_id ,r.[status] AS 'request_status' ,w.[state] AS 'wait_state' ,r.resource_allocation_percentage ,r.importance ,r.classifier_name ,r.group_name ,w.priority ,w.request_time ,w.acquire_time ,r.total_elapsed_time AS 'request_elapsed_time' ,r.[label] ,ISNULL(r.command2, r.command) AS 'query_text' FROM sys.dm_pdw_waits w JOIN sys.dm_pdw_exec_requests r on w.request_id = r.request_id WHERE object_type = 'SYSTEM' AND w.[state]!='Granted' AND w.[type] NOT IN ('ConcurrencyResourceType','LocalQueriesConcurrencyResourceType') ORDER BY w.session_id,w.request_id,w.wait_id OPTION(LABEL='SynapseToolkit') GO /*************************************************************************** Procedure name: sp_waits_detail Description: When providing a suspended requestID: This sp will return all queries that have object locks on the same objects the provided query is queued on This query returns a message if a query with no waiting object locks is provided ****************************************************************************/ IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_NAME = 'sp_waits_detail') EXEC ('CREATE PROC dbo.sp_waits_detail AS SELECT ''TEMPORARY''') GO ALTER PROC [dbo].[sp_waits_detail] @request_id [varchar](20) AS --If the provided statement is suspended, show what's blocking it IF (SELECT [status] FROM sys.dm_pdw_exec_requests WHERE request_id = @request_id) = 'Suspended' BEGIN IF (SELECT TOP 1 [object_type] FROM sys.dm_pdw_waits WHERE request_id = @request_id AND STATE != 'GRANTED' ) != 'SYSTEM' BEGIN --Queued Object Locks for provided query SELECT 'Blocked Object Lock' AS 'Blocked Object Locks' ,session_id ,request_id ,wait_id ,[state] ,[type] ,object_type ,[object_name] ,priority ,request_time ,acquire_time FROM sys.dm_pdw_waits WHERE object_type != 'SYSTEM' AND [state]!='Granted' AND request_id = @request_id ORDER BY session_id,wait_id OPTION(LABEL='SynapseToolkit') --Granted Locks on the same objects as in query SELECT 'Possible Blocker' AS 'Possible Blockers' ,w2.session_id ,w2.request_id ,w2.wait_id ,w2.[state] ,w2.[type] ,w2.object_type ,w2.[object_name] ,w2.priority ,w2.request_time ,w2.acquire_time ,'EXEC sp_requests_detail @request_id=''' + w2.request_id + '''' AS 'request_detail_command' ,'EXEC sp_sessions_detail @session_id=''' + w2.session_id + '''' AS 'session_detail_command' FROM sys.dm_pdw_waits w1 JOIN sys.dm_pdw_waits w2 ON w1.[object_name] = w2.[object_name] WHERE w1.request_id = @request_id AND w2.[state] = 'Granted' ORDER BY w2.session_id,w2.wait_id OPTION(LABEL='SynapseToolkit') END END ELSE BEGIN SELECT 'No queued object Locks found for ' + @request_id AS 'Message' END GO /*************************************************************************** Procedure name: sp_tempdb Description: lists various information about tempdb usage ****************************************************************************/ IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_NAME = 'sp_tempDB') EXEC ('CREATE PROC dbo.sp_tempDB AS SELECT ''TEMPORARY''') GO ALTER PROC sp_tempDB AS --Total TempDB Usage SELECT 'Total TempDB usage' AS 'Total TempDB usage' ,sum(pdw.rows_processed) as 'rows_written' ,sum(pdw.bytes_processed) as 'bytes_written' ,CAST(sum(pdw.bytes_processed)/1024.0/1024.0/1024.0 AS Decimal(10,1)) AS 'GB_written' ,total_tempdb.total_tempdb_gb as 'Total_tempDB_size_GB' ,CAST(((sum(pdw.bytes_processed)/1024.0/1024.0/1024.0)/total_tempdb.total_tempdb_gb)*100.0 AS Decimal(10,1)) AS 'approx_percent_used' FROM Sys.dm_pdw_dms_workers pdw JOIN sys.dm_pdw_exec_requests req ON pdw.request_id = req.request_id JOIN (SELECT (count(1) * 1995) AS total_tempdb_gb FROM sys.dm_pdw_nodes WHERE type='COMPUTE') AS total_tempdb ON 1=1 WHERE pdw.type = 'Writer' AND req.status = 'running' GROUP BY total_tempdb.total_tempdb_gb /* --Tempdb usage per query SELECT 'TempDB per query' AS 'TempDB per query' ,req.request_id ,sum(pdw.bytes_processed) as 'bytes_written' ,CAST(sum(pdw.bytes_processed)/1024.0/1024.0/1024.0 AS Decimal(10,1)) AS 'GB_written' ,sum(pdw.rows_processed) as 'rows_written' ,'EXEC sp_requests_detail @request_id=''' + req.request_id + '''' AS 'request_detail_command' from Sys.dm_pdw_dms_workers pdw JOIN sys.dm_pdw_exec_requests req ON pdw.request_id = req.request_id WHERE pdw.type = 'Writer' AND req.status = 'running' GROUP BY req.request_id ORDER BY bytes_written desc */ /*************************************************************************** Procedure name: sp_tempdb_node Description: lists various information about tempdb usage ****************************************************************************/ IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_NAME = 'sp_tempdb_node') EXEC ('CREATE PROC dbo.sp_tempdb_node AS SELECT ''TEMPORARY''') GO ALTER PROC sp_tempdb_node AS --Tempdb usage per node SELECT 'TempDB per node' AS 'TempDB per node' ,pdw.pdw_node_id ,n.type ,sum(pdw.bytes_processed) as 'bytes_written' ,CAST(sum(pdw.bytes_processed)/1024.0/1024.0/1024.0 AS Decimal(10,1)) AS 'GB_written' ,'1995' AS 'Total_tempDB_size_GB' ,CAST(((sum(pdw.bytes_processed)/1024.0/1024.0/1024.0)/1995.0)*100 AS Decimal(10,1)) AS 'percent_used' ,sum(pdw.rows_processed) as 'rows_written' FROM sys.dm_pdw_nodes n LEFT JOIN Sys.dm_pdw_dms_workers pdw ON n.pdw_node_id = pdw.pdw_node_id LEFT JOIN sys.dm_pdw_exec_requests req ON pdw.request_id = req.request_id WHERE pdw.type = 'Writer' AND req.status = 'running' GROUP BY n.type,pdw.pdw_node_id ORDER BY bytes_written desc /*************************************************************************** Procedure name: sp_concurrency Description: Shows general information about how many queries are running/suspended and how many queued object locks or resource (concurrency) locks. Also shows the currentl percentage of resources allocated to running queries by workload group assignment ****************************************************************************/ IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_NAME = 'sp_concurrency') EXEC ('CREATE PROC dbo.sp_concurrency AS SELECT ''TEMPORARY''') GO ALTER PROC [dbo].[sp_concurrency] AS SELECT sum(case when r.status = 'Running' then r.resource_allocation_percentage else 0 end) as 'total_resources_granted' ,tempdb_metrics.percent_used as 'approx_tempdb_used_percent' --,sum(case when s.status = 'Active' then 1 else 0 end) as 'active_sessions' --sum(case when s.status = 'Idle' then 1 else 0 end) as 'idle_sessions' ,(SELECT count(1) FROM sys.dm_pdw_exec_sessions where status = 'Active') AS 'active_sessions' ,(SELECT count(1) FROM sys.dm_pdw_exec_sessions where status = 'Idle') AS 'idle_sessions' ,sum(case when r.status = 'Running' AND (r.group_name is not null OR r.result_cache_hit = 1) then 1 else 0 end) as running_queries ,sum(case when r.status = 'suspended' then 1 else 0 end) as queued_queries ,sum(case when w.queued_resource_waits > 0 then 1 else 0 end) AS concurrency_waits ,sum(case when w.queued_object_locks > 0 then 1 else 0 end) AS object_waits ,'EXEC sp_tempdb' AS 'tempdb_usage_detail' FROM sys.dm_pdw_exec_requests r JOIN sys.dm_pdw_exec_sessions s ON r.session_id = s.session_id LEFT JOIN ( SELECT request_id ,count(request_id) AS queued_locks ,sum(case when object_type = 'system' then 1 else 0 end) as queued_resource_waits ,sum(case when object_type != 'system' then 1 else 0 end) as queued_object_locks FROM sys.dm_pdw_waits WHERE state != 'Granted' GROUP BY request_id ) w ON w.request_id = r.request_id JOIN ( SELECT sum(pdw.bytes_processed) as 'bytes_written' ,CAST(sum(pdw.bytes_processed)/1024.0/1024.0/1024.0 AS Decimal(10,1)) AS 'GB_written' ,sum(pdw.rows_processed) as 'rows_written' ,total_tempdb.total_tempdb_gb ,CAST(((sum(pdw.bytes_processed)/1024.0/1024.0/1024.0)/total_tempdb.total_tempdb_gb)*100.0 AS Decimal(10,1)) AS 'percent_used' FROM Sys.dm_pdw_dms_workers pdw JOIN sys.dm_pdw_exec_requests req ON pdw.request_id = req.request_id JOIN (SELECT (count(1) * 1995) AS total_tempdb_gb FROM sys.dm_pdw_nodes WHERE type='COMPUTE') AS total_tempdb ON 1=1 WHERE pdw.type = 'Writer' AND req.status = 'running' GROUP BY total_tempdb.total_tempdb_gb ) AS tempdb_metrics ON 1=1 GROUP BY tempdb_metrics.percent_used OPTION(LABEL='SynapseToolkit') GO /*************************************************************************** Procedure name: sp_datamovement Description: Shows all data movement currently happening in order from largest to smallest. The items at the top of this list are likely the most resource- intensive queries currently running. ****************************************************************************/ IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_NAME = 'sp_datamovement') EXEC ('CREATE PROC dbo.sp_datamovement AS SELECT ''TEMPORARY''') GO ALTER PROC sp_datamovement AS WITH step_data AS ( SELECT SUM(rows_processed) AS Step_Rows_Processed , SUM(Bytes_processed) AS Step_Bytes_Processed , max(total_elapsed_time) AS Step_elapsed_time , request_id , step_index , status --, type FROM sys.dm_pdw_dms_workers WHERE status != 'StepComplete' AND type != 'Writer' --including writers gives you double counts on operations Group by request_id , step_index , status ) SELECT 'Data Movement' AS 'Data Movements' ,s.login_name ,step_data.request_id , per.session_id , rs.operation_type , (step_data.Step_elapsed_time/1000/60) AS 'step_elapsed_time_(m)' , step_data.Step_rows_processed --, step_data.step_bytes_processed , (step_data.Step_Bytes_Processed/1024/1024/1024) AS Step_GB_Processed , step_data.step_index --, step_data.type , step_data.status as Step_status --, per.status AS QID_Status , per.total_elapsed_time/1000/60 as 'QID_elapsed_time(m)' , ISNULL(per.command2, per.command) AS 'QID_Command' , per.resource_class , per.importance ,'EXEC sp_requests_detail @request_id=''' + per.request_id + '''' AS 'request_detail_command' FROM step_data LEFT JOIN sys.dm_pdw_exec_requests per ON step_data.request_id = per.request_id JOIN sys.dm_pdw_exec_sessions s ON per.session_id = s.session_id JOIN sys.dm_pdw_request_steps rs ON step_data.request_id = rs.request_id AND step_data.step_index = rs.step_index WHERE per.status = 'Running' ORDER BY step_data.Step_rows_processed DESC OPTION(LABEL='SynapseToolkit') GO /*************************************************************************** Procedure name: sp_sessions Description: status of all open sessions ****************************************************************************/ IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_NAME = 'sp_sessions') EXEC ('CREATE PROC dbo.sp_sessions AS SELECT ''TEMPORARY''') GO ALTER PROC sp_sessions AS SELECT 'Active Session' AS 'Active Sessions' ,s.session_id ,s.request_id ,s.login_name ,s.login_time ,s.query_count ,s.client_id ,s.[app_name] ,'EXEC sp_sessions_detail @session_id=''' + s.session_id + '''' AS 'detail_command' FROM sys.dm_pdw_exec_sessions s WHERE s.[status] = 'active' order by login_time asc OPTION(LABEL='SynapseToolkit') SELECT 'Idle Session' AS 'Idle Sessions' ,s.session_id ,s.request_id ,s.login_name ,s.login_time ,s.query_count ,s.client_id ,s.[app_name] ,'EXEC sp_sessions_detail @session_id=''' + s.session_id + '''' AS 'detail_command' FROM sys.dm_pdw_exec_sessions s WHERE s.[status] = 'idle' order by login_time asc OPTION(LABEL='SynapseToolkit') GO /*************************************************************************** Procedure name: sp_sessions_detail Description: ****************************************************************************/ IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_NAME = 'sp_sessions_detail') EXEC ('CREATE PROC dbo.sp_sessions_detail AS SELECT ''TEMPORARY''') GO ALTER PROC sp_sessions_detail @session_id [varchar](20) AS SELECT Session_id ,request_id ,[status] ,submit_time ,end_compile_time ,start_time ,end_time ,total_elapsed_time/1000 AS 'total_elapsed_time_s' ,[label] ,error_id ,command ,command2 ,classifier_name ,group_name ,importance ,resource_allocation_percentage ,result_cache_hit ,'EXEC sp_requests_detail @request_id=''' + request_id + '''' AS 'detail_command' FROM sys.dm_pdw_exec_requests WHERE session_id = @session_id ORDER BY submit_time ASC OPTION(LABEL='SynapseToolkit') /*************************************************************************** Procedure name: Description: ****************************************************************************/ /*IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_NAME = '') EXEC ('CREATE PROC dbo. AS SELECT ''TEMPORARY''') GO */ ================================================ FILE: Synapse_Toolkit/SynapseToolkit_beta.sql.bak ================================================ /*************************************************************************** Synapse Toolkit The Synapse Toolkit is a set of stored procedures that help investigate current activity on your Synapse Dedicated SQL Pool. sp_status is the overall summary procedure that calls various other procedures to provide a picture of current activity. Use the detail_command columns to deep dive into a particular session, query, or wait. List of SPs currently included: sp_status sp_concurrency sp_requests sp_reqeusts_detail sp_sessions sp_sessions_detail sp_waits sp_waits_detail sp_datamovement ****************************************************************************/ /*************************************************************************** Procedure name: sp_status Description: Runs a few of the included SPs to give overall system utilization. ****************************************************************************/ IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_NAME = 'sp_status') EXEC ('CREATE PROC dbo.sp_status AS SELECT ''TEMPORARY''') GO ALTER PROC [dbo].[sp_status] AS PRINT 'Synapse Toolkit v2.1_beta, 11/15/22' EXEC sp_concurrency; EXEC sp_requests; EXEC sp_datamovement GO /*************************************************************************** Procedure name: sp_requests Description: Collects running requests and suspended requests in two separate result windows. A running request provides a sp_requests_details query to see the plan for the running query. A suspended request provides the sp_waits_detail query so you can see why the query is in the suspended state. ****************************************************************************/ IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_NAME = 'sp_requests') EXEC ('CREATE PROC dbo.sp_requests AS SELECT ''TEMPORARY''') GO ALTER PROC [dbo].[sp_requests] AS SELECT 'Running Request' AS 'Running Requests' ,s.session_id ,r.request_id --,r.status ,r.command ,r.resource_allocation_percentage AS 'resource_grant' ,s.login_name ,r.submit_time ,r.end_compile_time ,r.total_elapsed_time ,r.[label] ,r.classifier_name ,r.group_name ,ISNULL(r.command2, r.command) AS 'query_text' ,r.result_cache_hit --,psr.step_index --,prs.operation_type --,prs.status ,sum(ner.cpu_time)/1000 AS 'step_cpu_time' ,sum(ner.reads) AS 'step_reads' ,sum(ner.writes) AS 'step_writes' --,sum(ner.logical_reads) AS 'total_logical_reads'ok, i' ,max(ner.granted_query_memory) AS 'step_total_granted_memory_pages' ,round(log(sum(g.query_cost)),2) AS 'step_cost' ,'EXEC sp_requests_detail @request_id=''' + r.request_id + '''' AS 'request_detail_command' ,'EXEC sp_sessions_detail @session_id=''' + s.session_id + '''' AS 'session_detail_command' FROM sys.dm_pdw_exec_requests r JOIN sys.dm_pdw_exec_sessions s on r.session_id = s.session_id LEFT JOIN sys.dm_pdw_request_steps rs ON r.request_id = rs.request_id LEFT JOIN sys.dm_pdw_sql_requests sr ON rs.request_id = sr.request_id AND rs.step_index = sr.step_index LEFT JOIN sys.dm_pdw_nodes_exec_requests ner ON sr.spid = ner.session_id AND sr.pdw_node_id = ner.pdw_node_id LEFT JOIN sys.dm_pdw_nodes_exec_query_memory_grants g ON ner.session_id = g.session_id AND ner.pdw_node_id = g.pdw_node_id WHERE (r.group_name is not null OR r.result_cache_hit = 1) AND rs.[status] = 'Running' GROUP BY r.request_id --,r.[status] ,r.request_id ,r.status ,r.command ,r.command2 ,r.resource_allocation_percentage ,s.session_id ,s.login_name ,r.submit_time ,r.end_compile_time ,r.total_elapsed_time ,r.[label] ,r.classifier_name ,r.group_name --,ISNULL(r.command2, r.command) ,r.result_cache_hit OPTION(LABEL='SynapseToolkit') SELECT 'Suspended Request' AS 'Suspended Requests' ,s.session_id ,r.request_id ,s.login_name ,r.submit_time ,r.total_elapsed_time AS 'wait_time' ,r.[label] ,r.classifier_name ,ISNULL(r.command2, r.command) AS 'query_text' ,w.resource_waits AS 'concurrency_waits' ,w.object_waits AS 'object_waits' ,'EXEC sp_waits_detail @request_id=''' + r.request_id + '''' AS 'waits_detail' ,'EXEC sp_sessions_detail @session_id=''' + r.session_id + '''' AS 'session_detail_command' FROM sys.dm_pdw_exec_requests r JOIN sys.dm_pdw_exec_sessions s on r.session_id = s.session_id LEFT JOIN ( SELECT request_id ,SUM(CASE WHEN object_type = 'SYSTEM' THEN 1 ELSE 0 END) AS resource_waits ,SUM(CASE WHEN object_type != 'SYSTEM' THEN 1 ELSE 0 END) AS object_waits FROM sys.dm_pdw_waits WHERE state != 'Granted' GROUP BY request_id ) w ON r.request_id = w.request_id WHERE r.[status] = 'Suspended' OPTION(LABEL='SynapseToolkit') GO /*************************************************************************** Procedure name: sp_requests_detail Description: Provides the detailed query plan for the specified requestID. This shows a results at the distribution-level. Use Step_index to determine which step you are looking at. ****************************************************************************/ IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_NAME = 'sp_requests_detail') EXEC ('CREATE PROC dbo.sp_requests_detail AS SELECT ''TEMPORARY''') GO ALTER PROC [dbo].[sp_requests_detail] @request_id [varchar](20) AS --Query Step Data SELECT 'Query Plan' AS 'Query Plan' ,rs.request_id ,rs.step_index ,rs.operation_type ,rs.[status] AS 'step_status' ,rs.estimated_rows AS 'step_estimated_rows' ,rs.row_count AS 'step_actual_rows' ,rs.total_elapsed_time AS 'step_elapsed_time' ,dist.pdw_node_id ,dist.distribution_id ,dist.[type] AS 'distribution_step_type' ,dist.[status] AS 'distribution_step_status' ,dist.total_elapsed_time AS 'distribution_elapsed_time' ,dist.bytes_per_sec ,dist.bytes_processed ,dist.row_count ,dist.start_time ,dist.end_time ,dist.spid ,rs.command ,dist.source_info AS 'distribution_source_command' ,dist.error_id FROM (--dms SELECT request_id ,step_index ,pdw_node_id ,distribution_id ,type ,status ,start_time ,end_time ,total_elapsed_time ,command ,error_id ,sql_spid AS spid ,bytes_per_sec ,bytes_processed ,rows_processed AS row_count ,command AS dist_text ,source_info FROM sys.dm_pdw_dms_workers WHERE request_id = @request_id UNION ALL --sql SELECT request_id ,step_index ,pdw_node_id ,distribution_id ,'SQL' AS type ,[status] ,start_time ,end_time ,total_elapsed_time ,command ,-1 AS 'distribution_source_command' ,error_id ,spid ,-1 AS bytes_per_sec ,-1 AS bytes_processed ,row_count ,command AS dist_text FROM sys.dm_pdw_sql_requests WHERE request_id = @request_id AND command not like '%DISTRIBUTED_MOVE%' ) dist RIGHT JOIN sys.dm_pdw_request_steps rs ON rs.request_id = dist.request_id AND rs.step_index = dist.step_index WHERE rs.request_id = @request_id ORDER BY rs.step_index,dist.pdw_node_id,dist.distribution_id,dist.type OPTION(LABEL='SynapseToolkit') GO /*************************************************************************** Procedure name: sp_waits Description: Collects information on granted and queued object and resource (concurrency) waits. Provides statements for waits_detail queries to get more information on what is blocking what. ****************************************************************************/ IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_NAME = 'sp_waits') EXEC ('CREATE PROC dbo.sp_waits AS SELECT ''TEMPORARY''') GO ALTER PROC [dbo].[sp_waits] AS --Granted Object Locks SELECT 'Granted Object Lock' AS 'Granted Object Locks' ,w.session_id ,w.request_id ,r.[status] AS 'request_status' ,w.[state] AS 'wait_state' ,w.[type] ,w.object_type ,w.[object_name] ,r.importance ,r.classifier_name ,r.group_name ,w.priority ,w.request_time ,w.acquire_time ,r.total_elapsed_time AS 'request_elapsed_time' ,r.[label] ,ISNULL(r.command2, r.command) AS 'query_text' --,'EXEC sp_waits_detail @request_id=''' + w.request_id + '''' AS 'detail_command' FROM sys.dm_pdw_waits w JOIN sys.dm_pdw_exec_requests r ON w.request_id = r.request_id WHERE w.object_type != 'SYSTEM' AND w.[state]='Granted' AND r.[status] != 'Completed' AND w.session_id != SESSION_ID() ORDER BY r.[status],r.start_time,r.submit_time,w.priority asc OPTION(LABEL='SynapseToolkit') --Queued Locks SELECT 'Queued Object Lock' AS 'Queued Object Locks' ,w.session_id ,w.request_id ,r.[status] AS 'request_status' ,w.[state] AS 'wait_state' ,w.[type] ,w.object_type ,w.[object_name] ,r.importance ,r.classifier_name ,r.group_name ,w.priority ,w.request_time ,w.acquire_time ,r.total_elapsed_time AS 'request_elapsed_time' ,r.[label] ,ISNULL(r.command2, r.command) AS 'query_text' ,'EXEC sp_waits_detail @request_id=''' + w.request_id + '''' AS 'detail_command' FROM sys.dm_pdw_waits w JOIN sys.dm_pdw_exec_requests r ON w.request_id = r.request_id WHERE w.object_type != 'SYSTEM' AND w.[state]!='Granted' AND r.[status] != 'Completed' ORDER BY r.[status],r.start_time,r.submit_time,w.priority asc OPTION(LABEL='SynapseToolkit') --Granted concurrency waits SELECT 'Granted Concurrency Wait' AS 'Granted Concurrency Waits' ,w.session_id ,w.request_id ,r.[status] AS 'request_status' ,w.[state] AS 'wait_state' ,r.resource_allocation_percentage ,r.importance ,r.classifier_name ,r.group_name ,w.priority ,w.request_time ,w.acquire_time ,r.total_elapsed_time AS 'request_elapsed_time' ,r.[label] ,ISNULL(r.command2, r.command) AS 'query_text' FROM sys.dm_pdw_waits w JOIN sys.dm_pdw_exec_requests r on w.request_id = r.request_id WHERE object_type = 'SYSTEM' AND w.[state]='Granted' AND w.[type] NOT IN ('ConcurrencyResourceType','LocalQueriesConcurrencyResourceType') ORDER BY w.session_id,w.request_id,w.wait_id OPTION(LABEL='SynapseToolkit') --Queued concurrency waits SELECT 'Queued Concurrency Wait' AS 'Queued Concurrency Waits' ,w.session_id ,w.request_id ,r.[status] AS 'request_status' ,w.[state] AS 'wait_state' ,r.resource_allocation_percentage ,r.importance ,r.classifier_name ,r.group_name ,w.priority ,w.request_time ,w.acquire_time ,r.total_elapsed_time AS 'request_elapsed_time' ,r.[label] ,ISNULL(r.command2, r.command) AS 'query_text' FROM sys.dm_pdw_waits w JOIN sys.dm_pdw_exec_requests r on w.request_id = r.request_id WHERE object_type = 'SYSTEM' AND w.[state]!='Granted' AND w.[type] NOT IN ('ConcurrencyResourceType','LocalQueriesConcurrencyResourceType') ORDER BY w.session_id,w.request_id,w.wait_id OPTION(LABEL='SynapseToolkit') GO /*************************************************************************** Procedure name: sp_waits_detail Description: When providing a suspended requestID: This sp will return all queries that have object locks on the same objects the provided query is queued on This query returns a message if a query with no waiting object locks is provided ****************************************************************************/ IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_NAME = 'sp_waits_detail') EXEC ('CREATE PROC dbo.sp_waits_detail AS SELECT ''TEMPORARY''') GO ALTER PROC [dbo].[sp_waits_detail] @request_id [varchar](20) AS --If the provided statement is suspended, show what's blocking it IF (SELECT [status] FROM sys.dm_pdw_exec_requests WHERE request_id = @request_id) = 'Suspended' BEGIN IF (SELECT TOP 1 [object_type] FROM sys.dm_pdw_waits WHERE request_id = @request_id AND STATE != 'GRANTED' ) != 'SYSTEM' BEGIN --Queued Object Locks for provided query SELECT 'Blocked Object Lock' AS 'Blocked Object Locks' ,session_id ,request_id ,wait_id ,[state] ,[type] ,object_type ,[object_name] ,priority ,request_time ,acquire_time FROM sys.dm_pdw_waits WHERE object_type != 'SYSTEM' AND [state]!='Granted' AND request_id = @request_id ORDER BY session_id,wait_id OPTION(LABEL='SynapseToolkit') --Granted Locks on the same objects as in query SELECT 'Possible Blocker' AS 'Possible Blockers' ,w2.session_id ,w2.request_id ,w2.wait_id ,w2.[state] ,w2.[type] ,w2.object_type ,w2.[object_name] ,w2.priority ,w2.request_time ,w2.acquire_time ,'EXEC sp_requests_detail @request_id=''' + w2.request_id + '''' AS 'request_detail_command' ,'EXEC sp_sessions_detail @session_id=''' + w2.session_id + '''' AS 'session_detail_command' FROM sys.dm_pdw_waits w1 JOIN sys.dm_pdw_waits w2 ON w1.[object_name] = w2.[object_name] WHERE w1.request_id = @request_id AND w2.[state] = 'Granted' ORDER BY w2.session_id,w2.wait_id OPTION(LABEL='SynapseToolkit') END END ELSE BEGIN SELECT 'No queued object Locks found for ' + @request_id AS 'Message' END GO /*************************************************************************** Procedure name: sp_tempdb Description: lists various information about tempdb usage ****************************************************************************/ IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_NAME = 'sp_tempDB') EXEC ('CREATE PROC dbo.sp_tempDB AS SELECT ''TEMPORARY''') GO ALTER PROC sp_tempDB AS --Total TempDB Usage SELECT 'Total TempDB usage' AS 'Total TempDB usage' ,sum(pdw.rows_processed) as 'rows_written' ,sum(pdw.bytes_processed) as 'bytes_written' ,CAST(sum(pdw.bytes_processed)/1024.0/1024.0/1024.0 AS Decimal(10,1)) AS 'GB_written' ,total_tempdb.total_tempdb_gb as 'Total_tempDB_size_GB' ,CAST(((sum(pdw.bytes_processed)/1024.0/1024.0/1024.0)/total_tempdb.total_tempdb_gb)*100.0 AS Decimal(10,1)) AS 'approx_percent_used' FROM Sys.dm_pdw_dms_workers pdw JOIN sys.dm_pdw_exec_requests req ON pdw.request_id = req.request_id JOIN (SELECT (count(1) * 1995) AS total_tempdb_gb FROM sys.dm_pdw_nodes WHERE type='COMPUTE') AS total_tempdb ON 1=1 WHERE pdw.type = 'Writer' AND req.status = 'running' GROUP BY total_tempdb.total_tempdb_gb --Tempdb usage per query SELECT 'TempDB per query' AS 'TempDB per query' ,req.request_id ,sum(pdw.bytes_processed) as 'bytes_written' ,CAST(sum(pdw.bytes_processed)/1024.0/1024.0/1024.0 AS Decimal(10,1)) AS 'GB_written' ,sum(pdw.rows_processed) as 'rows_written' ,'EXEC sp_requests_detail @request_id=''' + req.request_id + '''' AS 'request_detail_command' from Sys.dm_pdw_dms_workers pdw JOIN sys.dm_pdw_exec_requests req ON pdw.request_id = req.request_id WHERE pdw.type = 'Writer' AND req.status = 'running' GROUP BY req.request_id ORDER BY bytes_written desc --Tempdb usage per node SELECT 'TempDB per node' AS 'TempDB per node' ,pdw.pdw_node_id ,n.type ,sum(pdw.bytes_processed) as 'bytes_written' ,CAST(sum(pdw.bytes_processed)/1024.0/1024.0/1024.0 AS Decimal(10,1)) AS 'GB_written' ,'1995' AS 'Total_tempDB_size_GB' ,CAST(((sum(pdw.bytes_processed)/1024.0/1024.0/1024.0)/1995.0)*100 AS Decimal(10,1)) AS 'percent_used' ,sum(pdw.rows_processed) as 'rows_written' FROM sys.dm_pdw_nodes n LEFT JOIN Sys.dm_pdw_dms_workers pdw ON n.pdw_node_id = pdw.pdw_node_id LEFT JOIN sys.dm_pdw_exec_requests req ON pdw.request_id = req.request_id WHERE pdw.type = 'Writer' AND req.status = 'running' GROUP BY n.type,pdw.pdw_node_id ORDER BY bytes_written desc /*************************************************************************** Procedure name: sp_concurrency Description: Shows general information about how many queries are running/suspended and how many queued object locks or resource (concurrency) locks. Also shows the currentl percentage of resources allocated to running queries by workload group assignment ****************************************************************************/ IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_NAME = 'sp_concurrency') EXEC ('CREATE PROC dbo.sp_concurrency AS SELECT ''TEMPORARY''') GO ALTER PROC [dbo].[sp_concurrency] AS SELECT sum(case when r.status = 'Running' then r.resource_allocation_percentage else 0 end) as 'total_resources_granted' ,tempdb_metrics.percent_used as 'approx_tempdb_used_percent' --,sum(case when s.status = 'Active' then 1 else 0 end) as 'active_sessions' --sum(case when s.status = 'Idle' then 1 else 0 end) as 'idle_sessions' ,(SELECT count(1) FROM sys.dm_pdw_exec_sessions where status = 'Active') AS 'active_sessions' ,(SELECT count(1) FROM sys.dm_pdw_exec_sessions where status = 'Idle') AS 'idle_sessions' ,sum(case when r.status = 'Running' AND (r.group_name is not null OR r.result_cache_hit = 1) then 1 else 0 end) as running_queries ,sum(case when r.status = 'suspended' then 1 else 0 end) as queued_queries ,sum(case when w.queued_resource_waits > 0 then 1 else 0 end) AS concurrency_waits ,sum(case when w.queued_object_locks > 0 then 1 else 0 end) AS object_waits ,'EXEC sp_tempdb' AS 'tempdb_usage_detail' FROM sys.dm_pdw_exec_requests r JOIN sys.dm_pdw_exec_sessions s ON r.session_id = s.session_id LEFT JOIN ( SELECT request_id ,count(request_id) AS queued_locks ,sum(case when object_type = 'system' then 1 else 0 end) as queued_resource_waits ,sum(case when object_type != 'system' then 1 else 0 end) as queued_object_locks FROM sys.dm_pdw_waits WHERE state != 'Granted' GROUP BY request_id ) w ON w.request_id = r.request_id JOIN ( SELECT sum(pdw.bytes_processed) as 'bytes_written' ,CAST(sum(pdw.bytes_processed)/1024.0/1024.0/1024.0 AS Decimal(10,1)) AS 'GB_written' ,sum(pdw.rows_processed) as 'rows_written' ,total_tempdb.total_tempdb_gb ,CAST(((sum(pdw.bytes_processed)/1024.0/1024.0/1024.0)/total_tempdb.total_tempdb_gb)*100.0 AS Decimal(10,1)) AS 'percent_used' FROM Sys.dm_pdw_dms_workers pdw JOIN sys.dm_pdw_exec_requests req ON pdw.request_id = req.request_id JOIN (SELECT (count(1) * 1995) AS total_tempdb_gb FROM sys.dm_pdw_nodes WHERE type='COMPUTE') AS total_tempdb ON 1=1 WHERE pdw.type = 'Writer' AND req.status = 'running' GROUP BY total_tempdb.total_tempdb_gb ) AS tempdb_metrics ON 1=1 GROUP BY tempdb_metrics.percent_used OPTION(LABEL='SynapseToolkit') GO /*************************************************************************** Procedure name: sp_datamovement Description: Shows all data movement currently happening in order from largest to smallest. The items at the top of this list are likely the most resource- intensive queries currently running. ****************************************************************************/ IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_NAME = 'sp_datamovement') EXEC ('CREATE PROC dbo.sp_datamovement AS SELECT ''TEMPORARY''') GO ALTER PROC sp_datamovement AS WITH step_data AS ( SELECT SUM(rows_processed) AS Step_Rows_Processed , SUM(Bytes_processed) AS Step_Bytes_Processed , max(total_elapsed_time) AS Step_elapsed_time , request_id , step_index , status --, type FROM sys.dm_pdw_dms_workers WHERE status != 'StepComplete' AND type != 'Writer' --including writers gives you double counts on operations Group by request_id , step_index , status ) SELECT 'Data Movement' AS 'Data Movements' ,s.login_name ,step_data.request_id , per.session_id , rs.operation_type , (step_data.Step_elapsed_time/1000/60) AS 'step_elapsed_time_(m)' , step_data.Step_rows_processed --, step_data.step_bytes_processed , (step_data.Step_Bytes_Processed/1024/1024/1024) AS Step_GB_Processed , step_data.step_index --, step_data.type , step_data.status as Step_status --, per.status AS QID_Status , per.total_elapsed_time/1000/60 as 'QID_elapsed_time(m)' , ISNULL(per.command2, per.command) AS 'QID_Command' , per.resource_class , per.importance ,'EXEC sp_requests_detail @request_id=''' + per.request_id + '''' AS 'request_detail_command' FROM step_data LEFT JOIN sys.dm_pdw_exec_requests per ON step_data.request_id = per.request_id JOIN sys.dm_pdw_exec_sessions s ON per.session_id = s.session_id JOIN sys.dm_pdw_request_steps rs ON step_data.request_id = rs.request_id AND step_data.step_index = rs.step_index WHERE per.status = 'Running' ORDER BY step_data.Step_rows_processed DESC OPTION(LABEL='SynapseToolkit') GO /*************************************************************************** Procedure name: sp_sessions Description: status of all open sessions ****************************************************************************/ IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_NAME = 'sp_sessions') EXEC ('CREATE PROC dbo.sp_sessions AS SELECT ''TEMPORARY''') GO ALTER PROC sp_sessions AS SELECT 'Active Session' AS 'Active Sessions' ,s.session_id ,s.request_id ,s.login_name ,s.login_time ,s.query_count ,s.client_id ,s.[app_name] ,'EXEC sp_sessions_detail @session_id=''' + s.session_id + '''' AS 'detail_command' FROM sys.dm_pdw_exec_sessions s WHERE s.[status] = 'active' order by login_time asc OPTION(LABEL='SynapseToolkit') SELECT 'Idle Session' AS 'Idle Sessions' ,s.session_id ,s.request_id ,s.login_name ,s.login_time ,s.query_count ,s.client_id ,s.[app_name] ,'EXEC sp_sessions_detail @session_id=''' + s.session_id + '''' AS 'detail_command' FROM sys.dm_pdw_exec_sessions s WHERE s.[status] = 'idle' order by login_time asc OPTION(LABEL='SynapseToolkit') GO /*************************************************************************** Procedure name: sp_sessions_detail Description: ****************************************************************************/ IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_NAME = 'sp_sessions_detail') EXEC ('CREATE PROC dbo.sp_sessions_detail AS SELECT ''TEMPORARY''') GO ALTER PROC sp_sessions_detail @session_id [varchar](20) AS SELECT Session_id ,request_id ,[status] ,submit_time ,end_compile_time ,start_time ,end_time ,total_elapsed_time/1000 AS 'total_elapsed_time_s' ,[label] ,error_id ,command ,command2 ,classifier_name ,group_name ,importance ,resource_allocation_percentage ,result_cache_hit ,'EXEC sp_requests_detail @request_id=''' + request_id + '''' AS 'detail_command' FROM sys.dm_pdw_exec_requests WHERE session_id = @session_id ORDER BY submit_time ASC OPTION(LABEL='SynapseToolkit') /*************************************************************************** Procedure name: Description: ****************************************************************************/ /*IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_NAME = '') EXEC ('CREATE PROC dbo. AS SELECT ''TEMPORARY''') GO */ ================================================ FILE: TSQL_Queries/Current_Activity/CollectNodeMemoryUsage.sql ================================================ /* =============================== Node Memory Usage =============================== The following query will show how much memory is currently in use by each SQLDW node compared to the max for current DWU. If memory utilization regularly hits it's limits during workload execution, consider scaling up your data warehouse. */ SELECT pc1.cntr_value as Curr_Mem_KB, pc1.cntr_value/1024.0 as Curr_Mem_MB, (pc1.cntr_value/1048576.0) as Curr_Mem_GB, pc2.cntr_value as Max_Mem_KB, pc2.cntr_value/1024.0 as Max_Mem_MB, (pc2.cntr_value/1048576.0) as Max_Mem_GB, pc1.cntr_value * 100.0/pc2.cntr_value AS Memory_Utilization_Percentage, pc1.pdw_node_id FROM -- pc1: current memory sys.dm_pdw_nodes_os_performance_counters AS pc1 -- pc2: total memory allowed for this SQL instance JOIN sys.dm_pdw_nodes_os_performance_counters AS pc2 ON pc1.object_name = pc2.object_name AND pc1.pdw_node_id = pc2.pdw_node_id WHERE pc1.counter_name = 'Total Server Memory (KB)' AND pc2.counter_name = 'Target Server Memory (KB)' ================================================ FILE: TSQL_Queries/Current_Activity/CountGrantedConcurrencySlots.sql ================================================ /* =============================== Granted Concurrency Slots =============================== The following query will show how many conccurency slots are currently granted Source: https://docs.microsoft.com/en-us/azure/sql-data-warehouse/analyze-your-workload */ SELECT SUM([concurrency_slots_used]) as total_granted_slots FROM sys.[dm_pdw_resource_waits] WHERE [state] = 'Granted' AND [resource_class] is not null AND [session_id] <> session_id() ; ================================================ FILE: TSQL_Queries/Current_Activity/DMSHeavyHitters.sql ================================================ /* ========================== DMS Heavy Hitters ========================== The following query returns queries that are currently processing rows in DMS sorted from largest to smallest. Queries that are processing very large amounts of rows or volume of data could be spilling to tempdb and impacting other queries. When troubleshooting a "general slowness" issue, this query can help you find the query steps that are most likley to be impacting other resources. */ WITH step_data AS ( SELECT SUM(rows_processed) AS Step_Rows_Processed , SUM(Bytes_processed) AS Step_Bytes_Processed , request_id , step_index , status , type FROM sys.dm_pdw_dms_workers WHERE status != 'StepComplete' Group by request_id , step_index , status , type ) SELECT step_data.request_id , per.session_id , step_data.Step_rows_processed , step_data.step_bytes_processed , (step_data.Step_Bytes_Processed/1024/1024/1024) AS Step_GB_Processed , step_data.step_index , step_data.type , step_data.status as Step_status , per.status AS QID_Status , per.total_elapsed_time/1000/60 as 'QID_Elapsed_Time (min)' , per.command AS 'QID_Command' , per.resource_class , per.importance FROM step_data LEFT JOIN sys.dm_pdw_exec_requests per ON step_data.request_id = per.request_id WHERE per.status = 'Running' ORDER BY step_data.Step_rows_processed DESC ================================================ FILE: TSQL_Queries/Current_Activity/IdentifyBlocking1.sql ================================================ /* ========================== Identify Blocking 1 ========================== This query looks for any queries that are not currently granted, then returns all other waits on that same object. Returns no results if there are no blocked queries. Example: if there is a queued query waiting on an exclusive lock on an object, any other lock on that object that is currently granted is considered blocking that query. */ select * from sys.dm_pdw_waits where object_name in (select object_name from sys.dm_pdw_waits where state != 'Granted') order by object_name ================================================ FILE: TSQL_Queries/Current_Activity/IdentifyBlocking2.sql ================================================ /* ========================== Identify Blocking 2 ========================== NOTE: THIS QUERY IS NOT 100% ACCURATE, but is helpful in most cases. It attempts to link waiting queries to other queries that are blocking them. Sometimes if there are multiple queries blocking the waiting query, it cannot correctly identify the first query in the blocking chain. */ WITH WaitingSidsList AS ( SELECT DateDiff(minute, waiting_waits.request_time, getdate()) as Wait_Time, waiting_waits.session_id AS 'Waiting_SID', waiting_waits.request_id AS 'Waiting_QID', blocking_waits.session_id AS 'Blocking_SID', blocking_waits.request_id AS 'Blocking_QID', waiting_waits.wait_id AS 'waiting_waitID', waiting_sessions.login_name AS 'Waiting_Login_Name', blocking_sessions.login_name AS 'Blocking_Login_Name', waiting_sessions.app_name AS 'Waiting_App_Name', blocking_sessions.app_name AS 'Blocking_App_name', waiting_PER.command AS 'Waiting_command', blocking_PER.command AS 'Blocking_command' FROM sys.dm_pdw_waits waiting_waits JOIN sys.dm_pdw_waits blocking_waits on waiting_waits.object_name = blocking_waits.object_name and waiting_waits.request_id != blocking_waits.request_id LEFT JOIN sys.dm_pdw_exec_sessions waiting_sessions ON waiting_waits.session_id = waiting_sessions.session_id LEFT JOIN sys.dm_pdw_exec_sessions blocking_sessions ON blocking_waits.session_id = blocking_sessions.session_id LEFT JOIN sys.dm_pdw_exec_requests waiting_PER ON waiting_PER.request_id = waiting_waits.request_id LEFT JOIN sys.dm_pdw_exec_requests blocking_PER ON blocking_PER.request_id = blocking_waits.request_id WHERE waiting_waits.state = 'queued' ), MAX_WaitingSidsList AS ( SELECT Waiting_SID, MAX(waiting_waitID) as 'MAX_WaitID' FROM WaitingSidsList GROUP BY Waiting_SID ) SELECT WaitingSidsList.Wait_Time AS 'Wait_Time_(M)', WaitingSidsList.Waiting_SID, WaitingSidsList.Waiting_QID, WaitingSidsList.Blocking_SID, WaitingSidsList.Blocking_QID, WaitingSidsList.Waiting_Login_Name, WaitingSidsList.Blocking_Login_Name, WaitingSidsList.Waiting_App_Name, WaitingSidsList.Blocking_App_name, WaitingSidsList.Waiting_command, WaitingSidsList.Blocking_command FROM MAX_WaitingSidsList JOIN WaitingSidsList ON MAX_WaitingSidsList.Waiting_SID = WaitingSidsList.Waiting_SID AND MAX_WaitingSidsList.MAX_WaitID = WaitingSidsList.waiting_waitID ================================================ FILE: TSQL_Queries/Current_Activity/IdentifyResourceWaits.sql ================================================ /* ============================= Identify Resource Waits ============================= The following query can be used to determine what resources a request is waiting for. Source: https://docs.microsoft.com/en-us/azure/sql-data-warehouse/analyze-your-workload */ SELECT w.[wait_id] , w.[session_id] , w.[type] AS Wait_type , w.[object_type] , w.[object_name] , w.[request_id] , w.[request_time] , w.[acquire_time] , w.[state] , w.[priority] , SESSION_ID() AS Current_session , s.[status] AS Session_status , s.[login_name] , s.[query_count] , s.[client_id] , s.[sql_spid] , r.[command] AS Request_command , r.[label] , r.[status] AS Request_status , r.[submit_time] , r.[start_time] , r.[end_compile_time] , r.[end_time] , DATEDIFF(ms,r.[submit_time],r.[start_time]) AS Request_queue_time_ms , DATEDIFF(ms,r.[start_time],r.[end_compile_time]) AS Request_compile_time_ms , DATEDIFF(ms,r.[end_compile_time],r.[end_time]) AS Request_execution_time_ms , r.[total_elapsed_time] FROM sys.dm_pdw_waits w JOIN sys.dm_pdw_exec_sessions s ON w.[session_id] = s.[session_id] JOIN sys.dm_pdw_exec_requests r ON w.[request_id] = r.[request_id] WHERE w.[session_id] <> SESSION_ID() ; ================================================ FILE: TSQL_Queries/Current_Activity/MemoryGrantPerDistribution.sql ================================================ /* =================================== Memory Grant Per Distribution =================================== This query will return information on the memory grants per distribution.I n reality, your memory grant is less than the results of the following query. However, this query provides a level of guidance that you can use when sizing your partitions for data management operations. Maximum memory per distribution is govered by resource classes. Source: https://docs.microsoft.com/en-us/azure/sql-data-warehouse/sql-data-warehouse-tables-partition */ SELECT rp.[name] AS [pool_name] , rp.[max_memory_kb] AS [max_memory_kb] , rp.[max_memory_kb]/1024 AS [max_memory_mb] , rp.[max_memory_kb]/1048576 AS [mex_memory_gb] , rp.[max_memory_percent] AS [max_memory_percent] , wg.[name] AS [group_name] , wg.[importance] AS [group_importance] , wg.[request_max_memory_grant_percent] AS [request_max_memory_grant_percent] FROM sys.dm_pdw_nodes_resource_governor_workload_groups wg JOIN sys.dm_pdw_nodes_resource_governor_resource_pools rp ON wg.[pool_id] = rp.[pool_id] WHERE wg.[name] like 'SloDWGroup%' AND rp.[name] = 'SloDWPool' ; ================================================ FILE: TSQL_Queries/Current_Activity/QueuedQueryTime.sql ================================================ /* ======================= Queued Query Time ======================= The following query looks for queries that had the longest time between submit_time and start_time. These queries were blocked by resources being locked or waiting for a concurrentcy slot. Source: https://docs.microsoft.com/en-us/azure/sql-data-warehouse/analyze-your-workload */ SELECT r.[request_id] AS Request_ID , r.[status] AS Request_Status , r.[submit_time] AS Request_SubmitTime , r.[start_time] AS Request_StartTime , DATEDIFF(ms,[submit_time],[start_time]) AS Request_InitiateDuration_ms , r.resource_class AS Request_resource_class FROM sys.dm_pdw_exec_requests r ORDER BY Request_InitiateDuration_ms desc ; ================================================ FILE: TSQL_Queries/Current_Activity/RecentQueries.sql ================================================ --Recently ran queries still in exec_requests SELECT r.[session_id] ,r.[request_id] ,r.[status] ,s.[login_name] ,r.[command] ,r.[submit_time] ,r.[end_time] --,r.[end_compile_time] ,datediff(ms,r.[submit_time], r.[end_compile_time]) AS [compile_time_ms] ,datediff(ms,r.[end_compile_time],r.[start_time]) AS [wait_time_ms] ,datediff(ms,r.[start_time], r.[end_time]) AS [execution_time_ms] ,r.[total_elapsed_time] AS [total_time_ms] ,sum(CASE WHEN row_count=('-1') THEN 0 ELSE row_count END) AS [Total_Rows_Processed] ,r.[label] ,r.[resource_allocation_percentage] ,r.[importance] ,r.[group_name] ,r.[classifier_name] ,r.[result_cache_hit] ,s.[app_name] FROM sys.dm_pdw_exec_requests r LEFT JOIN sys.dm_pdw_exec_sessions s ON r.[session_id] = s.[session_id] LEFT JOIN sys.dm_pdw_request_steps steps ON r.[request_id] = steps.[request_id] --WHERE [group_name] is not null GROUP BY r.[request_id],r.[session_id],r.[status],r.[submit_time],r.[end_compile_time],r.[start_time],r.[end_time],r.[total_elapsed_time],r.[label],r.[command],r.[importance],r.[group_name],r.[classifier_name],r.[resource_allocation_percentage],r.[result_cache_hit],s.[login_name],s.[app_name] ORDER BY r.[submit_time] desc ================================================ FILE: TSQL_Queries/Current_Activity/ResourceWaitConsumptionByQuery.sql ================================================ /* ======================================== Resource Wait Consumption by Query ======================================== The following query Will show resource waits consumed by a given query. Source: https://docs.microsoft.com/en-us/azure/sql-data-warehouse/analyze-your-workload */ SELECT [session_id] , [type] , [object_type] , [object_name] , [request_id] , [request_time] , [acquire_time] , DATEDIFF(ms,[request_time],[acquire_time]) AS acquire_duration_ms , [concurrency_slots_used] AS concurrency_slots_reserved , [resource_class] , [wait_id] AS queue_position FROM sys.dm_pdw_resource_waits WHERE [session_id] <> SESSION_ID() ; ================================================ FILE: TSQL_Queries/Current_Activity/UsedConcurrencySlotsInfo.sql ================================================ /* ================================= Used Concurrency Slots Info ================================= The following query will show details of current granted and waiting concurrency slots including: How many concurrency slots are used What resource class the query is running in The query text */ SELECT prw.Session_id, prw.request_id, prw.request_time, prw.acquire_time, prw.state, prw.priority, prw.concurrency_slots_used, prw.resource_class, per.command AS 'Query_text' FROM sys.dm_pdw_resource_waits prw JOIN sys.dm_pdw_exec_requests per ON prw.request_id = per.request_id WHERE type = 'UserConcurrencyResourceType' ORDER BY state,concurrency_slots_used DESC ================================================ FILE: TSQL_Queries/Delta Lake/README.md ================================================ # Reading Delta Lake This stored procedure reads Delta Lake, it supports time travel but does not support schema drift. This is a breakdown of how the script works. - Read the _last_checkpoint file, this contains the highest checkpoint version number. - Read all the checkpoint files, these contain the 'Add' and 'Remove' files that need to be included and their timestamps. - Read the latest JSON transaction files (since the last checkpoint), these contain the most recent 'Add' and 'Remove' files that need to be included and their timestamps. - Filter out the 'Add' and 'Remove' files based on the 'modificationTime' and 'deletionTimestamp' - Return the data from all the 'Add' files excluding the 'Remove' files. (Batching up the COPY INTO statements) ## Installation Run Delta.sql to create the stored procedures in dbo. ## Using the Procedure Run the delta.sql script, this creates the delta stored procedure. ### Parameters ``` @Folder -> String. The location of the Delta Lake file, including HTTPS @DT -> Datetime2. Gives us the version of the file at this time. (NULL returns latest version) @Credential -> String. Full credential string (NULL defaults to AAD authentication) @Destination Table -> String. Destination table for loading the files. (NULL means a temp table is used) @Display -> Int. 0 = Don't display results, 1 = Display results. @Debug -> Int. 0 = Hide debug information. 1 = Show debug information. ``` ### Example ``` sql declare @path varchar(400), @dt datetime2, @credential varchar(500),@outputable varchar(500),@display int, @debug int; set @path = 'https://storageaccount.blob.core.windows.net/container/delta/demo/' --set @dt = convert(datetime2,'2022/07/06 18:37:00'); -- for time travel set @dt = getdate(); -- for time travel -- set @credential = 'IDENTITY= ''Shared Access Signature'', SECRET = ''___SECRET____'''; set @outputable = 'mpmtest' -- leave empty for temp table set @display = 1; -- if 1 display results set @debug = 1; -- if 1 display debugging information exec delta @path,@dt,@credential,@outputable,@display, @debug ``` ================================================ FILE: TSQL_Queries/Delta Lake/delta.sql ================================================ /* IF OBJECT_ID('mpmtest') IS NOT NULL BEGIN; DROP TABLE mpmtest END declare @path varchar(400), @dt datetime2, @credential varchar(500),@outputable varchar(500),@display int, @debug int; set @path = 'https://storageaccount.blob.core.windows.net/container/delta/demo/' --set @dt = convert(datetime2,'2022/07/06 18:37:00'); --getdate(); -- for time travel -- set @dt = getdate(); -- for time travel -- set @credential = 'IDENTITY= ''Shared Access Signature'', SECRET = ''___SECRET____'''; set @outputable = 'mpmtest' -- leave empty for temp table set @display = 1; -- if 1 display results set @debug = 1; exec delta @path,@dt,@credential,@outputable,@display, @debug --select count(*) from mpmtest; */ create PROC [dbo].[delta] @folder [varchar](4000), @dt [datetime2], @credential [varchar](4000), @dest_table [varchar](4000), @display int, -- 0 dont display, 1 display @debug int -- 0 dont debug , 1 debug mode AS begin -- version info -- 0.1 - Very basic, but sort of worked. -- 0.2 - Added support for remove files. -- 0.3 - Fixed bug , in authenication -- 0.4 - Improved performance in handling add/remove files -- 0.5 - Added support for checkpoint files -- 0.6 - Changed the json handling, added latest checkpoint handing DECLARE @ts bigint,@tsmil bigint, @json varchar(8000), @tsql varchar(8000); DECLARE @json_remove varchar(8000), @tsql_checkpoint varchar(8000); DECLARE @td_checkpoint1 datetime2, @td_checkpoint2 datetime2; DECLARE @last_checkpoint varchar(25), @jsonversionchar varchar(25),@checkpointversion varchar(25) ; DECLARE @output_sql varchar(max); DECLARE @checkpoint_file_count bigint; -- default: AAD authenication IF (@credential IS NULL) SET @credential = '' IF (@credential <> '') SET @credential = ' CREDENTIAL = (' + @credential + ')' -- default : display results IF @display IS NULL set @display = 1 -- default : debug is off IF @debug IS NULL SET @debug = 0 -- if the datetime is null, get the latest version IF (@dt IS NULL) set @dt = getdate() -- number of milliseconds since 1970 -- Datediff doesn't return a bigint - so I need todo this into 2 parts set @ts = datediff( s, '1970/1/1', convert(date,@dt) ) set @ts = @ts * 1000; set @tsmil = datediff(ms, convert(date,@dt) , @dt) set @ts = @ts + @tsmil; if (@dest_table IS NULL) set @dest_table = '#tmp_output' ---- Holds the raw json information ----------------------------- IF OBJECT_ID('tempdb..#last_checkpoint') IS NOT NULL DROP TABLE #last_checkpoint create table #last_checkpoint ( info varchar(max) ) with (distribution=round_robin, heap) ------ read _last_checkpoint -- This gives us the checkpoint if it exists, this gives us the starting point -- for the json files set @tsql = ' copy into #last_checkpoint (info) from ''' + @folder + '_delta_log/_last_checkpoint'' with ( ' + @credential + ' ,FILE_TYPE = ''CSV'' ,fieldterminator =''0x0b'' ,fieldquote = ''0x0b'' ,rowterminator = ''0x0d'' ) ' if @debug = 1 print @tsql; set @td_checkpoint1 = getdate(); exec(@tsql); set @td_checkpoint2 = getdate(); print 'Loading _last_checkpoint files took ' + convert(varchar(50),datediff(ms, @td_checkpoint1,@td_checkpoint2)) + ' ms' if @debug = 1 begin select '_Last_checkpoint', * from #last_checkpoint end select @checkpointversion = ISNULL(JSON_VALUE(info,'$.version'),'00') from #last_checkpoint; if NOT EXISTS(SELECT * FROM #last_checkpoint) BEGIN SET @checkpointversion = '00' END PRINT 'checkpointversion=' +@checkpointversion set @jsonversionchar = '00000000000000000000'; IF OBJECT_ID('tempdb..#delta_checkpoint') IS NOT NULL DROP TABLE #delta_checkpoint create table #delta_checkpoint ( txn varchar(max), [add] varchar(max), [remove] varchar(max), metaData varchar(max), protocol varchar(max) ) with (distribution=round_robin, heap) --- Code to pull the the add / remove files from the checkpoint files. set @tsql_checkpoint = ' copy into #delta_checkpoint from ''' + @folder + '_delta_log/*.checkpoint.parquet'' with ( ' + @credential + ' ,FILE_TYPE = ''PARQUET'', AUTO_CREATE_TABLE = ''ON'' ) ' if @debug = 1 BEGIN print @tsql_checkpoint; END set @td_checkpoint1 = getdate() exec(@tsql_checkpoint); set @td_checkpoint2 = getdate() print 'Loading checkpoint files took ' + convert(varchar(50),datediff(ms, @td_checkpoint1,@td_checkpoint2)) + ' ms' SELECT @checkpoint_file_count = count(*) from #delta_checkpoint if @debug = 1 BEGIN print 'No of checkpoint files ' + convert(varchar(10),@checkpoint_file_count); SELECT * FROM #delta_checkpoint order by [add],[remove] END -- Holds the information from the checkpoint files --------- IF OBJECT_ID('tempdb..#delta_files_checkpoint') IS NOT NULL BEGIN; print 'Dropping table #delta_files_checkpoint' DROP TABLE #delta_files_checkpoint END create table #delta_files_checkpoint ( fname varchar(99), ts bigint, dt datetime2, [action] char(1) ) with (distribution=round_robin, heap) -- create a table of add/remove files with the datetimestamp INSERT INTO #delta_files_checkpoint select DISTINCT CASE WHEN JSON_VALUE([add],'$.path') is NULL THEN JSON_VALUE([remove],'$.path') ELSE JSON_VALUE([add],'$.path') END fname, CASE WHEN JSON_VALUE([add],'$.path') is NULL THEN convert(bigint,JSON_VALUE([remove],'$.deletionTimestamp')) ELSE convert(bigint,JSON_VALUE([add],'$.modificationTime')) END updatetime, CASE WHEN JSON_VALUE([add],'$.path') is NULL THEN dateadd(s, convert(bigint,JSON_VALUE([remove],'$.deletionTimestamp')) / 1000 , '1970/1/1') ELSE dateadd(s, convert(bigint,JSON_VALUE([add],'$.modificationTime')) / 1000 , '1970/1/1') END updatetimedt, CASE WHEN JSON_VALUE([add],'$.path') is NULL THEN 'R' ELSE 'A' END [action] from #delta_checkpoint DELETE from #delta_files_checkpoint where fname is null if @debug = 1 SELECT 'checkpoint', * , @ts, @dt FROM #delta_files_checkpoint order by dt desc -- remove files after the given time DELETE FROM #delta_files_checkpoint WHERE ts > @ts if @debug = 1 SELECT 'checkpoint filtered', * , @ts, @dt FROM #delta_files_checkpoint order by dt desc ---- Holds the raw json information ----------------------------- IF OBJECT_ID('tempdb..#delta_json') IS NOT NULL BEGIN; DROP TABLE #delta_json END create table #delta_json ( jsoninput varchar(max) ) with (distribution=round_robin, heap) ---------------------------------------------------------------- set @jsonversionchar= left(substring(@jsonversionchar,0,len(@jsonversionchar)-len(@checkpointversion)+1) + @checkpointversion,len(@jsonversionchar)-1) + '*' -- Read all the delta transaction logs, we cant filter out things by file name. set @tsql = ' copy into #delta_json (jsoninput) from ''' + @folder + '_delta_log/'+ @jsonversionchar +'.json'' with ( ' + @credential + ' ,FILE_TYPE = ''CSV'' ,fieldterminator =''0x0b'' ,fieldquote = ''0x0b'' ,rowterminator = ''0x0d'' ) ' if @debug = 1 print @tsql; set @td_checkpoint1 = getdate(); exec(@tsql); set @td_checkpoint2 = getdate(); print 'Loading json files took ' + convert(varchar(50),datediff(ms, @td_checkpoint1,@td_checkpoint2)) + ' ms' if @debug = 1 SELECT 'JSON Files', * , @ts, @dt FROM #delta_json ---- delta file details.. IF OBJECT_ID('tempdb..#delta_active_json') IS NOT NULL BEGIN; DROP TABLE #delta_active_json END create table #delta_active_json ( jsoninput varchar(max) , ts bigint, dt datetime2, [action] char(1) ) with (distribution=round_robin, heap) ----------------------------------------------------------- -- inserting into temp table, so the date and time is associated to each row insert into #delta_active_json select convert(varchar(max),jsoninput) , convert(bigint,JSON_VALUE(jsoninput,'$.commitInfo.timestamp')) as ts , dateadd(s, convert(bigint,JSON_VALUE(jsoninput,'$.commitInfo.timestamp')) / 1000 , '1970/1/1') ,'' from #delta_json WHERE convert(bigint,JSON_VALUE(jsoninput,'$.commitInfo.timestamp')) < @ts if @debug = 1 select 'json filtered by date',*, @ts, @dt from #delta_active_json order by dt desc -- left in for debugging -- shows each version of the JSON if @debug = 1 begin select 'not filtered', convert(bigint,JSON_VALUE(jsoninput,'$.commitInfo.timestamp')) as ts , convert(varchar(8000),jsoninput) , dateadd(s, convert(bigint,JSON_VALUE(jsoninput,'$.commitInfo.timestamp')) / 1000 , '1970/1/1') ,ROW_NUMBER() OVER(PARTITION BY NULL ORDER BY JSON_VALUE(jsoninput,'$.commitInfo.timestamp') DESC) AS "Row Number" ,convert(varchar(8000),jsoninput) , @ts, @dt from #delta_json order by convert(bigint,JSON_VALUE(jsoninput,'$.commitInfo.timestamp')) desc end --------------------------------------------------------- -- insert the JSON adds and removes to the existing list from checkpoint insert into #delta_files_checkpoint select substring(value,charindex('path',value)+7 ,67) [path] , convert(bigint,JSON_VALUE(jsoninput,'$.commitInfo.timestamp')) ts , dateadd(s, convert(bigint,JSON_VALUE(jsoninput,'$.commitInfo.timestamp')) / 1000 , '1970/1/1') td ,'A' as [action] from #delta_active_json cross apply STRING_SPLIT(jsoninput,',') where value like '%path%' and charindex('add',value) > 0 union all select substring(value,charindex('path',value)+7 ,67) , convert(bigint,JSON_VALUE(jsoninput,'$.commitInfo.timestamp')) ts , dateadd(s, convert(bigint,JSON_VALUE(jsoninput,'$.commitInfo.timestamp')) / 1000 , '1970/1/1') td , 'R' from #delta_active_json cross apply STRING_SPLIT(jsoninput,',') where value like '%path%' and charindex('remove',value) > 0 if @debug = 1 begin -- all the adds and removes from the json select 'adds', substring(value,charindex('path',value)+7 ,67) [path] , convert(bigint,JSON_VALUE(jsoninput,'$.commitInfo.timestamp')) ts , dateadd(s, convert(bigint,JSON_VALUE(jsoninput,'$.commitInfo.timestamp')) / 1000 , '1970/1/1') td ,'A' as [action] , @ts, @dt from #delta_active_json cross apply STRING_SPLIT(jsoninput,',') where value like '%path%' and charindex('add',value) > 0 select 'removes', substring(value,charindex('path',value)+7 ,67) , convert(bigint,JSON_VALUE(jsoninput,'$.commitInfo.timestamp')) ts , dateadd(s, convert(bigint,JSON_VALUE(jsoninput,'$.commitInfo.timestamp')) / 1000 , '1970/1/1') td , 'R', @ts, @dt from #delta_active_json cross apply STRING_SPLIT(jsoninput,',') where value like '%path%' and charindex('remove',value) > 0 select 'New list with adds and removes', *, @ts, @dt from #delta_files_checkpoint order by ts desc; select distinct 'distinct list ', fname, dt, [action], @ts, @dt from #delta_files_checkpoint order by dt desc; end ---- Holds the raw json information ----------------------------- IF OBJECT_ID('tempdb..#delta_files') IS NOT NULL BEGIN; DROP TABLE #delta_files END create table #delta_files ( filenames varchar(max), rownumber bigint ) with (distribution=round_robin, heap) insert into #delta_files select fname, ROW_NUMBER() OVER(PARTITION BY NULL ORDER BY fname DESC) from #delta_files_checkpoint where [action] = 'A' and fname not in (select fname from #delta_files_checkpoint where [action] = 'R') if @debug = 1 select '#delta_files', * from #delta_files; if @debug = 1 select 'parquet to read ', fname,ts, @ts, dt, @dt from #delta_files_checkpoint where [action] = 'A' and fname not in (select fname from #delta_files_checkpoint where [action] = 'R') --where ts < @ts --- This batching code might appear over kill, but STRING_AGG falls over when the string -- is too long.. so I am batching up the inserts. DECLARE @flist varchar(max); DECLARE @batchsize int = 100000; DECLARE @iParquetFileCount int =0; DECLARE @iParquetFilePos int =1; select @iParquetFileCount = count(*) from #delta_files IF OBJECT_ID('tempdb..#_files') IS NOT NULL DROP TABLE #_files create table #_files ( fname varchar(999) ) with (distribution=round_robin,heap) ---- creating batches of COPY INTO statements while(@iParquetFilePos <= @iParquetFileCount) BEGIN INSERT INTO #_files SELECT [filenames] FROM #delta_files where rownumber between @iParquetFilePos and @iParquetFilePos + @batchsize -- Had issues with STRING_AGG with if the string gets too long SELECT @flist = 'COPY INTO ' + @dest_table + ' FROM ' + STRING_AGG(CAST(''''+@folder+fname+'''' AS VARCHAR(MAX)), ', ') + ' with ( ' + @credential + ' ,FILE_TYPE = ''PARQUET'' , AUTO_CREATE_TABLE = ''ON'' )' FROM #_files if @debug =1 select '_filelist', * from #_files; if @debug =1 print @flist; if @debug =1 print len(@flist); set @td_checkpoint1 = getdate(); exec(@flist); set @td_checkpoint2 = getdate(); print 'Loading batch of parquet ' + convert(varchar(10),@iParquetFilePos) + '->' + convert(varchar(10), @iParquetFilePos + @batchsize ) + ' took ' + convert(varchar(50),datediff(ms, @td_checkpoint1,@td_checkpoint2)) + ' ms' truncate table #_files; set @iParquetFilePos = @iParquetFilePos + @batchsize +1; END -- if there is no file, there is no table and this causes a problem if charindex('#',@dest_table) > 0 set @output_sql = 'IF OBJECT_ID(''tempdb..' + @dest_table + ''') IS NOT NULL SELECT * from ' + @dest_table + ';' ELSE set @output_sql = 'IF OBJECT_ID(''' + @dest_table + ''') IS NOT NULL SELECT * from ' + @dest_table + ';' if @debug = 1 PRINT @output_sql; if @display = 1 exec(@output_sql ); end ================================================ FILE: TSQL_Queries/Identity_Columns/IdentityColumns.sql ================================================ /* ====================== Identity Columns ====================== This query will return information about identity columns for the given table. See source link for more information. **Fill in Schema and Table information Source: https://docs.microsoft.com/en-us/azure/sql-data-warehouse/sql-data-warehouse-tables-identity */ SELECT sm.name , tb.name , co.name , CASE WHEN ic.column_id IS NOT NULL THEN 1 ELSE 0 END AS is_identity FROM sys.schemas AS sm JOIN sys.tables AS tb ON sm.schema_id = tb.schema_id JOIN sys.columns AS co ON tb.object_id = co.object_id LEFT JOIN sys.identity_columns AS ic ON co.object_id = ic.object_id AND co.column_id = ic.column_id WHERE sm.name = 'dbo' AND tb.name = 'T1' ; ================================================ FILE: TSQL_Queries/Indexes/CCIHealthByTable.sql ================================================ /* ================================================= Clustered Columnstore Index Health by Table ================================================= This query will return the health of the columnstore index on each table. Collection Date: Date this collection was ran Database Name Table Name Distribution Type: Hash (distributed), Replicated, Round Robin. Open Row Group: */ SELECT SYSDATETIME() as 'Collection_Date', DB_Name() as 'Database_Name', s.name as 'Schema_Name', t.name as 'Table_Name', tdp.distribution_policy_desc as 'Distribution_type', SUM(rg.Total_rows) as 'Total_Rows', pt.max_column_id_used as 'Column_Count', --MAX(p.partition_number) as 'Partition_Count', SUM(CASE WHEN rg.State = 1 THEN 1 else 0 end) as 'OPEN_Row_Groups', SUM(CASE WHEN rg.State = 1 THEN rg.Total_rows else 0 end) as 'OPEN_rows', MIN(CASE WHEN rg.State = 1 THEN rg.Total_rows else NULL end) as 'MIN OPEN Row Group Rows', MAX(CASE WHEN rg.State = 1 THEN rg.Total_rows else NULL end) as 'MAX OPEN_Row Group Rows', AVG(CASE WHEN rg.State = 1 THEN rg.Total_rows else NULL end) as 'AVG OPEN_Row Group Rows', SUM(CASE WHEN rg.State = 3 THEN 1 else 0 end) as 'COMPRESSED_Row_Groups', SUM(CASE WHEN rg.State = 3 THEN rg.Total_rows else 0 end) as 'COMPRESSED_Rows', SUM(CASE WHEN rg.State = 3 THEN rg.deleted_rows else 0 end) as 'Deleted_COMPRESSED_Rows', MIN(CASE WHEN rg.State = 3 THEN rg.Total_rows else NULL end) as 'MIN COMPRESSED Row Group Rows', MAX(CASE WHEN rg.State = 3 THEN rg.Total_rows else NULL end) as 'MAX COMPRESSED Row Group Rows', AVG(CASE WHEN rg.State = 3 THEN rg.Total_rows else NULL end) as 'AVG_COMPRESSED_Rows', SUM(CASE WHEN rg.State = 2 THEN 1 else 0 end) as 'CLOSED_Row_Groups', SUM(CASE WHEN rg.State = 2 THEN rg.Total_rows else 0 end) as 'CLOSED_Rows', MIN(CASE WHEN rg.State = 2 THEN rg.Total_rows else NULL end) as 'MIN CLOSED Row Group Rows', MAX(CASE WHEN rg.State = 2 THEN rg.Total_rows else NULL end) as 'MAX CLOSED Row Group Rows', AVG(CASE WHEN rg.State = 2 THEN rg.Total_rows else NULL end) as 'AVG CLOSED Row Group Rows' FROM sys.dm_pdw_nodes_db_column_store_row_group_physical_stats rg INNER JOIN sys.pdw_nodes_tables pt ON rg.object_id = pt.object_id AND rg.pdw_node_id = pt.pdw_node_id AND rg.distribution_id = pt.distribution_id INNER JOIN sys.pdw_table_mappings mp ON pt.name = mp.physical_name INNER JOIN sys.tables t ON mp.object_id = t.object_id INNER JOIN sys.schemas s ON t.schema_id = s.schema_id INNER JOIN sys.pdw_table_distribution_properties tdp ON tdp.object_id = t.object_id --INNER JOIN sys.partitions p -- ON P.object_id = t.object_id GROUP BY t.name,s.name,tdp.distribution_policy_desc,pt.max_column_id_used ================================================ FILE: TSQL_Queries/Indexes/CCIHealthWithTrimReasons ================================================ * ================================================= Clustered Columnstore Index Health by Table ================================================= This query will return the health of the columnstore index on each table. Collection Date: Date this collection was ran Database Name Table Name Distribution Type: Hash (distributed), Replicated, Round Robin. Open Row Group: */ SELECT SYSDATETIME() as 'Collection_Date', DB_Name() as 'Database_Name', s.name as 'Schema_Name', t.name as 'Table_Name', tdp.distribution_policy_desc as 'Distribution_type', SUM(rg.Total_rows) as 'Total_Rows', pt.max_column_id_used as 'Column_Count', --MAX(p.partition_number) as 'Partition_Count', SUM(CASE WHEN rg.State = 1 THEN 1 else 0 end) as 'OPEN_Row_Groups', SUM(CASE WHEN rg.State = 1 THEN rg.Total_rows else 0 end) as 'OPEN_rows', MIN(CASE WHEN rg.State = 1 THEN rg.Total_rows else NULL end) as 'MIN OPEN Row Group Rows', MAX(CASE WHEN rg.State = 1 THEN rg.Total_rows else NULL end) as 'MAX OPEN_Row Group Rows', AVG(CASE WHEN rg.State = 1 THEN rg.Total_rows else NULL end) as 'AVG OPEN_Row Group Rows', SUM(CASE WHEN rg.State = 3 THEN 1 else 0 end) as 'COMPRESSED_Row_Groups', SUM(CASE WHEN rg.State = 3 THEN rg.Total_rows else 0 end) as 'COMPRESSED_Rows', SUM(CASE WHEN rg.State = 3 THEN rg.deleted_rows else 0 end) as 'Deleted_COMPRESSED_Rows', MIN(CASE WHEN rg.State = 3 THEN rg.Total_rows else NULL end) as 'MIN COMPRESSED Row Group Rows', MAX(CASE WHEN rg.State = 3 THEN rg.Total_rows else NULL end) as 'MAX COMPRESSED Row Group Rows', AVG(CASE WHEN rg.State = 3 THEN rg.Total_rows else NULL end) as 'AVG_COMPRESSED_Rows', SUM(CASE WHEN rg.State = 2 THEN 1 else 0 end) as 'CLOSED_Row_Groups', SUM(CASE WHEN rg.State = 2 THEN rg.Total_rows else 0 end) as 'CLOSED_Rows', MIN(CASE WHEN rg.State = 2 THEN rg.Total_rows else NULL end) as 'MIN CLOSED Row Group Rows', MAX(CASE WHEN rg.State = 2 THEN rg.Total_rows else NULL end) as 'MAX CLOSED Row Group Rows', AVG(CASE WHEN rg.State = 2 THEN rg.Total_rows else NULL end) as 'AVG CLOSED Row Group Rows', SUM(CASE WHEN rg.trim_reason = 0 THEN 1 else 0 end) as 'Unknown Trim', SUM(CASE WHEN rg.trim_reason = 1 THEN 1 else 0 end) as 'No_Trim', SUM(CASE WHEN rg.trim_reason = 2 THEN 1 else 0 end) as 'BULKLOAD', SUM(CASE WHEN rg.trim_reason = 3 THEN 1 else 0 end) as 'REORG', SUM(CASE WHEN rg.trim_reason = 4 THEN 1 else 0 end) as 'DICTIONARY_SIZE', SUM(CASE WHEN rg.trim_reason = 5 THEN 1 else 0 end) as 'MEMORY_LIMITATION', SUM(CASE WHEN rg.trim_reason = 6 THEN 1 else 0 end) as 'RESIDUAL_ROW_GROUP', SUM(CASE WHEN rg.trim_reason = 7 THEN 1 else 0 end) as 'STATS_MISMATCH', SUM(CASE WHEN rg.trim_reason = 8 THEN 1 else 0 end) as 'SPILLOVER', SUM(CASE WHEN rg.trim_reason = 9 THEN 1 else 0 end) as 'AUTO_MERGE' FROM sys.dm_pdw_nodes_db_column_store_row_group_physical_stats rg INNER JOIN sys.pdw_nodes_tables pt ON rg.object_id = pt.object_id AND rg.pdw_node_id = pt.pdw_node_id AND rg.distribution_id = pt.distribution_id INNER JOIN sys.pdw_table_mappings mp ON pt.name = mp.physical_name INNER JOIN sys.tables t ON mp.object_id = t.object_id INNER JOIN sys.schemas s ON t.schema_id = s.schema_id INNER JOIN sys.pdw_table_distribution_properties tdp ON tdp.object_id = t.object_id --INNER JOIN sys.partitions p -- ON P.object_id = t.object_id GROUP BY t.name,s.name,tdp.distribution_policy_desc,pt.max_column_id_used ================================================ FILE: TSQL_Queries/Indexes/CCITrimReason_BETA.sql ================================================ /* ================================= CCI Trim Reason ================================= This query reports the Trim Reason for the individual Compressed RowGoups. */ WITH cte_All_RowGroups AS ( SELECT [Schema_Name], [Table_Name], Distribution_Type, COUNT(*) AS rg_compressed_count_total FROM [dbo].[vCS_rg_physical_stats] WHERE rg_state = 3 GROUP BY [Schema_Name], [Table_Name], Distribution_Type ), cte_Compressed_RowGroups AS ( SELECT [Schema_Name], [Table_Name], rg_trim_reason as trim_reason, rg_trim_reason_desc as trim_reason_desc, COUNT(*) as trim_reason_rg_count FROM [dbo].[vCS_rg_physical_stats] WHERE rg_state = 3 GROUP BY [Schema_Name], [Table_Name], rg_trim_reason, rg_trim_reason_desc ) SELECT SYSDATETIME() as 'Collection_Date', DB_Name(), a.*, c.trim_reason, c.trim_reason_desc, c.trim_reason_rg_count FROM cte_All_RowGroups a LEFT OUTER JOIN cte_Compressed_RowGroups c ON a.[Schema_Name] = c.[Schema_Name] AND a.[Table_Name] = c.[Table_Name] ORDER BY a.[Schema_Name], a.[Table_Name], c.trim_reason ================================================ FILE: TSQL_Queries/Indexes/CreateRowgroupHealthView.sql ================================================ /* ================================= Create Rowgroup Health View ================================= This query will create a view that contains useful information such as the number of rows in rowgroups and the reason for trimming if there was trimming. See source link for more info. Source: https://docs.microsoft.com/en-us/azure/sql-data-warehouse/sql-data-warehouse-memory-optimizations-for-columnstore-compression */ create view dbo.vCS_rg_physical_stats as with cte as ( select tb.[name] AS [logical_table_name] , rg.[row_group_id] AS [row_group_id] , rg.[state] AS [state] , rg.[state_desc] AS [state_desc] , rg.[total_rows] AS [total_rows] , rg.[trim_reason_desc] AS trim_reason_desc , mp.[physical_name] AS physical_name FROM sys.[schemas] sm JOIN sys.[tables] tb ON sm.[schema_id] = tb.[schema_id] JOIN sys.[pdw_permanent_table_mappings] mp ON tb.[object_id] = mp.[object_id] JOIN sys.[pdw_nodes_tables] nt ON nt.[name] = mp.[physical_name] JOIN sys.[dm_pdw_nodes_db_column_store_row_group_physical_stats] rg ON rg.[object_id] = nt.[object_id] AND rg.[pdw_node_id] = nt.[pdw_node_id] AND rg.[distribution_id] = nt.[distribution_id] ) select * from cte; ================================================ FILE: TSQL_Queries/Indexes/ReorgOrRebuildColumnstoreByPartition_All.sql ================================================ /* ============================================ Rebuild Columnstore Index By partition ============================================ This query will loop through all partitions in a table and rebuild the columnstore index per partition. Perfoming rebuilds this way require a smaller memory grant Choose whether you want to perform a reorganize (online) or REBUILD (offline) by commenting and uncommenting the proper command. */ DECLARE @schemaName VARCHAR(50) = 'dbo' DECLARE @tableName VARCHAR(100)= 'FactInternetSales_partitioned' DECLARE @counter INT DECLARE @partitionCount INT SET @counter=1 SET @partitionCount=( SELECT max(p.partition_number) AS 'Num_Partitions' FROM sys.partitions p JOIN sys.tables t ON P.object_id = t.object_id JOIN sys.schemas s ON t.[schema_id] = s.[schema_id] WHERE s.name = @schemaName AND t.name = @tableName group by s.[name],t.[name] ) WHILE ( @counter <= @partitionCount) BEGIN DECLARE @s NVARCHAR(4000) = N'' --Choose whether or not you want to do a rebuild or reorganize by uncommenting the proper command. Default is reorganize. --SET @s = ('ALTER INDEX ALL ON ' + @schemaName + '.' + @tableName + ' REBUILD PARTITION = ' + CAST(@counter AS varchar(10))) --rebuild command (offline operation) SET @s = ('ALTER INDEX ALL ON ' + @schemaName + '.' + @tableName + ' REORGANIZE PARTITION = ' + CAST(@counter AS varchar(10)) + ' WITH (COMPRESS_ALL_ROW_GROUPS = ON)') --REORGANIZE command (online operation) PRINT @s EXEC sp_executesql @s SET @counter = @counter + 1 END ================================================ FILE: TSQL_Queries/Indexes/ReorgOrRebuildColumnstore_LatestPartitionsOnly.sql ================================================ /* ============================================ Rebuild Columnstore Index By partiiton ============================================ This query will loop through all partitions in a table and rebuild the columnstore index per partition. Perfoming rebuilds this way require a smaller memory grant SET Schema, dbo, and number of partitions to alter before running */ --Set these 3 variables DECLARE @schemaName VARCHAR(50) = 'dbo' DECLARE @tableName VARCHAR(100) = 'FactInternetSales_partitioned' DECLARE @numPartitionsToAlter INT = 2 --1 for only max partition with data, 2 for last 2, etc. DECLARE @counter INT DECLARE @maxPartitionWithData INT SET @maxPartitionWithData=( SELECT max(pnp.partition_number) AS 'Max_Parititon_With_Data' FROM sys.tables t INNER JOIN sys.indexes i ON t.[object_id] = i.[object_id] AND i.[index_id] <= 1 /* HEAP = 0, CLUSTERED or CLUSTERED_COLUMNSTORE =1 */ INNER JOIN sys.pdw_table_mappings tm ON t.[object_id] = tm.[object_id] INNER JOIN sys.pdw_nodes_tables nt ON tm.[physical_name] = nt.[name] INNER JOIN sys.pdw_nodes_partitions pnp ON nt.[object_id]=pnp.[object_id] AND nt.[pdw_node_id]=pnp.[pdw_node_id] AND nt.[distribution_id] = pnp.[distribution_id] INNER JOIN sys.dm_pdw_nodes_db_partition_stats nps ON nt.[object_id] = nps.[object_id] AND nt.[pdw_node_id] = nps.[pdw_node_id] AND nt.[distribution_id] = nps.[distribution_id] AND pnp.[partition_id]=nps.[partition_id] JOIN sys.schemas s ON s.[schema_id] = t.[schema_id] WHERE s.name = @schemaName AND t.name=@tableName AND nps.[row_count] > 0 GROUP BY s.[name],t.[name] ) SET @counter=@maxPartitionWithData - @numPartitionsToAlter + 1 WHILE ( @counter <= @maxPartitionWithData) BEGIN DECLARE @s NVARCHAR(4000) = N'' --SET @s = ('ALTER INDEX ALL ON ' + @schemaName + '.' + @tableName + ' REBUILD PARTITION = ' + CAST(@counter AS varchar(10))) --rebuild command (offline operation) SET @s = ('ALTER INDEX ALL ON ' + @schemaName + '.' + @tableName + ' REORGANIZE PARTITION = ' + CAST(@counter AS varchar(10)) + ' WITH (COMPRESS_ALL_ROW_GROUPS = ON)') --REORGANIZE command (online operation) PRINT @s EXEC sp_executesql @s SET @counter = @counter + 1 END ================================================ FILE: TSQL_Queries/Partitions/GetPartitionColumn.sql ================================================ select c.name from sys.index_columns ic join sys.tables t on t.object_id = ic.object_id join sys.columns c on c.object_id = ic.object_id and c.column_id = ic.column_id where ic.partition_ordinal > 0 and t.object_id = (select object_id from sys.objects where name = 'FactInternetSalespartition') ================================================ FILE: TSQL_Queries/Partitions/MaxPartitionWithData.sql ================================================ /* ============================= Max Parititon With Data ============================= This query will use sys.dm_pdw_nodes_db_partition_stats to return the last partition that has data for the specified table. Using sys.dm_pdw_nodes_db_partition_stats is much more accurate than just using sys.partition_stats. This is useful if you have pre-built partitions, but need to identify the last one that contains data for maintenance activities like columnstore rebuilds. */ SELECT s.[name] ,t.[name] ,sum(nps.[row_count]) AS 'Table_Row_Count' ,sum(nps.[used_page_count]*8.0/1024) AS 'Table_Used_Space_MB' ,max(pnp.partition_number) AS 'Max_Parititon_With_Data' FROM sys.tables t INNER JOIN sys.indexes i ON t.[object_id] = i.[object_id] AND i.[index_id] <= 1 /* HEAP = 0, CLUSTERED or CLUSTERED_COLUMNSTORE =1 */ INNER JOIN sys.pdw_table_mappings tm ON t.[object_id] = tm.[object_id] INNER JOIN sys.pdw_nodes_tables nt ON tm.[physical_name] = nt.[name] INNER JOIN sys.pdw_nodes_partitions pnp ON nt.[object_id]=pnp.[object_id] AND nt.[pdw_node_id]=pnp.[pdw_node_id] AND nt.[distribution_id] = pnp.[distribution_id] INNER JOIN sys.dm_pdw_nodes_db_partition_stats nps ON nt.[object_id] = nps.[object_id] AND nt.[pdw_node_id] = nps.[pdw_node_id] AND nt.[distribution_id] = nps.[distribution_id] AND pnp.[partition_id]=nps.[partition_id] JOIN sys.schemas s ON s.[schema_id] = t.[schema_id] WHERE s.name = 'dbo' --comment out for all schemas AND t.name='FactInternetSales' --comment out for all tables AND nps.[row_count] > 0 GROUP BY s.[name],t.[name] ================================================ FILE: TSQL_Queries/Partitions/RowsPerPartition.sql ================================================ /* ============================= Row count per partition ============================= This query will use sys.dm_pdw_nodes_db_partition_stats to return the row count in each partition for the specified table. Using sys.dm_pdw_nodes_db_partition_stats is much more accurate than just using sys.partition_stats. */ SELECT pnp.partition_number ,s.[name] ,t.[name] ,sum(nps.[row_count]) ,sum(nps.[used_page_count]*8.0/1024) as usedSpaceMB FROM sys.tables t INNER JOIN sys.indexes i ON t.[object_id] = i.[object_id] AND i.[index_id] <= 1 /* HEAP = 0, CLUSTERED or CLUSTERED_COLUMNSTORE =1 */ INNER JOIN sys.pdw_table_mappings tm ON t.[object_id] = tm.[object_id] INNER JOIN sys.pdw_nodes_tables nt ON tm.[physical_name] = nt.[name] INNER JOIN sys.pdw_nodes_partitions pnp ON nt.[object_id]=pnp.[object_id] AND nt.[pdw_node_id]=pnp.[pdw_node_id] AND nt.[distribution_id] = pnp.[distribution_id] INNER JOIN sys.dm_pdw_nodes_db_partition_stats nps ON nt.[object_id] = nps.[object_id] AND nt.[pdw_node_id] = nps.[pdw_node_id] AND nt.[distribution_id] = nps.[distribution_id] AND pnp.[partition_id]=nps.[partition_id] JOIN sys.schemas s ON s.[schema_id] = t.[schema_id] WHERE s.name = 'dbo' --comment out for all schemas AND t.name='FactInternetSales_partitioned' --comment out for all tables GROUP BY pnp.partition_number,s.[name],t.[name] ORDER BY pnp.partition_number ASC; ================================================ FILE: TSQL_Queries/Permissions/All_Database_Permissions.sql ================================================ --This query will list ALL PERMISSIONS in the database. It includes permissions granted to principals through role membership and permissions granted explicitly to principals. --It also includes all role membership whether or not permissions are granted through that role. In this case the permission columns will be NULL. SELECT DB_NAME() AS 'Database',* FROM ( --List permissions granted outside of database roles SELECT prin.name AS 'Database_Principal', '' AS 'Permission_Derived_From', prin.type_desc AS 'Principal_Type', prin.authentication_type_desc AS 'Authnetication', perm.state_desc AS 'Action', perm.permission_name AS 'Permission', CASE perm.class WHEN 0 THEN 'Database::' + DB_NAME() WHEN 1 THEN OBJECT_NAME(perm.major_id) WHEN 3 THEN 'Schema::' + SCHEMA_NAME(perm.major_id) END AS 'Securable' , GETDATE() AS 'Collection_Date' FROM sys.database_principals prin JOIN sys.database_permissions perm ON prin.principal_id = perm.grantee_principal_id UNION ALL --List Database Role Members and their derived permission SELECT DP2.name AS 'Database_Principal', DP1.name AS 'Permission_Derived_From', DP2.type_desc AS 'Principal_Type', DP2.authentication_type_desc AS 'Authnetication', CASE DP1.name WHEN 'db_owner' THEN 'IMPLICIT - FDR' WHEN 'db_ddladmin' THEN 'IMPLICIT - FDR' WHEN 'db_datareader' THEN 'IMPLICIT - FDR' WHEN 'db_datawriter' THEN 'IMPLICIT - FDR' WHEN 'db_securityadmin' THEN 'IMPLICIT - FDR' WHEN 'db_accessadmin' THEN 'IMPLICIT - FDR' WHEN 'db_backupoperator' THEN 'IMPLICIT - FDR' WHEN 'db_denydatawriter' THEN 'IMPLICIT - FDR' WHEN 'db_denydatareader' THEN 'IMPLICIT - FDR' ELSE pe.state_desc END AS 'Action', CASE DP1.name WHEN 'db_owner' THEN 'CONTROL' WHEN 'db_ddladmin' THEN 'CREATE, DROP, ALTER ON ANY OBJECTS' WHEN 'db_datareader' THEN 'SELECT' WHEN 'db_datawriter' THEN 'INSERT,UPDATE,DELETE' WHEN 'db_securityadmin' THEN 'Mange Role Membership and perms' WHEN 'db_accessadmin' THEN 'GRANT/REVOKE access to users/roles' WHEN 'db_backupoperator' THEN 'Can BACKUP DB' WHEN 'db_denydatawriter' THEN 'DENY INSERT,UPDATE,DELETE' WHEN 'db_denydatareader' THEN 'DENY SELECT' ELSE pe.permission_name END AS 'Permission', CASE pe.class WHEN 0 THEN 'Database::' + DB_NAME() WHEN 1 THEN OBJECT_NAME(pe.major_id) WHEN 3 THEN 'Schema::' + SCHEMA_NAME(pe.major_id) ELSE 'Database::' + DB_NAME() END AS 'Securable' , GETDATE() AS 'Collection_Date' FROM sys.database_role_members AS DRM RIGHT OUTER JOIN sys.database_principals AS DP1 ON DRM.role_principal_id = DP1.principal_id LEFT OUTER JOIN sys.database_principals AS DP2 ON DRM.member_principal_id = DP2.principal_id LEFT JOIN sys.database_permissions AS pe ON pe.grantee_principal_id = DP1.principal_id WHERE DP1.type = 'R' AND DP2.name IS NOT NULL ) perms ORDER BY Permission ================================================ FILE: TSQL_Queries/Query_Store/GetApproxTimeRemaining_QueryStore.sql ================================================ --Calculate approximate time remaining for running queries based on hits on teh query text in query store. SELECT req.session_id, req.request_id, req.total_elapsed_time/1000/60 As Elapsed_minutes, ROUND(avg(abs([stats].avg_duration))/1000/1000/60,1) as 'AVG_Duration (min)', min(abs([stats].min_duration))/1000/1000/60 AS 'MIN_Duration (min)', MAX(abs([stats].max_duration))/1000/1000/60 AS 'MAX_duration (min)', ROUND((avg(abs([stats].avg_duration))/1000 - req.total_elapsed_time)/1000/60,1) AS avg_estimated_mins_remaining, (min(abs([stats].min_duration))/1000 - req.total_elapsed_time)/1000/60 AS min_estimated_mins_remaining, (MAX(abs([stats].max_duration))/1000 - req.total_elapsed_time)/1000/60 AS max_estimated_mins_remaining, req.command FROM sys.dm_pdw_exec_requests req LEFT JOIN sys.query_store_query_text [text] ON LEFT(req.command,4000) = LEFT([text].query_sql_text,4000) LEFT JOIN sys.query_store_query query ON query.query_text_id = [text].query_text_id LEFT JOIN sys.query_store_plan [plan] ON query.query_id = [plan].query_id LEFT JOIN sys.query_store_runtime_stats [stats] ON [stats].plan_id = [plan].plan_id WHERE req.status = 'Running' AND req.resource_allocation_percentage IS NOT NULL AND [stats].Execution_type = 0 GROUP BY req.command,req.request_id,req.total_elapsed_time,req.session_id order by req.total_elapsed_time desc ================================================ FILE: TSQL_Queries/Query_Store/GetFullQueryText.sql ================================================ /* =============================== Get Full Query Text =============================== The following query will collect the full query text for a query out of the query store Filter on your query_id to see a particular query. */ SELECT q.query_id , t.query_sql_text FROM sys.query_store_query q JOIN sys.query_store_query_text t ON q.query_text_id = t.query_text_id; ================================================ FILE: TSQL_Queries/Query_Store/GetQueriesWithBiggestIOReads.sql ================================================ /* ======================================================== Get Queries with biggest IO Reads in last 24 hours ======================================================== The following query will collect the top 10 quereis with the largest average physical IO reads in the last 24 hours. */ SELECT TOP 10 rs.avg_physical_io_reads, qt.query_sql_text, q.query_id, qt.query_text_id, p.plan_id, rs.runtime_stats_id, rsi.start_time, rsi.end_time, rs.avg_rowcount, rs.count_executions FROM sys.query_store_query_text AS qt JOIN sys.query_store_query AS q ON qt.query_text_id = q.query_text_id JOIN sys.query_store_plan AS p ON q.query_id = p.query_id JOIN sys.query_store_runtime_stats AS rs ON p.plan_id = rs.plan_id JOIN sys.query_store_runtime_stats_interval AS rsi ON rsi.runtime_stats_interval_id = rs.runtime_stats_interval_id WHERE rsi.start_time >= DATEADD(hour, -24, GETUTCDATE()) ORDER BY rs.avg_physical_io_reads DESC; ================================================ FILE: TSQL_Queries/Query_Store/GetQueriesWithMultiplePlans.sql ================================================ /* ======================================================== Get Queries with Multiple plans ======================================================== These queries are especially interesting because they are candidates for regressions due to plan choice change. The following query identifies these queries along with all plans: */ WITH Query_MultPlans AS ( SELECT COUNT(*) AS cnt, q.query_id FROM sys.query_store_query_text AS qt JOIN sys.query_store_query AS q ON qt.query_text_id = q.query_text_id JOIN sys.query_store_plan AS p ON p.query_id = q.query_id GROUP BY q.query_id HAVING COUNT(distinct plan_id) > 1 ) SELECT q.query_id, object_name(object_id) AS ContainingObject, query_sql_text, plan_id, p.query_plan AS plan_xml, p.last_compile_start_time, p.last_execution_time FROM Query_MultPlans AS qm JOIN sys.query_store_query AS q ON qm.query_id = q.query_id JOIN sys.query_store_plan AS p ON q.query_id = p.query_id JOIN sys.query_store_query_text qt ON qt.query_text_id = q.query_text_id ORDER BY query_id, plan_id; ================================================ FILE: TSQL_Queries/Query_Store/GetQueryExecutionTime.sql ================================================ /* ====================================== Find exeuction times for a query ====================================== The following query will Query also gathers runtime query statistics to help you focus on queries with variance in execution. The variance could be for a variety of reasons such as loading a bunch of new data. */ SELECT q.query_id [query_id] , t.query_sql_text [command] , rs.avg_duration [avg_duration] , rs.min_duration [min_duration] , rs.max_duration [max_duration] FROM sys.query_store_query q JOIN sys.query_store_query_text t ON q.query_text_id = t.query_text_id JOIN sys.query_store_plan p ON p.query_id = q.query_id JOIN sys.query_store_runtime_stats rs ON rs.plan_id = p.plan_id WHERE q.query_id = 10 AND rs.avg_duration > 0; ================================================ FILE: TSQL_Queries/Query_Store/GetQueryStoreSpaceUsage.sql ================================================ /* ======================================================== Get Query Store Space Usage ======================================================== The following query will check current the Query Store size and size limit. To clear space you can use: ALTER DATABASE SET QUERY_STORE CLEAR; */ SELECT current_storage_size_mb, max_storage_size_mb FROM sys.database_query_store_options; ================================================ FILE: TSQL_Queries/Query_Store/GetQueryStoreState.sql ================================================ /* ======================================================== Get QUery Store State ======================================================== The following query will determine if Query Store is currently active, and whether it is currently collects runtime stats or not. */ SELECT actual_state, actual_state_desc, readonly_reason, current_storage_size_mb, max_storage_size_mb FROM sys.database_query_store_options; ================================================ FILE: TSQL_Queries/Query_Store/GetRecentlyRegressedQueries.sql ================================================ /* ======================================================== Get Recently Regressed Queries ======================================================== The following query example returns all queries for which execution time doubled in last 48 hours due to a plan choice change. Query compares all runtime stat intervals side by side. */ SELECT qt.query_sql_text, q.query_id, qt.query_text_id, rs1.runtime_stats_id AS runtime_stats_id_1, rsi1.start_time AS interval_1, p1.plan_id AS plan_1, rs1.avg_duration AS avg_duration_1, rs2.avg_duration AS avg_duration_2, p2.plan_id AS plan_2, rsi2.start_time AS interval_2, rs2.runtime_stats_id AS runtime_stats_id_2 FROM sys.query_store_query_text AS qt JOIN sys.query_store_query AS q ON qt.query_text_id = q.query_text_id JOIN sys.query_store_plan AS p1 ON q.query_id = p1.query_id JOIN sys.query_store_runtime_stats AS rs1 ON p1.plan_id = rs1.plan_id JOIN sys.query_store_runtime_stats_interval AS rsi1 ON rsi1.runtime_stats_interval_id = rs1.runtime_stats_interval_id JOIN sys.query_store_plan AS p2 ON q.query_id = p2.query_id JOIN sys.query_store_runtime_stats AS rs2 ON p2.plan_id = rs2.plan_id JOIN sys.query_store_runtime_stats_interval AS rsi2 ON rsi2.runtime_stats_interval_id = rs2.runtime_stats_interval_id WHERE rsi1.start_time > DATEADD(hour, -48, GETUTCDATE()) AND rsi2.start_time > rsi1.start_time AND p1.plan_id <> p2.plan_id AND rs2.avg_duration > 2*rs1.avg_duration ORDER BY q.query_id, rsi1.start_time, rsi2.start_time; ================================================ FILE: TSQL_Queries/Query_Store/GetTopQueriesByExecutionCount.sql ================================================ /* ==================================== Top Queries By Execution Count ==================================== The following query will find the top 10 queries by execution count */ SELECT TOP 10 q.query_id [query_id] , t.query_sql_text [command] , SUM(rs.count_executions) [execution_count] FROM sys.query_store_query q JOIN sys.query_store_query_text t ON q.query_text_id = t.query_text_id JOIN sys.query_store_plan p ON p.query_id = q.query_id JOIN sys.query_store_runtime_stats rs ON rs.plan_id = p.plan_id GROUP BY q.query_id , t.query_sql_text ORDER BY 3 DESC; ================================================ FILE: TSQL_Queries/Query_Store/GetTopQueriesByExecutionTime.sql ================================================ /* ==================================== Top Queries By Execution Time ==================================== The following query will find the top queries by execution time */ SELECT q.query_id [query_id] , t.query_sql_text [command] , rs.avg_duration [avg_duration] , rs.min_duration [min_duration] , rs.max_duration [max_duration] FROM sys.query_store_query q JOIN sys.query_store_query_text t ON q.query_text_id = t.query_text_id JOIN sys.query_store_plan p ON p.query_id = q.query_id JOIN sys.query_store_runtime_stats rs ON rs.plan_id = p.plan_id WHERE --q.query_id = 71 rs.avg_duration > 0 ORDER BY rs.max_duration DESC; ================================================ FILE: TSQL_Queries/Query_Store/PerfRegressionPlanChoiceChange.sql ================================================ /* ====================================== Perf Regression with plan change ====================================== The following query will find queries that have regressed in performance and also had a plan choice change. */ SELECT qt.query_sql_text, q.query_id, qt.query_text_id, rs1.runtime_stats_id AS runtime_stats_id_1, rsi1.start_time AS interval_1, p1.plan_id AS plan_1, rs1.avg_duration AS avg_duration_1, rs2.avg_duration AS avg_duration_2, p2.plan_id AS plan_2, rsi2.start_time AS interval_2, rs2.runtime_stats_id AS runtime_stats_id_2 FROM sys.query_store_query_text AS qt JOIN sys.query_store_query AS q ON qt.query_text_id = q.query_text_id JOIN sys.query_store_plan AS p1 ON q.query_id = p1.query_id JOIN sys.query_store_runtime_stats AS rs1 ON p1.plan_id = rs1.plan_id JOIN sys.query_store_runtime_stats_interval AS rsi1 ON rsi1.runtime_stats_interval_id = rs1.runtime_stats_interval_id JOIN sys.query_store_plan AS p2 ON q.query_id = p2.query_id JOIN sys.query_store_runtime_stats AS rs2 ON p2.plan_id = rs2.plan_id JOIN sys.query_store_runtime_stats_interval AS rsi2 ON rsi2.runtime_stats_interval_id = rs2.runtime_stats_interval_id WHERE rsi1.start_time > DATEADD(hour, -48, GETUTCDATE()) AND rsi2.start_time > rsi1.start_time AND p1.plan_id <> p2.plan_id AND rs2.avg_duration > 2*rs1.avg_duration ORDER BY q.query_id, rsi1.start_time, rsi2.start_time; ================================================ FILE: TSQL_Queries/Query_Store/QueriesWithPerfRegression.sql ================================================ /* ====================================== Queries with Perf Regression ====================================== The following query will find queries that have regressed in performance for any reason. */ SELECT qt.query_sql_text, q.query_id, qt.query_text_id, rs1.runtime_stats_id AS runtime_stats_id_1, rsi1.start_time AS interval_1, p1.plan_id AS plan_1, rs1.avg_duration AS avg_duration_1, rs2.avg_duration AS avg_duration_2, p2.plan_id AS plan_2, rsi2.start_time AS interval_2, rs2.runtime_stats_id AS runtime_stats_id_2 FROM sys.query_store_query_text AS qt JOIN sys.query_store_query AS q ON qt.query_text_id = q.query_text_id JOIN sys.query_store_plan AS p1 ON q.query_id = p1.query_id JOIN sys.query_store_runtime_stats AS rs1 ON p1.plan_id = rs1.plan_id JOIN sys.query_store_runtime_stats_interval AS rsi1 ON rsi1.runtime_stats_interval_id = rs1.runtime_stats_interval_id JOIN sys.query_store_plan AS p2 ON q.query_id = p2.query_id JOIN sys.query_store_runtime_stats AS rs2 ON p2.plan_id = rs2.plan_id JOIN sys.query_store_runtime_stats_interval AS rsi2 ON rsi2.runtime_stats_interval_id = rs2.runtime_stats_interval_id WHERE rsi1.start_time > DATEADD(hour, -48, GETUTCDATE()) AND rsi2.start_time > rsi1.start_time AND rs2.avg_duration > 2*rs1.avg_duration ORDER BY q.query_id, rsi1.start_time, rsi2.start_time; ================================================ FILE: TSQL_Queries/Replicated_Tables/RepTablesRebuildNeeded.sql ================================================ /* ================================ Replicated Tables Modified but not rebuilt ================================= The following query will list replicated tables that have been modified, but not rebuilt. THis will cause a rebuild at execution time next time the table is touched and will affect performance. You can manually trigger a rebuild by: SELECT TOP 1 * FROM [ReplicatedTable] Source: https://docs.microsoft.com/en-us/azure/sql-data-warehouse/design-guidance-for-replicated-tables */ SELECT [ReplicatedTable] = t.[name] FROM sys.tables t JOIN sys.pdw_replicated_table_cache_state c ON c.object_id = t.object_id JOIN sys.pdw_table_distribution_properties p ON p.object_id = t.object_id WHERE c.[state] = 'NotReady' AND p.[distribution_policy_desc] = 'REPLICATE' ================================================ FILE: TSQL_Queries/SLO-DWU/ChangeDwuSetting.sql ================================================ /* ======================== Change DWU Setting ======================== This query will set the DWU setting to the specified setting. Source: https://docs.microsoft.com/en-us/azure/sql-data-warehouse/what-is-a-data-warehouse-unit-dwu-cdwu */ --Enter Databasename and new Service Level Objective ALTER DATABASE MySQLDW MODIFY (SERVICE_OBJECTIVE = 'DW1000') ; ================================================ FILE: TSQL_Queries/SLO-DWU/CheckDwuChangeStatus.sql ================================================ /* ================================ Check Status of DWU Change ================================ This query will check the status of the DWU change for the specified database It will either return IN_PROGRESS or COMPMLETED Source: https://docs.microsoft.com/en-us/azure/sql-data-warehouse/what-is-a-data-warehouse-unit-dwu-cdwu */ SELECT * FROM sys.dm_operation_status WHERE resource_type_desc = 'Database' AND major_resource_id = 'MySQLDW' ; ================================================ FILE: TSQL_Queries/SLO-DWU/CreateColumnstoreDensityView.sql ================================================ /* ===================================== Create Columnstore Density View ===================================== This query will create a view that holds infomration that is useful in identifying sub-optimal clustered columnstore indexes. See source link for more information. Source: https://docs.microsoft.com/en-us/azure/sql-data-warehouse/sql-data-warehouse-tables-index */ CREATE VIEW dbo.vColumnstoreDensity AS SELECT GETDATE() AS [execution_date] , DB_Name() AS [database_name] , s.name AS [schema_name] , t.name AS [table_name] , COUNT(DISTINCT rg.[partition_number]) AS [table_partition_count] , SUM(rg.[total_rows]) AS [row_count_total] , SUM(rg.[total_rows])/COUNT(DISTINCT rg.[distribution_id]) AS [row_count_per_distribution_MAX] , CEILING ((SUM(rg.[total_rows])*1.0/COUNT(DISTINCT rg.[distribution_id]))/1048576) AS [rowgroup_per_distribution_MAX] , SUM(CASE WHEN rg.[State] = 0 THEN 1 ELSE 0 END) AS [INVISIBLE_rowgroup_count] , SUM(CASE WHEN rg.[State] = 0 THEN rg.[total_rows] ELSE 0 END) AS [INVISIBLE_rowgroup_rows] , MIN(CASE WHEN rg.[State] = 0 THEN rg.[total_rows] ELSE NULL END) AS [INVISIBLE_rowgroup_rows_MIN] , MAX(CASE WHEN rg.[State] = 0 THEN rg.[total_rows] ELSE NULL END) AS [INVISIBLE_rowgroup_rows_MAX] , AVG(CASE WHEN rg.[State] = 0 THEN rg.[total_rows] ELSE NULL END) AS [INVISIBLE_rowgroup_rows_AVG] , SUM(CASE WHEN rg.[State] = 1 THEN 1 ELSE 0 END) AS [OPEN_rowgroup_count] , SUM(CASE WHEN rg.[State] = 1 THEN rg.[total_rows] ELSE 0 END) AS [OPEN_rowgroup_rows] , MIN(CASE WHEN rg.[State] = 1 THEN rg.[total_rows] ELSE NULL END) AS [OPEN_rowgroup_rows_MIN] , MAX(CASE WHEN rg.[State] = 1 THEN rg.[total_rows] ELSE NULL END) AS [OPEN_rowgroup_rows_MAX] , AVG(CASE WHEN rg.[State] = 1 THEN rg.[total_rows] ELSE NULL END) AS [OPEN_rowgroup_rows_AVG] , SUM(CASE WHEN rg.[State] = 2 THEN 1 ELSE 0 END) AS [CLOSED_rowgroup_count] , SUM(CASE WHEN rg.[State] = 2 THEN rg.[total_rows] ELSE 0 END) AS [CLOSED_rowgroup_rows] , MIN(CASE WHEN rg.[State] = 2 THEN rg.[total_rows] ELSE NULL END) AS [CLOSED_rowgroup_rows_MIN] , MAX(CASE WHEN rg.[State] = 2 THEN rg.[total_rows] ELSE NULL END) AS [CLOSED_rowgroup_rows_MAX] , AVG(CASE WHEN rg.[State] = 2 THEN rg.[total_rows] ELSE NULL END) AS [CLOSED_rowgroup_rows_AVG] , SUM(CASE WHEN rg.[State] = 3 THEN 1 ELSE 0 END) AS [COMPRESSED_rowgroup_count] , SUM(CASE WHEN rg.[State] = 3 THEN rg.[total_rows] ELSE 0 END) AS [COMPRESSED_rowgroup_rows] , SUM(CASE WHEN rg.[State] = 3 THEN rg.[deleted_rows] ELSE 0 END) AS [COMPRESSED_rowgroup_rows_DELETED] , MIN(CASE WHEN rg.[State] = 3 THEN rg.[total_rows] ELSE NULL END) AS [COMPRESSED_rowgroup_rows_MIN] , MAX(CASE WHEN rg.[State] = 3 THEN rg.[total_rows] ELSE NULL END) AS [COMPRESSED_rowgroup_rows_MAX] , AVG(CASE WHEN rg.[State] = 3 THEN rg.[total_rows] ELSE NULL END) AS [COMPRESSED_rowgroup_rows_AVG] , 'ALTER INDEX ALL ON ' + s.name + '.' + t.NAME + ' REBUILD;' AS [Rebuild_Index_SQL] FROM sys.[pdw_nodes_column_store_row_groups] rg JOIN sys.[pdw_nodes_tables] nt ON rg.[object_id] = nt.[object_id] AND rg.[pdw_node_id] = nt.[pdw_node_id] AND rg.[distribution_id] = nt.[distribution_id] JOIN sys.[pdw_table_mappings] mp ON nt.[name] = mp.[physical_name] JOIN sys.[tables] t ON mp.[object_id] = t.[object_id] JOIN sys.[schemas] s ON t.[schema_id] = s.[schema_id] GROUP BY s.[name] , t.[name] ; ================================================ FILE: TSQL_Queries/SLO-DWU/GetDwuSetting.sql ================================================ /* ============================= Get Current DWU Setting ============================= This query will return the current DWU settings of your database. Source: https://docs.microsoft.com/en-us/azure/sql-data-warehouse/what-is-a-data-warehouse-unit-dwu-cdwu */ SELECT db.name [Database] , ds.edition [Edition] , ds.service_objective [Service Objective] FROM sys.database_service_objectives AS ds JOIN sys.databases AS db ON ds.database_id = db.database_id ; ================================================ FILE: TSQL_Queries/ServerlessSql/CostPerQuery.sql ================================================ SELECT ERH.status as [status], ERH.login_name as [login_name], ERH.start_time as [start_time], ERH.end_time as [end_time], ERH.total_elapsed_time_ms as [duration_ms], /* Data processed = data scanned + data moved + data written */ ERH.data_processed_mb as [data_processed_MB], /* Cost management for serverless SQL pool The amount of data processed is rounded up to the nearest MB per query. Each query has a minimum of 10 MB of data processed. */ CASE WHEN ERH.data_processed_mb < 10 THEN 10 ELSE ERH.data_processed_mb END as [data_pricing_MB], cast(ERH.total_elapsed_time_ms/1000.0 as decimal(12,2)) as [duration_sec], /*$5 per 1TB scan, minimum 10M */ cast((CASE WHEN ERH.data_processed_mb < 10 THEN 10 ELSE ERH.data_processed_mb END)*5/100000.0 as decimal(19,7)) as cost_in_$, ERH.command as [statement], ERH.query_text as [command] FROM sys.dm_exec_requests_history ERH ORDER BY ERH.start_time desc --order by cast((CASE WHEN ERH.data_processed_mb < 10 THEN 10 ELSE ERH.data_processed_mb END)*5/100000.0 as decimal(19,7)) desc ================================================ FILE: TSQL_Queries/Statistics/CheckAutoStatsEnabled.sql ================================================ SELECT name, is_auto_create_stats_on FROM sys.databases --To turn on auto create stats: --ALTER DATABASE --SET AUTO_CREATE_STATISTICS ON ================================================ FILE: TSQL_Queries/Statistics/CreateSP_CreateStatsAllColumnsAllTables.sql ================================================ /* ======================================================= Create SP for Create Stats all columns all tables ======================================================= This query will create a stored procedure that, when executed, will create statistics on all columns, all tables in the Azure SQL Data Warehouse database. Source: https://docs.microsoft.com/en-us/azure/sql-data-warehouse/sql-data-warehouse-tables-statistics =========================== EXECUTING THIS PROCEDURE: =========================== Create statistics on all columns on all tables using defaults: EXEC [dbo].[prc_sqldw_create_stats] 1, NULL; Create statistics on all columns on all tables using fullscan: EXEC [dbo].[prc_sqldw_create_stats] 2, NULL; Create sampled statistics on all columns on all tables using 20% sample: EXEC [dbo].[prc_sqldw_create_stats] 3, 20; */ CREATE PROCEDURE [dbo].[prc_sqldw_create_stats] ( @create_type tinyint -- 1 default 2 Fullscan 3 Sample , @sample_pct tinyint ) AS IF @create_type IS NULL BEGIN SET @create_type = 1; END; IF @create_type NOT IN (1,2,3) BEGIN THROW 151000,'Invalid value for @stats_type parameter. Valid range 1 (default), 2 (fullscan) or 3 (sample).',1; END; IF @sample_pct IS NULL BEGIN; SET @sample_pct = 20; END; IF OBJECT_ID('tempdb..#stats_ddl') IS NOT NULL BEGIN; DROP TABLE #stats_ddl; END; CREATE TABLE #stats_ddl WITH ( DISTRIBUTION = HASH([seq_nmbr]) , LOCATION = USER_DB ) AS WITH T AS ( SELECT t.[name] AS [table_name] , s.[name] AS [table_schema_name] , c.[name] AS [column_name] , c.[column_id] AS [column_id] , t.[object_id] AS [object_id] , ROW_NUMBER() OVER(ORDER BY (SELECT NULL)) AS [seq_nmbr] FROM sys.[tables] t JOIN sys.[schemas] s ON t.[schema_id] = s.[schema_id] JOIN sys.[columns] c ON t.[object_id] = c.[object_id] LEFT JOIN sys.[stats_columns] l ON l.[object_id] = c.[object_id] AND l.[column_id] = c.[column_id] AND l.[stats_column_id] = 1 LEFT JOIN sys.[external_tables] e ON e.[object_id] = t.[object_id] WHERE l.[object_id] IS NULL AND e.[object_id] IS NULL -- not an external table ) SELECT [table_schema_name] , [table_name] , [column_name] , [column_id] , [object_id] , [seq_nmbr] , CASE @create_type WHEN 1 THEN CAST('CREATE STATISTICS '+QUOTENAME('stat_'+table_schema_name+ '_' + table_name + '_'+column_name)+' ON '+QUOTENAME(table_schema_name)+'.'+QUOTENAME(table_name)+'('+QUOTENAME(column_name)+')' AS VARCHAR(8000)) WHEN 2 THEN CAST('CREATE STATISTICS '+QUOTENAME('stat_'+table_schema_name+ '_' + table_name + '_'+column_name)+' ON '+QUOTENAME(table_schema_name)+'.'+QUOTENAME(table_name)+'('+QUOTENAME(column_name)+') WITH FULLSCAN' AS VARCHAR(8000)) WHEN 3 THEN CAST('CREATE STATISTICS '+QUOTENAME('stat_'+table_schema_name+ '_' + table_name + '_'+column_name)+' ON '+QUOTENAME(table_schema_name)+'.'+QUOTENAME(table_name)+'('+QUOTENAME(column_name)+') WITH SAMPLE '+CONVERT(varchar(4),@sample_pct)+' PERCENT' AS VARCHAR(8000)) END AS create_stat_ddl FROM T ; DECLARE @i INT = 1 , @t INT = (SELECT COUNT(*) FROM #stats_ddl) , @s NVARCHAR(4000) = N'' ; WHILE @i <= @t BEGIN SET @s=(SELECT create_stat_ddl FROM #stats_ddl WHERE seq_nmbr = @i); PRINT @s EXEC sp_executesql @s SET @i+=1; END DROP TABLE #stats_ddl; ================================================ FILE: TSQL_Queries/Statistics/CreateSP_GenUpdateStatsStatements.sql ================================================ /* ======================================================= Create SP for Update Stats all columns all tables ======================================================= This query will create a stored procedure that, when executed, will generate statements to update all statistics found in the current Azure SQL Data Warehouse database. Executing the procedure will NOT EXECUTE the update statements, rather it will return them for you to execute separately. Source: https://docs.microsoft.com/en-us/azure/sql-data-warehouse/sql-data-warehouse-tables-statistics =========================== EXECUTING THIS PROCEDURE: =========================== --update statistics on all columns on all tables using defaults: EXEC [dbo].[prc_sqldw_update_stats] 1, NULL; --update statistics on all columns on all tables using fullscan: EXEC [dbo].[prc_sqldw_update_stats] 2, NULL; --update sampled statistics on all columns on all tables using 20% sample: EXEC [dbo].[prc_sqldw_update_stats] 3, 20; */ CREATE PROCEDURE [dbo].[prc_sqldw_Gen_update_stats_Statements] ( @update_type tinyint -- 1 default 2 fullscan 3 sample 4 resample ,@sample_pct tinyint ) AS IF @update_type NOT IN (1,2,3,4) BEGIN; THROW 151000,'Invalid value for @update_type parameter. Valid range 1 (default), 2 (fullscan), 3 (sample) or 4 (resample).',1; END; IF @sample_pct IS NULL BEGIN; SET @sample_pct = 20; END; IF OBJECT_ID('tempdb..#stats_ddl') IS NOT NULL BEGIN DROP TABLE #stats_ddl END CREATE TABLE #stats_ddl WITH ( DISTRIBUTION = HASH([seq_nmbr]) ) AS ( SELECT sm.[name] AS [schema_name] , tb.[name] AS [table_name] , st.[name] AS [stats_name] , st.[has_filter] AS [stats_is_filtered] , ROW_NUMBER() OVER(ORDER BY (SELECT NULL)) AS [seq_nmbr] , QUOTENAME(sm.[name])+'.'+QUOTENAME(tb.[name]) AS [two_part_name] , QUOTENAME(DB_NAME())+'.'+QUOTENAME(sm.[name])+'.'+QUOTENAME(tb.[name]) AS [three_part_name] FROM sys.objects AS ob JOIN sys.stats AS st ON ob.[object_id] = st.[object_id] JOIN sys.stats_columns AS sc ON st.[stats_id] = sc.[stats_id] AND st.[object_id] = sc.[object_id] JOIN sys.columns AS co ON sc.[column_id] = co.[column_id] AND sc.[object_id] = co.[object_id] JOIN sys.tables AS tb ON co.[object_id] = tb.[object_id] JOIN sys.schemas AS sm ON tb.[schema_id] = sm.[schema_id] WHERE 1=1 AND st.[user_created] = 1 GROUP BY sm.[name] , tb.[name] , st.[name] , st.[filter_definition] , st.[has_filter] ) SELECT CASE @update_type WHEN 1 THEN 'UPDATE STATISTICS '+[two_part_name]+'('+[stats_name]+');' WHEN 2 THEN 'UPDATE STATISTICS '+[two_part_name]+'('+[stats_name]+') WITH FULLSCAN;' WHEN 3 THEN 'UPDATE STATISTICS '+[two_part_name]+'('+[stats_name]+') WITH SAMPLE '+CAST(@sample_pct AS VARCHAR(20))+' PERCENT;' WHEN 4 THEN 'UPDATE STATISTICS '+[two_part_name]+'('+[stats_name]+') WITH RESAMPLE;' END AS [update_stats_ddl] , [seq_nmbr] FROM #stats_ddl ; GO ================================================ FILE: TSQL_Queries/Statistics/CreateStatsAllColumnsAllTables.sql ================================================ /* ================================================= Create Statistics on all columns all tables ================================================= This query will generate AND execute the statistics creation queries to create statistics on all columns, all tables in the Azure SQL Data Warehouse database. Set the following two variables dependind on what type of statistics you want to create or leave them as is to create default statistics */ DECLARE @create_type TINYINT = 1; --1 default 2 Fullscan 3 Sample DECLARE @sample_pct TINYINT = 20; --if option 3 selected, set sample size to desired value ----------------------------------------------------------------------------------- ----------------------------------------------------------------------------------- IF @create_type IS NULL BEGIN SET @create_type = 1; END; IF @create_type NOT IN (1,2,3) BEGIN THROW 151000,'Invalid value for @stats_type parameter. Valid range 1 (default), 2 (fullscan) or 3 (sample).',1; END; IF @sample_pct IS NULL BEGIN; SET @sample_pct = 20; END; IF OBJECT_ID('tempdb..#stats_ddl') IS NOT NULL BEGIN; DROP TABLE #stats_ddl; END; CREATE TABLE #stats_ddl WITH ( DISTRIBUTION = HASH([seq_nmbr]) , LOCATION = USER_DB ) AS WITH T AS ( SELECT t.[name] AS [table_name] , s.[name] AS [table_schema_name] , c.[name] AS [column_name] , c.[column_id] AS [column_id] , t.[object_id] AS [object_id] , ROW_NUMBER() OVER(ORDER BY (SELECT NULL)) AS [seq_nmbr] FROM sys.[tables] t JOIN sys.[schemas] s ON t.[schema_id] = s.[schema_id] JOIN sys.[columns] c ON t.[object_id] = c.[object_id] LEFT JOIN sys.[stats_columns] l ON l.[object_id] = c.[object_id] AND l.[column_id] = c.[column_id] AND l.[stats_column_id] = 1 LEFT JOIN sys.[external_tables] e ON e.[object_id] = t.[object_id] WHERE l.[object_id] IS NULL AND e.[object_id] IS NULL -- not an external table ) SELECT [table_schema_name] , [table_name] , [column_name] , [column_id] , [object_id] , [seq_nmbr] , CASE @create_type WHEN 1 THEN CAST('CREATE STATISTICS '+QUOTENAME('stat_'+table_schema_name+ '_' + table_name + '_'+column_name)+' ON '+QUOTENAME(table_schema_name)+'.'+QUOTENAME(table_name)+'('+QUOTENAME(column_name)+')' AS VARCHAR(8000)) WHEN 2 THEN CAST('CREATE STATISTICS '+QUOTENAME('stat_'+table_schema_name+ '_' + table_name + '_'+column_name)+' ON '+QUOTENAME(table_schema_name)+'.'+QUOTENAME(table_name)+'('+QUOTENAME(column_name)+') WITH FULLSCAN' AS VARCHAR(8000)) WHEN 3 THEN CAST('CREATE STATISTICS '+QUOTENAME('stat_'+table_schema_name+ '_' + table_name + '_'+column_name)+' ON '+QUOTENAME(table_schema_name)+'.'+QUOTENAME(table_name)+'('+QUOTENAME(column_name)+') WITH SAMPLE '+CONVERT(varchar(4),@sample_pct)+' PERCENT' AS VARCHAR(8000)) END AS create_stat_ddl FROM T ; DECLARE @i INT = 1 , @t INT = (SELECT COUNT(*) FROM #stats_ddl) , @s NVARCHAR(4000) = N'' ; WHILE @i <= @t BEGIN SET @s=(SELECT create_stat_ddl FROM #stats_ddl WHERE seq_nmbr = @i); PRINT @s EXEC sp_executesql @s SET @i+=1; END DROP TABLE #stats_ddl; ================================================ FILE: TSQL_Queries/Statistics/GetStatsLastUpdateDate.sql ================================================ /* ===================================== Get Statistics Last Update Date ===================================== This query will return the last update date for all stats found in the current Azure SQL Data Warehouse Database. This is useful in detemrining if statistics updates jobs are working successfully, but does not gaurantee the statistics are still accurate, which varies depending on what changes have been made to the table since the last update. Source: https://docs.microsoft.com/en-us/azure/sql-data-warehouse/sql-data-warehouse-tables-statistics */ SELECT sm.[name] AS [schema_name], tb.[name] AS [table_name], co.[name] AS [stats_column_name], st.[name] AS [stats_name], STATS_DATE(st.[object_id],st.[stats_id]) AS [stats_last_updated_date] FROM sys.objects ob JOIN sys.stats st ON ob.[object_id] = st.[object_id] JOIN sys.stats_columns sc ON st.[stats_id] = sc.[stats_id] AND st.[object_id] = sc.[object_id] JOIN sys.columns co ON sc.[column_id] = co.[column_id] AND sc.[object_id] = co.[object_id] JOIN sys.types ty ON co.[user_type_id] = ty.[user_type_id] JOIN sys.tables tb ON co.[object_id] = tb.[object_id] JOIN sys.schemas sm ON tb.[schema_id] = sm.[schema_id] WHERE st.[user_created] = 1; ================================================ FILE: TSQL_Queries/Statistics/ListAllStats.sql ================================================ --Get all stats that exist Select db_name() as [Database] , sch.name as [Schema] , t.name as [Table] , t.object_id as Table_ID , s.user_created as [is_user_created] , s.name as [Statistic] , s.stats_id as stats_id , c.name as [Column] , c.column_id as column_id From sys.tables t inner join sys.stats s on t.object_id = s.object_id inner join sys.stats_columns sc on t.object_id = sc.object_id and s.stats_id = sc.stats_id inner join sys.columns c on sc.column_id = c.column_id and t.object_id = c.object_id inner join sys.schemas sch ON t.schema_id = sch.schema_id WHERE 1=1 --AND sch.name like '%dbo%' --uncomment to choose a schema --AND t.name like '%Trips%' --Uncomment to pick a specific table --AND s.user_created=1 ================================================ FILE: TSQL_Queries/Statistics/ListAllStats.sql.bak ================================================ --Get all stats that exist Select db_name() as [Database] , sch.name as [Schema] , t.name as [Table] , t.object_id as Table_ID , s.name as [Statistic] , s.stats_id as stats_id , c.name as [Column] , c.column_id as column_id From sys.tables t inner join sys.stats s on t.object_id = s.object_id inner join sys.stats_columns sc on t.object_id = sc.object_id and s.stats_id = sc.stats_id inner join sys.columns c on sc.column_id = c.column_id and t.object_id = c.object_id inner join sys.schemas sch ON t.schema_id = sch.schema_id WHERE 1=1 --AND sch.name like '%dbo%' --uncomment to choose a schema --AND t.name like '%Trips%' --Uncomment to pick a specific table ================================================ FILE: TSQL_Queries/Statistics/StatisticsAccuracy.sql ================================================ select objIdsWithStats.[object_id], actualRowCounts.[schema], actualRowCounts.logical_table_name, statsRowCounts.stats_row_count, actualRowCounts.actual_row_count, row_count_difference = CASE WHEN actualRowCounts.actual_row_count >= statsRowCounts.stats_row_count THEN actualRowCounts.actual_row_count - statsRowCounts.stats_row_count ELSE statsRowCounts.stats_row_count - actualRowCounts.actual_row_count END, percent_deviation_from_actual = CASE WHEN actualRowCounts.actual_row_count = 0 THEN statsRowCounts.stats_row_count WHEN statsRowCounts.stats_row_count = 0 THEN actualRowCounts.actual_row_count WHEN actualRowCounts.actual_row_count >= statsRowCounts.stats_row_count THEN CONVERT(NUMERIC(18, 0), CONVERT(NUMERIC(18, 2), (actualRowCounts.actual_row_count - statsRowCounts.stats_row_count)) / CONVERT(NUMERIC(18, 2), actualRowCounts.actual_row_count) * 100) ELSE CONVERT(NUMERIC(18, 0), CONVERT(NUMERIC(18, 2), (statsRowCounts.stats_row_count - actualRowCounts.actual_row_count)) / CONVERT(NUMERIC(18, 2), actualRowCounts.actual_row_count) * 100) END from ( select distinct object_id from sys.stats where stats_id > 1 ) objIdsWithStats left join ( select object_id, sum(rows) as stats_row_count from sys.partitions group by object_id ) statsRowCounts on objIdsWithStats.object_id = statsRowCounts.object_id left join ( SELECT sm.name [schema] , tb.name logical_table_name , tb.object_id object_id , SUM(rg.row_count) actual_row_count FROM sys.schemas sm INNER JOIN sys.tables tb ON sm.schema_id = tb.schema_id INNER JOIN sys.pdw_table_mappings mp ON tb.object_id = mp.object_id INNER JOIN sys.pdw_nodes_tables nt ON nt.name = mp.physical_name INNER JOIN sys.dm_pdw_nodes_db_partition_stats rg ON rg.object_id = nt.object_id AND rg.pdw_node_id = nt.pdw_node_id AND rg.distribution_id = nt.distribution_id --WHERE rg.index_id = 1 --this woudl only include CCI tables GROUP BY sm.name, tb.name, tb.object_id ) actualRowCounts on objIdsWithStats.object_id = actualRowCounts.object_id ================================================ FILE: TSQL_Queries/Table_Information/CollectTableInformation.sql ================================================ --Table Information query SELECT t.name AS 'Table_Name', t.object_id, t.create_date, t.modify_date, ptdp.Distribution_policy_desc AS 'Table_Type', dist.column_name AS Distribution_Column, i.name AS Index_name, i.type_desc AS Index_Type FROM sys.tables t JOIN sys.pdw_table_distribution_properties ptdp ON t.object_id = ptdp.object_id LEFT JOIN ( select c.name as column_name,pcdp.distribution_ordinal,c.object_id from sys.pdw_column_distribution_properties pcdp join sys.columns c ON pcdp.[object_id] = c.[object_id] AND pcdp.column_id = c.column_id AND pcdp.distribution_ordinal = 1 ) as Dist ON ptdp.object_id = dist.object_id JOIN sys.indexes i ON t.object_id = i.object_id ORDER BY Table_Name ================================================ FILE: TSQL_Queries/Table_Information/CreateTableInfoView.sql ================================================ --Create Table information view for use with various other queries --pulled from: https://docs.microsoft.com/en-us/azure/sql-data-warehouse/sql-data-warehouse-tables-overview#table-size-queries CREATE VIEW dbo.vTableSizes AS WITH base AS ( SELECT GETDATE() AS [execution_time] , DB_NAME() AS [database_name] , s.name AS [schema_name] , t.name AS [table_name] , QUOTENAME(s.name)+'.'+QUOTENAME(t.name) AS [two_part_name] , nt.[name] AS [node_table_name] , ROW_NUMBER() OVER(PARTITION BY nt.[name] ORDER BY (SELECT NULL)) AS [node_table_name_seq] , tp.[distribution_policy_desc] AS [distribution_policy_name] , c.[name] AS [distribution_column] , nt.[distribution_id] AS [distribution_id] , i.[type] AS [index_type] , i.[type_desc] AS [index_type_desc] , nt.[pdw_node_id] AS [pdw_node_id] , pn.[type] AS [pdw_node_type] , pn.[name] AS [pdw_node_name] , di.name AS [dist_name] , di.position AS [dist_position] , nps.[partition_number] AS [partition_nmbr] , nps.[reserved_page_count] AS [reserved_space_page_count] , nps.[reserved_page_count] - nps.[used_page_count] AS [unused_space_page_count] , nps.[in_row_data_page_count] + nps.[row_overflow_used_page_count] + nps.[lob_used_page_count] AS [data_space_page_count] , nps.[reserved_page_count] - (nps.[reserved_page_count] - nps.[used_page_count]) - ([in_row_data_page_count] + [row_overflow_used_page_count]+[lob_used_page_count]) AS [index_space_page_count] , nps.[row_count] AS [row_count] from sys.schemas s INNER JOIN sys.tables t ON s.[schema_id] = t.[schema_id] INNER JOIN sys.indexes i ON t.[object_id] = i.[object_id] AND i.[index_id] <= 1 INNER JOIN sys.pdw_table_distribution_properties tp ON t.[object_id] = tp.[object_id] INNER JOIN sys.pdw_table_mappings tm ON t.[object_id] = tm.[object_id] INNER JOIN sys.pdw_nodes_tables nt ON tm.[physical_name] = nt.[name] INNER JOIN sys.dm_pdw_nodes pn ON nt.[pdw_node_id] = pn.[pdw_node_id] INNER JOIN sys.pdw_distributions di ON nt.[distribution_id] = di.[distribution_id] INNER JOIN sys.dm_pdw_nodes_db_partition_stats nps ON nt.[object_id] = nps.[object_id] AND nt.[pdw_node_id] = nps.[pdw_node_id] AND nt.[distribution_id] = nps.[distribution_id] LEFT OUTER JOIN (select * from sys.pdw_column_distribution_properties where distribution_ordinal = 1) cdp ON t.[object_id] = cdp.[object_id] LEFT OUTER JOIN sys.columns c ON cdp.[object_id] = c.[object_id] AND cdp.[column_id] = c.[column_id] ) , size AS ( SELECT [execution_time] , [database_name] , [schema_name] , [table_name] , [two_part_name] , [node_table_name] , [node_table_name_seq] , [distribution_policy_name] , [distribution_column] , [distribution_id] , [index_type] , [index_type_desc] , [pdw_node_id] , [pdw_node_type] , [pdw_node_name] , [dist_name] , [dist_position] , [partition_nmbr] , [reserved_space_page_count] , [unused_space_page_count] , [data_space_page_count] , [index_space_page_count] , [row_count] , ([reserved_space_page_count] * 8.0) AS [reserved_space_KB] , ([reserved_space_page_count] * 8.0)/1000 AS [reserved_space_MB] , ([reserved_space_page_count] * 8.0)/1000000 AS [reserved_space_GB] , ([reserved_space_page_count] * 8.0)/1000000000 AS [reserved_space_TB] , ([unused_space_page_count] * 8.0) AS [unused_space_KB] , ([unused_space_page_count] * 8.0)/1000 AS [unused_space_MB] , ([unused_space_page_count] * 8.0)/1000000 AS [unused_space_GB] , ([unused_space_page_count] * 8.0)/1000000000 AS [unused_space_TB] , ([data_space_page_count] * 8.0) AS [data_space_KB] , ([data_space_page_count] * 8.0)/1000 AS [data_space_MB] , ([data_space_page_count] * 8.0)/1000000 AS [data_space_GB] , ([data_space_page_count] * 8.0)/1000000000 AS [data_space_TB] , ([index_space_page_count] * 8.0) AS [index_space_KB] , ([index_space_page_count] * 8.0)/1000 AS [index_space_MB] , ([index_space_page_count] * 8.0)/1000000 AS [index_space_GB] , ([index_space_page_count] * 8.0)/1000000000 AS [index_space_TB] FROM base ) SELECT * FROM size ; ================================================ FILE: TSQL_Queries/Table_Information/DataTypeMismatch.sql ================================================ SET NOCOUNT ON; --Identify columns that have the same name, but different data types or data lengths WITH Query as ( SELECT COLUMN_NAME, COUNT(DISTINCT DATA_TYPE)AS 'Diff_Type_Count' , COUNT(DISTINCT Character_Maximum_length) AS 'Diff_Length_Count', count(table_name) AS Found_In_Table_Count FROM INFORMATION_SCHEMA.COLUMNS GROUP BY COLUMN_NAME ) SELECT * FROM Query WHERE Diff_Type_Count > 1 or Diff_Length_Count > 1 Order by Diff_Type_Count desc,Diff_Length_Count desc --Use this query to see all individual uses of a specific column name including data type and length SELECT TABLE_SCHEMA, TABLE_NAME, COLUMN_NAME, DATA_TYPE, Character_Maximum_length FROM INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME = 'SEQ_NUM' --Change to column name to investigate ================================================ FILE: TSQL_Queries/Table_Information/DistributionSpaceSummary.sql ================================================ --Distribution Space Summary --PRE-REQUISITE: must have the table info view created --FROM: https://docs.microsoft.com/en-us/azure/sql-data-warehouse/sql-data-warehouse-tables-overview#table-size-queries SELECT distribution_id , SUM(row_count) as total_node_distribution_row_count , SUM(reserved_space_MB) as total_node_distribution_reserved_space_MB , SUM(data_space_MB) as total_node_distribution_data_space_MB , SUM(index_space_MB) as total_node_distribution_index_space_MB , SUM(unused_space_MB) as total_node_distribution_unused_space_MB FROM dbo.vTableSizes GROUP BY distribution_id ORDER BY distribution_id ; ================================================ FILE: TSQL_Queries/Table_Information/FindNullableDistColumns.sql ================================================ /* ======================================== Find Nullable Distribution Columns ======================================== This query will return any distribution columns in the Azure SQL Data Warehouse Database that are set to allow NULLs. As a best practice and to avoid data skew, all distribution columns should be set to NOT NULL Author: Nicksalc@Microsoft.com */ SELECT s.name as 'Schema Name', t.name as 'Table Name', c.name as 'Distribution Column', c.is_nullable, c.object_id FROM sys.pdw_column_distribution_properties pcdp JOIN sys.columns c ON pcdp.[object_id] = c.[object_id] AND pcdp.column_id = c.column_id AND pcdp.distribution_ordinal = 1 JOIN sys.tables t ON c.object_id = t.object_id JOIN sys.schemas s ON t.schema_id = s.schema_id WHERE c.is_nullable = 1 ================================================ FILE: TSQL_Queries/Table_Information/GenerateTableSchemas.sql ================================================ --Generate Schemas of all tables --This is an early release that may not cover all data types or table structures and should not be considered perfect WITH ColumnList AS ( select s.name AS 'Schema' ,t.name AS 'Table' ,c.name AS 'Column' ,c.column_id ,type.name AS 'Type' ,c.max_length ,c.precision ,c.scale ,c.is_nullable , ColumnDefinition = CASE WHEN type.name in ('varchar') AND c.is_nullable=1 THEN '[' + c.name + '] ' + type.name + '(' + cast(c.max_length as nvarchar(5)) + ') NULL,' WHEN type.name in ('varchar') AND c.is_nullable=0 THEN '[' + c.name + '] ' + type.name + '(' + cast(c.max_length as nvarchar(5)) + ') NOT NULL,' WHEN type.name in ('nvarchar') AND c.is_nullable=1 THEN '[' + c.name + '] ' + type.name + '(' + cast(c.max_length/2 as nvarchar(5)) + ') NULL,' WHEN type.name in ('nvarchar') AND c.is_nullable=0 THEN '[' + c.name + '] ' + type.name + '(' + cast(c.max_length/2 as nvarchar(5)) + ') NOT NULL,' WHEN type.name in ('real','int','datetime','bigint','bit','smallint','tinyint','smallmoney','money','float','sysname','date') AND c.is_nullable=0 THEN '[' + c.name + '] ' + type.name + ' NOT NULL,' WHEN type.name in ('real','int','datetime','bigint','bit','smallint','tinyint','smallmoney','money','float','sysname','date') AND c.is_nullable=1 THEN '[' + c.name + '] ' + type.name + ' NULL,' WHEN type.name in ('numeric','decimal') AND c.is_nullable=0 THEN '[' + c.name + '] ' + type.name + '(' + cast(c.precision as nvarchar(5)) + ', ' + cast(c.scale as nvarchar(5)) + ') NOT NULL,' WHEN type.name in ('numeric','decimal') AND c.is_nullable=1 THEN '[' + c.name + '] ' + type.name + '(' + cast(c.precision as nvarchar(5)) + ', ' + cast(c.scale as nvarchar(5)) + ') NULL,' ELSE '--no match--' END , CTAS_Version = CASE WHEN type.name in ('varchar','nvarchar') THEN 'ISNULL([' + c.name + '],'''') AS [' + c.name + '],' ELSE '[' + c.name + '],' END from sys.tables t join sys.schemas s on t.schema_id = s.schema_id join sys.columns c on t.object_id = c.object_id join sys.types type on c.user_type_id = type.user_type_id ) SELECT s.name AS 'Schema' ,t.name AS 'Table' ,t.object_id ,ptdp.Distribution_policy_desc AS 'Table_Type' ,dist.column_name AS Distribution_Column ,i.name AS Index_name ,ISNULL(i.type_desc,'HEAP') AS Index_Type --,ic.column_id as 'Index_Column_ID' ,CL.[Column] ,CL.column_id ,i.index_id ,CL.[Type] ,CL.max_length ,CL.precision ,CL.scale ,CL.is_nullable ,CL.ColumnDefinition ,CL.Ctas_version ,t.create_date ,t.modify_date FROM sys.tables t JOIN sys.schemas s ON t.schema_id = s.schema_id JOIN sys.pdw_table_distribution_properties ptdp ON t.object_id = ptdp.object_id LEFT JOIN ( select c.name as column_name,pcdp.distribution_ordinal,c.object_id from sys.pdw_column_distribution_properties pcdp join sys.columns c ON pcdp.[object_id] = c.[object_id] AND pcdp.column_id = c.column_id AND pcdp.distribution_ordinal = 1 ) as Dist ON ptdp.object_id = dist.object_id JOIN ColumnList CL ON CL.[schema] = s.[name] AND t.[name] = CL.[table] LEFT JOIN sys.index_columns ic on t.object_id = ic.object_id AND CL.column_id = ic.column_id LEFT JOIN sys.indexes i ON ic.object_id = i.object_id AND ic.index_id = i.index_id ORDER BY [schema],[Table] ================================================ FILE: TSQL_Queries/Table_Information/IdentifyLargeDataTypes.sql ================================================ SET NOCOUNT ON; --This query will just collect the largest data types it can find in the database. --You can change the character maximum length as desired SELECT TABLE_SCHEMA,TABLE_NAME, COLUMN_NAME, DATA_TYPE, Character_Maximum_length FROM INFORMATION_SCHEMA.COLUMNS WHERE Character_Maximum_length > 100 order by Character_Maximum_length desc ================================================ FILE: TSQL_Queries/Table_Information/MostUsedTables_BETA.sql ================================================ --This query joins the index usage stats from all nodes to determine which tables are the most used. SELECT s.name , t.name , MAX(pnt.create_date) AS create_date , MAX(pnt.modify_date) AS modify_date , MAX(IUS.user_seeks) AS user_seeks , MAX(IUS.user_scans) AS user_scans , MAX(IUS.user_lookups) AS user_lookups , MAX(IUS.user_updates) AS user_updates , MAX(IUS.last_user_seek) AS last_user_seek , MAX(IUS.last_user_scan) AS last_user_scan , MAX(IUS.last_user_lookup) AS last_user_lookup , MAX(IUS.last_user_update) AS last_user_update , SUM(IUS.user_seeks + IUS.user_scans + IUS.user_lookups + IUS.user_updates) AS total_touches FROM sys.pdw_nodes_tables pnt LEFT JOIN sys.dm_pdw_nodes_db_index_usage_stats IUS ON IUS.object_id = pnt.object_id JOIN sys.pdw_table_mappings ptm ON ptm.physical_name = pnt.name JOIN sys.tables t ON t.object_id = ptm.object_id JOIN sys.schemas s ON s.schema_id = t.schema_id GROUP BY t.object_id, s.name,t.name ORDER BY total_touches DESC ================================================ FILE: TSQL_Queries/Table_Information/TableSizeByDistType.sql ================================================ --Table size by distribution type --PRE-REQUISITE: must have table info view created already --pulled from: https://docs.microsoft.com/en-us/azure/sql-data-warehouse/sql-data-warehouse-tables-overview#table-size-queries SELECT distribution_policy_name , SUM(row_count) as table_type_row_count , SUM(reserved_space_GB) as table_type_reserved_space_GB , SUM(data_space_GB) as table_type_data_space_GB , SUM(index_space_GB) as table_type_index_space_GB , SUM(unused_space_GB) as table_type_unused_space_GB FROM dbo.vTableSizes GROUP BY distribution_policy_name ; ================================================ FILE: TSQL_Queries/Table_Information/TableSizeByIndexType.sql ================================================ --Table space by index type --PRE-REQUISITE: MUST HAVE TABLE INFO VIEW CREATED ALREADY --SOURCE: https://docs.microsoft.com/en-us/azure/sql-data-warehouse/sql-data-warehouse-tables-overview#table-size-queries SELECT index_type_desc , SUM(row_count) as table_type_row_count , SUM(reserved_space_GB) as table_type_reserved_space_GB , SUM(data_space_GB) as table_type_data_space_GB , SUM(index_space_GB) as table_type_index_space_GB , SUM(unused_space_GB) as table_type_unused_space_GB FROM dbo.vTableSizes GROUP BY index_type_desc ; ================================================ FILE: TSQL_Queries/Table_Information/TableSizeSummary.sql ================================================ --Table size summary --PRE-REQUISITE: CREATE THE TABLE INFO VIEW FIRST --SOURCE: https://docs.microsoft.com/en-us/azure/sql-data-warehouse/sql-data-warehouse-tables-overview#table-size-queries SELECT database_name , schema_name , table_name , distribution_policy_name , distribution_column , index_type_desc , COUNT(distinct partition_nmbr) as nbr_partitions , SUM(row_count) as table_row_count , SUM(reserved_space_GB) as table_reserved_space_GB , SUM(data_space_GB) as table_data_space_GB , SUM(index_space_GB) as table_index_space_GB , SUM(unused_space_GB) as table_unused_space_GB FROM dbo.vTableSizes GROUP BY database_name , schema_name , table_name , distribution_policy_name , distribution_column , index_type_desc ORDER BY table_reserved_space_GB desc ; ================================================ FILE: TSQL_Queries/Table_Information/TableSkew.sql ================================================ /* ======================================== Find tables with data skew over 10% ======================================== This query will return tables that have data skew over 10%. These tables could be affecting query processing time and a different distribution column should be considered. PRE-REQUISITE: must have the vtableSizes view created: https://raw.githubusercontent.com/Microsoft/AzureDW_Query_Toolbox/master/TableInformation/CreateTableInfoView.dsql Source: https://docs.microsoft.com/en-us/azure/sql-data-warehouse/sql-data-warehouse-tables-distribute */ select * from dbo.vTableSizes where two_part_name in ( select two_part_name from dbo.vTableSizes where row_count > 0 group by two_part_name having min(row_count * 1.000)/max(row_count * 1.000) > .10 ) order by two_part_name, row_count ; ================================================ FILE: TSQL_Queries/Table_Information/TableUsageInformation.sql ================================================ SELECT s.name AS SchemaName , t.name AS TableName , MAX(i.last_user_seek) as Last_seek , MAX(i.last_user_scan) as last_scan , MAX(i.last_user_lookup) as last_lookup , MAX(i.last_user_update) as last_update FROM sys.schemas s INNER JOIN sys.tables t ON s.schema_id = t.schema_id INNER JOIN sys.pdw_permanent_table_mappings ptm ON t.object_id = ptm.object_id INNER JOIN sys.pdw_nodes_tables nt ON ptm.physical_name = nt.name INNER JOIN sys.dm_pdw_nodes_db_index_usage_stats i ON i.object_id = nt.Object_id INNER JOIN sys.databases d ON i.database_id = d.database_id WHERE d.database_id <> 1 --AND s.name = '' GROUP BY s.name, t.name ORDER BY last_scan DESC ================================================ FILE: TSQL_Queries/Table_Information/TablesWithMostLargeTypes.sql ================================================ SET NOCOUNT ON; --This query will find tables with the most number of large types SELECT TABLE_SCHEMA,TABLE_NAME, COUNT(*) AS Num_Lg_Types FROM INFORMATION_SCHEMA.COLUMNS WHERE Character_Maximum_length > 100 GROUP BY TABLE_SCHEMA,TABLE_NAME order by Num_Lg_Types desc ================================================ FILE: TSQL_Queries/TempDB/TempDbPerNode.sql ================================================ --Tempdb usage per node SELECT 'TempDB per node' AS 'TempDB per node' ,pdw.pdw_node_id ,n.type ,sum(pdw.bytes_processed) as 'bytes_written' ,CAST(sum(pdw.bytes_processed)/1024.0/1024.0/1024.0 AS Decimal(10,1)) AS 'GB_written' ,'1995' AS 'Total_tempDB_size_GB' ,CAST(((sum(pdw.bytes_processed)/1024.0/1024.0/1024.0)/1995.0)*100 AS Decimal(10,1)) AS 'percent_used' ,sum(pdw.rows_processed) as 'rows_written' FROM sys.dm_pdw_nodes n LEFT JOIN Sys.dm_pdw_dms_workers pdw ON n.pdw_node_id = pdw.pdw_node_id LEFT JOIN sys.dm_pdw_exec_requests req ON pdw.request_id = req.request_id WHERE pdw.type = 'Writer' AND req.status = 'running' GROUP BY n.type,pdw.pdw_node_id ORDER BY bytes_written desc ================================================ FILE: TSQL_Queries/TempDB/TempDbPerQuery.sql ================================================ --Tempdb usage per query SELECT 'TempDB per query' AS 'TempDB per query' ,req.request_id ,sum(pdw.bytes_processed) as 'bytes_written' ,CAST(sum(pdw.bytes_processed)/1024.0/1024.0/1024.0 AS Decimal(10,1)) AS 'GB_written' ,sum(pdw.rows_processed) as 'rows_written' ,'EXEC sp_requests_detail @request_id=''' + req.request_id + '''' AS 'request_detail_command' from Sys.dm_pdw_dms_workers pdw JOIN sys.dm_pdw_exec_requests req ON pdw.request_id = req.request_id WHERE pdw.type = 'Writer' AND req.status = 'running' GROUP BY req.request_id ORDER BY bytes_written desc ================================================ FILE: TSQL_Queries/TempDB/TotalTempDbUsage.sql ================================================ --Total TempDB Usage SELECT 'Total TempDB usage' AS 'Total TempDB usage' ,sum(pdw.rows_processed) as 'rows_written' ,sum(pdw.bytes_processed) as 'bytes_written' ,CAST(sum(pdw.bytes_processed)/1024.0/1024.0/1024.0 AS Decimal(10,1)) AS 'GB_written' ,total_tempdb.total_tempdb_gb as 'Total_tempDB_size_GB' ,CAST(((sum(pdw.bytes_processed)/1024.0/1024.0/1024.0)/total_tempdb.total_tempdb_gb)*100.0 AS Decimal(10,1)) AS 'approx_percent_used' FROM Sys.dm_pdw_dms_workers pdw JOIN sys.dm_pdw_exec_requests req ON pdw.request_id = req.request_id JOIN (SELECT (count(1) * 1995) AS total_tempdb_gb FROM sys.dm_pdw_nodes WHERE type='COMPUTE') AS total_tempdb ON 1=1 WHERE pdw.type = 'Writer' AND req.status = 'running' GROUP BY total_tempdb.total_tempdb_gb ================================================ FILE: TSQL_Queries/Workarounds/RecursionWorkaround_HierarchicalTableSample.sql ================================================ SET NOCOUNT ON DROP TABLE dbo.Employee; GO CREATE TABLE dbo.Employee ( EmployeeId BIGINT NOT NULL, EmployeeName VARCHAR(255) NOT NULL, ParentId BIGINT NOT NULL ) WITH ( DISTRIBUTION = HASH (EmployeeId), HEAP ); GO insert into Employee values (10, 'Ken Snchez', 1); insert into Employee values (11, 'Brian Welker', 10); insert into Employee values (12, 'Stephen Jiang', 11); insert into Employee values (13, 'Michael Blythe', 2); insert into Employee values (14, 'Linda Mitchell', 13); insert into Employee values (15, 'Syed Abbas', 3); insert into Employee values (16, 'Lynn Tsoflias', 15); insert into Employee values (17, 'David Bradley', 16); insert into Employee values (18, 'Hanan Almira', 17); insert into Employee values (19, 'Yunia Damayanti', 18); insert into Employee values (20, 'Mike Decker', 19); insert into Employee values (21, 'Lovely Sugiyanti', 12); GO SELECT * FROM dbo.Employee f -- Insert first record where no parent exists IF OBJECT_ID('tempdb..#employee') IS NOT NULL DROP TABLE #employee; CREATE TABLE #employee WITH ( DISTRIBUTION = HASH (EmployeeId) ) AS WITH cte AS ( SELECT 1 AS xlevel, p.EmployeeId, p.ParentId, p.EmployeeName, CAST(p.ParentId AS VARCHAR(255)) AS PathString, 0 AS PathLength, 1 as IsRoot, Case when exists (Select 1 from dbo.employee pcheck where pcheck.ParentId = p.EmployeeID) then 0 else 1 end as IsLeaf FROM dbo.Employee p WHERE NOT EXISTS ( SELECT * FROM dbo.Employee c WHERE p.ParentId = c.EmployeeId ) ) SELECT * FROM cte SELECT 'before' s, * FROM #employee ORDER BY EmployeeId; -- Loop thru Features DECLARE @counter int = 1; --Begin Loop WHILE EXISTS ( SELECT * FROM #employee p INNER JOIN dbo.employee c ON p.EmployeeId = c.ParentId WHERE p.xlevel = @counter ) BEGIN -- Insert next level INSERT INTO #employee ( xlevel, EmployeeId, ParentId, EmployeeName, PathString, PathLength, IsRoot, IsLeaf ) SELECT @counter + 1 AS xlevel, c.EmployeeId, c.ParentId, c.EmployeeName, p.PathString + '*' + CAST(c.ParentId AS VARCHAR(255)) AS PathString, @counter AS PathLength, 0 as IsRoot, Case when exists (Select 1 from dbo.employee pcheck where pcheck.ParentId = C.EmployeeID) then 0 else 1 end as IsLeaf FROM #employee p INNER JOIN dbo.employee c ON p.EmployeeId = c.ParentId WHERE p.xlevel = @counter; SET @counter = @counter + 1; -- Loop safety IF @counter > 99 BEGIN RAISERROR('Too many loops!', 16, 1) BREAK END END SELECT * FROM dbo.Employee f SELECT 'after' s, * FROM #employee ORDER BY EmployeeId; --Get Leaf Rows SELECT 'after' s, * FROM #employee e Where not exists (select parentid from #Employee p where e.employeeid = p.parentid) ================================================ FILE: TSQL_Queries/Workload_Management/CurrentRoleByUser.sql ================================================ /* ========================== Current Role By User ========================== The following query returns what DWU role each user is currently assigned to. Source: https://docs.microsoft.com/en-us/azure/sql-data-warehouse/analyze-your-workload */ SELECT r.name AS role_principal_name , m.name AS member_principal_name FROM sys.database_role_members rm JOIN sys.database_principals AS r ON rm.role_principal_id = r.principal_id JOIN sys.database_principals AS m ON rm.member_principal_id = m.principal_id WHERE r.name IN ('mediumrc','largerc','xlargerc') ; ================================================ FILE: TSQL_Queries/Workload_Management/ViewWorkloadGroups.sql ================================================ /* ========================= View Workload Groups ========================= The following query shows details of the memory resource allocation from the perspective of the resource governor. This is helpful for analyzing active and historic usage of the workload groups when troubleshooting. Source: https://docs.microsoft.com/en-us/azure/sql-data-warehouse/analyze-your-workload */ WITH rg AS ( SELECT pn.name AS node_name ,pn.[type] AS node_type ,pn.pdw_node_id AS node_id ,rp.name AS pool_name ,rp.max_memory_kb*1.0/1024 AS pool_max_mem_MB ,wg.name AS group_name ,wg.importance AS group_importance ,wg.request_max_memory_grant_percent AS group_request_max_memory_grant_pcnt ,wg.max_dop AS group_max_dop ,wg.effective_max_dop AS group_effective_max_dop ,wg.total_request_count AS group_total_request_count ,wg.total_queued_request_count AS group_total_queued_request_count ,wg.active_request_count AS group_active_request_count ,wg.queued_request_count AS group_queued_request_count FROM sys.dm_pdw_nodes_resource_governor_workload_groups wg JOIN sys.dm_pdw_nodes_resource_governor_resource_pools rp ON wg.pdw_node_id = rp.pdw_node_id AND wg.pool_id = rp.pool_id JOIN sys.dm_pdw_nodes pn ON wg.pdw_node_id = pn.pdw_node_id WHERE wg.name like 'SloDWGroup%' AND rp.name = 'SloDWPool' ) SELECT pool_name , pool_max_mem_MB , group_name , group_importance , (pool_max_mem_MB/100)*group_request_max_memory_grant_pcnt AS max_memory_grant_MB , node_name , node_type , group_total_request_count , group_total_queued_request_count , group_active_request_count , group_queued_request_count FROM rg ORDER BY node_name , group_request_max_memory_grant_pcnt , group_importance ; ================================================ FILE: TSQL_Queries/Workload_Management/WorkloadManagementMappingsAndUsage.sql ================================================ --Mapping details per classifier + effective grants + specified grants SELECT * FROM (SELECT wc.name AS 'ClassifierName' ,wc.group_name AS 'GroupName' ,wc.importance AS 'ClassifierImportance' ,wg.importance AS 'GroupImportance' ,wcd.classifier_type ,wcd.classifier_value ,wg.min_percentage_resource ,wgs.effective_min_percentage_resource ,wg.cap_percentage_resource ,wgs.effective_cap_percentage_resource ,wg.request_min_resource_grant_percent ,wgs.effective_request_min_resource_grant_percent ,wg.request_max_resource_grant_percent ,wgs.effective_request_max_resource_grant_percent ,wgs.total_request_count ,wgs.total_shared_resource_requests ,wgs.total_queued_request_count ,wgs.total_request_execution_timeouts ,wgs.total_resource_grant_timeouts FROM sys.workload_management_workload_classifiers wc JOIN sys.workload_management_workload_classifier_details wcd ON wc.classifier_id = wcd.classifier_id JOIN sys.dm_workload_management_workload_groups_stats wgs ON wgs.name = wc.group_name JOIN sys.workload_management_workload_groups wg ON wg.group_id = wgs.group_id ) AS Source PIVOT (max(Classifier_Value) FOR Classifier_Type in ([membername],[wlm_label],[wlm_context],[start_time],[end_time])) AS PivotTable