<?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 json array searching in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/json-array-searching/m-p/559598#M92547</link>
    <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to return results if an item in the array has both values set to specific values.&lt;/P&gt;&lt;P&gt;ie bu = "blob" and disp="enforce" on the one array item&lt;/P&gt;&lt;P&gt;However,&amp;nbsp; my search seems to happen across items.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;|makeresults&lt;BR /&gt;|eval _raw ="{&lt;BR /&gt;\"sp_v\":[&lt;BR /&gt;{\"bu\":\"blob\",\"disp\":\"enforce\"},&lt;BR /&gt;{\"bu\":\"inline\",\"disp\":\"report\"}&lt;BR /&gt;]&lt;BR /&gt;}"&lt;BR /&gt;| spath&lt;BR /&gt;| search sp_v{}.bu=blob AND sp_v{}.disp=report&lt;/P&gt;&lt;P&gt;This is returning result as the first item has 'blob' and the second has 'report'.&lt;/P&gt;&lt;P&gt;I would not expect any results in this search&lt;/P&gt;&lt;P&gt;Would appreciate any help,&lt;/P&gt;&lt;P&gt;Kind Regards,&lt;/P&gt;&lt;P&gt;Maurice&lt;/P&gt;</description>
    <pubDate>Thu, 15 Jul 2021 13:59:01 GMT</pubDate>
    <dc:creator>Maurice</dc:creator>
    <dc:date>2021-07-15T13:59:01Z</dc:date>
    <item>
      <title>json array searching</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/json-array-searching/m-p/559598#M92547</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to return results if an item in the array has both values set to specific values.&lt;/P&gt;&lt;P&gt;ie bu = "blob" and disp="enforce" on the one array item&lt;/P&gt;&lt;P&gt;However,&amp;nbsp; my search seems to happen across items.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;|makeresults&lt;BR /&gt;|eval _raw ="{&lt;BR /&gt;\"sp_v\":[&lt;BR /&gt;{\"bu\":\"blob\",\"disp\":\"enforce\"},&lt;BR /&gt;{\"bu\":\"inline\",\"disp\":\"report\"}&lt;BR /&gt;]&lt;BR /&gt;}"&lt;BR /&gt;| spath&lt;BR /&gt;| search sp_v{}.bu=blob AND sp_v{}.disp=report&lt;/P&gt;&lt;P&gt;This is returning result as the first item has 'blob' and the second has 'report'.&lt;/P&gt;&lt;P&gt;I would not expect any results in this search&lt;/P&gt;&lt;P&gt;Would appreciate any help,&lt;/P&gt;&lt;P&gt;Kind Regards,&lt;/P&gt;&lt;P&gt;Maurice&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jul 2021 13:59:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/json-array-searching/m-p/559598#M92547</guid>
      <dc:creator>Maurice</dc:creator>
      <dc:date>2021-07-15T13:59:01Z</dc:date>
    </item>
    <item>
      <title>Re: json array searching</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/json-array-searching/m-p/559607#M92549</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/236229"&gt;@Maurice&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you please try this?&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;YOUR_SEARCH
| spath
| rename sp_v{}.* as *
| eval t = mvzip(bu,disp) | mvexpand t| eval bu=mvindex(split(t,","),0),disp=mvindex(split(t,","),1)
| where bu="blob" AND disp="report"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;My Sample Search :&lt;/STRONG&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;|makeresults
|eval _raw ="{
\"sp_v\":[
{\"bu\":\"blob\",\"disp\":\"enforce\"},
{\"bu\":\"inline\",\"disp\":\"report\"}
]
}"
| spath
| rename sp_v{}.* as *
| eval t = mvzip(bu,disp) | mvexpand t| eval bu=mvindex(split(t,","),0),disp=mvindex(split(t,","),1)
| where bu="blob" AND disp="report"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;BR /&gt;KV&lt;BR /&gt;▄︻̷̿┻̿═━一&lt;BR /&gt;&lt;BR /&gt;If any of my reply helps you to solve the problem Or gain knowledge, an upvote would be appreciated.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jul 2021 14:48:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/json-array-searching/m-p/559607#M92549</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2021-07-15T14:48:37Z</dc:date>
    </item>
    <item>
      <title>Re: json array searching</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/json-array-searching/m-p/559618#M92550</link>
      <description>&lt;P&gt;Thanks KV,&lt;/P&gt;&lt;P&gt;&amp;nbsp;That works great.&lt;/P&gt;&lt;P&gt;&amp;nbsp;My only issue is that in my dashboard I am building up this query using inputs (for most properties on the array).&lt;/P&gt;&lt;P&gt;So there could be up to 7 or 8 properties to search on.&lt;/P&gt;&lt;P&gt;I notice from the docs that mvzip only works with 2 properties by default. so I tried with 3 which worked(see below):&lt;/P&gt;&lt;P&gt;|makeresults&lt;BR /&gt;|eval _raw ="{&lt;BR /&gt;\"sp_v\":[&lt;BR /&gt;{\"bu\":\"blob\",\"disp\":\"enforce\", \"an\":\"test\"},&lt;BR /&gt;{\"bu\":\"inline\",\"disp\":\"report\", \"an\":\"another\"}&lt;BR /&gt;]&lt;BR /&gt;}"&lt;BR /&gt;| spath&lt;BR /&gt;| rename sp_v{}.* as *&lt;BR /&gt;| eval t = mvzip(mvzip(bu,disp), an)&lt;BR /&gt;| mvexpand t&lt;BR /&gt;| eval bu=mvindex(split(t,","),0),disp=mvindex(split(t,","),1), an=mvindex(split(t,","),2)&lt;BR /&gt;| where bu="blob" AND disp="enforce" AND an="test"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'd imagine the code would become hard to read as I have to nest mvzip inside itself and also change the index&lt;/P&gt;&lt;P&gt;Do you know of a more readable way it accomplish this with&amp;nbsp; more properties?&lt;/P&gt;&lt;P&gt;Kind regards,&lt;/P&gt;&lt;P&gt;Maurice&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jul 2021 15:36:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/json-array-searching/m-p/559618#M92550</guid>
      <dc:creator>Maurice</dc:creator>
      <dc:date>2021-07-15T15:36:17Z</dc:date>
    </item>
    <item>
      <title>Re: json array searching</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/json-array-searching/m-p/559619#M92551</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/236229"&gt;@Maurice&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you have multiple fields then I suggest this solution.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;|makeresults
|eval _raw ="{
\"sp_v\":[
{\"bu\":\"blob\",\"disp\":\"enforce\", \"an\":\"test\"},
{\"bu\":\"inline\",\"disp\":\"report\", \"an\":\"another\"}
]
}"
| spath path=sp_v{} output=data | stats count by data | rename data as _raw | extract 
| where bu="blob" AND disp="enforce" AND an="test"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;BR /&gt;KV&lt;BR /&gt;▄︻̷̿┻̿═━一&lt;BR /&gt;&lt;BR /&gt;If any of my reply helps you to solve the problem Or gain knowledge, an upvote would be appreciated.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jul 2021 15:40:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/json-array-searching/m-p/559619#M92551</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2021-07-15T15:40:16Z</dc:date>
    </item>
    <item>
      <title>Re: json array searching</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/json-array-searching/m-p/559789#M92567</link>
      <description>&lt;P&gt;Thanks KV,&lt;/P&gt;&lt;P&gt;That looks like much more maintainable code.&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":grinning_face:"&gt;😀&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;One last think, I wanted to create a timechart also off the data but it fails once i use a real index instead of make results.&lt;/P&gt;&lt;P&gt;I am presuming it has something to do with _time not being in the result set:&lt;/P&gt;&lt;P&gt;index=myIndex source=mySource&amp;nbsp; spath path=sp_v{} output=data | stats count by data | rename data as _raw | extract | timechart span=1d count(bu)&amp;nbsp; useother=f usenull=f&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any ideas?&lt;/P&gt;&lt;P&gt;Kind Regards,&lt;/P&gt;&lt;P&gt;Maurice&lt;/P&gt;</description>
      <pubDate>Fri, 16 Jul 2021 11:00:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/json-array-searching/m-p/559789#M92567</guid>
      <dc:creator>Maurice</dc:creator>
      <dc:date>2021-07-16T11:00:21Z</dc:date>
    </item>
    <item>
      <title>Re: json array searching</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/json-array-searching/m-p/559790#M92568</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/236229"&gt;@Maurice&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For timechart try this.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=myIndex source=mySource 
| spath path=sp_v{} output=data 
| stats count by _time data 
| rename data as _raw | extract 
| timechart span=1d count(bu)  useother=f usenull=f&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Jul 2021 11:03:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/json-array-searching/m-p/559790#M92568</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2021-07-16T11:03:33Z</dc:date>
    </item>
  </channel>
</rss>

