ApiManagementGatewayLogs 數據表的查詢
如需在 Azure 入口網站 使用這些查詢的詳細資訊,請參閱Log Analytics教學課程。 如需 REST API,請參閱 查詢。
要求數目
計算過去 24 小時內所有 API 上的呼叫總數。
//Total number of call per resource
ApiManagementGatewayLogs
| where TimeGenerated > ago(1d)
| summarize count(CorrelationId) by _ResourceId
最後 100 個呼叫的記錄
取得過去 24 小時內最近 100 個呼叫的記錄。
ApiManagementGatewayLogs
| top 100 by TimeGenerated desc
API 的呼叫次數
檢視過去 24 小時內每個 API 的呼叫總數。
//Calls by API ID
ApiManagementGatewayLogs
| where TimeGenerated > ago(1d)
| summarize count(CorrelationId) by ApiId
耗用的頻寬
過去 24 小時內耗用的頻寬總數。
// To create an alert for this query, click '+ New alert rule'
ApiManagementGatewayLogs
| where TimeGenerated > ago(1d)
| extend bandwidth = RequestSize + ResponseSize
| summarize sum(bandwidth) by bin(TimeGenerated, 15m), _ResourceId
| render timechart
要求大小
過去 24 小時內要求大小的統計資料。
// To create an alert for this query, click '+ New alert rule'
ApiManagementGatewayLogs
| where TimeGenerated > ago(1d)
| summarize Average=avg(RequestSize), Median=percentile(RequestSize, 50), 90th_Percentile=percentile(RequestSize, 90) by bin(TimeGenerated, 5m)
| render timechart
回應大小
過去 24 小時內回應大小的統計資料。
// To create an alert for this query, click '+ New alert rule'
ApiManagementGatewayLogs
| where TimeGenerated > ago(1d)
| summarize Average=avg(ResponseSize), Median=percentile(ResponseSize, 50), 90th_Percentile=percentile(ResponseSize, 90) by bin(TimeGenerated, 5m)
| render timechart
用戶端 TLS 版本
過去 24 小時內用戶端 TLS 版本的明細。
ApiManagementGatewayLogs
| where TimeGenerated > ago(1d)
| summarize count(CorrelationId) by ClientTlsVersion, _ResourceId
錯誤原因明細
過去24小時內所有錯誤原因的細目。
// To create an alert for this query, click '+ New alert rule'
ApiManagementGatewayLogs
| where TimeGenerated > ago(1d)
| where IsRequestSuccess == false
| summarize count(CorrelationId) by LastErrorReason, _ResourceId
最後 100 個失敗的要求
取得最後 100 個失敗要求的記錄。
ApiManagementGatewayLogs
| where TimeGenerated > ago(1d)
| where IsRequestSuccess == false
| top 100 by TimeGenerated desc| where ResponseCode >= 400
因後端相關問題而取得失敗的要求
取得因為後端問題失敗的要求記錄。
// To create an alert for this query, click '+ New alert rule'
ApiManagementGatewayLogs
| where TimeGenerated > ago(1d)
| where IsRequestSuccess == false
| where BackendResponseCode >= 400
因為與後端無關的問題而取得失敗的要求
取得失敗要求的記錄,因為與後端無關的問題(例如 API 管理原則設定、超出速率限制、用戶端中斷連線)。
// To create an alert for this query, click '+ New alert rule'
ApiManagementGatewayLogs
| where TimeGenerated > ago(1d)
| where IsRequestSuccess == false
| where isnull(BackendResponseCode) or BackendResponseCode < 400
| where ResponseCode >= 400
整體延遲
API 管理開始接收要求的時間與 API 管理 完成將回應傳回用戶端之間的整體延遲統計數據(在 miliseconds 中)。
// To create an alert for this query, click '+ New alert rule'
ApiManagementGatewayLogs
| where TimeGenerated > ago(1d)
| summarize Average=avg(TotalTime), Median=percentile(TotalTime, 50), 90th_Percentile=percentile(TotalTime, 90) by bin(TimeGenerated, 15m)
| render timechart
後端延遲
在後端 IO 中花費的時間統計數據(以 miliseconds 為單位)。
// To create an alert for this query, click '+ New alert rule'
ApiManagementGatewayLogs
| where TimeGenerated > ago(1d)
| summarize Average=avg(BackendTime), Median=percentile(BackendTime, 50), 90th_Percentile=percentile(BackendTime, 90) by bin(TimeGenerated, 15m)
| render timechart
用戶端延遲
在用戶端 IO 中花費的時間統計數據(以 miliseconds 為單位)。
// To create an alert for this query, click '+ New alert rule'
ApiManagementGatewayLogs
| where TimeGenerated > ago(1d)
| summarize Average=avg(ClientTime), Median=percentile(ClientTime, 50), 90th_Percentile=percentile(ClientTime, 90) by bin(TimeGenerated, 15m)
| render timechart
快取命中率
快取點擊/遺漏比率的統計數據。
// To create an alert for this query, click '+ New alert rule'
ApiManagementGatewayLogs
| where TimeGenerated > ago(1d)
| summarize Cache_Miss=countif(Cache == "miss"), Cache_Hit=countif(Cache == "hit") by bin(TimeGenerated, 15m)
| extend Ratio=Cache_Hit / (Cache_Hit + Cache_Miss)
| project-away Cache_Hit , Cache_Miss
| render timechart