首页 > 解决方案 > Application Insights Analytics 同一会话中的多个事件

问题描述

对 AI 查询来说非常新,所以任何帮助都将不胜感激。

我们有许多用于特定操作的自定义事件,例如预约、订购产品、设置地址。我想运行一个查询来查看在同一会话中同时执行订购产品和设置地址的用户。我可以获得发生的任一事件的计数和 dcount,但很难指定两者都发生在同一个会话中我们捕获 User_authID 以及带有自定义事件的会话 ID。有任何想法吗?

谢谢,克里斯

标签: azureazure-application-insights

解决方案


有几种方法可以做到这一点。我发现使用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


推荐阅读