<?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 How to search indexed JSON array output for objects that match a distinct name/value pair in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-indexed-JSON-array-output-for-objects-that-match-a/m-p/508692#M142125</link>
    <description>&lt;P&gt;I'm calling a REST API using curl on a UF to collect data from a remote DataPower appliance; the output is in JSON format and is written to a flat file that Splunk ingests and indexes. The JSON data looks like this (this snippet represents one event ingested by Splunk with three classes/objects cited in the "ObjectStatus" array; in reality, there can be dozens and dozens of classes/objects within the array):&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;"_links" : {&lt;/P&gt;&lt;P&gt;"self" : {"href" : "/mgmt/status/default/ObjectStatus"},&lt;/P&gt;&lt;P&gt;"doc" : {"href" : "/mgmt/docs/status/ObjectStatus"}},&lt;/P&gt;&lt;P&gt;"ObjectStatus" : [{&lt;/P&gt;&lt;P&gt;"Class" : "DNSNameService",&lt;/P&gt;&lt;P&gt;"OpState" : "up",&lt;/P&gt;&lt;P&gt;"AdminState" : "enabled",&lt;/P&gt;&lt;P&gt;"Name" : "dns",&lt;/P&gt;&lt;P&gt;"EventCode" : "0x00000000",&lt;/P&gt;&lt;P&gt;"ErrorCode" : "",&lt;/P&gt;&lt;P&gt;"ConfigState" : "saved"}, {&lt;/P&gt;&lt;P&gt;"Class" : "CRLFetch",&lt;/P&gt;&lt;P&gt;"OpState" : "down",&lt;/P&gt;&lt;P&gt;"AdminState" : "enabled",&lt;/P&gt;&lt;P&gt;"Name" : "crl",&lt;/P&gt;&lt;P&gt;"EventCode" : "0x00360010",&lt;/P&gt;&lt;P&gt;"ErrorCode" : "No CRLs configured",&lt;/P&gt;&lt;P&gt;"ConfigState" : "saved"}, {&lt;/P&gt;&lt;P&gt;"Class" : "Statistics",&lt;/P&gt;&lt;P&gt;"OpState" : "up",&lt;/P&gt;&lt;P&gt;"AdminState" : "enabled",&lt;/P&gt;&lt;P&gt;"Name" : "statistics",&lt;/P&gt;&lt;P&gt;"EventCode" : "0x00000000",&lt;/P&gt;&lt;P&gt;"ErrorCode" : "",&lt;/P&gt;&lt;P&gt;"ConfigState" : "saved"}]}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm using a custom sourcetype to process the events in Splunk; props.conf looks like this (installed on both the UF and my indexers):&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; [dp_json]&lt;BR /&gt;&amp;nbsp; &amp;nbsp; INDEXED_EXTRACTIONS = json&lt;BR /&gt;&amp;nbsp; &amp;nbsp; KV_MODE = none&lt;/P&gt;&lt;P&gt;Splunk appears to be processing the events correctly, as the following fields are present (and match up with the expected values):&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; ObjectStatus{}.AdminState&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;ObjectStatus{}.Class&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;ObjectStatus{}.ConfigState&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;ObjectStatus{}.ErrorCode&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;ObjectStatus{}.EventCode&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;ObjectStatus{}.Name&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;ObjectStatus{}.OpState&lt;/P&gt;&lt;P&gt;Here's my dilemma. I would like to identify objects in a particular state. For example:&amp;nbsp; I would like to know which objects in the array have ObjectStatus{}.OpState equal to "down", with the ObjectStatus{}.Class and ObjectStatus{}.OpState returned for each object that matches. I've tried a search query such as this...&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;sourcetype=dp_json index=main "ObjectStatus{}.OpState"="down" | table "ObjectStatus{}.Class", "ObjectStatus{}.OpState"&lt;/P&gt;&lt;P&gt;...but this returns every Class from each event, regardless of OpState being "up" or "down".&lt;/P&gt;&lt;P&gt;What adjustments are required in order to get the output I'm looking for?&lt;/P&gt;</description>
    <pubDate>Sun, 12 Jul 2020 16:38:55 GMT</pubDate>
    <dc:creator>beetlegeuse</dc:creator>
    <dc:date>2020-07-12T16:38:55Z</dc:date>
    <item>
      <title>How to search indexed JSON array output for objects that match a distinct name/value pair</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-indexed-JSON-array-output-for-objects-that-match-a/m-p/508692#M142125</link>
      <description>&lt;P&gt;I'm calling a REST API using curl on a UF to collect data from a remote DataPower appliance; the output is in JSON format and is written to a flat file that Splunk ingests and indexes. The JSON data looks like this (this snippet represents one event ingested by Splunk with three classes/objects cited in the "ObjectStatus" array; in reality, there can be dozens and dozens of classes/objects within the array):&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;"_links" : {&lt;/P&gt;&lt;P&gt;"self" : {"href" : "/mgmt/status/default/ObjectStatus"},&lt;/P&gt;&lt;P&gt;"doc" : {"href" : "/mgmt/docs/status/ObjectStatus"}},&lt;/P&gt;&lt;P&gt;"ObjectStatus" : [{&lt;/P&gt;&lt;P&gt;"Class" : "DNSNameService",&lt;/P&gt;&lt;P&gt;"OpState" : "up",&lt;/P&gt;&lt;P&gt;"AdminState" : "enabled",&lt;/P&gt;&lt;P&gt;"Name" : "dns",&lt;/P&gt;&lt;P&gt;"EventCode" : "0x00000000",&lt;/P&gt;&lt;P&gt;"ErrorCode" : "",&lt;/P&gt;&lt;P&gt;"ConfigState" : "saved"}, {&lt;/P&gt;&lt;P&gt;"Class" : "CRLFetch",&lt;/P&gt;&lt;P&gt;"OpState" : "down",&lt;/P&gt;&lt;P&gt;"AdminState" : "enabled",&lt;/P&gt;&lt;P&gt;"Name" : "crl",&lt;/P&gt;&lt;P&gt;"EventCode" : "0x00360010",&lt;/P&gt;&lt;P&gt;"ErrorCode" : "No CRLs configured",&lt;/P&gt;&lt;P&gt;"ConfigState" : "saved"}, {&lt;/P&gt;&lt;P&gt;"Class" : "Statistics",&lt;/P&gt;&lt;P&gt;"OpState" : "up",&lt;/P&gt;&lt;P&gt;"AdminState" : "enabled",&lt;/P&gt;&lt;P&gt;"Name" : "statistics",&lt;/P&gt;&lt;P&gt;"EventCode" : "0x00000000",&lt;/P&gt;&lt;P&gt;"ErrorCode" : "",&lt;/P&gt;&lt;P&gt;"ConfigState" : "saved"}]}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm using a custom sourcetype to process the events in Splunk; props.conf looks like this (installed on both the UF and my indexers):&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; [dp_json]&lt;BR /&gt;&amp;nbsp; &amp;nbsp; INDEXED_EXTRACTIONS = json&lt;BR /&gt;&amp;nbsp; &amp;nbsp; KV_MODE = none&lt;/P&gt;&lt;P&gt;Splunk appears to be processing the events correctly, as the following fields are present (and match up with the expected values):&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; ObjectStatus{}.AdminState&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;ObjectStatus{}.Class&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;ObjectStatus{}.ConfigState&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;ObjectStatus{}.ErrorCode&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;ObjectStatus{}.EventCode&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;ObjectStatus{}.Name&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;ObjectStatus{}.OpState&lt;/P&gt;&lt;P&gt;Here's my dilemma. I would like to identify objects in a particular state. For example:&amp;nbsp; I would like to know which objects in the array have ObjectStatus{}.OpState equal to "down", with the ObjectStatus{}.Class and ObjectStatus{}.OpState returned for each object that matches. I've tried a search query such as this...&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;sourcetype=dp_json index=main "ObjectStatus{}.OpState"="down" | table "ObjectStatus{}.Class", "ObjectStatus{}.OpState"&lt;/P&gt;&lt;P&gt;...but this returns every Class from each event, regardless of OpState being "up" or "down".&lt;/P&gt;&lt;P&gt;What adjustments are required in order to get the output I'm looking for?&lt;/P&gt;</description>
      <pubDate>Sun, 12 Jul 2020 16:38:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-indexed-JSON-array-output-for-objects-that-match-a/m-p/508692#M142125</guid>
      <dc:creator>beetlegeuse</dc:creator>
      <dc:date>2020-07-12T16:38:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to search indexed JSON array output for objects that match a distinct name/value pair</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-indexed-JSON-array-output-for-objects-that-match-a/m-p/514905#M144545</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/167489"&gt;@beetlegeuse&lt;/a&gt;&amp;nbsp;, your query looks correct , but have you tried with&amp;nbsp;&lt;SPAN&gt;"ObjectStatus{}.OpState"="*down*"&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;to rule any possibility of spaces in the value.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Aug 2020 10:40:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-indexed-JSON-array-output-for-objects-that-match-a/m-p/514905#M144545</guid>
      <dc:creator>Nisha18789</dc:creator>
      <dc:date>2020-08-19T10:40:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to search indexed JSON array output for objects that match a distinct name/value pair</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-indexed-JSON-array-output-for-objects-that-match-a/m-p/514914#M144546</link>
      <description>&lt;LI-CODE lang="markup"&gt;index=_internal | head 1| fields _raw
| eval _raw="{\"_links\":{\"self\":{\"href\":\"/mgmt/status/default/ObjectStatus\"},\"doc\":{\"href\":\"/mgmt/docs/status/ObjectStatus\"}},\"ObjectStatus\":[{\"Class\":\"DNSNameService\",\"OpState\":\"up\",\"AdminState\":\"enabled\",\"Name\":\"dns\",\"EventCode\":\"0x00000000\",\"ErrorCode\":\"\",\"ConfigState\":\"saved\"},{\"Class\":\"CRLFetch\",\"OpState\":\"down\",\"AdminState\":\"enabled\",\"Name\":\"crl\",\"EventCode\":\"0x00360010\",\"ErrorCode\":\"No CRLs configured\",\"ConfigState\":\"saved\"},{\"Class\":\"Statistics\",\"OpState\":\"up\",\"AdminState\":\"enabled\",\"Name\":\"statistics\",\"EventCode\":\"0x00000000\",\"ErrorCode\":\"\",\"ConfigState\":\"saved\"}]}"
| spath ObjectStatus{} output=ObjectStatus
| spath
| stats values(links.*) as * by ObjectStatus
| spath input=ObjectStatus
| fields - ObjectStatus
| search OpState=down&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 19 Aug 2020 11:09:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-indexed-JSON-array-output-for-objects-that-match-a/m-p/514914#M144546</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-08-19T11:09:32Z</dc:date>
    </item>
  </channel>
</rss>

