共用方式為


FunctionAppLogs 數據表的查詢

如需在 Azure 入口網站 中使用這些查詢的詳細資訊,請參閱Log Analytics教學課程。 如需 REST API,請參閱 查詢

顯示函式應用程式的應用程式記錄

應用程式記錄的清單,依時間排序(第一次顯示的最新記錄)。

FunctionAppLogs 
| project TimeGenerated, HostInstanceId, Message, _ResourceId
| sort by TimeGenerated desc

顯示具有警告或例外狀況的記錄

包含警告或例外狀況的記錄清單(第一次顯示的最新記錄)。

FunctionAppLogs
| where Level == "Warning" or Level == "Error"
| project TimeGenerated, HostInstanceId, Level, Message, _ResourceId
| sort by TimeGenerated desc

錯誤與例外狀況計數

顯示每個應用程式過去一小時內包含警告或錯誤的記錄數目柱形圖。

FunctionAppLogs 
| where TimeGenerated > ago(1h)
| where Level == "Warning" or Level == "Error"
| summarize count_per_app = count() by _ResourceId
| sort by count_per_app desc 
| render columnchart

一段時間的函式活動

折線圖顯示一段時間內函式要求量的趨勢。

FunctionAppLogs
//| where _ResourceId == "MyResourceId" // Uncomment and enter a resource ID to get results for a specific resource
| where Category startswith "Function." and Message startswith "Executed "
| summarize count() by bin(TimeGenerated, 1h), FunctionName // Aggregate by hour
| render timechart

函式結果

個別函式調用會產生最後一個小時(第一次顯示的最新記錄)。

FunctionAppLogs
| where TimeGenerated > ago(1h)
| where Category startswith "Function." and Message startswith "Executed "
| parse Message with "Executed '" Name "' ("  Result ", Id=" Id ", Duration=" Duration:long "ms)"
| project TimeGenerated, FunctionName, Result, FunctionInvocationId, Duration, _ResourceId
| sort by TimeGenerated desc

函式錯誤率

每小時摘要函式成功和錯誤。

FunctionAppLogs
| where Category startswith "Function." and Message startswith "Executed "
| parse Message with "Executed '" Name "' ("  Result ", Id=" Id ", Duration=" Duration:long "ms)"
// | where Name == "MyFunction" // Use this to restrict to a specific function
| summarize count() by bin(TimeGenerated, 1h), Name, Result, _ResourceId
| order by TimeGenerated desc