Kusto/ADX 中有几个内置的用户分析插件:https ://docs.microsoft.com/en-us/azure/kusto/query/useranalytics
例如,其中之一是activity_engagement
插件:https ://docs.microsoft.com/en-us/azure/kusto/query/activity-engagement-plugin
例如:
let T = datatable(Event:string, UID:int, Timestamp:datetime)
[
'event 1', 0, datetime(9/25/19 9:00 AM),
'event 2', 1, datetime(9/25/19 3:00 PM),
'event 3', 2, datetime(9/26/19 2:00 PM),
'event 4', 1, datetime(9/28/19 5:00 PM),
'event 5', 3, datetime(9/29/19 7:00 AM),
]
;
let min_date_time = toscalar(T | summarize startofday(min(Timestamp)));
let max_date_time = toscalar(T | summarize startofday(max(Timestamp)));
T
| evaluate activity_engagement (UID, Timestamp, 1d, 1d + max_date_time - min_date_time)
| project Timestamp, dcount_activities_outer
而且,如果您想在 9 月 27 日“填补空白”,您可以执行以下操作:
let T = datatable(Event:string, UID:int, Timestamp:datetime)
[
'event 1', 0, datetime(9/25/19 9:00 AM),
'event 2', 1, datetime(9/25/19 3:00 PM),
'event 3', 2, datetime(9/26/19 2:00 PM),
'event 4', 1, datetime(9/28/19 5:00 PM),
'event 5', 3, datetime(9/29/19 7:00 AM),
]
;
let min_date_time = toscalar(T | summarize startofday(min(Timestamp)));
let max_date_time = toscalar(T | summarize startofday(max(Timestamp)));
range Timestamp from min_date_time to max_date_time step 1d
| join kind=leftouter (
T
| evaluate activity_engagement (UID, Timestamp, 1d, 1d + max_date_time - min_date_time)
| project Timestamp, dcount_activities_outer
) on Timestamp
| order by Timestamp asc
| project Timestamp, coalesce(dcount_activities_outer, prev(dcount_activities_outer))