Skip to content

Commit f1e1e44

Browse files
authored
Merge pull request #240321 from guywi-ms/arg-cross-service-query
Arg cross service query
2 parents fb824d9 + 960a69b commit f1e1e44

File tree

6 files changed

+78
-33
lines changed

6 files changed

+78
-33
lines changed
Lines changed: 75 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,49 @@
11
---
2-
title: Cross-resource query Azure Data Explorer by using Azure Monitor
3-
description: Use Azure Monitor to perform cross-product queries between Azure Data Explorer, Log Analytics workspaces, and classic Application Insights applications in Azure Monitor.
2+
title: Query data in Azure Data Explorer and Azure Resource Graph from Azure Monitor
3+
description: Query data in Azure Data Explorer and Azure Resource Graph from Azure Monitor.
44
author: guywi-ms
55
ms.author: guywild
66
ms.topic: conceptual
7-
ms.date: 07/25/2023
7+
ms.date: 08/22/2023
88
ms.reviewer: osalzberg
99

1010
---
11-
# Cross-resource query Azure Data Explorer by using Azure Monitor
12-
Azure Monitor supports cross-service queries between Azure Data Explorer, [Application Insights](../app/app-insights-overview.md), and [Log Analytics](../logs/data-platform-logs.md). You can then query your Azure Data Explorer cluster by using Log Analytics or Application Insights tools and refer to it in a cross-service query. This article shows how to make a cross-service query.
11+
# Query data in Azure Data Explorer and Azure Resource Graph from Azure Monitor
12+
Azure Monitor lets you query data in [Azure Data Explorer](/azure/data-explorer/data-explorer-overview) and [Azure Resource Graph](../../governance/resource-graph/overview.md) from your Log Analytics workspace and Application Insights resources. This article explains how to query data in Azure Resource Graph and Azure Data Explorer from Azure Monitor.
1313

14-
The following diagram shows the Azure Monitor cross-service flow:
14+
You can run cross-service queries by using any client tools that support Kusto Query Language (KQL) queries, including the Log Analytics web UI, workbooks, PowerShell, and the REST API.
1515

16-
:::image type="content" source="media\azure-data-explorer-monitor-proxy\azure-monitor-data-explorer-flow.png" alt-text="Diagram that shows the flow of queries between a user, Azure Monitor, a proxy, and Azure Data Explorer.":::
16+
## Permissions required
1717

18-
## Cross query your Log Analytics or Application Insights resources and Azure Data Explorer
18+
To run a cross-service query, you need:
1919

20-
You can run cross-resource queries by using client tools that support Kusto queries. Examples of these tools include the Log Analytics web UI, workbooks, PowerShell, and the REST API.
21-
22-
Enter the identifier for an Azure Data Explorer cluster in a query within the `adx` pattern, followed by the database name and table.
23-
24-
```kusto
25-
adx('https://help.kusto.windows.net/Samples').StormEvents
26-
```
27-
:::image type="content" source="media/azure-data-explorer-monitor-proxy/azure-monitor-cross-service-query-example.png" alt-text="Screenshot that shows an example of a cross-service query.":::
28-
29-
> [!NOTE]
30-
>* Database names are case sensitive.
31-
>* Cross-resource query as an alert isn't supported.
32-
>* Identifying the Timestamp column in the cluster isn't supported. The Log Analytics Query API won't pass along the time filter.
33-
> * The cross-service query ability is used for data retrieval only. For more information, see [Function supportability](#function-supportability).
34-
> * Private Link is not supported with this feature.
20+
- `Microsoft.OperationalInsights/workspaces/query/*/read` permissions to the Log Analytics workspaces you query, as provided by the [Log Analytics Reader built-in role](../logs/manage-access.md#log-analytics-reader), for example.
21+
- Reader permissions to the resources you query in Azure Resource Graph.
22+
- Viewer permissions to the tables you query in Azure Data Explorer.
3523

3624
## Function supportability
3725

38-
The Azure Monitor cross-service queries support functions for Application Insights, Log Analytics, and Azure Data Explorer.
39-
This capability enables cross-cluster queries to reference an Azure Monitor or Azure Data Explorer tabular function directly.
26+
Azure Monitor cross-service queries support functions for Application Insights, Log Analytics, Azure Data Explorer, and Azure Resource Graph.
27+
This capability enables cross-cluster queries to reference an Azure Monitor, Azure Data Explorer, or Azure Resource Graph tabular function directly.
4028
The following commands are supported with the cross-service query:
4129

4230
* `.show functions`
4331
* `.show function {FunctionName}`
4432
* `.show database {DatabaseName} schema as json`
4533

46-
## Combine Azure Data Explorer cluster tables with a Log Analytics workspace
34+
## Query data in Azure Data Explorer
35+
36+
Enter the identifier for an Azure Data Explorer cluster in a query within the `adx` pattern, followed by the database name and table.
37+
38+
```kusto
39+
adx('https://help.kusto.windows.net/Samples').StormEvents
40+
```
41+
### Combine Azure Data Explorer cluster tables with a Log Analytics workspace
4742

4843
Use the `union` command to combine cluster tables with a Log Analytics workspace.
4944

45+
For example:
46+
5047
```kusto
5148
union customEvents, adx('https://help.kusto.windows.net/Samples').StormEvents
5249
| take 10
@@ -55,19 +52,20 @@ union customEvents, adx('https://help.kusto.windows.net/Samples').StormEvents
5552
let CL1 = adx('https://help.kusto.windows.net/Samples').StormEvents;
5653
union customEvents, CL1 | take 10
5754
```
58-
:::image type="content" source="media/azure-data-explorer-monitor-proxy/azure-monitor-union-cross-query.png" alt-text="Screenshot that shows a cross-service query example with the union command.":::
5955

6056
> [!TIP]
6157
> Shorthand format is allowed: *ClusterName*/*InitialCatalog*. For example, `adx('help/Samples')` is translated to `adx('help.kusto.windows.net/Samples')`.
6258
63-
When you use the [`join` operator](/azure/data-explorer/kusto/query/joinoperator) instead of union, you're required to use a [`hint`](/azure/data-explorer/kusto/query/joinoperator#join-hints) to combine the data in the Azure Data Explorer cluster with the Log Analytics workspace. Use `Hint.remote={Direction of the Log Analytics Workspace}`. For example:
59+
When you use the [`join` operator](/azure/data-explorer/kusto/query/joinoperator) instead of union, you're required to use a [`hint`](/azure/data-explorer/kusto/query/joinoperator#join-hints) to combine the data in the Azure Data Explorer cluster with the Log Analytics workspace. Use `Hint.remote={Direction of the Log Analytics Workspace}`.
60+
61+
For example:
6462

6563
```kusto
6664
AzureDiagnostics
6765
| join hint.remote=left adx("cluster=ClusterURI").AzureDiagnostics on (ColumnName)
6866
```
6967

70-
## Join data from an Azure Data Explorer cluster in one tenant with an Azure Monitor resource in another
68+
### Join data from an Azure Data Explorer cluster in one tenant with an Azure Monitor resource in another
7169

7270
Cross-tenant queries between the services aren't supported. You're signed in to a single tenant for running the query that spans both resources.
7371

@@ -76,13 +74,59 @@ If the Azure Data Explorer resource is in Tenant A and the Log Analytics workspa
7674
* Use Azure Data Explorer to add roles for principals in different tenants. Add your user ID in Tenant B as an authorized user on the Azure Data Explorer cluster. Validate that the [TrustedExternalTenant](/powershell/module/az.kusto/update-azkustocluster) property on the Azure Data Explorer cluster contains Tenant B. Run the cross query fully in Tenant B.
7775
* Use [Lighthouse](../../lighthouse/index.yml) to project the Azure Monitor resource into Tenant A.
7876

79-
## Connect to Azure Data Explorer clusters from different tenants
77+
### Connect to Azure Data Explorer clusters from different tenants
8078

8179
Kusto Explorer automatically signs you in to the tenant to which the user account originally belongs. To access resources in other tenants with the same user account, you must explicitly specify `TenantId` in the connection string:
8280

8381
`Data Source=https://ade.applicationinsights.io/subscriptions/SubscriptionId/resourcegroups/ResourceGroupName;Initial Catalog=NetDefaultDB;AAD Federated Security=True;Authority ID=TenantId`
8482

83+
## Query data in Azure Resource Graph
84+
85+
Enter the `arg("")` pattern, followed by the Azure Resource Graph table name.
86+
87+
`arg(״״).<Azure-Resource-Graph-table-name>`
88+
89+
90+
For example:
91+
92+
```kusto
93+
arg("").<Azure-Resource-Graph-table-name>
94+
```
95+
96+
### Combine Azure Resource Graph tables with a Log Analytics workspace
97+
98+
Use the `union` command to combine cluster tables with a Log Analytics workspace.
99+
100+
For example:
101+
102+
```kusto
103+
union AzureActivity, arg("").Resources
104+
| take 10
105+
```
106+
```kusto
107+
let CL1 = arg("").Resources ;
108+
union AzureActivity, CL1 | take 10
109+
```
110+
111+
When you use the [`join` operator](/azure/data-explorer/kusto/query/joinoperator) instead of union, you're required to use a [`hint`](/azure/data-explorer/kusto/query/joinoperator#join-hints) to combine the data in Azure Resource Graph with the Log Analytics workspace. Use `Hint.remote={Direction of the Log Analytics Workspace}`. For example:
112+
113+
```kusto
114+
Perf | where ObjectName == "Memory" and (CounterName == "Available MBytes Memory")
115+
| extend _ResourceId = replace_string(replace_string(replace_string(_ResourceId, 'microsoft.compute', 'Microsoft.Compute'), 'virtualmachines','virtualMachines'),"resourcegroups","resourceGroups")
116+
| join hint.remote=left (arg("").Resources | where type =~ 'Microsoft.Compute/virtualMachines' | project _ResourceId=id, tags) on _ResourceId | project-away _ResourceId1 | where tostring(tags.env) == "prod"
117+
```
118+
119+
## Create an alert based on a cross-service query
120+
121+
To create a new alert rule based on a cross-service query, follow the steps in [Create a new alert rule](../alerts/alerts-create-new-alert-rule.md), selecting your Log Analytics workspace on the Scope tab.
122+
123+
## Limitations
124+
125+
* Database names are case sensitive.
126+
* Identifying the Timestamp column in the cluster isn't supported. The Log Analytics Query API won't pass along the time filter.
127+
* The cross-service query ability is used for data retrieval only.
128+
* [Private Link](../logs/private-link-security.md) does not support cross-service queries.
129+
85130
## Next steps
86131
* [Write queries](/azure/data-explorer/write-queries)
87-
* [Query data in Azure Monitor by using Azure Data Explorer](/azure/data-explorer/query-monitor-data)
88132
* [Perform cross-resource log queries in Azure Monitor](../logs/cross-workspace-query.md)

articles/azure-monitor/toc.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1246,7 +1246,8 @@ items:
12461246
href: logs/workspace-expression.md
12471247
- name: resource expression
12481248
href: logs/resource-expression.md
1249-
- name: Query Azure Data Explorer from Azure Monitor
1249+
- name: Query data in Azure Data Explorer or Resource Graph
1250+
displayName: arg(), adx()
12501251
href: logs/azure-monitor-data-explorer-proxy.md
12511252
- name: API
12521253
items:

articles/sentinel/livestream.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ You can create a livestream session from an existing hunting query, or create yo
5050
- If you started livestream from scratch, create your query.
5151

5252
> [!NOTE]
53-
> Livestream supports **cross-resource queries** of data in Azure Data Explorer. [**Learn more about cross-resource queries**](../azure-monitor/logs/azure-monitor-data-explorer-proxy.md#cross-query-your-log-analytics-or-application-insights-resources-and-azure-data-explorer).
53+
> Livestream supports **cross-resource queries** of data in Azure Data Explorer. [**Learn more about cross-resource queries**](../azure-monitor/logs/azure-monitor-data-explorer-proxy.md).
5454
5555
1. Select **Play** from the command bar.
5656

0 commit comments

Comments
 (0)