azure - 按每个事件组的时间戳显示第一个条目
问题描述
我们为用户发送到聊天机器人的每条消息收集应用程序洞察中的自定义事件。该事件称为user_message
。我们使用自定义维度字段customDimensions.conversationid
来了解哪个消息与哪个对话相关。
我想查看每个对话的第一条消息,所以基本上是基于对话 ID 的每个事件的“最旧”时间戳。
我尝试使用 arg_max 但我不知道它是如何工作的。
customEvents
| extend itemType = iif(itemType == 'customEvent',itemType,"")
| where (itemType == 'customEvent')
| where name == 'User_Message'
我能够按对话ID显示所有用户消息,但是它显示了多行,我只需要按对话的第一条消息。
数据模型:
timestamp [UTC] 2019-04-05T13:24:10.359Z
name User_Message
itemType customEvent
customDimensions
confidence N/A
conversationId BNu0SqC5RfA1S0lZmdxxxxx
intent N/A
userMessage user text
operation_Name POST /api/messages
operation_Id xxxxxxxa5d422eadebfebb2
operation_ParentId xxxxx545a5d422eadebfebb2.99811380_13.f033f887_
application_Version 1.0.0
client_Type PC
client_OS Windows_NT 10.0.14393
client_IP 0.0.0.0
client_City Amsterdam
client_StateOrProvince North Holland
client_CountryOrRegion Netherlands
cloud_RoleName Web
cloud_RoleInstance XXXXXXXFF74D594
appId ccccccc-8b24-41bb-a02a-1cb101da84e5
appName bot-XXXXX
iKey XXXXXX
sdkVersion node:XX
itemId XXXXXXXX-57a6-11e9-a5a7-ebc91e7cf64e
itemCount 1
解决方案
customEvents
| extend itemType = iif(itemType == 'customEvent',itemType,"")
| where (itemType == 'customEvent')
| where (name=='User_Message')
| summarize list=makeset(customDimensions.userMessage) by
tostring(customDimensions.conversationId)
| mv-expand firstMessage=list[0]
解决方案
更新:
customEvents
| where name == "User_Message"
| summarize timestamp=min(timestamp) by myconid=tostring(customDimensions.[conversationID])
| join kind= inner (
customEvents
| where name == "User_Message"
| extend myconid = tostring(customDimensions.[conversationID])
) on myconid,timestamp
您可以使用内部连接来做到这一点。
我没有您的数据,因此在您的情况下,代码如下所示(也许您需要进行一些更改):
customEvents
| summarize timestamp=min(timestamp) by conversationID
| join kind= inner (
customEvents
) on conversationID,timestamp
| project-away conversationID1,timestamp1
如果您有更多问题,请告诉我。
推荐阅读
- amazon-web-services - 当查询超时值较高时,AWS 海王星抛出超时错误
- vba - vb.net如何退出递归循环
- c# - 订阅 Firebase 实时数据库 ChildChange 事件会触发事件,其中子级不是来自订阅路径
- excel - 如何将电子邮件标记为公共与内部?
- python - ImportError:无法从“bson.py3compat”导入名称“abc”
- javascript - npm run build-storybook 失败并显示“模块解析失败:意外令牌 (20:25)”
- python - 不能在双重嵌套列表理解中使用本地类成员?
- java - 双向链表快速排序实现问题
- idris - 如何在 Idris2 中编写 CV-Coalgebra?
- c++ - 了解和排除 SIGILL