Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kusto's `parse_json` doesn't work on custom dimensions

I'm hoping to be able to analyze structured data stored in a custom dimension of a custom telemetry event emitted to application insights, and getting some weird behavior. It seems like the JSON can't be parsed normally, but if I pass it through strcat it is able to parse the json just fine.

customEvents 
| where name == "PbConfigFilterComponentSaved"
| take 1
| project 
    jsonType=gettype(customDimensions.Json), 
    parsedType=gettype(parse_json(customDimensions.Json)), 
    strcatType=gettype(strcat('', customDimensions.Json)),
    strcatParsedType=gettype(parse_json(strcat('', customDimensions.Json)))

Result:

jsonType:         string
parsedType:       string
strcatType:       string
strcatParsedType: dictionary

Is there a better approach to getting parse_json to work on this kind of value?

Update

In case it's in any way relevant, here's the value of customDimensions.Json:

{"filterComponentKey":"CatalystAgeRange","typeKey":"TemporalConstraint","uiConfig":{"name":"Age","displayMode":"Age"},"config":{"dateSelector":"pat.BirthDTS"},"disabledForScenes":false,"disabledForFilters":false}
like image 766
StriplingWarrior Avatar asked Sep 09 '25 14:09

StriplingWarrior


1 Answers

The type of customDimensions is dynamic and so accessing a property like customDimensions.json from it will return a string typed as dynamic.

You have to explicitly cast it as string and then parse it:

todynamic(tostring(customDimensions.json)).property

I think the "Notes" section in the documentation is exactly the issue, as mentioned by Yoni L. in the previous answer.

like image 56
data Avatar answered Sep 13 '25 17:09

data