我想使用Application Insights分析我的Azure Functions的日志记录输出。如果一个函数执行的日志输出至少包含一个错误,那么我想查看该执行的整个日志输出。
起点:
traces
| where severityLevel == 3
| where operation_Name == "MyFunctionName"
| project timestamp, operation_Name, message
但这仅提供错误本身,而不提供函数执行的其他输出。
答案 0 :(得分:1)
对于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的行都属于一个函数执行。