在 Application Insights 中使用 Kusto 从 Json 中提取字段

问题描述 投票:0回答:2

我在 traces.customDimensions 的特定字段中包含以下 json:

当我解析这个 Json 以提取特定值时,我总是得到一个空列,例如:

traces | order by timestamp desc
| project CurrentContext = parse_json(customDimensions.CurrentPluginContext)
| extend Source = CurrentContext.source
| project Source

查询返回以下内容:

我也试过:

traces | order by timestamp desc
| project timestamp, CurrentContext = customDimensions.CurrentPluginContext, CurrentParentContext = customDimensions.CurrentParentluginContext,
Source = parse_json(tostring(customDimensions.CurrentPluginContext)).source,
DepthCurrentContext = parse_json(tostring(customDimensions.CurrentPluginContext)).depth,
DepthCurrentParentContext = parse_json(tostring(customDimensions.CurrentParentluginContext)).depth
| mv-expand CurrentContext
| extend Source = CurrentContext.source

但在这里我也得到一个空的“来源”列。并且列“DepthCurrentContext”和“DepthCurrentParentContext”甚至没有出现。

Json 有效。

我在这里错过了什么吗?

非常感谢任何帮助!

更新 27.02.2023

当我执行以下操作时:

let json = '{"source": "GetUserData","correlationId": "00000000-0000-0000-0000-000000000000","depth": "1","initiatingUserId": "00000000-0000-0000-0000-000000000000","isInTransaction": "False","isolationMode": "2","message": "Update","mode": "Asynchronus","operationId": "00000000-0000-0000-0000-000000000000","orgId": "00000000-0000-0000-0000-000000000000","orgName": "unqXXXXXXXXXXXXXXXXXXXX","requestId": "00000000-0000-0000-0000-000000000000","userId": "00000000-0000-0000-0000-000000000000","entityId": "00000000-0000-0000-0000-000000000000","entityName": "systemuser","type": "Plugin","stage": "Post-operation"}';

traces
| extend properties = parse_json(json)
| project Source = properties.source, CorrelationID = properties.correlationId

我从 Json 中获取属性。 Json 与日志中的 ohne 完全相同。

有什么想法吗?

json parsing azure-application-insights kql
2个回答
0
投票
traces | order by timestamp desc
| project CurrentContext = parse_json(customDimensions.CurrentPluginContext)
| extend Source = parse_json(tostring(CurrentContext)).source
| project Source

0
投票

文档中所述:您需要在内部属性包上使用

tostring

parse_json(tostring(parse_json(customDimensions).CurrentPluginContext))

© www.soinside.com 2019 - 2024. All rights reserved.