From f8dfeda3384dd5ec91e7bb12bd486ea8574c76fb Mon Sep 17 00:00:00 2001 From: Alex Protsenko <53046834+msalexprotsenko@users.noreply.github.com> Date: Thu, 18 Jul 2019 16:23:27 +0300 Subject: [PATCH 1/9] Added a sample for how to disable checks --- .../DisablingBuiltInChecks_sample.json | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 samples/manage/sql-assessment-api/DisablingBuiltInChecks_sample.json diff --git a/samples/manage/sql-assessment-api/DisablingBuiltInChecks_sample.json b/samples/manage/sql-assessment-api/DisablingBuiltInChecks_sample.json new file mode 100644 index 0000000000..af51fee528 --- /dev/null +++ b/samples/manage/sql-assessment-api/DisablingBuiltInChecks_sample.json @@ -0,0 +1,12 @@ +{ + "checks":[ + { + "id": "SqlServer.Database.AutoCreateStats", + "enabled": false + }, + { + "select": ["TraceFlag"], + "enabled": false + } + ] +} \ No newline at end of file From 3ed0b8b364cf109a3dd657371c1423fbf3c73aaf Mon Sep 17 00:00:00 2001 From: Alex Protsenko <53046834+msalexprotsenko@users.noreply.github.com> Date: Thu, 18 Jul 2019 16:26:22 +0300 Subject: [PATCH 2/9] Added a sample of making new custom checks --- .../MakingCustomChecks_sample.json | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 samples/manage/sql-assessment-api/MakingCustomChecks_sample.json diff --git a/samples/manage/sql-assessment-api/MakingCustomChecks_sample.json b/samples/manage/sql-assessment-api/MakingCustomChecks_sample.json new file mode 100644 index 0000000000..abd1a0bdb5 --- /dev/null +++ b/samples/manage/sql-assessment-api/MakingCustomChecks_sample.json @@ -0,0 +1,60 @@ +{ + "checks":[ + { + "target": { + "type": "Database", + "platform": "Windows" + }, + "id": "Custom_SqlServer.Database.AutoUpdateStats", + "tags": [ "InternalBestPracticeSet", "Performance" ], + "displayName": "Auto-Update Statistics should be on", + "description": "The query optimizer needs up-to-date and accurate statistics in order to generate good plans. In most cases, it's best to let SQL Server maintain the statistics. If you turn 'Auto Create Stats' and 'Auto Update Stats' off, then it is up to you to keep the statistics up-to-date somehow. Failure to do so will lead to poor query performance. Most applications should have these options ON.\n \n When the Auto Update Statistics setting is ON, the query optimizer updates statistics when they are used by a query and when they might be out-of-date. Statistics become out-of-date after insert, update, delete, or merge operations change the data distribution in the table or indexed view. The query optimizer determines when statistics might be out-of-date by counting the number of data modifications since the last statistics update and comparing the number of modifications to a threshold. The threshold is based on the number of rows in the table or indexed view. The query optimizer checks for out-of-date statistics before compiling a query and before executing a cached query plan. Before compiling a query, the query optimizer uses the columns, tables, and indexed views in the query predicate to determine which statistics might be out-of-date. Before executing a cached query plan, the Database Engine verifies that the query plan references up-to-date statistics. The AUTO_UPDATE_STATISTICS option applies to statistics created for indexes, single-columns in query predicates, and statistics that are created by using the CREATE STATISTICS statement. This option also applies to filtered statistics.", + "message": "Turn Auto-Update Statistics option on to improve query performance.", + "helpLink": "https://blogs.msdn.microsoft.com/buckwoody/2009/08/18/sql-server-best-practices-auto-create-and-auto-update-statistics-should-be-on-most-of-the-time/", + "probes": [ "DatabaseConfiguration" ], + "condition": "@is_auto_update_stats_on" + }, + { + "target": { + "type": "Database", + "version": "[12.0,)", + "platform": "Windows", + "name": { "not": "/^(master|msdb)$/" } + }, + "id": "Custom_SqlServer.Database.QueryStoreOn", + "tags": [ "InternalBestPracticeSet", "Performance" ], + "displayName": "Query Store should be on", + "description": "The SQL Server Query Store feature provides you with insight on query plan choice and performance. It simplifies performance troubleshooting by helping you quickly find performance differences caused by query plan changes. Query Store automatically captures a history of queries, plans, and runtime statistics, and retains these for your review. It separates data by time windows so you can see database usage patterns and understand when query plan changes happened on the server.", + "message": "Turn Query Store option on to improve query performance troubleshooting.", + "helpLink": "https://docs.microsoft.com/sql/relational-databases/performance/monitoring-performance-by-using-the-query-store", + "probes": [ "DatabaseConfiguration" ], + "condition": "@is_query_store_on" + } + ], + "probes":{ + "DatabaseConfiguration": [ + { + "type": "SQL", + "target": { + "type": "Database", + "version": "(,12.0)", + "platform": "Windows" + }, + "implementation": { + "query": "SELECT db.[is_auto_create_stats_on] AS is_auto_create_stats_on, db.[is_auto_update_stats_on] AS is_auto_update_stats_on, 0 AS is_query_store_on FROM sys.databases AS db WHERE db.[name]='@DatabaseName'" + } + }, + { + "type": "SQL", + "target": { + "type": "Database", + "version": "[12.0,)", + "platform": "Windows" + }, + "implementation": { + "query": "SELECT db.[is_auto_create_stats_on] AS is_auto_create_stats_on, db.[is_auto_update_stats_on] AS is_auto_update_stats_on, db.[is_query_store_on] AS is_query_store_on FROM sys.databases AS db WHERE db.[name]='@DatabaseName'" + } + } + ] + } +} \ No newline at end of file From 7f31796de5abe0b4927861aa6fb69269b488e4bc Mon Sep 17 00:00:00 2001 From: Alex Protsenko <53046834+msalexprotsenko@users.noreply.github.com> Date: Thu, 18 Jul 2019 16:38:40 +0300 Subject: [PATCH 3/9] Updated readme.md Added some short description for sql-assessment-api folder and described the json file Disabling... --- samples/manage/sql-assessment-api/README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/samples/manage/sql-assessment-api/README.md b/samples/manage/sql-assessment-api/README.md index e69de29bb2..ff39bc3418 100644 --- a/samples/manage/sql-assessment-api/README.md +++ b/samples/manage/sql-assessment-api/README.md @@ -0,0 +1,7 @@ +# SQL Assessment API samples + +Contains samples for customizing SQL Assessment API. Learn more about API and how run it with your own customization here . + +## DisablingBuiltInChecks_sample.json + +Contains two parts. First shows how you can disable a specified check by its name. The second disables all the checks with the "TraceFlag" tag. From acbaa9ba130c452aa80a2b93523858023ceccb77 Mon Sep 17 00:00:00 2001 From: Alex Protsenko <53046834+msalexprotsenko@users.noreply.github.com> Date: Thu, 18 Jul 2019 17:33:47 +0300 Subject: [PATCH 4/9] Added description of MakingCustomChecks_sample.json --- samples/manage/sql-assessment-api/README.md | 60 ++++++++++++++++++++- 1 file changed, 59 insertions(+), 1 deletion(-) diff --git a/samples/manage/sql-assessment-api/README.md b/samples/manage/sql-assessment-api/README.md index ff39bc3418..493a11338b 100644 --- a/samples/manage/sql-assessment-api/README.md +++ b/samples/manage/sql-assessment-api/README.md @@ -4,4 +4,62 @@ Contains samples for customizing SQL Assessment API. Learn more about API and ho ## DisablingBuiltInChecks_sample.json -Contains two parts. First shows how you can disable a specified check by its name. The second disables all the checks with the "TraceFlag" tag. +Contains two parts. First shows how you can disable a specified check by its ID. The second disables all the checks with the "TraceFlag" tag. + +## MakingCustomChecks_sample.json + +Demonstrates how to make a custom rule set containing two checks. The sample contains two schemas: `checks` and `probes`. `Checks` is for check (or rule) definitions. Usually, checks or rules are best practices or a company's internal policies that should be applied to SQL Server. Here's one of the checks from this sample with comments on each property: + +``` +{ + "target": { //Object to describe which SQL Server object this check is applied. + "type": "Database", //This check targets at Database object. + "version": "[12.0,)", //Applies to SQL Server 2014 and higher. + //Another example: "[12.0,13.0)" reads as "any SQL Server with version >= 12.0 and < 13.0. + "platform": "Windows", //Applies to SQL Server on Windows. + "name": { "not": "/^(master|msdb)$/" } //Applies to any database but master and msdb. + }, + "id": "CustomCheck1", //Check ID. + "tags": [ "InternalBestPracticeSet", "Performance" ], //Tags combine checks in different subsets. + "displayName": "Query Store should be on", //Short name for check. + "description": "The SQL Server Query Store feature provides you with insight on query plan choice and performance. It simplifies performance troubleshooting by helping you quickly find performance differences caused by query plan changes. /n Query Store automatically captures a history of queries, plans, and runtime statistics, and retains these for your review. It separates data by time windows so you can see database usage patterns and understand when query plan changes happened on the server.", + //Some more detailed explanation of the best practice or policy. + "message": "Turn Query Store option on to improve query performance troubleshooting.", + //Usually, it's for recommendation what the user should do if the check fires up + "helpLink": "https://docs.microsoft.com/sql/relational-databases/performance/monitoring-performance-by-using-the-query-store", + //Reference material + "probes": [ "DatabaseConfiguration" ], //List of probes that are used to get the required data for this check. + //Probes will be explained below. + "condition": "@is_query_store_on" //Check will pass if condition is true. Otherwise, the check fires up. +} +``` + +`Probes`, in fact, describe how and where get required data to perform a check. For this, you can use T-SQL queries as well as methods from assemblies. The probe below uses a T-SQL query. +``` +"probes":{ + "DatabaseConfiguration": [ + { + "type": "SQL", + "target": { + "type": "Database", + "version": "(,12.0)", + "platform": "Windows" + }, + "implementation": { + "query": "SELECT db.[is_auto_create_stats_on] AS is_auto_create_stats_on, db.[is_auto_update_stats_on] AS is_auto_update_stats_on, 0 AS is_query_store_on FROM sys.databases AS db WHERE db.[name]='@DatabaseName'" + } + }, + { + "type": "SQL", + "target": { + "type": "Database", + "version": "[12.0,)", + "platform": "Windows" + }, + "implementation": { + "query": "SELECT db.[is_auto_create_stats_on] AS is_auto_create_stats_on, db.[is_auto_update_stats_on] AS is_auto_update_stats_on, db.[is_query_store_on] AS is_query_store_on FROM sys.databases AS db WHERE db.[name]='@DatabaseName'" + } + } + ] +} +``` From 1d9a83655bfa950542a34e895a856ef3ae35fcc2 Mon Sep 17 00:00:00 2001 From: Alex Protsenko <53046834+msalexprotsenko@users.noreply.github.com> Date: Thu, 18 Jul 2019 18:40:17 +0300 Subject: [PATCH 5/9] Replaced spaces with tabs --- .../DisablingBuiltInChecks_sample.json | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/samples/manage/sql-assessment-api/DisablingBuiltInChecks_sample.json b/samples/manage/sql-assessment-api/DisablingBuiltInChecks_sample.json index af51fee528..c8352a056f 100644 --- a/samples/manage/sql-assessment-api/DisablingBuiltInChecks_sample.json +++ b/samples/manage/sql-assessment-api/DisablingBuiltInChecks_sample.json @@ -1,12 +1,12 @@ { - "checks":[ - { - "id": "SqlServer.Database.AutoCreateStats", - "enabled": false - }, + "checks":[ + { + "id": "SqlServer.Database.AutoCreateStats", + "enabled": false + }, { - "select": ["TraceFlag"], - "enabled": false - } - ] -} \ No newline at end of file + "select": ["TraceFlag"], + "enabled": false + } + ] +} From 779aff467dfb7a7bc3bc37b973058e7f9b3e48c6 Mon Sep 17 00:00:00 2001 From: Alex Protsenko <53046834+msalexprotsenko@users.noreply.github.com> Date: Thu, 18 Jul 2019 18:49:30 +0300 Subject: [PATCH 6/9] Replaced spaces with tabs --- .../MakingCustomChecks_sample.json | 94 +++++++++---------- 1 file changed, 47 insertions(+), 47 deletions(-) diff --git a/samples/manage/sql-assessment-api/MakingCustomChecks_sample.json b/samples/manage/sql-assessment-api/MakingCustomChecks_sample.json index abd1a0bdb5..a81012d692 100644 --- a/samples/manage/sql-assessment-api/MakingCustomChecks_sample.json +++ b/samples/manage/sql-assessment-api/MakingCustomChecks_sample.json @@ -1,60 +1,60 @@ { "checks":[ { - "target": { - "type": "Database", - "platform": "Windows" - }, - "id": "Custom_SqlServer.Database.AutoUpdateStats", - "tags": [ "InternalBestPracticeSet", "Performance" ], - "displayName": "Auto-Update Statistics should be on", - "description": "The query optimizer needs up-to-date and accurate statistics in order to generate good plans. In most cases, it's best to let SQL Server maintain the statistics. If you turn 'Auto Create Stats' and 'Auto Update Stats' off, then it is up to you to keep the statistics up-to-date somehow. Failure to do so will lead to poor query performance. Most applications should have these options ON.\n \n When the Auto Update Statistics setting is ON, the query optimizer updates statistics when they are used by a query and when they might be out-of-date. Statistics become out-of-date after insert, update, delete, or merge operations change the data distribution in the table or indexed view. The query optimizer determines when statistics might be out-of-date by counting the number of data modifications since the last statistics update and comparing the number of modifications to a threshold. The threshold is based on the number of rows in the table or indexed view. The query optimizer checks for out-of-date statistics before compiling a query and before executing a cached query plan. Before compiling a query, the query optimizer uses the columns, tables, and indexed views in the query predicate to determine which statistics might be out-of-date. Before executing a cached query plan, the Database Engine verifies that the query plan references up-to-date statistics. The AUTO_UPDATE_STATISTICS option applies to statistics created for indexes, single-columns in query predicates, and statistics that are created by using the CREATE STATISTICS statement. This option also applies to filtered statistics.", - "message": "Turn Auto-Update Statistics option on to improve query performance.", - "helpLink": "https://blogs.msdn.microsoft.com/buckwoody/2009/08/18/sql-server-best-practices-auto-create-and-auto-update-statistics-should-be-on-most-of-the-time/", - "probes": [ "DatabaseConfiguration" ], - "condition": "@is_auto_update_stats_on" + "target": { + "type": "Database", + "platform": "Windows" + }, + "id": "Custom_SqlServer.Database.AutoUpdateStats", + "tags": [ "InternalBestPracticeSet", "Performance" ], + "displayName": "Auto-Update Statistics should be on", + "description": "The query optimizer needs up-to-date and accurate statistics in order to generate good plans. In most cases, it's best to let SQL Server maintain the statistics. If you turn 'Auto Create Stats' and 'Auto Update Stats' off, then it is up to you to keep the statistics up-to-date somehow. Failure to do so will lead to poor query performance. Most applications should have these options ON.\n \n When the Auto Update Statistics setting is ON, the query optimizer updates statistics when they are used by a query and when they might be out-of-date. Statistics become out-of-date after insert, update, delete, or merge operations change the data distribution in the table or indexed view. The query optimizer determines when statistics might be out-of-date by counting the number of data modifications since the last statistics update and comparing the number of modifications to a threshold. The threshold is based on the number of rows in the table or indexed view. The query optimizer checks for out-of-date statistics before compiling a query and before executing a cached query plan. Before compiling a query, the query optimizer uses the columns, tables, and indexed views in the query predicate to determine which statistics might be out-of-date. Before executing a cached query plan, the Database Engine verifies that the query plan references up-to-date statistics. The AUTO_UPDATE_STATISTICS option applies to statistics created for indexes, single-columns in query predicates, and statistics that are created by using the CREATE STATISTICS statement. This option also applies to filtered statistics.", + "message": "Turn Auto-Update Statistics option on to improve query performance.", + "helpLink": "https://blogs.msdn.microsoft.com/buckwoody/2009/08/18/sql-server-best-practices-auto-create-and-auto-update-statistics-should-be-on-most-of-the-time/", + "probes": [ "DatabaseConfiguration" ], + "condition": "@is_auto_update_stats_on" }, { - "target": { - "type": "Database", - "version": "[12.0,)", - "platform": "Windows", - "name": { "not": "/^(master|msdb)$/" } - }, - "id": "Custom_SqlServer.Database.QueryStoreOn", - "tags": [ "InternalBestPracticeSet", "Performance" ], - "displayName": "Query Store should be on", - "description": "The SQL Server Query Store feature provides you with insight on query plan choice and performance. It simplifies performance troubleshooting by helping you quickly find performance differences caused by query plan changes. Query Store automatically captures a history of queries, plans, and runtime statistics, and retains these for your review. It separates data by time windows so you can see database usage patterns and understand when query plan changes happened on the server.", - "message": "Turn Query Store option on to improve query performance troubleshooting.", - "helpLink": "https://docs.microsoft.com/sql/relational-databases/performance/monitoring-performance-by-using-the-query-store", - "probes": [ "DatabaseConfiguration" ], - "condition": "@is_query_store_on" + "target": { + "type": "Database", + "version": "[12.0,)", + "platform": "Windows", + "name": { "not": "/^(master|msdb)$/" } + }, + "id": "Custom_SqlServer.Database.QueryStoreOn", + "tags": [ "InternalBestPracticeSet", "Performance" ], + "displayName": "Query Store should be on", + "description": "The SQL Server Query Store feature provides you with insight on query plan choice and performance. It simplifies performance troubleshooting by helping you quickly find performance differences caused by query plan changes. Query Store automatically captures a history of queries, plans, and runtime statistics, and retains these for your review. It separates data by time windows so you can see database usage patterns and understand when query plan changes happened on the server.", + "message": "Turn Query Store option on to improve query performance troubleshooting.", + "helpLink": "https://docs.microsoft.com/sql/relational-databases/performance/monitoring-performance-by-using-the-query-store", + "probes": [ "DatabaseConfiguration" ], + "condition": "@is_query_store_on" } ], "probes":{ "DatabaseConfiguration": [ - { - "type": "SQL", - "target": { - "type": "Database", - "version": "(,12.0)", - "platform": "Windows" - }, - "implementation": { - "query": "SELECT db.[is_auto_create_stats_on] AS is_auto_create_stats_on, db.[is_auto_update_stats_on] AS is_auto_update_stats_on, 0 AS is_query_store_on FROM sys.databases AS db WHERE db.[name]='@DatabaseName'" - } - }, - { - "type": "SQL", - "target": { - "type": "Database", - "version": "[12.0,)", - "platform": "Windows" + { + "type": "SQL", + "target": { + "type": "Database", + "version": "(,12.0)", + "platform": "Windows" + }, + "implementation": { + "query": "SELECT db.[is_auto_create_stats_on] AS is_auto_create_stats_on, db.[is_auto_update_stats_on] AS is_auto_update_stats_on, 0 AS is_query_store_on FROM sys.databases AS db WHERE db.[name]='@DatabaseName'" + } }, - "implementation": { - "query": "SELECT db.[is_auto_create_stats_on] AS is_auto_create_stats_on, db.[is_auto_update_stats_on] AS is_auto_update_stats_on, db.[is_query_store_on] AS is_query_store_on FROM sys.databases AS db WHERE db.[name]='@DatabaseName'" + { + "type": "SQL", + "target": { + "type": "Database", + "version": "[12.0,)", + "platform": "Windows" + }, + "implementation": { + "query": "SELECT db.[is_auto_create_stats_on] AS is_auto_create_stats_on, db.[is_auto_update_stats_on] AS is_auto_update_stats_on, db.[is_query_store_on] AS is_query_store_on FROM sys.databases AS db WHERE db.[name]='@DatabaseName'" + } } - } ] } -} \ No newline at end of file +} From 1ef94bdd2681001644825ca20bd8f3620706cf42 Mon Sep 17 00:00:00 2001 From: Alex Protsenko <53046834+msalexprotsenko@users.noreply.github.com> Date: Thu, 18 Jul 2019 19:22:37 +0300 Subject: [PATCH 7/9] Updated description of MakingCustomChecks_sample.json Explained json format for probes --- samples/manage/sql-assessment-api/README.md | 43 +++++++++++---------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/samples/manage/sql-assessment-api/README.md b/samples/manage/sql-assessment-api/README.md index 493a11338b..c88c4cd40c 100644 --- a/samples/manage/sql-assessment-api/README.md +++ b/samples/manage/sql-assessment-api/README.md @@ -37,28 +37,31 @@ Demonstrates how to make a custom rule set containing two checks. The sample con `Probes`, in fact, describe how and where get required data to perform a check. For this, you can use T-SQL queries as well as methods from assemblies. The probe below uses a T-SQL query. ``` "probes":{ - "DatabaseConfiguration": [ + "DatabaseConfiguration": [ //Probe name that is used to reference the probe from a check. + //Probe can have a few implementations that will be used for different targets. + //This probe has two implementations for different version of SQL Server. { - "type": "SQL", - "target": { - "type": "Database", - "version": "(,12.0)", - "platform": "Windows" + "type": "SQL", //Probe uses a T-SQL query to get the required data + "target": { + "type": "Database", //Targets at database + "version": "(,12.0)", //This implementation is for SQL Server before 2014 + "platform": "Windows" //Targets at SQL on Windows + }, + "implementation": { //Implementation object with a T-SQL query. + //sys.databases of SQL Server before 2014 doesn't have the field is_query_store_on so we replace it with 0. + "query": "SELECT db.[is_auto_create_stats_on] AS is_auto_create_stats_on, db.[is_auto_update_stats_on] AS is_auto_update_stats_on, 0 AS is_query_store_on FROM sys.databases AS db WHERE db.[name]='@DatabaseName'" + } }, - "implementation": { - "query": "SELECT db.[is_auto_create_stats_on] AS is_auto_create_stats_on, db.[is_auto_update_stats_on] AS is_auto_update_stats_on, 0 AS is_query_store_on FROM sys.databases AS db WHERE db.[name]='@DatabaseName'" - } - }, - { - "type": "SQL", - "target": { - "type": "Database", - "version": "[12.0,)", - "platform": "Windows" - }, - "implementation": { - "query": "SELECT db.[is_auto_create_stats_on] AS is_auto_create_stats_on, db.[is_auto_update_stats_on] AS is_auto_update_stats_on, db.[is_query_store_on] AS is_query_store_on FROM sys.databases AS db WHERE db.[name]='@DatabaseName'" - } + { //Second implementation + "type": "SQL", + "target": { + "type": "Database", + "version": "[12.0,)", //This implementation is for SQL Server 2014 and up. + "platform": "Windows" + }, + "implementation": { //Query of the second implementation. + "query": "SELECT db.[is_auto_create_stats_on] AS is_auto_create_stats_on, db.[is_auto_update_stats_on] AS is_auto_update_stats_on, db.[is_query_store_on] AS is_query_store_on FROM sys.databases AS db WHERE db.[name]='@DatabaseName'" + } } ] } From 1765353c94ae697044248af59e639956f3fba43a Mon Sep 17 00:00:00 2001 From: Alex Protsenko <53046834+msalexprotsenko@users.noreply.github.com> Date: Thu, 18 Jul 2019 19:55:10 +0300 Subject: [PATCH 8/9] replaced schemas with sections --- samples/manage/sql-assessment-api/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/manage/sql-assessment-api/README.md b/samples/manage/sql-assessment-api/README.md index c88c4cd40c..398d6e87df 100644 --- a/samples/manage/sql-assessment-api/README.md +++ b/samples/manage/sql-assessment-api/README.md @@ -8,7 +8,7 @@ Contains two parts. First shows how you can disable a specified check by its ID. ## MakingCustomChecks_sample.json -Demonstrates how to make a custom rule set containing two checks. The sample contains two schemas: `checks` and `probes`. `Checks` is for check (or rule) definitions. Usually, checks or rules are best practices or a company's internal policies that should be applied to SQL Server. Here's one of the checks from this sample with comments on each property: +Demonstrates how to make a custom rule set containing two checks. The sample contains two sections: `checks` and `probes`. `Checks` is for check (or rule) definitions. Usually, checks or rules are best practices or a company's internal policies that should be applied to SQL Server. Here's one of the checks from this sample with comments on each property: ``` { From 1b839b43c2457fee8b9508520ca6cddeed30ec9e Mon Sep 17 00:00:00 2001 From: msalexprotsenko Date: Mon, 12 Aug 2019 21:01:48 +0300 Subject: [PATCH 9/9] Added a json to fix QueryStore check + described it in readme --- .../sql-assessment-api/QueryStoreCheck_fix.json | 13 +++++++++++++ samples/manage/sql-assessment-api/README.md | 9 +++++++++ 2 files changed, 22 insertions(+) create mode 100644 samples/manage/sql-assessment-api/QueryStoreCheck_fix.json diff --git a/samples/manage/sql-assessment-api/QueryStoreCheck_fix.json b/samples/manage/sql-assessment-api/QueryStoreCheck_fix.json new file mode 100644 index 0000000000..28d980100b --- /dev/null +++ b/samples/manage/sql-assessment-api/QueryStoreCheck_fix.json @@ -0,0 +1,13 @@ +{ + "checks":[ + { + "id": "SqlServer.Database.QueryStoreOn", + "target":{ + "type": "Database", + "version": "[13.0,)", + "platform": "Windows", + "name": { "not": "/^(master|tempdb)$/" } + } + } + ] +} diff --git a/samples/manage/sql-assessment-api/README.md b/samples/manage/sql-assessment-api/README.md index 1285f808f1..f334c5ab87 100644 --- a/samples/manage/sql-assessment-api/README.md +++ b/samples/manage/sql-assessment-api/README.md @@ -71,3 +71,12 @@ Demonstrates how to make a custom rule set containing two checks. The sample con } ``` +## QueryStoreCheck_fix.json + +Overrides the default ruleset to fix the rule "Query Store should be on." Query Store appeared in SQL Server 2016 but the rule checks for it starting with SQL Server 2014. + +Here's an example of applying the fix to running the InvokeSqlAssessment cmdlet. + +```PowerShell +Get-SqlInstance -ServerInstance 'localhost' | Get-SqlDatabase | Invoke-SqlAssessment -configuration "C:\SQLAssessment\QueryStore_fix.json" +```