Application Insight Analytics Pivot

孤人 提交于 2019-12-13 03:49:39

问题


Is there a way to pivot in Azure Application insight analytic queries? SQL has a Pivot Keyword, can similar be achieved in Application insight Analytics?

When I run the below query I get exceptions and count, but I would like to see a day on day trending

exceptions 
| where timestamp >= ago(24h) 
| extend Api = replace(@"/(\d+)",@"/xxxx", operation_Name)
| summarize count() by type
| sort by count_ desc 
| limit 10
| project Exception = type, Count = count_ 

I am looking for something below day wise.


回答1:


The easiest way to achieve something similar to what you need is by using:

exceptions
| where timestamp >= ago(7d)
| summarize count() by type, bin(timestamp, 1d) 

This will give in the output one line per-type, per-day. Not exactly what you wanted but it will look good when rendered in graph (will give you a line for each type).

To get a table similar to what you put in your example would be more difficult, but this query should do the trick:

exceptions 
| where timestamp >= startofday(ago(3d)) 
| extend Api = replace(@"/(\d+)",@"/xxxx", operation_Name)
| summarize count() by type, bin(timestamp, 1d)
| summarize 
    Today = sumif(count_, timestamp == startofday(now())),
    Today_1 = sumif(count_, timestamp == startofday(ago(1d))),
    Today_2 = sumif(count_, timestamp == startofday(ago(2d))),
    Today_3 = sumif(count_, timestamp == startofday(ago(3d)))
    by type


来源:https://stackoverflow.com/questions/44585032/application-insight-analytics-pivot

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!