Search code examples
azure-application-insightsms-app-analytics

App Insights - Pivot result


How can I pivot the result of a App Insights analytics query?

For example i would like to have a value-column for every cloud_RoleInstace:

performanceCounters  
| where timestamp > todatetime("2017-07-24T13:44:00.251Z")  
    and timestamp < todatetime("2017-07-24T13:49:00.251Z")   
| where name in ("% Processor Time")//, "Request Execution Time")  
| sort by timestamp asc nulls last  
| project timestamp, value, cloud_RoleInstance 

Solution

  • yes, just add

    | evaluate pivot(cloud_RoleInstance)
    

    or possibly more complicated but maybe more correct:

    | summarize value=sum(value) by bin(timestamp, 1m), cloud_RoleInstance 
    | evaluate pivot(cloud_RoleInstance, sum(value))
    

    to your query :)

    also, you can simplify the time part of your query to use the between operator

    | where timestamp between(todatetime("2017-07-24T13:44:00.251Z")..todatetime"2017-07-24T13:49:00.251Z")