我在 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 完全相同。
有什么想法吗?
traces | order by timestamp desc
| project CurrentContext = parse_json(customDimensions.CurrentPluginContext)
| extend Source = parse_json(tostring(CurrentContext)).source
| project Source
如文档中所述:您需要在内部属性包上使用
tostring
。
即
parse_json(tostring(parse_json(customDimensions).CurrentPluginContext))