Search code examples
azureazure-application-insightskql

Azure App Insights request count and response using time range set in query


Trying to pull Request count and response time for a particular timerange in query from azure app Insights in below format

enter image description here

let startDatetime = todatetime("2023-03-15 14:00:00.0");
let endDatetime = todatetime("2023-03-15 15:45:00.0");
requests
| summarize RequestsCount=sum(itemCount), AverageDuration=avg(duration), percentiles(duration, 50, 95, 99) by operation_Name 
| order by RequestsCount desc // order from highest to lower (descending)
| where timestamp > startDatetime and timestamp < endDatetime

Getting following error while running query

'where' operator: Failed to resolve column or scalar expression named 'timestamp'


Solution

  • You need to use the where statement before grouping the result because timestamp is not a column in the result set of the group.

    Try

    let startDatetime = todatetime("2023-03-15 14:00:00.0");
    let endDatetime = todatetime("2023-03-15 15:45:00.0");
    requests
    | where timestamp > startDatetime and timestamp < endDatetime
    | summarize RequestsCount=sum(itemCount), AverageDuration=avg(duration), percentiles(duration, 50, 95, 99) by operation_Name 
    | order by RequestsCount desc // order from highest to lower (descending)