监视工作负荷 - Azure 门户

本文介绍如何使用 Azure 门户监视工作负荷。 这包括设置 Azure Monitor 日志,以使用适用于 Synapse SQL 的日志分析来调查查询执行和工作负荷趋势。

先决条件

  • Azure 订阅:如果你没有 Azure 订阅,请在开始之前创建一个 Azure 试用帐户
  • SQL 池:我们将收集 SQL 池的日志。 如果尚未预配 SQL 池,请参阅创建 SQL 池中的说明。

创建 Log Analytics 工作区

在 Azure 门户中,导航到 Log Analytics 工作区的页面,或使用 Azure 服务搜索窗口创建新的 Log Analytics 工作区。

Screenshot shows the Log Analytics workspaces where you can select Add.

Screenshot shows the Log Analytics workspace where you can enter values.

有关工作区的详细信息,请参阅创建 Log Analytics 工作区

启用资源日志

配置诊断设置,以便从 SQL 池发出日志。 日志包含与最常用的性能故障排除 DMV 等效的遥测视图。 目前支持以下视图:

Screenshot of the page to create a diagnostic setting in the Azure portal.

可将日志发送到 Azure 存储、流分析或 Log Analytics。 本教程选择了“Log Analytics”。 选择所有所需的类别和指标,然后选择“发送到 Log Analytics 工作区”。

Screenshot of the page to specify which logs to collect in the Azure portal.

选择“保存”以创建新的诊断设置。 数据可能需要几分钟才能显示在查询中。

针对 Log Analytics 运行查询

导航到 Log Analytics 工作区,在其中可执行以下操作:

  • 使用日志查询分析日志,并保存查询以便重复使用
  • 保存查询以便重复使用
  • 创建日志警报
  • 将查询结果固定到仪表板

有关使用 Kusto 的日志查询功能的详细信息,请参阅 Kusto 查询语言 (KQL) 概述

Log Analytics workspace editor.

Log Analytics workspace queries.

示例日志查询

查询的范围设置为 Log Analytics 工作区资源。

//List all queries
AzureDiagnostics
| where Category contains "ExecRequests"
| project TimeGenerated, StartTime_t, EndTime_t, Status_s, Command_s, ResourceClass_s, duration=datetime_diff('millisecond',EndTime_t, StartTime_t)
//Chart the most active resource classes
AzureDiagnostics
| where Category contains "ExecRequests"
| where Status_s == "Completed"
| summarize totalQueries = dcount(RequestId_s) by ResourceClass_s
| render barchart
//Count of all queued queries
AzureDiagnostics
| where Category contains "waits"
| where Type == "UserConcurrencyResourceType"
| summarize totalQueuedQueries = dcount(RequestId_s)

后续步骤

设置并配置 Azure Monitor 日志后,请自定义 Azure 仪表板以便在整个团队中共享。