I have a Java application that sends log4j2 logs to App Insights. When logging an exception I basically pass a JSON in string format and the exception something like this
JSONObject json=new JSONObject();
json.put(...)
....
log.error(json.toString(), exception)
On the App Insights side; the message is stored under customDimensions with the key Logger Message in a JSON format.
From this stored information, I would like to make a query that would fetch all the exception messages where the statusCode > 200 and statusCode < 300. I've tried couple of queries but I was not able to extract those specific exception messages.
One of the queries I was trying was
exceptions
| limit 50
| where toint(customDimensions["Logger Message"].statusCode) > 200
and toint(customDimensions["Logger Message"].statusCode) < 300
Any help would be appreciated
Update: I've running the query
exceptions
| limit 50
| project s1 = customDimensions["Logger Message"]
| extend s2 = s1.statusCode
| extend s3 = toint(s2)
| extend s4 = s3 >= 200 and s3 < 300