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
Copy file name to clipboardExpand all lines: articles/log-analytics/log-analytics-cross-workspace-search.md
+28-25Lines changed: 28 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,7 +12,7 @@ ms.workload: na
12
12
ms.tgt_pltfrm: na
13
13
ms.devlang: na
14
14
ms.topic: conceptual
15
-
ms.date: 04/17/2018
15
+
ms.date: 11/15/2018
16
16
ms.author: magoedte
17
17
ms.component:
18
18
---
@@ -98,32 +98,35 @@ union Update, workspace("contosoretail-it").Update, workspace("b459b4u5-912x-46d
98
98
```
99
99
100
100
## Using cross-resource query for multiple resources
101
-
When using cross-resource queries to correlate data from multiple Log Analytics and Application Insights resources, the query can become complex and difficult to maintain. You should leverage functions separate the query logic from the scoping of the query resources, which simplifies the query structure.
101
+
When using cross-resource queries to correlate data from multiple Log Analytics and Application Insights resources, the query can become complex and difficult to maintain. You should leverage [functions in Log Analytics](query-language/functions.md) to separate the query logic from the scoping of the query resources, which simplifies the query structure. The following example demonstrates how you can monitor multiple Application Insights resources and visualize the count of failed requests by application name.
102
+
103
+
Create a query like the following that references the scope of Application Insights resources. The `withsource= SourceApp` command adds a column that designates the application name that sent the log.
104
+
105
+
```Kusto
106
+
// crossResource function that scopes my Application Insights resources
107
+
union withsource= SourceApp
108
+
app('Contoso-app1').requests,
109
+
app(''Contoso-app2').requests,
110
+
app(''Contoso-app3').requests,
111
+
app(''Contoso-app4').requests,
112
+
app(''Contoso-app5').requests
113
+
```
102
114
103
-
The following example demonstrates how you can monitor multiple Application Insights resources and visualize the count of failed requests by application name. The following steps are performed in Azure Log Analytics portal. Navigate to your workspace in Azure portal and click Logs on the left navigation pane.
115
+
[Save the query as function](query-language/functions.md#create-a-function) with the alias _applicationsScoping_.
104
116
105
-
1. Author a function – this query reference the scope of Application Insights resources. You can edit the applications in the function at any time.<br>Note: the ‘withsource= SourceApp’ command adds a column that designates the application name that sent the log. This will help you to identify to which application the failures are attributed.
106
-
```
107
-
// crossResource function that scopes my Application Insights resources
108
-
union withsource= SourceApp
109
-
app('Contoso-app1').requests,
110
-
app(''Contoso-app2').requests,
111
-
app(''Contoso-app3').requests,
112
-
app(''Contoso-app4').requests,
113
-
app(''Contoso-app5').requests
114
-
```
115
-
2. Save the query as function by clicking the **save** icon. The ‘Function alias’ is the entity to be used for calling the function from within a query.<br>Note: managing the list of applications in the function is available at any time by navigating to Query explorer in Logs portal.<br>Name: Production applications<br>Save as: Function<br>Function alias: applicationsScoping<br>Category: Failures analytics
116
-
1. Using the applicationsScoping function in cross-resource query – the Function alias (applicationsScoping) returns the union of requests table from all the defined applications in Production applications function. The query then filters for failed requests and visualize the trends by application
117
-
```
118
-
applicationsScoping
119
-
| where timestamp > ago(12h)
120
-
| where success == 'False'
121
-
| parse SourceApp with * '(' applicationName ')' *
122
-
| summarize count() by applicationName, bin(timestamp, 1h)
123
-
| sort by count_ desc
124
-
| render timechart
125
-
```
126
-
The ‘parse’ operator is optional in this case – it extracts the application name from ‘SourceApp’ property.
117
+
You can now [use this function](query-language/functions.md#use-a-function) in a cross-resource query like the following. The Function alias _applicationsScoping_ returns the union of requests table from all the defined applications. The query then filters for failed requests and visualizes the trends by application
118
+
119
+
```Kusto
120
+
applicationsScoping
121
+
| where timestamp > ago(12h)
122
+
| where success == 'False'
123
+
| parse SourceApp with * '(' applicationName ')' *
124
+
| summarize count() by applicationName, bin(timestamp, 1h)
125
+
| sort by count_ desc
126
+
| render timechart
127
+
```
128
+
129
+
The _parse_ operator is optional in this example. It extracts the application name from _SourceApp_ property.
> Saving a function is possible in Log Analytics queries, but currently not for Application Insights queries.
30
-
31
28
32
29
To use a Log Analytics query with another query you can save it as a function. This allows you to simplify complex queries by breaking them into parts and allows you to reuse common code with multiple queries.
33
30
34
-
> [!NOTE]
35
-
> A function in Log Analytics cannot contain another function.
36
-
37
31
## Create a function
38
32
39
33
Create a function in the Azure portal by clicking **Save** and then providing the information in the following table.
@@ -45,6 +39,14 @@ Create a function in the Azure portal by clicking **Save** and then providing th
45
39
| Function Alias | Short name to use the function in other queries. May not contain spaces and must be unique. |
46
40
| Category | A category to organize saved queries and functions in **Query explorer**. |
47
41
42
+
> [!NOTE]
43
+
> A function in Log Analytics cannot contain another function.
44
+
45
+
> [!NOTE]
46
+
> Saving a function is possible in Log Analytics queries, but currently not for Application Insights queries.
47
+
48
+
49
+
48
50
## Use a function
49
51
Use a function by including its alias in another query. It can be used like any other table.
0 commit comments