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
一段时间内的函数活动
显示每个 Function 随时间推移的 Function 请求量趋势的折线图。
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