Azure Application Insights Cheat sheet
Some simple examples on what you can do with Application Insights logs
Exceptions, group by beginning of outerMessage:
exceptions
| summarize count() by tostring(split(outerMessage, "[")[0])
| order by count_ desc
Requests with 5xx response, group by name and statusCode
requests
| where toint(resultCode) >= 500
| summarize count() by name, resultCode
| order by count_ desc
Get List of all Request endpoints and their success rate
requests
| extend successRate = iff(success == true, 100.0, 0.0)
| summarize avg(successRate) by name
| where avg_successRate < 1
| order by avg_successRate asc
Get List of all Requests their non 5xx response rate
requests
| extend successRate = iff(toint(resultCode) >= 500, 0.0, 1.0)
| summarize avg(successRate) by name
| where avg_successRate < 1
| order by avg_successRate asc
Combine previous 2, show all requests with at least 1 4xx response or 5xx response and show percentage for both 5xx and 4xx
requests
| extend percent500 = iff(toint(resultCode) >= 500, 100.0, 0.0)
| summarize avg(percent500) by name
| join
(
requests
| extend percent400 = iff(toint(resultCode) >= 400 and toint(resultCode) < 500, 100.0, 0.0)
| summarize avg(percent400) by name
) on name
| project name, avg_percent500, avg_percent400
| where avg_percent500 > 0 or avg_percent400 > 0
| order by avg_percent500, avg_percent400
Join Requests with Exceptions. Assuming both have Custom properties named customDimensions show count by outer Exception message
requests
| where name contains "ENDPOINT_NAME"
| join exceptions on operation_Id
| summarize count() by tostring(split(tostring(customDimensions1["FormattedMessage"]), "[")[0])
See which requests exceptions are coming from base on the the exception outerMessage
exceptions
| where outerMessage startswith "Unhandled error:"
| join requests on operation_Id
| summarize count() by name
Render column chart for resultCode over time for a specific request
requests
| where name contains "REQUEST_NAME"
| summarize count() by bin(timestamp,1d), resultCode
| render columnchart