You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following query produces two tabular results. User agent tools can then display those results with the appropriate name associated with each (`Count of events in Florida` and `Count of events in Guam`, respectively).
@@ -32,9 +34,25 @@ StormEvents | where State == "FLORIDA" | count | as ['Count of events in Florida
32
34
StormEvents | where State == "GUAM" | count | as ['Count of events in Guam']
33
35
```
34
36
37
+
**Output**
38
+
39
+
### [Count of events in Florida](#tab/florida)
40
+
41
+
| Count |
42
+
| -- |
43
+
| 1042 |
44
+
45
+
### [Count of events in Guam](#tab/guam)
46
+
47
+
| Count |
48
+
| -- |
49
+
| 4 |
50
+
51
+
---
52
+
35
53
### Share a calculation
36
54
37
-
Batching is useful for scenarios where a common calculation is shared by multiple subqueries, such as for dashboards. If the common calculation is complex, use the [materialize() function](materialize-function.md) and construct the query so that it will be executed only once:
55
+
Batching is useful for scenarios where a common calculation is shared by multiple subqueries, such as for dashboards. If the common calculation is complex, use the [materialize() function](materialize-function.md) and construct the query so that it will be executed only once.
38
56
39
57
:::moniker range="azure-data-explorer"
40
58
> [!div class="nextstepaction"]
@@ -46,3 +64,26 @@ let m = materialize(StormEvents | summarize n=count() by State);
A **pattern** is a construct that maps string tuples to tabular expressions. Each pattern must *declare* a pattern name and optionally *define* a pattern mapping. Patterns that define a mapping return a tabular expression when invoked. Any two statements must be separated by a semicolon.
14
+
A **pattern** is a construct that maps string tuples to tabular expressions.
15
15
16
-
*Empty patterns* are patterns that are declared but don't define a mapping. When invoked, they return error *SEM0036* along with the details of the missing pattern definitions in the HTTP header. Middle-tier applications that provide a Kusto Query Language (KQL) experience can use the returned details as part of their process to enrich KQL query results.
16
+
Each pattern must *declare* a pattern name and optionally *define* a pattern mapping. Patterns that define a mapping return a tabular expression when invoked. Separate any two statements by a semicolon.
17
+
18
+
Empty patterns are patterns that are declared but don't define a mapping. When invoked, they return error *SEM0036* along with the details of the missing pattern definitions in the HTTP header.
19
+
20
+
Middle-tier applications that provide a Kusto Query Language (KQL) experience can use the returned details as part of their process to enrich KQL query results.
17
21
For more information, see [Working with middle-tier applications](#work-with-middle-tier-applications).
18
22
19
23
## Syntax
@@ -56,11 +60,13 @@ For more information, see [Working with middle-tier applications](#work-with-mid
56
60
57
61
## Examples
58
62
59
-
In each of the following examples, a pattern is declared, defined, and then invoked.
The following example defines a pattern that maps states to an expression that returns its capital/major city.
67
+
### Define a simple pattern
68
+
69
+
This example defines a pattern that maps states to an expression that returns its capital/major city.
64
70
65
71
:::moniker range="azure-data-explorer"
66
72
> [!div class="nextstepaction"]
@@ -77,21 +83,23 @@ declare pattern country = (name:string)[state:string]
77
83
country("Canada").Alberta
78
84
```
79
85
80
-
**Output**
86
+
**Output**
81
87
82
88
|Capital|
83
89
|-------|
84
90
|Edmonton|
85
91
92
+
### Define a scoped pattern
93
+
94
+
This example defines a pattern to scope data and metrics of application data. The pattern is invoked to return a union of the data.
95
+
86
96
:::moniker range="azure-data-explorer"
87
97
> [!div class="nextstepaction"]
88
98
> <ahref="https://dataexplorer.azure.com/clusters/help/databases/Samples?query=H4sIAAAAAAAAA62RsQrCMBCGd6Hv8FOHtlDFtrgoHQQXB5+gdAhpLJWahCRCofruJpjBCi7SwJHckfv/fJeG0Z4oBkmMYYrjICVKxETKvqPEdIKfmp02quNtUmkqJPNZDQSLMVjArjgiWZSsq+hIDIlqVyoxQhHeMgy4KHFDBiOwhTZM2vMDUokro8Ybhm5bZmEKJ/EWGPDcf+mfmfWm2lr8re8lbM22N3HyaZLPAZFPILINVlOSYg6S4heJizu33+aueyT3mtTnbo6+8QXib67/+wEAAA=="target="_blank">Run the query</a>
89
99
::: moniker-end
90
100
91
-
The following example defines a pattern that defines some scoped application data.
('a1').['Data'] = { range x from 1 to 5 step 1 | project App = "App #1", Data = x };
97
105
('a1').['Metrics'] = { range x from 1 to 5 step 1 | project App = "App #1", Metrics = rand() };
@@ -147,23 +155,34 @@ union app("ApplicationX").["*"]
147
155
| count
148
156
```
149
157
150
-
**Returns semantic error**
158
+
**Output semantic error**
159
+
151
160
> One or more pattern references were not declared. Detected pattern references: ["app('ApplicationX').['*']"]
152
161
153
162
## Work with middle-tier applications
154
163
155
164
A middle-tier application provides its users with the ability to use KQL and wants to enhance the experience by enriching the query results with augmented data from its internal service.
156
165
157
-
To this end, the application provides users with a pattern statement that returns tabular data that their users can use in their queries. The pattern's arguments are the keys the application will use to retrieve the enrichment data. When the user runs the query, the application does not parse the query itself but instead plans to leverage the error returned by an empty pattern to retrieve the keys it requires. So it prepends the query with the empty pattern declaration, sends it to the cluster for processing, and then parses the returned HTTP header to retrieve the values of missing pattern arguments. The application uses these values to look up the enrichment data and builds a new declaration that defines the appropriate enrichment data mapping. Finally, the application prepends the new definition to the user's query, resends it for processing, and returns the result it receives to the user.
166
+
To this end, the application provides users with a pattern statement that returns tabular data that their users can use in their queries. The pattern's arguments are the keys the application will use to retrieve the enrichment data.
167
+
168
+
When the user runs the query, the application doesn't parse the query itself but instead uses the error returned by an empty pattern to retrieve the keys it requires. So it prepends the query with the empty pattern declaration, sends it to the cluster for processing, and then parses the returned HTTP header to retrieve the values of missing pattern arguments. The application uses these values to look up the enrichment data and builds a new declaration that defines the appropriate enrichment data mapping.
169
+
170
+
Finally, the application prepends the new definition to the query, resends it for processing, and returns the result it receives to the user.
158
171
159
172
### Example
160
173
161
-
In the following example, a middle-tier application provides the ability to enrich queries with longitude/latitude locations. The application uses an internal service to map IP addresses to longitude/latitude locations, and provides a pattern called `map_ip_to_longlat` for this purpose. Let's suppose the application gets the following query from the user:
174
+
In the examples, a pattern is declared, defined, and then invoked.
175
+
176
+
#### Declare an empty pattern
177
+
178
+
In this example, a middle-tier application enriches queries with longitude/latitude locations. The application uses an internal service to map IP addresses to longitude/latitude locations, and provides a pattern called `map_ip_to_longlat`. When the query is run, it returns an error with missing pattern definitions:
162
179
163
180
```kusto
164
181
map_ip_to_longlat("10.10.10.10")
165
182
```
166
183
184
+
#### Declare and define a pattern
185
+
167
186
The application does not parse this query and hence does not know which IP address (*10.10.10.10*) was passed to the pattern. So it prepends the user query with an empty `map_ip_to_longlat` pattern declaration and sends it for processing:
The application receives the following error in response.
175
194
> One or more pattern references were not declared. Detected pattern references: ["map_ip_to_longlat('10.10.10.10')"]
176
195
177
-
The application inspects the error, determines that the error indicates a missing pattern reference, and retrieves the missing IP address (*10.10.10.10*). It uses the IP address to look up the enrichment data in its internal service and builds a new pattern defining the mapping of the IP address to the corresponding longitude and latitude data. The new pattern is prepended to the user's query and run again. This time the query succeeds because the enrichment data is now declared in the query, and the result is sent to the user.
196
+
#### Invoke a pattern
197
+
198
+
The application inspects the error, determines that the error indicates a missing pattern reference, and retrieves the missing IP address (*10.10.10.10*). It uses the IP address to look up the enrichment data in its internal service and builds a new pattern defining the mapping of the IP address to the corresponding longitude and latitude data. The new pattern is prepended to the user's query and run again.
199
+
200
+
This time the query succeeds because the enrichment data is now declared in the query, and the result is sent to the user.
> <ahref="https://dataexplorer.azure.com/clusters/help/databases/Samples?query=H4sIAAAAAAAAA4WNuw7CMBAE+0j5hytBpKAFBBUpXEOPrHgFjvzifAEi8fEkQUBJO9qZNWicZtC1A/enpFl7CDjPvH6o0HYMs3YxnGlLq+V8UxYHiezrG4JkKosn3S8Y9GlqkfeW0QgtvkAF80Y7+hVHL3FsR14nm6OBMhVN1WOfUJFE0e7TGL7/9l+H314eyAAAAA=="target="_blank">Run the query</a>
The following example uses a [let statement](let-statement.md) appearing before `restrict` statement.
45
+
The example uses a [let statement](let-statement.md) appearing before `restrict` statement.
44
46
45
47
```kusto
46
48
// Limit access to 'Test' let statement only
@@ -50,7 +52,7 @@ restrict access to (Test);
50
52
51
53
### Tables or functions
52
54
53
-
The following example uses references to [tables](../management/tables.md) or [functions](../management/functions.md) that are defined in the database metadata.
55
+
The example uses references to [tables](../management/tables.md) or [functions](../management/functions.md) that are defined in the database metadata.
54
56
55
57
```kusto
56
58
// Assuming the database that the query uses has table Table1 and Func1 defined in the metadata,
@@ -61,7 +63,7 @@ restrict access to (database().Table1, database().Func1, database('DB2').Table2)
61
63
62
64
### Patterns
63
65
64
-
The following example uses wildcard patterns that can match multiples of [let statements](let-statement.md) or tables/functions.
66
+
The example uses wildcard patterns that can match multiples of [let statements](let-statement.md) or tables/functions.
65
67
66
68
```kusto
67
69
let Test1 = () { print x=1 };
@@ -82,7 +84,7 @@ restrict access to (database('DB2').*);
82
84
83
85
### Prevent user from querying other user data
84
86
85
-
The following example shows how a middle-tier application can prepend a user's query
87
+
The example shows how a middle-tier application can prepend a user's query
86
88
with a logical model that prevents the user from querying any other user's data.
The following query counts the number of records in the `StormEvents` table that have a value of "FLORIDA" in the `State` column.
48
+
This query counts the number of records in the `StormEvents` table that have a value of "FLORIDA" in the `State` column.
47
49
48
50
:::moniker range="azure-data-explorer"
49
51
> [!div class="nextstepaction"]
@@ -64,7 +66,7 @@ StormEvents
64
66
65
67
### Combine data from two tables
66
68
67
-
In the following example, the [join](join-operator.md) operator is used to combine records from two tabular data sources: the `StormEvents` table and the `PopulationData` table.
69
+
In this example, the [join](join-operator.md) operator is used to combine records from two tabular data sources: the `StormEvents` table and the `PopulationData` table.
Copy file name to clipboardExpand all lines: data-explorer/monitor-queued-ingestion.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -269,5 +269,5 @@ Click away from the settings to get the full chart that compares the number of e
269
269
## Related content
270
270
271
271
*[Monitor Azure Data Explorer performance, health, and usage with metrics](using-metrics.md)
272
-
*[Monitor Azure Data Explorer ingestion, commands, queries, and tables using diagnostic logs](using-diagnostic-logs.md)
272
+
*[Monitor Azure Data Explorer ingestion, commands, queries, and tables using diagnostic logs](monitor-data-explorer.md#monitor-azure-data-explorer-ingestion-commands-queries-and-tables-using-diagnostic-logs)
0 commit comments