Azure Application Insights - objects 内的值

Azure Application Insights - values within objects

我正在尝试在 Azure Application Insights 中编写查询,它正在捕获与使用 Azure Bot Framework 构建的机器人的交互。

我有一个 table,标题为 timestampnamecustomDimensionscustomDimensions,在 customDimensions 中是 objects 比如

{ "conversationData": "{}", "privateConversationData": "{\"nameForm\":{\"NAME\":\"foo\",\"ICCID\":\"12121212121212121212\"}}", "userData": "{}", "conversationId": "878fhiee1k33j5ci", "userId": "default-user", "metrics": "92.25833" }

例如,我可以轻松地按名称对 select 项编写查询 customEvents | where name contains "Activity"

但是我如何 select 基于 objects 中的键,例如上面 privateConversationData 中的键?

例如 "privateConversationData": "{\"nameForm\":{\"NAME\":\"foo\",\"ICCID\":\"12121212121212121212\"}}", 指的是一个名为 nameForm 的对话框,我该如何编写一个查询来显示 nameForm 被使用的次数?或者包含其他类型对话框(例如,不仅是 nameForm,还有 fooForm、barForm)和它们被使用次数的查询?

非常感谢您的帮助!

'customDimensions' 属性 是动态类型,因此可以视为 JSON 文档。

例如-获取nameForm在最后一天被使用的次数:

customEvents
| extend conversationData = customDimensions["privateConversationData"]
| where timestamp > ago(1d) and isnotempty(conversationData) and conversationData contains "{\\"nameForm\\""
| count

获取不同的对话计数会比较棘手,但可以通过使用 parse operator:

解析 customDimensions JSON 文档来实现
customEvents
| where timestamp > ago(1d) 
| parse customDimensions with * "privateConversationData\": \"{\\"" dialogKind "\\":{\\"NAME\\"" *
| where isnotempty(dialogKind) and isnotnull(dialogKind)
| summarize count() by dialogKind

您可以阅读 Analytics Reference 以了解有关该语言的更多信息。