none
App Insights analytics gets confused when fields contain JSON with newlines

    Question

  • I have a custom field called message which contains JSON, and querying it in AI analytics is very difficult. It seems like the engine tries (and sometimes succeeds) to implicitly convert it to a dynamic object, but cannot due to it containing newlines. If I do:

    traces | limit 5 | project m = customDimensions.message

    The results pane indicates it is an object (not a string), and I can expand the "object" in the pane and see its fields. However if I try to access a nested member, I get blanks, i.e. with

    traces | limit 5 | project m = customDimensions.message.Value

    After much trial and error, the only way I found to be able to access inner members was with the following:

    let mytraces = traces | limit 5 | project m = parsejson(replace(@'\\n', ' ', tostring(customDimensions.message))).Value;
    

    This is a bit of a pain; it would be great if App Insights could automatically (or even explicitly) parse JSON that contains newlines.

    Wednesday, April 13, 2016 9:14 PM

Answers

  • AI SDK doesn't support sending JSON object as a custom dimension value but rather only a dictionary of <String, String>. We can't identify JSON objects as we only expect String. This would require an enhancement to AI SDK. At the moment, only manipulating the data as you have done, will support your scenario.
    Monday, April 18, 2016 7:47 AM