建立和共用 Log Analytics 資料的儀表板Create and share dashboards of Log Analytics data

Log Analytics 儀表板可以視覺化方式呈現所有儲存的記錄查詢,讓您可以尋找、相互關聯,並共用組織中的 IT 作業資料。Log Analytics dashboards can visualize all of your saved log queries, giving you the ability to find, correlate, and share IT operational data in the organization. 本教學課程涵蓋建立記錄查詢,其將用來支援由您的 IT 作業支援團隊存取的共用儀表板。This tutorial covers creating a log query that will be used to support a shared dashboard that will be accessed by your IT operations support team. 您會了解如何:You learn how to:

  • 在 Azure 入口網站中建立共用儀表板Create a shared dashboard in the Azure portal
  • 以視覺化方式呈現效能記錄查詢Visualize a performance log query
  • 將記錄查詢新增至共用儀表板Add a log query to a shared dashboard
  • 在共用儀表板中自訂圖格Customize a tile in a shared dashboard

若要完成本教學課程中的範例,您目前必須有連線至 Log Analytics 工作區的虛擬機器。To complete the example in this tutorial, you must have an existing virtual machine connected to the Log Analytics workspace.

登入 Azure 入口網站Sign in to Azure portal

https://portal.azure.com 登入 Azure 入口網站。Sign in to the Azure portal at https://portal.azure.com.

建立共用儀表板Create a shared dashboard

選取 [儀表板] 以開啟您的預設儀表板Select Dashboard to open your default dashboard. 您的儀表板外觀與以下範例不同。Your dashboard will look different than the example below.

Azure 入口網站儀表板

您可以在這裡將所有 Azure 資源中對 IT 最重要的作業資料結合在一起,包括來自 Azure Log Analytics 的遙測資料。Here you can bring together operational data that is most important to IT across all your Azure resources, including telemetry from Azure Log Analytics. 在我們進入以視覺化方式呈現記錄查詢之前,請先建立並共用儀表板。Before we step into visualizing a log query, let's first create a dashboard and share it. 接著我們可以專注於範例效能記錄查詢,該查詢會轉譯為折線圖,然後將其新增至儀表板。We can then focus on our example performance log query, which will render as a line chart, and add it to the dashboard.

若要建立儀表板,請選取目前的儀表板名稱旁的 [新增儀表板] 按鈕。To create a dashboard, select the New dashboard button next to the current dashboard's name.

在 Azure 入口網站中建立新儀表板

這個動作會建立全新的空白私人儀表板並讓您進入自訂模式,供您為儀表板命名並新增或重新排列圖格。This action creates a new, empty, private dashboard and puts you into customization mode where you can name your dashboard and add or rearrange tiles. 編輯儀表板名稱,並指定此教學課程的「範例儀表板」 ,然後選取 [自訂完成] 。Edit the name of the dashboard and specify Sample Dashboard for this tutorial, and then select Done customizing.

儲存自訂的 Azure 儀表板Save customized Azure dashboard

當您建立儀表板時,它預設是私人用途,這表示只有您會看得到。When you create a dashboard, it is private by default, which means you are the only person who can see it. 若要讓其他人也能看見,請使用與其他儀表板命令一同出現的 [共用] 按鈕。To make it visible to others, use the Share button that appears alongside the other dashboard commands.

在 Azure 入口網站中共用新儀表板

系統會要求您選擇可將儀表板發佈至的訂用帳戶和資源群組。You are asked to choose a subscription and resource group for your dashboard to be published to. 為了方便起見,入口網站的發佈體驗會引導您朝向將儀表板放在稱為 儀表板的資源群組中的模式。For convenience, the portal's publishing experience guides you towards a pattern where you place dashboards in a resource group called dashboards. 確認選取的訂用帳戶,然後按一下[發行] 。Verify the subscription selected and then click Publish. 使用Azure 資源存取控制來控制對儀表板中顯示資訊的存取權。Access to the information displayed in the dashboard is controlled with Azure Resource Based Access Control.

以視覺化方式呈現記錄查詢Visualize a log query

Log Analytics 是專用的入口網站,用來處理記錄查詢及其結果。Log Analytics is a dedicated portal used to work with log queries and their results. 功能包括在多行上編輯查詢、選擇性執行程式碼、區分內容的 Intellisense 和 Smart Analytics。Features include the ability to edit a query on multiple lines, selectively execute code, context sensitive Intellisense, and Smart Analytics. 在本教學課程中,您將會使用 Log Analytics,以圖形的形式建立效能檢視,儲存以用於未來查詢,然後將其釘選在稍早建立的共用儀表板。In this tutorial, you will use Log Analytics to create a performance view in graphical form, save it for a future query, and pin it to the shared dashboard created earlier.

藉由選取 [Azure 監視器] 功能表中的 [記錄] 來開啟 Log Analytics。Open Log Analytics by selecting Logs in the Azure Monitor menu. 它會從新的空白查詢來開始。It starts with a new blank query.

首頁

輸入下列查詢,只為 Windows 和 Linux 電腦傳回處理器使用率記錄,依電腦和 TimeGenerated 分組並顯示在視覺化圖表中。Enter the following query to return processor utilization records for both Windows and Linux computers, grouped by Computer and TimeGenerated, and displayed in a visual chart. 按一下 [執行] 以執行查詢,並且檢視產生的圖表。Click Run to run the query and view the resulting chart.

Perf 
| where CounterName == "% Processor Time" and ObjectName == "Processor" and InstanceName == "_Total" 
| summarize AggregatedValue = avg(CounterValue) by bin(TimeGenerated, 1hr), Computer 
| render timechart

從頁面上方選取 [儲存] 按鈕來儲存查詢。Save the query by selecting the Save button from the top of the page.

儲存查詢

在 [儲存查詢] 控制台中,提供像是「Azure VM - 處理器使用率」 的名稱,和例如「儀表板」 的分類,然後按一下 [儲存] 。In the Save Query control panel, provide a name such as Azure VMs - Processor Utilization and a category such as Dashboards and then click Save. 這樣一來,您可以建立可使用及修改的常用查詢程式庫。This way you can create a library of common queries that you can use and modify. 最後,從頁面右上角選取 [釘選到儀表板] ,然後選取儀表板名稱,將此項目釘選在稍早建立的共用儀表板。Finally, pin this to the shared dashboard created earlier by selecting the Pin to dashboard button from the top right corner of the page and then selecting the dashboard name.

現在我們已將查詢釘選在儀表板,您會注意到其下方會有一般標題與註解。Now that we have a query pinned to the dashboard, you will notice it has a generic title and comment below it.

Azure 儀表板範例

我們應將它重新命名為有意義的名稱,讓檢視者容易了解。We should rename it to something meaningful that can be easily understood by those viewing it. 按一下 [編輯] 按鈕以自訂圖格的標題和子標題,然後按一下 [更新] 。Click the edit button to customize the title and subtitle for the tile, and then click Update. 橫幅隨即出現,要求您發行變更或捨棄。A banner will appear asking you to publish changes or discard. 按一下 [儲存複本] 。Click Save a copy.

已完成儀表板範例的設定

後續步驟Next steps

在本教學課程中,您已了解如何在 Azure 入口網站中建立儀表板,並新增記錄查詢。In this tutorial, you learned how to create a dashboard in the Azure portal and add a log query to it. 前進至下一個教學課程,以了解您可以根據記錄查詢結果實作的不同回應。Advance to the next tutorial to learn the different responses you can implement based on log query results.