首页 > 解决方案 > Application Insights 聚合事件发生的总和

问题描述

UserRegistered在应用洞察中记录了一个事件,以便我可以看到哪些用户在注册后做了正确的事情。我想使用这个事件来显示一段时间内注册的用户总数。

我目前有这个查询:

customEvents
| where timestamp >= datetime(2021-06-04T16:08:10.602Z) and timestamp < datetime(2021-06-11T16:08:10.602Z)
| summarize ['customEvents/count_sum'] = sum(itemCount) by bin(timestamp, 1d)
| order by timestamp desc

然而,这只给了我每个垃圾箱的总数。因此,如果用户在第 1 天和第 3 天注册,我会看到如下内容:


                     |
|                    |
1         2          3

但是,我希望看到随着时间的推移而增长,因此这些箱需要汇总它们的总和,给我这个:

                     |
                     |
|         |          |
1         2          3

我可以在 App Insights 中实现这一点吗?

标签: azure-application-insights

解决方案


试试这个 ?

customEvents
| where timestamp >= datetime(2021-06-04T16:08:10.602Z) and timestamp < datetime(2021-06-11T16:08:10.602Z)
| summarize ['customEvents/count_sum'] = sum(itemCount) by bin(timestamp, 1d)
| order by timestamp desc
| extend total=row_cumsum(['customEvents/count_sum'])

推荐阅读