在 Application Insights 中探索度量Exploring Metrics in Application Insights

Application Insights 中的度量為從您的應用程式傳送的遙測中的測量值和事件計數。Metrics in Application Insights are measured values and counts of events that are sent in telemetry from your application. 它們幫助您偵測效能問題,並觀察使用應用程式方式的趨勢。They help you detect performance issues and watch trends in how your application is being used. 標準度量的範圍很廣泛,而您也可以建立自己的自訂度量和事件。There's a wide range of standard metrics, and you can also create your own custom metrics and events.

注意

這篇文章將告訴您目前已過時,且最終將遭到淘汰的傳統計量瀏覽器體驗。This article describes the classic metrics explorer experience which is currently deprecated and will eventually be retired. 建議您了解這篇文章中描述的新體驗。We recommend checking out the new experience which is described in this article.

度量和事件計數會顯示在彙總值 (例如總和、平均或計數) 的圖表中。Metrics and event counts are displayed in charts of aggregated values such as sums, averages, or counts.

以下是一組範例圖表︰Here's a sample set of charts:

您可在 Application Insights 入口網站中找到度量圖表。You find metrics charts everywhere in the Application Insights portal. 在大部分情況下,您可以自訂它們,而且您可以將更多圖表新增至刀鋒視窗。In most cases, they can be customized, and you can add more charts to the blade. 從 [概觀] 刀鋒視窗中,按一下以取得更詳細的圖表 (有「伺服器」之類的標題),或按一下 [計量瀏覽器] ,以開啟新的刀鋒視窗讓您建立自訂圖表。From the Overview blade, click through to more detailed charts (which have titles such as "Servers"), or click Metrics Explorer to open a new blade where you can create custom charts.

時間範圍Time range

您可以在任何刀鋒視窗上變更圖表或格線涵蓋的時間範圍。You can change the Time range covered by the charts or grids on any blade.

開啟 Azure 入口網站中應用程式的 [概觀] 刀鋒視窗

如果您預期的部分資料尚未出現,請按一下 [重新整理]。If you're expecting some data that hasn't appeared yet, click Refresh. 圖表本身會定期重新整理,但是時間範圍越大,間隔時間會越長。Charts refresh themselves at intervals, but the intervals are longer for larger time ranges. 資料從分析管線往圖表上顯示可能需要一些時間。It can take a while for data to come through the analysis pipeline onto a chart.

若要放大圖表的局部,請拖曳過該部分︰To zoom into part of a chart, drag over it:

拖曳過圖表的一部分。

按一下 [復原縮放] 按鈕可將它還原。Click the Undo Zoom button to restore it.

資料粒度和點值Granularity and point values

將滑鼠移至圖表上可顯示該點度量的值。Hover your mouse over the chart to display the values of the metrics at that point.

將滑鼠移至圖表上

特定點的度量值會繼著前一個取樣間隔而彙總。The value of the metric at a particular point is aggregated over the preceding sampling interval.

取樣間隔或「資料粒度」會顯示在刀鋒視窗的頂端。The sampling interval or "granularity" is shown at the top of the blade.

刀鋒視窗的標題。

您可以在時間範圍刀鋒視窗中調整資料粒度:You can adjust the granularity in the Time range blade:

刀鋒視窗的標題。

可提供的資料粒度取決於您選取的時間範圍。The granularities available depend on the time range you select. 明確的資料粒度可替代時間範圍內的「自動」資料粒度。The explicit granularities are alternatives to the "automatic" granularity for the time range.

編輯圖表和格線Editing charts and grids

若要對刀鋒視窗加入新圖表:To add a new chart to the blade:

在 [計量瀏覽器] 中,選擇 [加入圖表]

選取現有或新圖表上的 [編輯] 來編輯其顯示的內容:Select Edit on an existing or new chart to edit what it shows:

選取一或多個度量

您可以在圖表上顯示一個以上的度量,不過,可以一起顯示的組合有一些限制。You can display more than one metric on a chart, though there are restrictions about the combinations that can be displayed together. 只要您選取一個度量,便會停用某些其他度量。As soon as you choose one metric, some of the others are disabled.

如果您編寫自訂度量到您的應用程式 (對 TrackMetric 和 TrackEvent 呼叫),會在這裡予以列出。If you coded custom metrics into your app (calls to TrackMetric and TrackEvent) they will be listed here.

分段資料Segment your data

您可以依照屬性分割度量 - 例如,比較使用不同作業系統的用戶端上的頁面檢視。You can split a metric by property - for example, to compare page views on clients with different operating systems.

選取圖表或格線,將分組切換成開啟,並選取要分組依據的屬性:Select a chart or grid, switch on grouping and pick a property to group by:

選取 [分組開啟],然後在 [群組依據] 中選取屬性

注意

當您使用群組時,[區域] 及 [橫條圖] 類型會提供堆疊的顯示。When you use grouping, the Area and Bar chart types provide a stacked display. 這適合於 [彙總] 方法是 [加總] 的情況。This is suitable where the Aggregation method is Sum. 但如果彙總類型是 [平均],則選擇 [線條] 或[格線] 顯示類型。But where the aggregation type is Average, choose the Line or Grid display types.

如果您將自訂度量編寫至您的應用程式,並且它們包含屬性值,將可以在清單中選取屬性。If you coded custom metrics into your app and they include property values, you'll be able to select the property in the list.

圖表是否對分段的資料來說太小?Is the chart too small for segmented data? 調整其高度:Adjust its height:

調整滑桿

彙總類型Aggregation types

旁邊的圖例通常預設會顯示圖表在這段期間的彙總值。The legend at the side by default usually shows the aggregated value over the period of the chart. 如果您將滑鼠停留在圖表上,它會顯示在該點的值。If you hover over the chart, it shows the value at that point.

圖表上的每個資料點是在先前取樣間隔或「資料粒度」中所收到的資料值彙總。Each data point on the chart is an aggregate of the data values received in the preceding sampling interval or "granularity". 資料粒度會顯示在刀鋒視窗頂端,並隨著圖表的時幅而有所不同。The granularity is shown at the top of the blade, and varies with the overall timescale of the chart.

度量可以用不同方式彙總:Metrics can be aggregated in different ways:

  • 計數是在取樣間隔中接收到的事件計數。Count is a count of the events received in the sampling interval. 它用於事件,例如要求。It is used for events such as requests. 圖表的高度變化指出事件發生的速率變化。Variations in the height of the chart indicates variations in the rate at which the events occur. 但請注意,數字的值會隨變更取樣間隔而變更。But note that the numeric value changes when you change the sampling interval.

  • 總和 :將取樣間隔或圖表期間收到的所有資料點的值相加。Sum adds up the values of all the data points received over the sampling interval, or the period of the chart.

  • 平均 :將總和除以間隔期間收到的資料點數目。Average divides the Sum by the number of data points received over the interval.

  • 唯一 :計數會用於使用者及帳戶的計數。Unique counts are used for counts of users and accounts. 在取樣間隔或圖表期間,圖形顯示在該時間看到的不同使用者的計數。Over the sampling interval, or over the period of the chart, the figure shows the count of different users seen in that time.

  • % - 每個彙總百分比版本只會搭配分段圖表使用。% - percentage versions of each aggregation are used only with segmented charts. 總計永遠會加總至 100%,圖表會顯示總計的不同元件之相對貢獻。The total always adds up to 100%, and the chart shows the relative contribution of different components of a total.

    百分比彙總

變更彙總類型Change the aggregation type

編輯圖表,然後選取彙總

當您建立新的圖表或所有度量皆已取消選取時,會顯示每個度量的預設方法:The default method for each metric is shown when you create a new chart or when all metrics are deselected:

取消選取所有度量以查看預設值

釘選 Y 軸Pin Y-axis

根據預設,圖表會顯示資料範圍中從零到最大值的 Y 軸值,以提供值配量的視覺表示法。By default a chart shows Y axis values starting from zero till maximum values in the data range, to give a visual representation of quantum of the values. 但是在某些超過配量的情況下,以視覺化方式檢查值的些微變化可能有興趣。But in some cases more than the quantum it might be interesting to visually inspect minor changes in values. 對於類似這種的自訂,請使用 Y 軸範圍編輯功能,將 Y 軸的最小值或最大值釘選在所要的位置。For customizations like this use the Y-axis range editing feature to pin the Y-axis minimum or maximum value at desired place. 按一下 [進階設定] 核取方塊以顯示 [Y 軸範圍] 設定Click on "Advanced Settings" check box to bring up the Y-axis range Settings

按一下 [進階設定]、選取 [自訂範圍],然後指定最小值與最大值

篩選資料Filter your data

若只要查看選取的一組屬性值的度量:To see just the metrics for a selected set of property values:

按一下 [篩選器],然後檢查一些值

如果您不為特定屬性選取任何值,這與將它們全選相同:該屬性上沒有篩選器。If you don't select any values for a particular property, it's the same as selecting them all: there is no filter on that property.

請注意每個屬性值旁的事件計數。Notice the counts of events alongside each property value. 選取一個屬性的值時,會調整計數與其他屬性值。When you select values of one property, the counts alongside other property values are adjusted.

篩選會套用至刀鋒視窗上的所有圖表。Filters apply to all the charts on a blade. 如果您要將不同的篩選套用到不同的圖表,請建立並儲存不同的計量刀鋒視窗。If you want different filters applied to different charts, create and save different metrics blades. 如果想要,您可以將不同刀鋒視窗中的圖表釘選到儀表板,以便並排查看兩者。If you want, you can pin charts from different blades to the dashboard, so that you can see them alongside each other.

移除 Bot 和 Web 測試流量Remove bot and web test traffic

使用篩選器真實或綜合流量並勾選真實Use the filter Real or synthetic traffic and check Real.

您也可以依 綜合流量的來源篩選。You can also filter by Source of synthetic traffic.

將屬性加入篩選器清單To add properties to the filter list

您要根據自己選擇的類別篩選遙測嗎?Would you like to filter telemetry on a category of your own choosing? 例如,您可能將使用者劃分成不同的類別,且您想要依照這些類別來分割資料。For example, maybe you divide up your users into different categories, and you would like segment your data by these categories.

建立您自己的屬性Create your own property. 遙測初始設定式 中設定,以使其顯示在所有遙測中 - 包括不同 SDK 模組所傳送的標準遙測。Set it in a Telemetry Initializer to have it appear in all telemetry - including the standard telemetry sent by different SDK modules.

編輯圖表類型Edit the chart type

請注意您可以在格線與圖形之間切換:Notice that you can switch between grids and graphs:

選取格線或圖表,然後選擇圖表類型

儲存您的度量刀鋒視窗Save your metrics blade

建立一些圖表後,請將它們儲存為我的最愛。When you've created some charts, save them as a favorite. 如果您使用組織帳戶,可以選擇是否要將它與他小組成員分享。You can choose whether to share it with other team members, if you use an organizational account.

選擇 [我的最愛]

若要再次查看分頁,請 前往 [概觀] 分頁 ,並開啟 [我的最愛]:To see the blade again, go to the overview blade and open Favorites:

在 [概觀] 刀鋒視窗中,選擇 [我的最愛]

如果儲存時選擇「相對」時間範圍,會以最新度量更新刀鋒視窗。If you chose Relative time range when you saved, the blade will be updated with the latest metrics. 如果選擇「絕對」時間範圍,它會每次都顯示相同資料。If you chose Absolute time range, it will show the same data every time.

重設刀鋒視窗Reset the blade

如果您編輯刀鋒視窗,但之後想要回到原始儲存的集合,只需要按一下 [重設]。If you edit a blade but then you'd like to get back to the original saved set, just click Reset.

在 [計量瀏覽器] 上方的按鈕中

即時計量串流Live metrics stream

如需更加立即的遙測檢視,請開啟即時串流For a much more immediate view of your telemetry, open Live Stream. 因為彙總程序,大部分的計量需要數分鐘才會出現。Most metrics take a few minutes to appear, because of the process of aggregation. 相較之下,即時計量已針對低延遲進行最佳化。By contrast, live metrics are optimized for low latency.

設定警示Set alerts

若要在任何度量有不尋常的值時收到電子郵件通知,請加入警示。To be notified by email of unusual values of any metric, add an alert. 您可以選擇將電子郵件傳送給帳戶管理員,或傳送給特定的電子郵件地址。You can choose either to send the email to the account administrators, or to specific email addresses.

在 [計量瀏覽器] 中,選擇 [警示規則],然後選擇 [加入警示]

深入了解警示Learn more about alerts.

連續匯出Continuous Export

如果您想要連續匯出資料,讓您能夠在外部加以處理,請考慮使用 連續匯出If you want data continuously exported so that you can process it externally, consider using Continuous export.

Power BIPower BI

如果您希望更完整地檢視您的資料,您可以 匯出至 Power BIIf you want even richer views of your data, you can export to Power BI.

分析Analytics

分析 是使用強大的查詢語言來分析遙測的更靈活方式。Analytics is a more versatile way to analyze your telemetry using a powerful query language. 如果您想要合併或計算計量的結果,或執行您應用程式近期效能的深入探索,請使用它。Use it if you want to combine or compute results from metrics, or perform an in-depth exploration of your app's recent performance.

從計量圖表中,您可以按一下 [分析] 圖示,直接前往對應的分析查詢。From a metric chart, you can click the Analytics icon to get directly to the equivalent Analytics query.

疑難排解Troubleshooting

我看不到我的圖表上的任何資料。I don't see any data on my chart.

  • 篩選會套用至刀鋒視窗上的所有圖表。Filters apply to all the charts on the blade. 請確定,當您將焦點放在某個圖表時,您未在其他圖表上設定會排除所有資料的篩選。Make sure that, while you're focusing on one chart, you didn't set a filter that excludes all the data on another.

    如果您想要在不同的圖表上設定不同的篩選,請在不同的刀鋒視窗中建立圖表,將它們儲存為個別的最愛圖表。If you want to set different filters on different charts, create them in different blades, save them as separate favorites. 如果想要,您可以將這些圖表釘選到儀表板,以便並排查看兩者。If you want, you can pin them to the dashboard so that you can see them alongside each other.

  • 如果您依據計量上未定義的屬性將圖表分組,則圖表上不會有任何資料。If you group a chart by a property that is not defined on the metric, then there will be nothing on the chart. 請嘗試清除 [分組依據],或選擇不同的群組屬性。Try clearing 'group by', or choose a different grouping property.

  • 效能資料 (CPU、IO 速率等等) 適用於 Java Web 服務、Windows 傳統型應用程式、IIS Web 應用程式和服務 (若您安裝狀態監視器)Azure 雲端服務Performance data (CPU, IO rate, and so on) is available for Java web services, Windows desktop apps, IIS web apps and services if you install status monitor, and Azure Cloud Services. 它不適用於 Azure 網站。It isn't available for Azure websites.

影片Video

後續步驟Next steps