我想使用Application Insights来分析Azure功能的日志输出。如果函数执行的日志记录输出包含至少一个错误,我想查看该执行的整个日志记录输出。
初始点:
traces
| where severityLevel == 3
| where operation_Name == "MyFunctionName"
| project timestamp, operation_Name, message
但这仅提供错误本身,而不是函数执行的其他输出。
对于Azure Functions V1:
traces
| where severityLevel == 3
| where operation_Id != ""
| where operation_Name == "MyFunctionName"
| project operation_Name , operation_Id, severityLevel
| join (traces | project timestamp, operation_Id, message ) on operation_Id
| project timestamp, operation_Name, operation_Id, message
具有相同operation_Id的所有行都属于一个函数执行。
对于Azure Functions V2:
traces
| extend invocationId = tostring(customDimensions.InvocationId)
| where severityLevel == 3
| where invocationId != ""
| where operation_Name == "MyFunctionName"
| project operation_Name, severityLevel, invocationId
| join (traces |extend invocationId = tostring(customDimensions.InvocationId)| project timestamp, invocationId, message ) on invocationId
| project timestamp, operation_Name, message, invocationId
具有相同invocationId的所有行都属于一个函数执行。