Application Insights Analytics在同一会话中发生多个事件

时间:2018-06-21 16:12:25

标签: azure azure-application-insights

对于AI查询来说还很新,因此任何帮助将不胜感激。

我们为特定操作提供了一系列自定义事件,例如预订约会,订购产品,设置地址。我想运行一个查询来查看在同一会话中既执行产品订购又设置地址的用户。我可以获取发生的两个事件的计数和计数,但是很难指定两者都在同一会话中发生。我们使用自定义事件捕获User_authID以及会话ID。有什么想法吗?

谢谢, 克里斯

1 个答案:

答案 0 :(得分:0)

有几种方法可以做到这一点。我发现使用in运算符和一个子查询是最容易阅读的。这是一个执行此操作的示例:

let timeRange = ago(1d);
let sessionsWithBothEvents = customEvents
| where timestamp > timeRange
| summarize CountEvent1=countif(name == "event1"), CountEvent2=countif(name == "event2") by session_Id
| where CountEvent1 > 0 and CountEvent2 > 0
| project session_Id;
customEvents
| where timestamp > timeRange
| where session_Id in (sessionsWithBothEvents)
// Here you have all the events in sessions that contained at least one instance of each event
// From here you can dcount users, etc.

重要的是要注意,这种方法最多只能用于符合条件的100万个会话ID。这是由于in运算符的限制。有关更多信息,请参见https://docs.loganalytics.io/docs/Language-Reference/Scalar-operators/in_!in-operators