AbdulKareem
AbdulKareem

Reputation: 1207

Extending data from json in customDimensions

I'm using following code to send data to application insights

appInsights.trackEvent({
   name:'EventName',
   proprties:{'keys1':'value1' , 'key2':JSON.stringify({'nestedKey':'someValue'})}
});

when querying same in data explorer

customEvents
| extend key2_1 = parse_json(customDimensions.key2)
| extend key1_1 = tostring(customDimensions.key1)
| extend nestedKey1 = tostring(key2_1.nestedKey)
| extend nestedKey2 = tostring(customDimensions.key2.nestedKey)

both nestedKey1 and nestedKey2 are null , but both key1_1 and key2_1 has data

Upvotes: 4

Views: 528

Answers (1)

Ivan Glasenberg
Ivan Glasenberg

Reputation: 29950

Just replace the 2 lines:

| extend nestedKey1 = tostring(key2_1.nestedKey)
| extend nestedKey2 = tostring(customDimensions.key2.nestedKey)

with the following 2 lines:

| extend nestedKey1 = parse_json(tostring(key2_1)).nestedKey
| extend nestedKey2 = parse_json(tostring(parse_json(customDimensions.key2))).nestedKey

Here is the test result at my side:

enter image description here

Upvotes: 1

Related Questions