Azure Standard Load Balancer 的 Azure 監視器記錄Azure Monitor logs for Azure Standard Load Balancer

您可以使用不同類型的 Azure 監視器記錄來管理和疑難排解 Azure Standard Load Balancer。You can use different types of Azure Monitor logs to manage and troubleshoot Azure Standard Load Balancer. 記錄可以串流至事件中樞或 Log Analytics 工作區。Logs can be streamed to an event hub or a Log Analytics workspace. 您可以從 Azure Blob 儲存體解壓縮所有記錄,並在 Excel 和 Power BI 等工具中加以查看。You can extract all logs from Azure Blob Storage and view them in tools like Excel and Power BI.

記錄類型為:The types of logs are:

  • 活動記錄: 您可以查看所有提交至您 Azure 訂用帳戶的活動及其狀態。Activity logs: You can view all activity being submitted to your Azure subscriptions, along with their status. 如需詳細資訊,請參閱 查看活動記錄以監視資源上的動作For more information, see View activity logs to monitor actions on resources. 預設會啟用活動記錄,並可在 Azure 入口網站中查看。Activity logs are enabled by default and can be viewed in the Azure portal. 這些記錄適用于 Azure 基本 Load Balancer 和 Standard Load Balancer。These logs are available for both Azure Basic Load Balancer and Standard Load Balancer.
  • Standard Load Balancer 計量: 您可以使用此記錄來查詢匯出為 Standard Load Balancer 記錄的度量。Standard Load Balancer metrics: You can use this log to query the metrics exported as logs for Standard Load Balancer. 這些記錄僅適用于 Standard Load Balancer。These logs are available only for Standard Load Balancer.

重要

健康情況探查和 Load Balancer 警示事件記錄檔目前無法運作,而且會列在 Azure Load Balancer 的已知問題中。Health probe and Load Balancer alert event logs are not currently functional and are listed in the known issues for Azure Load Balancer.

重要

記錄僅適用於在 Azure Resource Manager 部署模型中部署的資源。Logs are available only for resources deployed in the Azure Resource Manager deployment model. 您無法將記錄用於傳統部署模型中的資源。You can't use logs for resources in the classic deployment model. 如需這些部署模型的詳細資訊,請參閱了解 Resource Manager 部署和傳統部署For more information about the deployment models, see Understanding Resource Manager deployment and classic deployment.

啟用記錄Enable logging

每個 Resource Manager 資源都會自動啟用活動記錄功能。Activity logging is automatically enabled for every Resource Manager resource. 啟用事件和健康情況探查記錄,以開始收集可透過這些記錄取得的資料。Enable event and health probe logging to start collecting the data available through those logs. 使用下列步驟:Use the following steps:

  1. 登入 Azure 入口網站Sign in to the Azure portal. 如果您還沒有負載平衡器,請先 建立負載平衡器 再繼續。If you don't already have a load balancer, create a load balancer before you continue.

  2. 在入口網站中,選取 [ 資源群組]。In the portal, select Resource groups.

  3. 選取 <resource-group-name> 負載平衡器所在的位置。Select <resource-group-name> where your load balancer is.

  4. 選取負載平衡器。Select your load balancer.

  5. 選取 [活動記錄 > 診斷設定]。Select Activity log > Diagnostic settings.

  6. 在 [ 診斷設定 ] 窗格中,選取 [ 診斷設定] 下的 [ + 新增診斷設定]。In the Diagnostics settings pane, under Diagnostics settings, select + Add diagnostic setting.

  7. 在 [診斷設定 建立] 窗格的 [名稱] 方塊中,輸入 myLBDiagnosticsIn the Diagnostics settings creation pane, enter myLBDiagnostics in the Name box.

  8. 診斷設定 有三個選項。You have three options for the Diagnostics settings. 您可以選擇其中一個、兩個或全部三個,並針對您的需求進行設定:You can choose one, two, or all three and configure each for your requirements:

    • 封存至儲存體帳戶Archive to a storage account. 您將需要已為此進程建立的儲存體帳戶。You'll need a storage account already created for this process. 若要建立儲存體帳戶,請參閱儲存體帳戶To create a storage account, see Create a storage account.

      1. 選取 [封存 至儲存體帳戶 ] 核取方塊。Select the Archive to a storage account check box.
      2. 選取 [ 設定 ] 以開啟 [ 選取儲存體帳戶 ] 窗格。Select Configure to open the Select a storage account pane.
      3. 在 [ 用帳戶] 下拉式清單中,選取您的儲存體帳戶建立所在的訂用帳戶。In the Subscription drop-down list, select the subscription where your storage account was created.
      4. 在 [ 儲存體帳戶 ] 下拉式清單中,選取您的儲存體帳戶名稱。In the Storage account drop-down list, select the name of your storage account.
      5. 選取 [確定]。Select OK.
    • 串流處理至事件中樞Stream to an event hub. 您將需要已經為此進程建立的事件中樞。You'll need an event hub already created for this process. 若要建立事件中樞,請參閱 快速入門:使用 Azure 入口網站建立事件中樞To create an event hub, see Quickstart: Create an event hub by using the Azure portal.

      1. 選取 [串流至事件中樞] 核取方塊。Select the Stream to an event hub check box.
      2. 選取 [ 設定 ] 以開啟 [ 選取事件中樞 ] 窗格。Select Configure to open the Select event hub pane.
      3. 在 [ 用帳戶] 下拉式清單中,選取您的事件中樞建立所在的訂用帳戶。In the Subscription drop-down list, select the subscription where your event hub was created.
      4. 在 [ 選取事件中樞命名空間 ] 下拉式清單中,選取命名空間。In the Select event hub namespace drop-down list, select the namespace.
      5. 在 [ 選取事件中樞原則名稱 ] 下拉式清單中,選取名稱。In the Select event hub policy name drop-down list, select the name.
      6. 選取 [確定]。Select OK.
    • 傳送至 Log AnalyticsSend to Log Analytics. 您必須已經為此程式建立並設定 log analytics 工作區。You'll need to already have a log analytics workspace created and configured for this process. 若要建立 Log Analytics 工作區,請參閱 Azure 入口網站中的建立 Log analytics 工作區To create a Log Analytics workspace, see Create a Log Analytics workspace in the Azure portal.

      1. 選取 [傳送至 Log Analytics] 核取方塊。Select the Send to Log Analytics check box.
      2. 在 [ 用帳戶] 下拉式清單中,選取您的 Log Analytics 工作區所在的訂用帳戶。In the Subscription drop-down list, select the subscription where your Log Analytics workspace is.
      3. 在 [ Log Analytics 工作區 ] 下拉式清單中,選取工作區。In the Log Analytics Workspace drop-down list, select the workspace.
  9. 在 [診斷設定] 窗格的 [度量] 區段中,選取 [ AllMetrics ] 核取方塊。In the METRIC section of the Diagnostics settings pane, select the AllMetrics check box.

  10. 確認一切看起來正確,然後選取 [診斷設定 建立] 窗格頂端的 [儲存]。Verify that everything looks correct, and then select Save at the top of the Diagnostic settings creation pane.

檢視和分析活動記錄檔View and analyze the activity log

預設會產生活動記錄。The activity log is generated by default. 您可以 遵循本文中的指示,將其設定為在訂用帳戶層級上匯出。You can configure it to be exported on a subscription level by following instructions in this article. 若要深入瞭解這些記錄,請閱讀 View 活動記錄以監視資源的動作 文章。Learn more about these logs by reading the View activity logs to monitor actions on resources article.

您可以使用下列其中一種方法來查看和分析活動記錄資料:You can view and analyze activity log data by using either of the following methods:

  • Azure 工具: 透過 Azure PowerShell、Azure CLI、Azure REST API 或 Azure 入口網站,從活動記錄中取出資訊。Azure tools: Retrieve information from the activity log through Azure PowerShell, the Azure CLI, the Azure REST API, or the Azure portal. 使用 Resource Manager 的「審核作業」一文會提供每個方法的逐步指示。The Audit operations with Resource Manager article provides step-by-step instructions for each method.
  • Power BI︰ 如果還沒有 Power BI 帳戶,您可以免費試用。Power BI: If you don't already have a Power BI account, you can try it for free. 藉由使用 適用于 Power BI 的 Azure Audit Logs 整合,您可以使用預先設定的儀表板來分析您的資料。By using the Azure Audit Logs integration for Power BI, you can analyze your data with preconfigured dashboards. 或者,您也可以自訂視圖以符合您的需求。Or you can customize views to suit your requirements.

以記錄形式來查看和分析計量View and analyze metrics as logs

藉由使用 Azure 監視器中的匯出功能,您可以匯出 Load Balancer 計量。By using the export functionality in Azure Monitor, you can export your Load Balancer metrics. 這些計量會產生每一分鐘取樣間隔的記錄專案。These metrics will generate a log entry for each one-minute sampling interval.

每個資源層級都會啟用計量至記錄匯出。Metrics-to-logs export is enabled on a per-resource level. 若要啟用這些記錄:To enable these logs:

  1. 移至 [ 診斷設定 ] 窗格。Go to the Diagnostic Settings pane.
  2. 依資源群組篩選,然後選取您想要為其啟用計量匯出的 Load Balancer 實例。Filter by resource group, and then select the Load Balancer instance that you want to enable metrics export for.
  3. Load Balancer 的 [診斷設定] 頁面開啟時,請選取 [ AllMetrics ],將合格的計量匯出為記錄檔。When the diagnostic settings page for Load Balancer is up, select AllMetrics to export eligible metrics as logs.

如需計量匯出的限制,請參閱本文的「 限制 」一節。For metric export limitations, see the Limitations section of this article.

在 Standard Load Balancer 的診斷設定中啟用 AllMetrics 之後,如果您使用的是事件中樞或 Log Analytics 工作區,這些記錄將會填入 AzureMonitor 資料表中。After you enable AllMetrics in the diagnostic settings of Standard Load Balancer, if you're using an event hub or Log Analytics workspace, these logs will be populated in the AzureMonitor table.

如果您要匯出至儲存體,請連接到您的儲存體帳戶,並取得事件和健康情況探查記錄的 JSON 記錄專案。If you're exporting to storage, connect to your storage account and retrieve the JSON log entries for event and health probe logs. 下載 JSON 檔案之後,您可以將它們轉換成 CSV,並在 Excel、Power BI 或任何其他資料視覺化檢視中加以查看。After you download the JSON files, you can convert them to CSV and view them in Excel, Power BI, or any other data visualization tool.

提示

如果您很熟悉如何在 c # 中變更常數和變數值的 Visual Studio 和基本概念,您可以使用 GitHub 提供的 記錄檔轉換器工具If you're familiar with Visual Studio and basic concepts of changing values for constants and variables in C#, you can use the log converter tools available from GitHub.

串流至事件中樞Stream to an event hub

當診斷資訊串流至事件中樞時,您可以將它用於具有 Azure 監視器整合的合作夥伴 SIEM 工具中的集中式記錄分析。When diagnostic information is streamed to an event hub, you can use it for centralized log analysis in a partner SIEM tool with Azure Monitor integration. 如需詳細資訊,請參閱 將 Azure 監視資料串流至事件中樞For more information, see Stream Azure monitoring data to an event hub.

傳送至 Log AnalyticsSend to Log Analytics

您可以將 Azure 中資源的診斷資訊直接傳送至 Log Analytics 工作區。You can send diagnostic information for resources in Azure directly to a Log Analytics workspace. 在該工作區中,您可以對資訊執行複雜的查詢,以進行疑難排解和分析。In that workspace, you can run complex queries against the information for troubleshooting and analysis. 如需詳細資訊,請參閱 在 Azure 監視器中收集 Log Analytics 工作區中的 Azure 資源記錄For more information, see Collect Azure resource logs in a Log Analytics workspace in Azure Monitor.

限制Limitations

Azure Load Balancer 的計量對記錄匯出功能有下列限制:The metrics-to-logs export feature for Azure Load Balancer has the following limitations:

  • 當匯出為記錄時,計量目前會透過內部名稱顯示。Metrics are currently displayed through internal names when exported as logs. 您可以在下表中找到對應。You can find the mapping in the below table.
  • 不會保留度量的維度。The dimensionality of metrics is not preserved. 例如,使用 DipAvailability (健康情況探查狀態) 之類的計量,您將無法依後端 IP 位址進行分割或查看。For example, with metrics such as DipAvailability (health probe status), you won't be able to split or view by back-end IP address.
  • 使用的 SNAT 埠和已配置 SNAT 埠的計量目前無法匯出為記錄。Metrics for used SNAT ports and allocated SNAT ports aren't currently available for export as logs.

下一步Next steps