KQL 扩展到新列,其中包含汇总

KQL extend to new column with summarize inside

我正在尝试用这些列

制作一个table
type | count

我试过了,但没有成功

exceptions 
| where timestamp > ago(144h) 
| extend 
    type = type, count = summarize count() by type
| limit 100

知道我做错了什么吗?

你应该这样做:

exceptions 
| where timestamp > ago(144h) 
| summarize count = count() by type
| limit 100

解释:

  • 当您想向结果中添加 new/replace 列时,您应该使用 extend,例如 extend day_of_month = dayofmonth(Timestamp) - 在这种情况下,您将保留完全相同的记录数- 在 doc
  • 中查看更多信息
  • 当您想要汇总多条记录时,您应该使用 summarize(因此 summarize 之后的记录数通常会小于原始记录数),就像您的情况一样 - 查看更多doc
  • 中的信息

顺便说一下,您可以使用 6d 而不是 144h,它完全一样,但对人眼来说更自然:)