Kusto 查询以计算自发布后 Y 天内遇到 X 次崩溃的用户数
Kusto query to calculate number of users who experienced X number of crashes in Y days since release
我的 kusto 数据 table 记录任何时候有人使用该产品遇到崩溃的事件。我想计算有多少用户在产品发布后的 "Y" 天内经历了至少 "X" 次崩溃。
所以如果产品是在 1 月 1 日发布的,并且 table 崩溃事件看起来像:
| Date | User Id | Days Since Release |
| 1/1 | A | 0 |
| 1/1 | A | 0 |
| 1/1 | B | 0 |
| 1/2 | A | 1 |
| 1/3 | B | 2 |
| 1/4 | C | 3 |
那么结果就是:
| Days Since Release | Number of Crashes | Number of users |
| 0 | 1 | 2 | // Users A and B experienced 1 crash on 0th day
| 0 | 2 | 1 | // User A experienced 2 crashes on 0th day
| 1 | 1 | 2 | // Users A and B experienced at least 1 crash on 1st day
| 1 | 2 | 1 | // User A experienced at least 2 crashes on 1st day
| 1 | 3 | 1 | // User A experienced at least 3 crashes on 1st day
| 2 | 1 | 2 | // Users A and B experienced at least 1 crash on 2nd day
| 2 | 2 | 2 | // Users A and B experienced at least 2 crashes on 2nd day
| 2 | 3 | 1 | // User A experienced at least 3 crashes on 2nd day
| 3 | 1 | 3 | // Users A, B and C experienced at least 1 crash on 3rd day
| 3 | 2 | 2 | // Users A and B experienced at least 2 crashes on 3rd day
| 3 | 3 | 1 | // User A experienced at least 3 crashes on 3rd day
我尝试使用 activity_engagement 函数执行此操作,但无法执行崩溃次数 "X" 和发布后天数 "Y" 所需的聚合。
请看下面的查询,我相信这就是您要找的。
这个想法是扩大每个用户从崩溃之日到总 DaysSinceRelease 的计数(因为如果崩溃发生在#1 天,那么在#1 之后的所有日子里也应该考虑)。然后,我们还扩展 range(1, NumCrashes, 1)
,因为如果用户有 3 次崩溃,这些也应该计入 at-least-1
和 at-least-2
容器中。
let totalDaysSinceRelease = 3;
datatable(Date:datetime, UserId:string, DaysSinceRelease:long)
[
datetime(2020-01-01), "A", 0,
datetime(2020-01-01), "A", 0,
datetime(2020-01-01), "B", 0,
datetime(2020-01-02), "A", 1,
datetime(2020-01-03), "B", 2,
datetime(2020-01-04), "C", 3
]
| summarize NumCrashes = count() by UserId, DaysSinceRelease
| order by UserId asc, DaysSinceRelease asc
| extend NumCrashes = row_cumsum(NumCrashes, UserId != prev(UserId))
| extend DaysSinceRelease = range(DaysSinceRelease, totalDaysSinceRelease, 1)
| mv-expand DaysSinceRelease to typeof(long)
| summarize NumCrashes=max(NumCrashes) by UserId, DaysSinceRelease
| extend NumCrashes = range(1, NumCrashes, 1) | mv-expand NumCrashes to typeof(long)
| summarize dcount(UserId) by DaysSinceRelease, NumCrashes
| order by DaysSinceRelease asc, NumCrashes asc
我的 kusto 数据 table 记录任何时候有人使用该产品遇到崩溃的事件。我想计算有多少用户在产品发布后的 "Y" 天内经历了至少 "X" 次崩溃。
所以如果产品是在 1 月 1 日发布的,并且 table 崩溃事件看起来像:
| Date | User Id | Days Since Release |
| 1/1 | A | 0 |
| 1/1 | A | 0 |
| 1/1 | B | 0 |
| 1/2 | A | 1 |
| 1/3 | B | 2 |
| 1/4 | C | 3 |
那么结果就是:
| Days Since Release | Number of Crashes | Number of users |
| 0 | 1 | 2 | // Users A and B experienced 1 crash on 0th day
| 0 | 2 | 1 | // User A experienced 2 crashes on 0th day
| 1 | 1 | 2 | // Users A and B experienced at least 1 crash on 1st day
| 1 | 2 | 1 | // User A experienced at least 2 crashes on 1st day
| 1 | 3 | 1 | // User A experienced at least 3 crashes on 1st day
| 2 | 1 | 2 | // Users A and B experienced at least 1 crash on 2nd day
| 2 | 2 | 2 | // Users A and B experienced at least 2 crashes on 2nd day
| 2 | 3 | 1 | // User A experienced at least 3 crashes on 2nd day
| 3 | 1 | 3 | // Users A, B and C experienced at least 1 crash on 3rd day
| 3 | 2 | 2 | // Users A and B experienced at least 2 crashes on 3rd day
| 3 | 3 | 1 | // User A experienced at least 3 crashes on 3rd day
我尝试使用 activity_engagement 函数执行此操作,但无法执行崩溃次数 "X" 和发布后天数 "Y" 所需的聚合。
请看下面的查询,我相信这就是您要找的。
这个想法是扩大每个用户从崩溃之日到总 DaysSinceRelease 的计数(因为如果崩溃发生在#1 天,那么在#1 之后的所有日子里也应该考虑)。然后,我们还扩展 range(1, NumCrashes, 1)
,因为如果用户有 3 次崩溃,这些也应该计入 at-least-1
和 at-least-2
容器中。
let totalDaysSinceRelease = 3;
datatable(Date:datetime, UserId:string, DaysSinceRelease:long)
[
datetime(2020-01-01), "A", 0,
datetime(2020-01-01), "A", 0,
datetime(2020-01-01), "B", 0,
datetime(2020-01-02), "A", 1,
datetime(2020-01-03), "B", 2,
datetime(2020-01-04), "C", 3
]
| summarize NumCrashes = count() by UserId, DaysSinceRelease
| order by UserId asc, DaysSinceRelease asc
| extend NumCrashes = row_cumsum(NumCrashes, UserId != prev(UserId))
| extend DaysSinceRelease = range(DaysSinceRelease, totalDaysSinceRelease, 1)
| mv-expand DaysSinceRelease to typeof(long)
| summarize NumCrashes=max(NumCrashes) by UserId, DaysSinceRelease
| extend NumCrashes = range(1, NumCrashes, 1) | mv-expand NumCrashes to typeof(long)
| summarize dcount(UserId) by DaysSinceRelease, NumCrashes
| order by DaysSinceRelease asc, NumCrashes asc