cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Unescape JSON content to JSON object with DPL (Dynatrace Pattern Language)

Ardhi
Guide

Hi,

Can we Unescape JSON content to JSON object with DPL?

The reason for this is we want to parse log like this 

{"content": "{\"level\":\"info\"}"}

to this

{"content": "{\"level\":\"info\"}"

"level":"info"

}

and if possible to do this dynamically without manual input of the field name and able to append the filed to become something like "xxx_level" so we can reuse in other log

{"content": "{\"level\":\"info\"}"

"xxx_level":"info"

}

3 REPLIES 3

ChadTurner
DynaMight Legend
DynaMight Legend

@Ardhi were you able to get a solution to this?

-Chad

unfortunately not, only able to do it manually one by one (not dynamic) to extract json field

Tiit_Hallas
Dynatrace Helper
Dynatrace Helper

It would be possible to parse selected members with the specified matcher from JSON objects. In your example you could try a pattern like this: 

 

json{json:"content"}:d

 

To test it out, you could try to execute the following query with mocked data:

 

data record(line = """{"content": "{\"level\":\"info\"}"}""")
| parse line, """json{json:"content"}:d"""

 

Maybe this would get you closer to what you're trying to achieve?

I had a life once. Then I bought my first computer ...

Featured Posts