<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Searching Nested JSON Data in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Searching-Nested-JSON-Data/m-p/670065#M229743</link>
    <description>&lt;P&gt;Usualy debugging involves just adding commands one by one and seeing if they yield the result you expect.&lt;/P&gt;&lt;P&gt;So just remove the last spath and see if you have separate "bundle" in each row. Then just do&lt;/P&gt;&lt;PRE&gt;| spath input=logs&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 28 Nov 2023 18:56:55 GMT</pubDate>
    <dc:creator>PickleRick</dc:creator>
    <dc:date>2023-11-28T18:56:55Z</dc:date>
    <item>
      <title>Searching Nested JSON Data</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Searching-Nested-JSON-Data/m-p/670047#M229737</link>
      <description>&lt;P&gt;Using SPL and Splunk Search, I would like to search the logs array for each separate test_name and results and create a table with the results&lt;/P&gt;
&lt;P&gt;my current query looks something like:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;index="factory_mtp_events" | spath logs{}.test_name | search "logs{}.test_name"="Sample Test1"&lt;/LI-CODE&gt;
&lt;PRE&gt;{ 
   logs: [ 
     { 
       result: Pass
       test_name: Sample Test1
     { 
       result: Pass
       test_name: Sample Test2
     }
     { 
       received: 4
       result: Pass
       test_name: Sample Test3
     }
     { 
       expected: sample
       received: sample
       result: Pass
       test_name: Sample Test4
     }
     { 
       expected: 1 A S
       received: 1 A S 

       result: Pass
       test_name: Sample Test5
     }
     {
       expected: 1
       reason: Sample Reason
       received: 1
       result: Pass
       test_name: Sample Test6
     }
     { 
       pt1: 25000
       pt1_recieved: 25012.666666666668
       pt2: 20000
       pt2_recieved: 25015.333333333332
       pt3: 15000
       pt3_recieved: 25017.0
       result: Fail
       test_name: Sample Test7
     }
     {
       result: Pass
       test_name: Sample Test8
       tolerance: + or - 5 C
       recieved_cj: 239
       user_temp: 250
     }
     { 
       expected: Open, Short, and Load verified OK.
       pt1: 2
       pt1_recieved: 0
       pt2: 1
       pt2_received: 0
       result: Fail
       test_name: Sample Test9
     }
     {
       pt1: 2070
       pt1_tolerance: 2070
       pt1_received: 540
       pt2: 5450
       pt2_tolerance: 2800
       pt2_received: 538
       result: Fail
       test_name: Sample Test10
     }
     { 
       expected: Soft Start verified by operator
       received: Soft Start verified
       result: Pass
       test_name: Sample Test11
     }
     { 
       F_name: AUGER 320 F
       F_rpm: 1475
       F_rpm_t: 150
       F_rpm_received: 1500
       F_v: 182
       F_v_t: 160
       F_v_received: 173
       R_name: AUGER 320 R
       R_rpm: 1475
       R_rpm_t: 150
       R_rpm_received: 1450
       R_v: 155
       R_v_t: 160
       R_v_ugc: 154.66666666666666
       result: Pass
       test_name: Sample Test12
     }
     { 
       result: Pass
       rpm: 2130
       rpm_t: 400
       test_name: Sample Test13
       received_rpm: 2126.6666666666665
       received_v: 615.6666666666666
       v: 630
       v_t: 160
     }
 ]
   result: Fail
   serial_number: XXXXXXXXXXXsample
   type: Test&lt;/PRE&gt;
&lt;P&gt;What is the purpose of the brackets after logs? I assume regex must be used to get the result from each test? How do I pull results from each test into a table containing the results of every separate log?&lt;/P&gt;
&lt;P&gt;I would like the table for each test to look something like:&lt;/P&gt;
&lt;P&gt;** Sample Test1**&lt;/P&gt;
&lt;DIV class=""&gt;Expected Actual Serial No.
&lt;TABLE&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;X&lt;/TD&gt;
&lt;TD&gt;X&lt;/TD&gt;
&lt;TD&gt;XXXXXXXsample&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;Y&lt;/TD&gt;
&lt;TD&gt;Z&lt;/TD&gt;
&lt;TD&gt;XXXXXX2sample&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;</description>
      <pubDate>Tue, 28 Nov 2023 16:54:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Searching-Nested-JSON-Data/m-p/670047#M229737</guid>
      <dc:creator>nkavouris</dc:creator>
      <dc:date>2023-11-28T16:54:36Z</dc:date>
    </item>
    <item>
      <title>Re: Searching Nested JSON Data</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Searching-Nested-JSON-Data/m-p/670051#M229738</link>
      <description>&lt;P&gt;1. The brackets are just part of field's name. Nothing more, nothing less.&lt;/P&gt;&lt;P&gt;2. Working with regex over structured data is... risky.&lt;/P&gt;&lt;P&gt;3. Extract the "logs" part. You should get a multivalued field of json-formatted objects. Do mvexpand to split it into separate results. Then do spath. Otherwise you'd just get huge multivalued blobs of data - Splunk doesn't play the "json structure" game so if you just flatten your json, you'll get all values of "the same" field compressed into a single multivalued field.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Nov 2023 16:30:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Searching-Nested-JSON-Data/m-p/670051#M229738</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2023-11-28T16:30:41Z</dc:date>
    </item>
    <item>
      <title>Re: Searching Nested JSON Data</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Searching-Nested-JSON-Data/m-p/670062#M229741</link>
      <description>&lt;P&gt;"&lt;SPAN&gt;Do mvexpand to split it into separate results. Then do spath" Need more detail please&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Is there a way to see what the mvexpand returns? feels like debugging queries is next to impossible&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;when spath-ing the mv results what exactly am inputting for?&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;index="factory_mtp_events"&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;|&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;spath "logs{}" output=logs | &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;mvexpand logs | &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;spath input=logs.test_name|&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Nov 2023 17:53:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Searching-Nested-JSON-Data/m-p/670062#M229741</guid>
      <dc:creator>nkavouris</dc:creator>
      <dc:date>2023-11-28T17:53:02Z</dc:date>
    </item>
    <item>
      <title>Re: Searching Nested JSON Data</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Searching-Nested-JSON-Data/m-p/670065#M229743</link>
      <description>&lt;P&gt;Usualy debugging involves just adding commands one by one and seeing if they yield the result you expect.&lt;/P&gt;&lt;P&gt;So just remove the last spath and see if you have separate "bundle" in each row. Then just do&lt;/P&gt;&lt;PRE&gt;| spath input=logs&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Nov 2023 18:56:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Searching-Nested-JSON-Data/m-p/670065#M229743</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2023-11-28T18:56:55Z</dc:date>
    </item>
    <item>
      <title>Re: Searching Nested JSON Data</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Searching-Nested-JSON-Data/m-p/670246#M229782</link>
      <description>&lt;P&gt;The problem is Splunk always flattens arrays. &amp;nbsp;The trick is to preserve logs{} as a vector before mvexpand.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index="factory_mtp_events"
| spath path=logs{} ``` alternative syntax: | spath logs{} ```
| mvexpand logs{}
| search test_name="Sample Test1"&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 30 Nov 2023 01:24:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Searching-Nested-JSON-Data/m-p/670246#M229782</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2023-11-30T01:24:24Z</dc:date>
    </item>
  </channel>
</rss>

