Skip to content

Commit 7c95098

Browse files
committed
updated cross resource article
1 parent 06f31f6 commit 7c95098

File tree

2 files changed

+36
-31
lines changed

2 files changed

+36
-31
lines changed

articles/log-analytics/log-analytics-cross-workspace-search.md

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ ms.workload: na
1212
ms.tgt_pltfrm: na
1313
ms.devlang: na
1414
ms.topic: conceptual
15-
ms.date: 04/17/2018
15+
ms.date: 11/15/2018
1616
ms.author: magoedte
1717
ms.component:
1818
---
@@ -98,32 +98,35 @@ union Update, workspace("contosoretail-it").Update, workspace("b459b4u5-912x-46d
9898
```
9999
100100
## 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+
```
102114

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_.
104116

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.
127130

128131

129132

articles/log-analytics/query-language/functions.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,9 @@ ms.component: na
2525
2626
[!INCLUDE [log-analytics-demo-environment](../../../includes/log-analytics-demo-environment.md)]
2727

28-
> [!NOTE]
29-
> Saving a function is possible in Log Analytics queries, but currently not for Application Insights queries.
30-
3128

3229
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.
3330

34-
> [!NOTE]
35-
> A function in Log Analytics cannot contain another function.
36-
3731
## Create a function
3832

3933
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
4539
| Function Alias | Short name to use the function in other queries. May not contain spaces and must be unique. |
4640
| Category | A category to organize saved queries and functions in **Query explorer**. |
4741

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+
4850
## Use a function
4951
Use a function by including its alias in another query. It can be used like any other table.
5052

0 commit comments

Comments
 (0)