|
| 1 | +--- |
| 2 | +title: Perform queries across Azure Log Analytics workspaces | Microsoft Docs |
| 3 | +description: This article describes how you can query across multiple workspaces in your subscription with examples to follow. |
| 4 | +services: log-analytics |
| 5 | +documentationcenter: '' |
| 6 | +author: MGoedtel |
| 7 | +manager: carmonm |
| 8 | +editor: '' |
| 9 | +ms.assetid: |
| 10 | +ms.service: log-analytics |
| 11 | +ms.workload: na |
| 12 | +ms.tgt_pltfrm: na |
| 13 | +ms.devlang: na |
| 14 | +ms.topic: article |
| 15 | +ms.date: 10/04/2017 |
| 16 | +ms.author: magoedte |
| 17 | + |
| 18 | +--- |
| 19 | + |
| 20 | +# Perform queries across multiple Log Analytics workspaces |
| 21 | + |
| 22 | +Previously with Azure Log Analytics, you could only analyze data from within the current workspace and this limited your ability to query across multiple workspaces defined in your subscription. |
| 23 | + |
| 24 | +Now you can query across multiple workspaces, providing a system-wide view of your data. You can only perform this type of query in the [Advanced portal](log-analytics-log-search-portals.md#advanced-analytics-portal), not in the Azure portal. |
| 25 | + |
| 26 | +## Querying across Log Analytics workspaces |
| 27 | +To reference another workspace in your query, use the *workspace* identifier. For example, the following query returns summarized counts of updates needed by their classification from the Update table from both the current workspace, and another workspace named *contosoretail-it*. |
| 28 | + |
| 29 | + |
| 30 | +## Identifying resources |
| 31 | +Identifying a workspace can be performed one of several ways: |
| 32 | + |
| 33 | +* Resource name - is a human-readable name of the workspace, sometimes referred to as *component name*. |
| 34 | + |
| 35 | + `workspace("contosoretail").Update | count` |
| 36 | + |
| 37 | + >[!NOTE] |
| 38 | + >Identifying a workspace by its name assumes it is unique 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. |
| 39 | +
|
| 40 | +* Qualified Name - is the “full name” of the workspace, composed of the subscription name, resource group and component name in this format: *subscriptionName/resourceGroup/componentName*. |
| 41 | + |
| 42 | + `workspace('contoso/contosoretail/development').requests | count ` |
| 43 | + |
| 44 | + >[!NOTE] |
| 45 | + >Because Azure subscription names are not unique, this identifier might be ambiguous. |
| 46 | + > |
| 47 | +
|
| 48 | +* workspace ID - A workspace ID is the unique, immutable, identifier assigned to each workspace represented as a globally unique identifier (GUID). |
| 49 | + |
| 50 | + `workspace("b438b4f6-912a-46d5-9cb1-b44069212ab4").Update | count` |
| 51 | + |
| 52 | +* Azure Resource ID – the Azure-defined unique identity of the workspace. You use this when the resource name is ambiguous. For workspaces, the format is: */subscriptions/subscriptionId/resourcegroups/resourceGroup/providers/microsoft.OperationalInsights/workspaces/componentName*. |
| 53 | + |
| 54 | + For example: |
| 55 | + ``` |
| 56 | + `workspace("/subscriptions/e427267-5645-4c4e-9c67-3b84b59a6982/resourcegroups/ContosoAzureHQ/providers/Microsoft.OperationalInsights/workspaces/contosoretail").Event | count |
| 57 | + ``` |
| 58 | +
|
| 59 | +## Next steps |
| 60 | +
|
| 61 | +Review the [Log Analytics log search reference](https://docs.loganalytics.io/docs/Language-Reference) to view all of the query syntax options available in Log Analytics. |
0 commit comments