"Failed to resolve 'top' key column" Application Insights Analytics 自定义维度错误

"Failed to resolve 'top' key column" Error in Application Insights Analytics Custom Dimensions

我在 Application Insights 中有一些数据,我正在使用 Analytics 视图针对它编写查询。

我可以看到我有一个跟踪,其中的 CustomDimensions 包含一个名为 ActivityID 的 属性,它是一个 guid:

我现在想要做的是 运行 对 return 包含该 ActivityId 的所有跟踪的另一个查询。

this为指导,我目前有以下内容:

union (traces
| extend ActivityId = tostring(customDimensions.ActivityId)
| project ActivityId
| where ActivityId  == "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")
| top 101 by timestamp desc

但是,这是 return 出现以下语法错误消息:

Failed to resolve 'top' key column

我做错了什么?如果可能的话,我也很感激并解释错误消息。

除非您实际在投影中包含时间戳列,否则您不能对投影执行 top

我做到了:

union (traces)
| top 101 by timestamp desc
| project session_Id

所以这应该有效

union (traces
| extend ActivityId = tostring(customDimensions.ActivityId)
| where ActivityId  == "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")
| top 101 by timestamp desc
| project ActivityId

然后就可以了。你的完整查询是什么(我猜你使用的是 union?)

如果要在顶部使用 'timestamp' 列,则必须投影它。

traces
| extend ActivityId = tostring(customDimensions.ActivityId)
| project ActivityId, timestamp
| where ActivityId  == "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
| top 101 by timestamp desc

*请注意,您也不需要使用 union