Reputation: 3711
I want to use Application Insights to analyse the logging output of my Azure Functions. If the logging output of a function execution contains at least one error, I want to see the whole logging output of that execution.
Starting point:
traces
| where severityLevel == 3
| where operation_Name == "MyFunctionName"
| project timestamp, operation_Name, message
But this only provides the errors themselves but not the other output of the function executions.
Upvotes: 1
Views: 2867
Reputation: 3711
For 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
All lines with the same operation_Id belong to one function execution.
For 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
All lines with the same invocationId belong to one function execution.
Upvotes: 3