Splunk Search

How to filter data from JSON object having one field name and list of values into table?

Splunk_321
Path Finder

I have data something like below.

 msg: { 
     applicationtest-app
     correlationid0.59680117.1667864418.7d2b8d5
     httpmethodGET
     levelINFO
     logMessage: { 
       apiNametestApi
       apiStatusSuccess
       clientIdtestClientId1
       errorNA
       list_items: [
         { 
           cityPHOENIX
           countryCodeUSA
           locationIddc5269a4-c043-4381-b757-63950feecac3
           matchRank1
           merchantNametestMerchant1
           postalCode12345
           stateAZ
           streetAddress4000 E SKY HARBOR BLVD
         }
         { 
           cityPHOENIX
           countryCodeUSA
           locationIdc7b97f03-b21b-4c11-aead-1ca3cd03d415
           matchRank2
           merchantNametestMerchant2
           postalCode56789
           stateAZ
           streetAddress4000 E SKY HARBOR BL
         }

      ......

    ]

I have to get a table with clientId and locationId something like below 

clientId                     locationId

testClientId1         dc5269a4-c043-4381-b757-63950feecac3

testClientId1         c7b97f03-b21b-4c11-aead-1ca3cd03d415

What I tried is | base search | | table "msg.logMessage.clientId", "msg.logMessage.matched_locations{}.locationId" 

which resulted in grouping the locationIds for clientId hence one row for even multiple locationIds

clientId                     locationId

testClientId1         dc5269a4-c043-4381-b757-63950feecac3

                                    c7b97f03-b21b-4c11-aead-1ca3cd03d415

Any help is appreciated. 

Labels (1)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

Use the mvexpand command to put the locationId values on different rows.

| base search | 
| table "msg.logMessage.clientId", "msg.logMessage.matched_locations{}.locationId" 
| mvexpand "msg.logMessage.matched_locations{}.locationId"

 

---
If this reply helps you, Karma would be appreciated.

View solution in original post

richgalloway
SplunkTrust
SplunkTrust

Use the mvexpand command to put the locationId values on different rows.

| base search | 
| table "msg.logMessage.clientId", "msg.logMessage.matched_locations{}.locationId" 
| mvexpand "msg.logMessage.matched_locations{}.locationId"

 

---
If this reply helps you, Karma would be appreciated.
Get Updates on the Splunk Community!

Data Management Digest – December 2025

Welcome to the December edition of Data Management Digest! As we continue our journey of data innovation, the ...

Index This | What is broken 80% of the time by February?

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

Unlock Faster Time-to-Value on Edge and Ingest Processor with New SPL2 Pipeline ...

Hello Splunk Community,   We're thrilled to share an exciting update that will help you manage your data more ...