ApplicationInsights:如何查询包含错误的azure函数执行的完整跟踪?

问题描述 投票:0回答:1

我想使用Application Insights来分析Azure功能的日志输出。如果函数执行的日志记录输出包含至少一个错误,我想查看该执行的整个日志记录输出。

初始点:

traces 
| where severityLevel == 3
| where operation_Name == "MyFunctionName" 
| project timestamp, operation_Name, message

但这仅提供错误本身,而不是函数执行的其他输出。

azure azure-functions azure-application-insights
1个回答
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的所有行都属于一个函数执行。

© www.soinside.com 2019 - 2024. All rights reserved.