SPL is a bit wonky but got results in the final format you were looking for, I'm curious how this SPL will perform against your live data. | makeresults | eval _raw="{
\"a.com\": [
{ \"yahoo.com\":\"10ms\",\"trans-id\": \"x1\"},
{ \"google.com\":\"20ms\",\"trans-id\": \"x2\"}
],
\"b.com\": [
{ \"aspera.com\":\"30ms\",\"trans-id\": \"x3\"},
{ \"arista.com\":\"40ms\",\"trans-id\": \"x4\"}
],
\"trans-id\":\"m1\",
\"duration\":\"33ms\"
}"
``` start parsing json object ```
| fromjson _raw
| foreach *.*
[
| eval
url_json=mvappend(
url_json,
case(
mvcount('<<FIELD>>')==1, if(isnotnull(json('<<FIELD>>')), json_set('<<FIELD>>', "url", "<<FIELD>>"), null()),
mvcount('<<FIELD>>')>1, mvmap('<<FIELD>>', if(isnotnull(json('<<FIELD>>')), json_set('<<FIELD>>', "url", "<<FIELD>>"), null()))
)
)
]
| fields + _time, url_json, "trans-id", duration
| rename
"trans-id" as "top_trans-id"
| fields - _raw
| mvexpand url_json
| fromjson url_json
| fields - url_json
| foreach *.*
[
| eval
sub_url=if(
isnotnull('<<FIELD>>') AND isnull(sub_url),
"<<FIELD>>",
'sub_url'
),
sub_duration=if(
isnotnull('<<FIELD>>') AND isnull(sub_duration),
'<<FIELD>>',
'sub_duration'
)
]
| rename
"trans-id" as "sub_trans-id"
| fields + _time, "top_trans-id", url, duration, sub_duration, sub_url, sub_trans-id
| rename
"top_trans-id" as "trans-id" Final output: There are some pretty big assumptions here, biggest being that the keys of the _raw json will have fields with the "*.*" format or a dot in the fieldname (domain names)
... View more