I have the following json contained in a particular field in the traces.customDimensions:
When I parse this Json to extract a particular value I always get an empty column, for example:
traces | order by timestamp desc
| project CurrentContext = parse_json(customDimensions.CurrentPluginContext)
| extend Source = CurrentContext.source
| project Source
The query returns the following:
I’ve also tried:
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
But here I get also an empty "Source" column. And the Columns "DepthCurrentContext" and "DepthCurrentParentContext" do not even appear.
The Json is valid.
Do I miss something here?
Any help is very appreciated!
UPDATE 27.02.2023
When I do the following:
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
I get the properties out of the Json. The Json is the exact same as the ohne from the log.
Any idea?
2
Answers
as mentioned in the documentation: you will need to use
tostring
on the internal property bag.i.e.
parse_json(tostring(parse_json(customDimensions).CurrentPluginContext))