使用 Azure 数据资源管理器查询 Azure Monitor 中的数据

Azure 数据资源管理器支持 Azure 数据资源管理器、Application Insights 资源(AI)Log Analytics工作区(LA)之间的跨服务查询。 你可使用 Azure 数据资源管理器查询工具和在跨服务查询中查询 Log Analytics 工作区或 Application Insights 资源。 本文介绍如何创建跨服务查询并将Log Analytics工作区或 Application Insights 资源添加到 Azure 数据资源管理器 Web UI。

Azure 数据资源管理器跨服务查询流:

显示 Azure 数据资源管理器跨服务查询流程的示意图。

将 Log Analytics 工作区/Application Insights 资源添加到 Azure 数据资源管理器客户端工具

将 Log Analytics 工作区或 Application Insights 资源添加到 Azure 数据资源管理器客户端工具,来实现对群集的跨服务查询。

Important

从 2025 年 7 月 1 日开始,在 对 Log Analytics 或 Application Insights 使用查询 API 终结点时,查询日志数据和事件需要 TLS 1.2 或更高版本。 有关详细信息,请参阅 传输中的安全数据

  1. 在连接到 Log Analytics 工作区或 Application Insights 资源之前,请先确认 Azure 数据资源管理器本机群集(例如 help 群集)是否显示在左侧菜单中。

    左侧菜单的屏幕截图,其中帮助群集被选为 Azure 数据资源管理器 原生群集。

  2. Azure 数据资源管理器用户界面中,选择 + 添加,然后选择 连接

  3. 在“添加连接”窗口中,添加 Log Analytics (LA) 工作区或 Application Insights (AI) 资源的 URL 和显示名称

    • 对于 Log Analytics (LA) 工作区:https://ade.loganalytics.io/subscriptions/<subscription-id>/resourcegroups/<resource-group-name>/providers/microsoft.operationalinsights/workspaces/<workspace-name>
    • 对于 Application Insights (AI) 资源:https://ade.applicationinsights.io/subscriptions/<subscription-id>/resourcegroups/<resource-group-name>/providers/microsoft.insights/components/<ai-app-name>

    Note

    指定 https://ade.applicationinsights.io/subscriptions/<subscription-id> 以查看订阅中的所有数据库。 此语法也适用于 Log Analytics 工作区群集。

  4. 选择 并添加

    显示添加连接窗口的屏幕截图。

    Note

    • 以下项有不同的终结点:
    • Azure 政府云:adx.monitor.azure.us/
    • 由 21Vianet 运营的 Microsoft Azure:adx.monitor.azure.cn/
    • 如果向多个Log Analytics工作区/Application Insights 资源添加连接,请为每个资源提供不同的名称。 否则,它们在左窗格中的名称都相同。
  5. 建立连接后,您的 Log Analytics 工作区或 Application Insights 资源将与本机 Azure 数据资源管理器 群集一起显示在左侧窗格中。

    显示 Log Analytics 工作区和 Azure 数据资源管理器群集的屏幕截图。

Note

从 Azure 数据资源管理器对 Azure Monitor 中的数据运行的查询具有跨资源查询限制

运行查询

可以使用支持 Kusto 查询的客户端工具运行查询,例如:Kusto Explorer、Azure 数据资源管理器 Web UI、具有 Kqlmagic、Flow、PowerQuery、PowerShell、Lens、REST API 的笔记本。

Note

跨服务查询仅用于数据检索。 有关详细信息,请参阅函数可支持性

Tip

  • 数据库应与跨服务查询中指定的资源同名。 名称区分大小写。
  • 在跨服务查询中,请确保 Application Insights 资源和 Log Analytics 工作区的名称正确。
  • 如果名称包含特殊字符,它们将被跨服务查询中的 URL 编码替换。
  • 如果名称包含不符合 KQL 标识符名称规则的字符,它们将被短划线 - 字符替换。

通过 Azure 数据资源管理器客户端工具直接查询 Log Analytics 工作区或 Application Insights 资源

可通过 Azure 数据资源管理器客户端工具对 Log Analytics 工作区或 Application Insights 资源运行查询。

  1. 验证是否已在左侧窗格中选择你的工作区。

  2. 运行以下查询:

Perf | take 10 // Demonstrate cross-service query on the Log Analytics workspace

显示 Query Log Analytics 工作区的屏幕截图。

对 Log Analytics 工作区或 Application Insights 资源与 Azure 数据资源管理器 原生群集进行跨查询

运行跨群集服务查询时,请验证是否已在左侧窗格中选择 Azure 数据资源管理器本机群集。 以下示例演示了如何(使用 union)将 Azure 数据资源管理器群集表与 Log Analytics 工作区组合在一起。

运行以下查询:

union StormEvents, cluster('https://ade.loganalytics.io/subscriptions/<subscription-id>/resourcegroups/<resource-group-name>/providers/microsoft.operationalinsights/workspaces/<workspace-name>').database('<workspace-name>').Perf
| take 10
let CL1 = 'https://ade.loganalytics.io/subscriptions/<subscription-id>/resourcegroups/<resource-group-name>/providers/microsoft.operationalinsights/workspaces/<workspace-name>';
union <ADX table>, cluster(CL1).database(<workspace-name>).<table name>

显示 Azure 数据资源管理器 Web UI 中跨服务查询的屏幕截图。

Tip

使用 join 运算符而不是 `union` 时,可能需要 hint 才能在 Azure 数据资源管理器 原生群集上运行该运算符。

将一个租户的 Azure 数据资源管理器群集中的数据与另一个租户的 Azure Monitor 资源联接

不支持这些服务之间的跨租户查询。 你已登录到单个租户中,以便运行跨这两个资源的查询。

如果 Azure 数据资源管理器资源位于 tenant-name-a 中,Log Analytics 工作区位于 tenant-name-b 中,则使用下述两种方法之一

  1. 通过 Azure 数据资源管理器,可以为不同租户中的主体添加角色。 将你在 tenant-name-b 中的用户 ID 添加为 Azure 数据资源管理器群集上的授权用户。 验证位于 tenant-name-b 中的 Azure 数据资源管理器群集上的 'TrustedExternalTenant' 属性。 在tenant-name-b中完整运行跨查询。

  2. 使用 Lighthouse 将 Azure Monitor 资源投射到 tenant-name-a 中

从不同租户连接到 Azure 数据资源管理器群集

Kusto Explorer 会自动将你登录到用户帐户最初所属的租户。 若要访问具有相同用户帐户的其他租户中的资源,必须在连接字符串中显式指定 tenantIdData Source=https://ade.applicationinsights.io/subscriptions/<SubscriptionId>/resourcegroups/<ResourceGroupName>;Initial Catalog=NetDefaultDB;AAD Federated Security=True;Authority ID=<TenantId>

Note

tenantId 参数不能直接在 Azure 数据资源管理器 Web UI 中配置。 对于 tenantId,请使用Microsoft Entra标识。

函数可支持性

Azure 数据资源管理器跨服务查询支持 Application Insights 资源和Log Analytics工作区的功能。 此功能允许跨群集查询直接引用 Azure Monitor 表格函数。 跨服务查询支持下列命令:

  • .show functions
  • .show function [FunctionName]
  • .show database [DatabaseName] schema as json

Limitations

  • 跨服务查询仅支持 .show functions。 此功能允许跨群集查询直接引用 Azure Monitor、Azure 数据资源管理器或 Azure Resource Graph 表格函数。 跨服务查询支持下列命令:

    • .show functions
    • .show function [FunctionName]
    • .show database [DatabaseName] schema as json
  • 专用链接(专用终结点)和 IP 限制不支持跨服务查询。

使用其他语法选项

调用 Application Insights 资源或 Log Analytics 工作区时,可使用以下语法选项:

语法说明 Application Insights 资源 Log Analytics 工作区
仅包含此订阅中所定义资源的群集中的数据库(建议用于跨群集查询 cluster('https://adx.monitor.azure.com/subscriptions/<subscription-id>/resourcegroups/<resource-group-name>/providers/microsoft.insights/components/<ai-app-name>').database('<ai-app-name>') cluster('https://adx.monitor.azure.com/subscriptions/<subscription-id>/resourcegroups/<resource-group-name>/providers/microsoft.operationalinsights/workspaces/<workspace-name>').database('<workspace-name>')
包含此订阅中所有应用/工作区的群集 cluster('https://adx.monitor.azure.com/subscriptions/<subscription-id>') cluster('https://adx.monitor.azure.com/subscriptions/<subscription-id>')
包含订阅中所有应用/工作区且属于此资源组的群集 cluster('https://adx.monitor.azure.com/subscriptions/<subscription-id>/resourcegroups/<resource-group-name>') cluster('https://adx.monitor.azure.com/subscriptions/<subscription-id>/resourcegroups/<resource-group-name>')
仅包含此订阅中定义的资源的群集 cluster('https://adx.monitor.azure.com/subscriptions/<subscription-id>/resourcegroups/<resource-group-name>/providers/microsoft.insights/components/<ai-app-name>') cluster('https://adx.monitor.azure.com/subscriptions/<subscription-id>/resourcegroups/<resource-group-name>/providers/microsoft.operationalinsights/workspaces/<workspace-name>')
UsGov 中的终结点 cluster('https://adx.monitor.azure.us/subscriptions/<subscription-id>/resourcegroups/<resource-group-name>/providers/microsoft.operationalinsights/workspaces/<workspace-name>')
对于中国世纪互联中的终结点 cluster('https://adx.monitor.azure.cn/subscriptions/<subscription-id>/resourcegroups/<resource-group-name>/providers/microsoft.operationalinsights/workspaces/<workspace-name>')