Skip to content

Commit acbaa9b

Browse files
Added description of MakingCustomChecks_sample.json
1 parent 7f31796 commit acbaa9b

1 file changed

Lines changed: 59 additions & 1 deletion

File tree

samples/manage/sql-assessment-api/README.md

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,62 @@ Contains samples for customizing SQL Assessment API. Learn more about API and ho
44

55
## DisablingBuiltInChecks_sample.json
66

7-
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.
7+
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.
8+
9+
## MakingCustomChecks_sample.json
10+
11+
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:
12+
13+
```
14+
{
15+
"target": { //Object to describe which SQL Server object this check is applied.
16+
"type": "Database", //This check targets at Database object.
17+
"version": "[12.0,)", //Applies to SQL Server 2014 and higher.
18+
//Another example: "[12.0,13.0)" reads as "any SQL Server with version >= 12.0 and < 13.0.
19+
"platform": "Windows", //Applies to SQL Server on Windows.
20+
"name": { "not": "/^(master|msdb)$/" } //Applies to any database but master and msdb.
21+
},
22+
"id": "CustomCheck1", //Check ID.
23+
"tags": [ "InternalBestPracticeSet", "Performance" ], //Tags combine checks in different subsets.
24+
"displayName": "Query Store should be on", //Short name for check.
25+
"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.",
26+
//Some more detailed explanation of the best practice or policy.
27+
"message": "Turn Query Store option on to improve query performance troubleshooting.",
28+
//Usually, it's for recommendation what the user should do if the check fires up
29+
"helpLink": "https://docs.microsoft.com/sql/relational-databases/performance/monitoring-performance-by-using-the-query-store",
30+
//Reference material
31+
"probes": [ "DatabaseConfiguration" ], //List of probes that are used to get the required data for this check.
32+
//Probes will be explained below.
33+
"condition": "@is_query_store_on" //Check will pass if condition is true. Otherwise, the check fires up.
34+
}
35+
```
36+
37+
`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.
38+
```
39+
"probes":{
40+
"DatabaseConfiguration": [
41+
{
42+
"type": "SQL",
43+
"target": {
44+
"type": "Database",
45+
"version": "(,12.0)",
46+
"platform": "Windows"
47+
},
48+
"implementation": {
49+
"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'"
50+
}
51+
},
52+
{
53+
"type": "SQL",
54+
"target": {
55+
"type": "Database",
56+
"version": "[12.0,)",
57+
"platform": "Windows"
58+
},
59+
"implementation": {
60+
"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'"
61+
}
62+
}
63+
]
64+
}
65+
```

0 commit comments

Comments
 (0)