我有这个查询按App Insights中例外的问题ID计算:
// exception count by problem ID
let start=datetime("2018-01-09T14:17:00.000Z");
let end=datetime("2018-01-10T14:17:00.000Z");
let timeGrain=5m;
let dataset=exceptions
// additional filters can be applied here
| where timestamp >= ago(24h)
| where client_Type == "PC" ;
dataset
| project problemId, cloud_RoleName, itemCount, details
| summarize count_=sum(itemCount) by problemId, cloud_RoleName, stacktrace_ = (tostring(details))
// calculate exception count for all exceptions
| union(dataset
| summarize count_=sum(itemCount)
| extend problemId="Overall")
| order by count_ desc
我还希望包含堆栈跟踪,但我只想获得第一个'详细信息'一组' problemId'的列。有任何想法吗?感谢
答案 0 :(得分:2)
我认为没有用于汇总的first()运算符,但如果您只想为每个组分配一个(随机)值,则可以使用any()
运算符。
喜欢
| summarize count_=sum(itemCount), any(details) by problemId, ...
"第一"通常意味着群体中的某种秩序,所以我不确定是否有一种简单的方法可以做到这一点,而不会使查询更复杂。
请参阅:https://docs.loganalytics.io/docs/Language-Reference/Aggregation-functions/any()
答案 1 :(得分:0)
arg_min()和 arg_max()可以解决问题。第一个参数是对组进行排序的字段。第二个及后续参数是要返回的字段。
https://docs.microsoft.com/en-us/azure/kusto/query/arg-min-aggfunction