问题描述
我有一个自定义事件,带有一个名为EventInfo的json(字符串)属性。有时,此属性将大于事件属性上设置的150个字符的限制,因此我必须将其拆分为多个属性,即EventInfo0,EventInfo1等。
例如(为简单起见已缩短)
EventInfo0: [{ "label" : "likeButton","stat]
,
EventInfo1: [us" : "success" }]
我发现了如何在诸如以下的应用程序见解中将EventInfo看做json:
customEvents
| where name == "people"
| extend Properties = todynamic(tostring(customDimensions.Properties))
| extend type=parsejson(Properties.['EventInfo'])
| mvexpand type
| project type,type.label,type.status]
有没有办法将EventInfo0和EventInfo1连接起来以创建完整的json字符串,并像上面那样查询?
解决方法
根据文档,150个字符的限制在 key 上,而不是在整个有效负载上。因此,实际上可能不需要拆分。
那是为了回答您的问题-虽然在查询时执行此操作效率低,但以下操作可能会起作用:
datatable(ei0:string,ei1:string)
[
'[{ "label" : "likeButton","stat]','[us" : "success" }]','[{ "lab]','[el" : "bar","hello": "world" }]'
]
| project properties = parse_json(strcat(substring(ei0,1,strlen(ei0) - 2),substring(ei1,strlen(ei1) - 2)))
| project properties.label
properties_label
----------------
likeButton
bar