【问题标题】:App insights: Can you concatenate two properties together?应用洞察:您可以将两个属性连接在一起吗?
【发布时间】:2021-02-13 05:58:15
【问题描述】:

我有一个带有名为 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 字符串,并像上面一样查询?

【问题讨论】:

  • 如果你能回复下面的答案,那就太好了,不管它是否适合你。如果它有效,你应该接受它作为答案,根据this link

标签: azure-application-insights azure-stream-analytics kql appinsights ms-app-analytics


【解决方案1】:

根据文档,150 个字符的限制是在 key 上,而不是在整个有效负载上。因此,实际上可能不需要进行拆分。

https://docs.microsoft.com/en-us/azure/azure-monitor/app/data-model-event-telemetry#custom-properties

也就是说,回答您的问题 - 虽然在查询时执行此操作效率不高,但以下方法可能有效:

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, 1, strlen(ei1) - 2)))
| project properties.label
properties_label
----------------
likeButton
bar

【讨论】:

  • strcat 是我想要的,谢谢。我对 Kusto 很陌生。
猜你喜欢
  • 2018-05-19
  • 1970-01-01
  • 1970-01-01
  • 2014-07-28
  • 1970-01-01
  • 2011-05-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多