Application Insights 記錄型計量

Application Insights 以記錄為基礎的計量可讓您分析受監視應用程式的健康情況、建立功能強大的儀表板,以及設定警示。 計量有兩種:

因為標準計量會在收集期間預先彙總,其在查詢時具有更好的效能。 這讓標準計量成為儀表板和即時警示的較佳選擇。 以記錄為基礎的計量有更多維度,讓其成為資料分析和臨機操作診斷的優先選項。 使用命名空間選取器,在計量瀏覽器中以記錄為基礎和標準計量之間切換。

解譯和使用本文的查詢

本文列出支持匯總和維度的計量。 記錄型計量的詳細數據包括基礎 Kusto 查詢語句。 為了方便起見,每個查詢都會使用時間粒度、圖表類型,有時會分割維度,以簡化在Log Analytics中使用查詢,而不需要修改。

當您在計量總管中繪製相同的計量時,沒有預設值 - 會根據您的圖表設定動態調整查詢:

  • 選取 的時間範圍 會轉譯為額外的 where timestamp... 子句,以便只從選取的時間範圍挑選事件。 例如,顯示最近 24 小時數據的圖表,查詢會包含 | where timestamp > ago(24 h)

  • 選取 的時間粒度 會放入最終 摘要中...by bin(timestamp, [time grain]) 子句。

  • 任何選取 的篩選 維度會轉譯成其他 where 子句。

  • 選取 的分割圖表 維度會轉譯為額外的summarize屬性。 例如,如果您依位置分割圖表,並使用 5 分鐘的時間粒度繪製,則 summarize 子句會摘要化...依 bin(時間戳,5 m),位置

注意

如果您不熟悉 Kusto 查詢語言,請先將 Kusto 語句複製並貼到 Log Analytics 查詢窗格中,而不進行任何修改。 按兩下 [ 執行 ] 以查看基本圖表。 當您開始瞭解查詢語言的語法時,您可以開始進行小型修改,並查看變更的影響。 探索您自己的數據是開始實現Log AnalyticsAzure 監視器完整功能的絕佳方式。

可用性計量

[可用性] 類別中的計量可讓您查看 Web 應用程式的健康情況,如世界各地的點所觀察到。 設定可用性測試 ,以從這個類別開始使用任何計量。

可用性 (availabilityResults/availabilityPercentage)

可用性計量會顯示未偵測到任何問題的 Web 測試回合百分比。 可能最低的值為 0,表示所有 Web 測試回合都失敗。 100 的值表示所有 Web 測試回合都通過驗證準則。

測量單位 支援的匯總 支援的維度
百分比 平均 執行位置、測試名稱
availabilityResults 
| summarize sum(todouble(success == 1) * 100) / count() by bin(timestamp, 5m), location
| render timechart

可用性測試持續時間 (availabilityResults/duration)

可用性測試持續時間計量會顯示 Web 測試執行所花費的時間。 針對多步驟 Web 測試,計量會反映所有步驟的總運行時間。

測量單位 支援的匯總 支援的維度
毫秒 Average、Min、Max 執行位置、測試名稱、測試結果
availabilityResults
| where notempty(duration)
| extend availabilityResult_duration = iif(itemType == 'availabilityResult', duration, todouble(''))
| summarize sum(availabilityResult_duration)/sum(itemCount) by bin(timestamp, 5m), location
| render timechart

可用性測試 (availabilityResults/count)

可用性測試計量會反映 Azure 監視器所執行的 Web 測試計數。

測量單位 支援的匯總 支援的維度
Count Count 執行位置、測試名稱、測試結果
availabilityResults
| summarize sum(itemCount) by bin(timestamp, 5m)
| render timechart

瀏覽器計量

瀏覽器計量是由 Application Insights JavaScript SDK 從實際的終端使用者瀏覽器收集。 他們提供您 Web 應用程式使用者體驗的絕佳見解。 瀏覽器計量通常不會取樣,這表示相較於可能因取樣而扭曲的伺服器端計量,它們提供使用量號碼的精確度較高。

注意

若要收集瀏覽器計量,您的應用程式必須使用Application Insights JavaScript SDK 進行檢測

瀏覽器頁面載入時間 (browserTimings/totalDuration)

從使用者要求到載入 DOM、樣式表單、腳本和影像的時間。

測量單位 支援的匯總 預先匯總的維度
毫秒 Average、Min、Max
browserTimings
| where notempty(totalDuration)
| extend _sum = totalDuration
| extend _count = itemCount
| extend _sum = _sum * _count
| summarize sum(_sum) / sum(_count) by bin(timestamp, 5m)
| render timechart

用戶端處理時間 (browserTiming/processingDuration)

在載入 DOM 之前,接收檔最後一個字節之間的時間。 異步要求可能仍在處理中。

測量單位 支援的匯總 預先匯總的維度
毫秒 Average、Min、Max
browserTimings
| where notempty(processingDuration)
| extend _sum = processingDuration
| extend _count = itemCount
| extend _sum = _sum * _count
| summarize sum(_sum)/sum(_count) by bin(timestamp, 5m)
| render timechart

頁面載入網路連線時間 (browserTimings/networkDuration)

使用者要求與網路連線之間的時間。 包含 DNS 查閱和傳輸連線。

測量單位 支援的匯總 預先匯總的維度
毫秒 Average、Min、Max
browserTimings
| where notempty(networkDuration)
| extend _sum = networkDuration
| extend _count = itemCount
| extend _sum = _sum * _count
| summarize sum(_sum) / sum(_count) by bin(timestamp, 5m)
| render timechart

接收回應時間 (browserTimings/receiveDuration)

第一個字節與最後一個字節之間的時間,或直到中斷連線為止。

測量單位 支援的匯總 預先匯總的維度
毫秒 Average、Min、Max
browserTimings
| where notempty(receiveDuration)
| extend _sum = receiveDuration
| extend _count = itemCount
| extend _sum = _sum * _count
| summarize sum(_sum) / sum(_count) by bin(timestamp, 5m)
| render timechart

傳送要求時間 (browserTimings/sendDuration)

網路連線與接收第一個字節之間的時間。

測量單位 支援的匯總 預先匯總的維度
毫秒 Average、Min、Max
browserTimings
| where notempty(sendDuration)
| extend _sum = sendDuration
| extend _count = itemCount
| extend _sum = _sum * _count
| summarize sum(_sum) / sum(_count) by bin(timestamp, 5m)
| render timechart

失敗計量

失敗中的計量會顯示處理要求、相依性呼叫和擲回例外狀況的問題。

瀏覽器例外狀況(例外狀況/瀏覽器)

此計量會反映在瀏覽器中執行之應用程式程式代碼擲回的例外狀況數目。 計量中只會包含使用 trackException() Application Insights API呼叫追蹤的例外狀況。

測量單位 支援的匯總 預先匯總的維度 備註
Count Count 記錄型版本使用 Sum 匯總
exceptions
| where notempty(client_Browser)
| summarize sum(itemCount) by bin(timestamp, 5m)
| render barchart

相依性呼叫失敗 (相依性/失敗)

失敗的相依性呼叫數目。

測量單位 支援的匯總 預先匯總的維度 備註
Count Count 記錄型版本使用 Sum 匯總
dependencies
| where success == 'False'
| summarize sum(itemCount) by bin(timestamp, 5m)
| render barchart

例外狀況(例外狀況/計數)

每次將例外狀況記錄至 Application Insights 時,都會呼叫 SDK 的 trackException() 方法 。 [例外狀況] 計量會顯示已記錄的例外狀況數目。

測量單位 支援的匯總 預先匯總的維度 備註
Count Count 雲端角色名稱、雲端角色實例、裝置類型 記錄型版本使用 Sum 匯總
exceptions
| summarize sum(itemCount) by bin(timestamp, 5m)
| render barchart

失敗的要求(要求/失敗)

標示為 失敗的追蹤伺服器要求計數。 根據預設,Application Insights SDK 會自動將傳回 HTTP 回應碼 5xx 或 4xx 的每個伺服器要求標示為失敗的要求。 您可以修改自定義遙測初始化表達式要求遙測專案的成功屬性,以自定義此邏輯。

測量單位 支援的匯總 預先匯總的維度 備註
Count Count 雲端角色實例、雲端角色名稱、實際或綜合流量、要求效能、回應碼 記錄型版本使用 Sum 匯總
requests
| where success == 'False'
| summarize sum(itemCount) by bin(timestamp, 5m)
| render barchart

伺服器例外狀況(例外狀況/伺服器)

此計量會顯示伺服器例外狀況的數目。

測量單位 支援的匯總 預先匯總的維度 備註
Count Count 雲端角色名稱、雲端角色實例 記錄型版本使用 Sum 匯總
exceptions
| where isempty(client_Browser)
| summarize sum(itemCount) by bin(timestamp, 5m)
| render barchart

效能計數器

使用性能計數器類別中的計量來存取 Application Insights 收集的系統性能計數器。

可用的記憶體 (performanceCounters/availableMemory)

performanceCounters
| where ((category == "Memory" and counter == "Available Bytes") or name == "availableMemory")
| extend performanceCounter_value = iif(itemType == "performanceCounter", value, todouble(''))
| summarize sum(performanceCounter_value) / count() by bin(timestamp, 1m)
| render timechart

例外狀況率 (performanceCounters/exceptionRate)

performanceCounters
| where ((category == ".NET CLR Exceptions" and counter == "# of Exceps Thrown / sec") or name == "exceptionRate")
| extend performanceCounter_value = iif(itemType == 'performanceCounter',value,todouble(''))
| summarize sum(performanceCounter_value) / count() by bin(timestamp, 1m)
| render timechart

HTTP 要求運行時間 (performanceCounters/requestExecutionTime)

performanceCounters
| where ((category == "ASP.NET Applications" and counter == "Request Execution Time") or name == "requestExecutionTime")
| extend performanceCounter_value = iif(itemType == "performanceCounter", value, todouble(''))
| summarize sum(performanceCounter_value) / count() by bin(timestamp, 1m)
| render timechart

HTTP 要求率 (performanceCounters/requestsPerSecond)

performanceCounters
| where ((category == "ASP.NET Applications" and counter == "Requests/Sec") or name == "requestsPerSecond")
| extend performanceCounter_value = iif(itemType == "performanceCounter", value, todouble(''))
| summarize sum(performanceCounter_value) / count() by bin(timestamp, 1m)
| render timechart

應用程式佇列中的 HTTP 要求 (performanceCounters/requestsInQueue)

performanceCounters
| where ((category == "ASP.NET Applications" and counter == "Requests In Application Queue") or name == "requestsInQueue")
| extend performanceCounter_value = iif(itemType == "performanceCounter", value, todouble(''))
| summarize sum(performanceCounter_value) / count() by bin(timestamp, 1m)
| render timechart

進程 CPU (performanceCounters/processCpuPercentage)

計量會顯示裝載受監視應用程式的進程所耗用的處理器容量總數。

測量單位 支援的匯總 支援的維度
百分比 Average、Min、Max 雲端角色執行個體
performanceCounters
| where ((category == "Process" and counter == "% Processor Time Normalized") or name == "processCpuPercentage")
| extend performanceCounter_value = iif(itemType == "performanceCounter", value, todouble(''))
| summarize sum(performanceCounter_value) / count() by bin(timestamp, 1m)
| render timechart

注意

計量的範圍介於 0 到 100 * n 之間,其中 n 是可用的 CPU 核心數目。 例如,200% 的計量值可能代表兩個 CPU 核心的完整使用率,或 4 個 CPU 核心的半使用率等等。 進程 CPU 標準化是由許多 SDK 所收集的替代計量,代表相同的值,但將其除以可用的 CPU 核心數目。 因此,進程 CPU 標準化計量的範圍是 0 到 100。

處理 IO 速率 (performanceCounters/processIOBytesPerSecond)

測量單位 支援的匯總 支援的維度
每秒位元組數 Average、Min、Max 雲端角色執行個體
performanceCounters
| where ((category == "Process" and counter == "IO Data Bytes/sec") or name == "processIOBytesPerSecond")
| extend performanceCounter_value = iif(itemType == "performanceCounter", value, todouble(''))
| summarize sum(performanceCounter_value) / count() by bin(timestamp, 1m)
| render timechart

處理私人位元組 (performanceCounters/processPrivateBytes)

受監視進程為其數據配置的非共用記憶體數量。

測量單位 支援的匯總 支援的維度
Bytes Average、Min、Max 雲端角色執行個體
performanceCounters
| where ((category == "Process" and counter == "Private Bytes") or name == "processPrivateBytes")
| extend performanceCounter_value = iif(itemType == "performanceCounter", value, todouble(''))
| summarize sum(performanceCounter_value) / count() by bin(timestamp, 1m)
| render timechart

處理器時間(performanceCounters/processorCpuPercentage)

監視伺服器實例上執行的所有 進程都會耗用CPU。

測量單位 支援的匯總 支援的維度
百分比 Average、Min、Max 雲端角色執行個體

注意

處理器時間計量不適用於裝載於 Azure App 服務的應用程式。 使用進程 CPU 計量來追蹤載入於 App Services 中的 Web 應用程式的 CPU 使用率。

performanceCounters
| where ((category == "Processor" and counter == "% Processor Time") or name == "processorCpuPercentage")
| extend performanceCounter_value = iif(itemType == "performanceCounter", value, todouble(''))
| summarize sum(performanceCounter_value) / count() by bin(timestamp, 1m)
| render timechart

伺服器計量

相依性呼叫 (相依性/計數)

此計量與相依性呼叫數目有關。

dependencies
| summarize sum(itemCount) by bin(timestamp, 5m)
| render barchart

相依性持續時間 (相依性/持續時間)

此計量是指相依性呼叫的持續時間。

dependencies
| where notempty(duration)
| extend dependency_duration = iif(itemType == 'dependency',duration,todouble(''))
| extend _sum = dependency_duration
| extend _count = itemCount
| extend _sum = _sum*_count
| summarize sum(_sum)/sum(_count) by bin(timestamp, 1m)
| render timechart

伺服器要求 (要求/計數)

此計量會反映 Web 應用程式收到的連入伺服器要求數目。

requests
| summarize sum(itemCount) by bin(timestamp, 5m)
| render barchart

伺服器回應時間 (要求/持續時間)

此計量會反映伺服器處理連入要求所需的時間。

requests
| where notempty(duration)
| extend request_duration = iif(itemType == 'request', duration, todouble(''))
| extend _sum = request_duration
| extend _count = itemCount
| extend _sum = _sum*_count
| summarize sum(_sum) / sum(_count) by bin(timestamp, 1m)
| render timechart

使用量指標

頁面檢視載入時間 (pageViews/duration)

此計量是指PageView事件載入所花費的時間量。

pageViews
| where notempty(duration)
| extend pageView_duration = iif(itemType == 'pageView', duration, todouble(''))
| extend _sum = pageView_duration
| extend _count = itemCount
| extend _sum = _sum * _count
| summarize sum(_sum) / sum(_count) by bin(timestamp, 5m)
| render barchart

頁面檢視 (pageViews/count)

使用 TrackPageView() Application Insights API 記錄的 PageView 事件計數。

pageViews
| summarize sum(itemCount) by bin(timestamp, 1h)
| render barchart

工作階段 (工作階段/計數)

此計量是指相異會話標識碼的計數。

union traces, requests, pageViews, dependencies, customEvents, availabilityResults, exceptions, customMetrics, browserTimings
| where notempty(session_Id)
| summarize dcount(session_Id) by bin(timestamp, 1h)
| render barchart

追蹤 (追蹤/計數)

使用 TrackTrace() Application Insights API 呼叫所記錄的追蹤語句計數。

traces
| summarize sum(itemCount) by bin(timestamp, 1h)
| render barchart

使用者 (使用者/計數)

存取您應用程式的不同用戶數目。 此計量的精確度可能會受到使用遙測取樣和篩選的影響。

union traces, requests, pageViews, dependencies, customEvents, availabilityResults, exceptions, customMetrics, browserTimings
| where notempty(user_Id)
| summarize dcount(user_Id) by bin(timestamp, 1h)
| render barchart

使用者、已驗證 (使用者/已驗證)

已向您的應用程式驗證的不同用戶數目。

union traces, requests, pageViews, dependencies, customEvents, availabilityResults, exceptions, customMetrics, browserTimings
| where notempty(user_AuthenticatedId)
| summarize dcount(user_AuthenticatedId) by bin(timestamp, 1h)
| render barchart