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/azure-monitor/logs/cross-workspace-query.md
+15-45Lines changed: 15 additions & 45 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ description: This article describes how you can query against resources from mul
4
4
ms.topic: conceptual
5
5
author: bwren
6
6
ms.author: bwren
7
-
ms.date: 04/28/2022
7
+
ms.date: 04/01/2023
8
8
9
9
---
10
10
@@ -32,66 +32,36 @@ There are two methods to query data that's stored in multiple workspaces and app
32
32
To reference another workspace in your query, use the [workspace](../logs/workspace-expression.md) identifier. For an app from Application Insights, use the [app](./app-expression.md) identifier.
33
33
34
34
### Identify workspace resources
35
-
The following examples demonstrate queries across Log Analytics workspaces to return summarized counts of logs from the Update table on a workspace named `contosoretail-it`.
36
35
37
36
You can identify a workspace in one of several ways:
38
37
39
-
***Resource name**: This human-readable name of the workspace is sometimes referred to as the *component name*.
40
-
41
-
>[!IMPORTANT]
42
-
>Because app and workspace names aren't unique, this identifier might be ambiguous. We recommend that the reference uses a qualified name, workspace ID, or Azure Resource ID.
43
-
44
-
`workspace("contosoretail-it").Update | count`
45
-
46
-
***Qualified name**: This "full name" of the workspace is composed of the subscription name, resource group, and component name in the format *subscriptionName/resourceGroup/componentName*.
***Azure Resource ID**: This ID is the Azure-defined unique identity of the workspace. You use the Resource ID when the resource name is ambiguous. For workspaces, the format is */subscriptions/subscriptionId/resourcegroups/resourceGroup/providers/microsoft.OperationalInsights/workspaces/componentName*.
The following examples return a summarized count of requests made against an app named *fabrikamapp* in Application Insights.
67
52
68
53
You can identify an application in Application Insights with the `app(Identifier)` expression. The `Identifier` argument specifies the app by using one of the following names or IDs:
69
54
70
-
* **Resource name**: This human readable name of the app is sometimes referred to as the *component name*.
71
-
72
-
`app("fabrikamapp")`
73
-
74
-
>[!NOTE]
75
-
>Identifying an application by name assumes uniqueness across all accessible subscriptions. If you have multiple applications with the specified name, the query fails because of the ambiguity. In this case, you must use one of the other identifiers.
76
-
77
-
* **Qualified name**: This "full name" of the app is composed of the subscription name, resource group, and component name in the format *subscriptionName/resourceGroup/componentName*.
* **Azure Resource ID**: This ID is the Azure-defined unique identity of the app. You use the resource ID when the resource name is ambiguous. The format is */subscriptions/subscriptionId/resourcegroups/resourceGroup/providers/microsoft.OperationalInsights/components/componentName*.
You can now [use this function](./functions.md#use-a-function) in a cross-resource query like the following example. The function alias `applicationsScoping` returns the union of the requests table from all the defined applications. The query then filters for failed requests and visualizes the trends by application. The `parse` operator is optional in this example. It extracts the application name from the `SourceApp` property.
@@ -127,16 +99,14 @@ You can now [use this function](./functions.md#use-a-function) in a cross-resour
127
99
applicationsScoping
128
100
| where timestamp > ago(12h)
129
101
| where success == 'False'
130
-
| parse SourceApp with * '(' applicationName ')' *
131
-
| summarize count() by applicationName, bin(timestamp, 1h)
102
+
| parse SourceApp with * '(' applicationId ')' *
103
+
| summarize count() by applicationId, bin(timestamp, 1h)
132
104
| render timechart
133
105
```
134
106
135
107
>[!NOTE]
136
108
> This method can't be used with log alerts because the access validation of the alert rule resources, including workspaces and applications, is performed at alert creation time. Adding new resources to the function after the alert creation isn't supported. If you prefer to use a function for resource scoping in log alerts, you must edit the alert rule in the portal or with an Azure Resource Manager template to update the scoped resources. Alternatively, you can include the list of resources in the log alert query.
137
109
138
-

139
-
140
110
## Next steps
141
111
142
112
See [Analyze log data in Azure Monitor](./log-query-overview.md) for an overview of log queries and how Azure Monitor log data is structured.
0 commit comments