Top 10 Charts in Azure Log Analytics and Application Insights

I’ve recently stumbled on forum question asking for chart that list only the top 10 resources or computers. Such chart is of course used a lot in performance metrics where for example you want to get the top 10 computers with CPU usage and list them in time chart.

In this blog post I will show you scenario but the example can be used for other performance metrics and resources. The key for achieving such chart is to use let function where we can first find the top 10 resources/computers by using some of the functions for summarization and after that we can build the chart that we want only scoped to those computers. This is simple as the query below:

let TopComputers = Perf 
| where ObjectName == 'Processor' and CounterName == '% Processor Time' and InstanceName == '_Total' 
| summarize AggregatedValue = avg(CounterValue) by Computer 
| sort by AggregatedValue desc 
| limit 10  
| project Computer; 
| where ObjectName == 'Processor' and CounterName == '% Processor Time' and InstanceName == '_Total' and Computer in (TopComputers) 
| summarize AggregatedValue = avg(CounterValue) by Computer, bin(TimeGenerated, 1h) | render timechart

As you can see by using let I can output only the names of the computers that are in top 10 of CPU usage. After that the next query that displays the chart is scoped only to those computers. The result of the query will look similar to this:


Additionally you can set different times for both queries depending on your scenario. For example you can only get top 10 computers based on the last hour but display the results for the last 24 hours.

Hope this will help you in monitoring your resources.

3 thoughts on “Top 10 Charts in Azure Log Analytics and Application Insights

  1. Hi, I see the query above can be very useful – thanks. I am not able to query table perf in application insights but understand it is part of log analytics. Can you provide further insight as to the differences in capabilities between both and differences in data models? Thanks.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.