gpt4 book ai didi

azure-application-insights - Application Insights 提取嵌套的自定义维度

转载 作者:行者123 更新时间:2023-12-03 21:36:08 31 4
gpt4 key购买 nike

我在 Application Insights Analytics 中有一些数据,它有一个动态对象作为自定义维度的属性。例如:

|        timestamp        |  name   | customDimensions                 | etc |
|-------------------------|---------|----------------------------------|-----|
| 2017-09-11T19:56:20.000 | Spinner | { | ... |
MyCustomDimension: "hi"
Properties:
context: "ABC"
userMessage: "Some other"
}

那有意义吗?所以customDimensions 中的键/值对。

我正在尝试提出 context属性作为结果中的适当列。所以预期将是:
|        timestamp        |  name   | customDimensions                 | context| etc |
|-------------------------|---------|----------------------------------|--------|-----|
| 2017-09-11T19:56:20.000 | Spinner | { | ABC | ...
MyCustomDimension: "hi"
Properties:
context: "ABC"
userMessage: "Some other"
}

我试过这个:
customEvents | where name == "Spinner" | extend Context = customDimensions.Properties["context"]

和这个:
customEvents | where name == "Spinner"  | extend Context = customDimensions.Properties.context

但似乎都不起作用。他们在最后给了我一个名为“上下文”的列,但该列是空的 - 没有值。

有任何想法吗?

编辑:

添加了一张说明数据格式的图片:

Application Insights Data

最佳答案

编辑为工作答案 :

customEvents
| where name == "Spinner"
| extend Properties = todynamic(tostring(customDimensions.Properties))
| extend Context = Properties.context
您需要一个额外的 tostringtodynamic在这里得到你所期望的(以及我所期望的!)
我得到的解释是:

Dynamic field "promises" you the upper/outer level of key / value access (this is how you access customDimensions.Properties).

Accessing internal structure of that json depends on the exact format of customDimensions.Properties content. It doesn’t have to be json by itself. Even if it looks like a well structured json, it still may be just a string that is not exactly well formatted json.


所以基本上,默认情况下,它不会尝试解析动态/json 块内的字符串,因为他们不想花费大量时间可能尝试并无法无限地将嵌套内容转换为 json。
我仍然认为额外的 tostring不应该在里面,因为 todynamic应该已经有效地允许字符串和动态,所以我正在检查拥有查询内容的团队是否可以使这一步变得更好。

关于azure-application-insights - Application Insights 提取嵌套的自定义维度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46164988/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com