Splunk Search

How to parse JSON arrays together?

incognito
Explorer

Hello, 

I have the next following event :

{ [-] 
   dimensionMap: { [+] 
   }

   dimensions: [ [+] 
   ]

   timestamps: [ [-] 
     1645718340000
     1645718400000
     1645718460000
     1645718520000
     1645718580000
     1645718640000
     1645718700000
     1645718760000
     1645718820000
     1645718880000
     1645718940000
   ]

   values: [ [-] 
     0.54
     0.63
     0.37
     0.56
     0.47
     0.45
     0.65
     0.64
     1
     null
     null
   ]

}

I would like to link each timestamp to its corresponding value.

For instance, following this example, it could look like this as a table :

      Timestamp                                                                 Value

1645716780000                                                            0.42
1645716840000                                                            0.79
1645716900000                                                            0.53
1645716960000                                                            0.63
1645717020000                                                            0.59
1645717080000                                                            0.5
1645717140000                                                            0.57
1645717200000                                                            0.59
1645717260000                                                            null
1645717380000                                                            null

Thank you.

Regards,

Labels (3)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

| spath timestamps{} output=timestamps
| spath values{} output=values
| eval timestampsvalues=mvzip(timestamps,values)
| mvexpand timestampsvalues
| eval timestamps=mvindex(split(timestampsvalues,","),0)
| eval values=mvindex(split(timestampsvalues,","),1)
| table timestamps values

View solution in original post

ITWhisperer
SplunkTrust
SplunkTrust

| spath timestamps{} output=timestamps
| spath values{} output=values
| eval timestampsvalues=mvzip(timestamps,values)
| mvexpand timestampsvalues
| eval timestamps=mvindex(split(timestampsvalues,","),0)
| eval values=mvindex(split(timestampsvalues,","),1)
| table timestamps values

Get Updates on the Splunk Community!

Enterprise Security Content Update (ESCU) | New Releases

In December, the Splunk Threat Research Team had 1 release of new security content via the Enterprise Security ...

Why am I not seeing the finding in Splunk Enterprise Security Analyst Queue?

(This is the first of a series of 2 blogs). Splunk Enterprise Security is a fantastic tool that offers robust ...

Index This | What are the 12 Days of Splunk-mas?

December 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...