Querying Logs in Application Insights#

Using the Application Insights service is a great way to log info about your application, but sometimes reading the logs can be a little difficult. The Kusto queries below show an example of how you can query the logs generated by your application, which are stored in the Application Insights service and can be viewed in the Azure Portal.

View log entries in Application Insights#

traces 
| project timestamp, customDimensions["eventSource"], message, customDimensions.LogLevel, severityLevel, customDimensions
// | where customDimensions.eventSource startswith "myEventSource"
| filter customDimensions["eventSource"] != '' 
and timestamp >= ago(30m) // ago(1d) ago(8h) ago(15m) 
| extend source = tostring(customDimensions["eventSource"])
| take 200
| order by timestamp desc 

View every time this function was called, not just the trace info#

requests
| project
    timestamp,id,operation_Name,success,resultCode,duration,operation_Id,cloud_RoleName,invocationId=customDimensions['InvocationId']
| where timestamp > ago(1d)
| where cloud_RoleName =~ 'myFunctionAppName' and operation_Name =~ 'myFunctionName'
| order by timestamp desc
| take 200

References#

For more information about the Kusto Query Language, see: https://learn.microsoft.com/en-us/azure/data-explorer/kusto/query/

Learning the Kusto Query Language