DQL
Questions about Dynatrace Query Language
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Regex/Parsing logic to extract nested or repeating patterns from a specific data record format

TrunksGr
Newcomer

I am looking for a way to extract specific substrings from a data record. I need to retrieve all values associated with the key Valuethat are contained inside the value="..." attribute of a data record.

data record(content="Hello value=\"something1\" value=\"something2\" value=\"something2\"  hello")

From the above data I want to return this [something1,something2,something2]

I am trying to replicate the same thing that Splunk is doing
| rex field=_raw max_match=9999 "(?s)VALUE=\"(?<term0>.*?)\""

1 REPLY 1

Maheedhar_T
Mentor

Hi @TrunksGr ,
You can use parseAll for this.
Documentation reference: https://docs.dynatrace.com/docs/shortlink/string-functions#parseAll

For the example you shared, it can be inferred as this

data record(content = "Hello value=\"something1\" value=\"something2\" value=\"something2\"  hello")
| fieldsAdd raw = parseAll(content, "'value=' DQS:val")
| fieldsAdd values = iCollectArray(replaceString(raw[], "\"", ""))


Hope this helps..

Happy Querying 😉

Thanks,
@Maheedhar_T 

Maheedhar

Featured Posts