<?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: Only select matching JSON data in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Only-select-matching-JSON-data/m-p/449764#M171422</link>
    <description>&lt;P&gt;Added event data.&lt;/P&gt;</description>
    <pubDate>Thu, 09 May 2019 07:16:36 GMT</pubDate>
    <dc:creator>joesecurity</dc:creator>
    <dc:date>2019-05-09T07:16:36Z</dc:date>
    <item>
      <title>Only select matching JSON data</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Only-select-matching-JSON-data/m-p/449762#M171420</link>
      <description>&lt;P&gt;I load JSON reports into Splunk and those reports have many arrays:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{  
   "analysis":{  
      "behavior":{  
         "processes":{  
            "process":[  
               {  
                  "fileactivities":{  
                     "fileCreated":{  
                        "call":[  
                           {  
                              "path":"C:\\Windows\\a"
                           },
                           {  
                              "path":"C:\\b"
                           }
                        ]
                     }
                  }
               }
            ]
         }
      }
   }
}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;When I search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source=test| search "behavior.system.processes.process{}.fileactivities.fileCreated.call{}.path"="C:\\Windows*"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I often like to show the matching data. I use a table to do so:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source=test| search "behavior.system.processes.process{}.fileactivities.fileCreated.call{}.path"="C:\\Windows*" | table "behavior.system.processes.process{}.fileactivities.fileCreated.call{}.path"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;However, the issue is that this shows me all fileCreated of the matching event and not only the one starting with C:\Windows.&lt;/P&gt;

&lt;P&gt;How do I filter that?&lt;/P&gt;</description>
      <pubDate>Wed, 08 May 2019 20:10:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Only-select-matching-JSON-data/m-p/449762#M171420</guid>
      <dc:creator>joesecurity</dc:creator>
      <dc:date>2019-05-08T20:10:59Z</dc:date>
    </item>
    <item>
      <title>Re: Only select matching JSON data</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Only-select-matching-JSON-data/m-p/449763#M171421</link>
      <description>&lt;P&gt;@joesecurity &lt;/P&gt;

&lt;P&gt;Can you please share sample event?&lt;/P&gt;</description>
      <pubDate>Thu, 09 May 2019 04:42:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Only-select-matching-JSON-data/m-p/449763#M171421</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2019-05-09T04:42:24Z</dc:date>
    </item>
    <item>
      <title>Re: Only select matching JSON data</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Only-select-matching-JSON-data/m-p/449764#M171422</link>
      <description>&lt;P&gt;Added event data.&lt;/P&gt;</description>
      <pubDate>Thu, 09 May 2019 07:16:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Only-select-matching-JSON-data/m-p/449764#M171422</guid>
      <dc:creator>joesecurity</dc:creator>
      <dc:date>2019-05-09T07:16:36Z</dc:date>
    </item>
    <item>
      <title>Re: Only select matching JSON data</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Only-select-matching-JSON-data/m-p/449765#M171423</link>
      <description>&lt;P&gt;Looks like your field is a multivalue field because the way through your JSON Object is the same for all fields called "path".&lt;/P&gt;

&lt;P&gt;You can select a value from a multivalue field with the help of eval and mvindex:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;source=test| search "behavior.system.processes.process{}.fileactivities.fileCreated.call{}.path"="C:\\Windows*" | eval path=mvindex('behavior.system.processes.process{}.fileactivities.fileCreated.call{}.path',0) | table path&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Does this work for you?&lt;/P&gt;</description>
      <pubDate>Thu, 09 May 2019 07:43:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Only-select-matching-JSON-data/m-p/449765#M171423</guid>
      <dc:creator>tom_frotscher</dc:creator>
      <dc:date>2019-05-09T07:43:32Z</dc:date>
    </item>
    <item>
      <title>Re: Only select matching JSON data</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Only-select-matching-JSON-data/m-p/449766#M171424</link>
      <description>&lt;P&gt;This does not really help as I want to search all paths in all events but obviously only show the paths which matched. &lt;/P&gt;</description>
      <pubDate>Thu, 09 May 2019 07:52:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Only-select-matching-JSON-data/m-p/449766#M171424</guid>
      <dc:creator>joesecurity</dc:creator>
      <dc:date>2019-05-09T07:52:18Z</dc:date>
    </item>
    <item>
      <title>Re: Only select matching JSON data</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Only-select-matching-JSON-data/m-p/449767#M171425</link>
      <description>&lt;P&gt;Then you might use mvfilter to filter down your multivalue fields to what you need in the end? Like using a regex with mvfilter that filters out only paths that start with &lt;CODE&gt;C:\\Windows*&lt;/CODE&gt;.&lt;/P&gt;</description>
      <pubDate>Thu, 09 May 2019 08:16:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Only-select-matching-JSON-data/m-p/449767#M171425</guid>
      <dc:creator>tom_frotscher</dc:creator>
      <dc:date>2019-05-09T08:16:25Z</dc:date>
    </item>
    <item>
      <title>Re: Only select matching JSON data</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Only-select-matching-JSON-data/m-p/449768#M171426</link>
      <description>&lt;P&gt;I will give you an example. You can copy this and run it in your splunk:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;| makeresults | eval field="C:\\Windows\\a,F:\\Foo" | makemv delim="," field | eval path=mvfilter(match(field,"C:\\\\Windows.*"))&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Everything up to &lt;CODE&gt;| makeresults | eval field="C:\\Windows\\a,F:\\Foo" | makemv delim="," field&lt;/CODE&gt; should look like your result and the &lt;CODE&gt;| eval path=mvfilter(match(field,"C:\\\\Windows.*"))&lt;/CODE&gt; filters down the result to the C:\Windows* match.&lt;/P&gt;</description>
      <pubDate>Thu, 09 May 2019 08:21:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Only-select-matching-JSON-data/m-p/449768#M171426</guid>
      <dc:creator>tom_frotscher</dc:creator>
      <dc:date>2019-05-09T08:21:54Z</dc:date>
    </item>
    <item>
      <title>Re: Only select matching JSON data</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Only-select-matching-JSON-data/m-p/449769#M171427</link>
      <description>&lt;P&gt;@joesecurity&lt;/P&gt;

&lt;P&gt;Can you please try below search?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source=test | rename "analysis.behavior.processes.process{}.fileactivities.fileCreated.call{}.path" as fileCreated_path 
| mvexpand fileCreated_path 
| search fileCreated_path="C:\\Windows\\*"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;My Sample Search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval _raw="{\"analysis\":{\"behavior\":{\"processes\":{\"process\":[{\"fileactivities\":{\"fileCreated\":{\"call\":[{\"path\":\"C:\\\\Windows\\\\a\"},{\"path\":\"C:\\\\b\"}]}}}]}}}}" 
| kv 
| rename "analysis.behavior.processes.process{}.fileactivities.fileCreated.call{}.path" as fileCreated_path 
| mvexpand fileCreated_path 
| search fileCreated_path="C:\\Windows\\*"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 09 May 2019 08:27:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Only-select-matching-JSON-data/m-p/449769#M171427</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2019-05-09T08:27:48Z</dc:date>
    </item>
    <item>
      <title>Re: Only select matching JSON data</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Only-select-matching-JSON-data/m-p/449770#M171428</link>
      <description>&lt;P&gt;I tried this on my data but I don't get any results. &lt;/P&gt;</description>
      <pubDate>Thu, 09 May 2019 09:04:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Only-select-matching-JSON-data/m-p/449770#M171428</guid>
      <dc:creator>joesecurity</dc:creator>
      <dc:date>2019-05-09T09:04:12Z</dc:date>
    </item>
    <item>
      <title>Re: Only select matching JSON data</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Only-select-matching-JSON-data/m-p/449771#M171429</link>
      <description>&lt;P&gt;Is there a way to debug the call to see why it does not work?&lt;/P&gt;</description>
      <pubDate>Thu, 09 May 2019 09:16:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Only-select-matching-JSON-data/m-p/449771#M171429</guid>
      <dc:creator>joesecurity</dc:creator>
      <dc:date>2019-05-09T09:16:58Z</dc:date>
    </item>
    <item>
      <title>Re: Only select matching JSON data</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Only-select-matching-JSON-data/m-p/449772#M171430</link>
      <description>&lt;P&gt;@joesecurity&lt;/P&gt;

&lt;P&gt;Did you get any results from the below search? Can you please confirm?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; source=test | table "analysis.behavior.processes.process{}.fileactivities.fileCreated.call{}.path"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 09 May 2019 10:08:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Only-select-matching-JSON-data/m-p/449772#M171430</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2019-05-09T10:08:26Z</dc:date>
    </item>
    <item>
      <title>Re: Only select matching JSON data</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Only-select-matching-JSON-data/m-p/449773#M171431</link>
      <description>&lt;P&gt;No results found in the visualization tab.&lt;/P&gt;</description>
      <pubDate>Thu, 09 May 2019 10:29:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Only-select-matching-JSON-data/m-p/449773#M171431</guid>
      <dc:creator>joesecurity</dc:creator>
      <dc:date>2019-05-09T10:29:47Z</dc:date>
    </item>
    <item>
      <title>Re: Only select matching JSON data</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Only-select-matching-JSON-data/m-p/449774#M171432</link>
      <description>&lt;P&gt;in Statistics tab?&lt;/P&gt;</description>
      <pubDate>Thu, 09 May 2019 10:31:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Only-select-matching-JSON-data/m-p/449774#M171432</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2019-05-09T10:31:26Z</dc:date>
    </item>
    <item>
      <title>Re: Only select matching JSON data</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Only-select-matching-JSON-data/m-p/449775#M171433</link>
      <description>&lt;P&gt;I found it. There was a difference between the JSON format listed in the example and the actual data.&lt;/P&gt;</description>
      <pubDate>Thu, 09 May 2019 10:42:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Only-select-matching-JSON-data/m-p/449775#M171433</guid>
      <dc:creator>joesecurity</dc:creator>
      <dc:date>2019-05-09T10:42:25Z</dc:date>
    </item>
    <item>
      <title>Re: Only select matching JSON data</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Only-select-matching-JSON-data/m-p/449776#M171434</link>
      <description>&lt;P&gt;One last question, let us assume "call" has more elements, also "status". How can I list the "path" and "status" for all calls which have path="C:\Windows*?&lt;/P&gt;</description>
      <pubDate>Thu, 09 May 2019 10:52:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Only-select-matching-JSON-data/m-p/449776#M171434</guid>
      <dc:creator>joesecurity</dc:creator>
      <dc:date>2019-05-09T10:52:15Z</dc:date>
    </item>
    <item>
      <title>Re: Only select matching JSON data</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Only-select-matching-JSON-data/m-p/449777#M171435</link>
      <description>&lt;P&gt;For that, I have a magic for you. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval _raw=" {  
    \"analysis\":{  
       \"behavior\":{  
          \"processes\":{  
             \"process\":[  
                {  
                   \"fileactivities\":{  
                      \"fileCreated\":{  
                         \"call\":[  
                            {  
                               \"path\":\"C:\\\\Windows\\\\a\",
                               \"status\":\"status1\"
                                    },
                            {  
                               \"path\":\"C:\\\\b\",
                               \"status\":\"status2\",
                            }
                         ]
                      }
                   }
                }
             ]
          }
       }
    }
 }" 
| kv 
| rename "analysis.behavior.processes.process{}.fileactivities.fileCreated.call{}.path" as fileCreated_path, "analysis.behavior.processes.process{}.fileactivities.fileCreated.call{}.status" as fileCreated_status 
| eval temp=mvzip(fileCreated_path,fileCreated_status) 
| mvexpand temp 
| eval fileCreated_path=mvindex(split(temp,","),0),fileCreated_status=mvindex(split(temp,","),1) 
| search fileCreated_path="C:\\Windows\\*"
| table _time fileCreated_path fileCreated_status
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;Happy Splunking&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 09 May 2019 11:27:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Only-select-matching-JSON-data/m-p/449777#M171435</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2019-05-09T11:27:19Z</dc:date>
    </item>
  </channel>
</rss>

