<?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 Number of fields occurrence  in json data in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Number-of-fields-occurrence-in-json-data/m-p/503005#M139962</link>
    <description>&lt;P&gt;I have below data &lt;/P&gt;

&lt;P&gt;`&lt;BR /&gt;
 { [-]&lt;BR /&gt;
   context: { [+]&lt;BR /&gt;
   }&lt;BR /&gt;
   level: INFO&lt;BR /&gt;
   logger: x.x.x.xxx.service.xxxService&lt;BR /&gt;
   msg: Filtered statements for account XXXXX: DocumentReferences[references=[DocumentReference[reference=0000001,name=XXXXX_2019,mimeType=APPLICATION_PDF,documentType=ANNUAL_STATEMENT,creationDate=2019-11-18T13:37:13.000Z], DocumentReference[reference=0000002,name=XXXXX_2018,mimeType=APPLICATION_PDF,documentType=ANNUAL_STATEMENT,creationDate=2019-12-03T10:54:47.000Z], DocumentReference[reference=0000003,name=XXXXX_2017,mimeType=APPLICATION_PDF,documentType=ANNUAL_STATEMENT,creationDate=2019-12-03T11:00:52.000Z]]]&lt;/P&gt;

&lt;P&gt;}&lt;BR /&gt;
`&lt;BR /&gt;
I want to search more than one ANNUAL_STATEMENT occurrence . As above data have 3 statement then this result should return in table &lt;/P&gt;</description>
    <pubDate>Wed, 30 Sep 2020 03:17:59 GMT</pubDate>
    <dc:creator>govindparashar1</dc:creator>
    <dc:date>2020-09-30T03:17:59Z</dc:date>
    <item>
      <title>Number of fields occurrence  in json data</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Number-of-fields-occurrence-in-json-data/m-p/503005#M139962</link>
      <description>&lt;P&gt;I have below data &lt;/P&gt;

&lt;P&gt;`&lt;BR /&gt;
 { [-]&lt;BR /&gt;
   context: { [+]&lt;BR /&gt;
   }&lt;BR /&gt;
   level: INFO&lt;BR /&gt;
   logger: x.x.x.xxx.service.xxxService&lt;BR /&gt;
   msg: Filtered statements for account XXXXX: DocumentReferences[references=[DocumentReference[reference=0000001,name=XXXXX_2019,mimeType=APPLICATION_PDF,documentType=ANNUAL_STATEMENT,creationDate=2019-11-18T13:37:13.000Z], DocumentReference[reference=0000002,name=XXXXX_2018,mimeType=APPLICATION_PDF,documentType=ANNUAL_STATEMENT,creationDate=2019-12-03T10:54:47.000Z], DocumentReference[reference=0000003,name=XXXXX_2017,mimeType=APPLICATION_PDF,documentType=ANNUAL_STATEMENT,creationDate=2019-12-03T11:00:52.000Z]]]&lt;/P&gt;

&lt;P&gt;}&lt;BR /&gt;
`&lt;BR /&gt;
I want to search more than one ANNUAL_STATEMENT occurrence . As above data have 3 statement then this result should return in table &lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 03:17:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Number-of-fields-occurrence-in-json-data/m-p/503005#M139962</guid>
      <dc:creator>govindparashar1</dc:creator>
      <dc:date>2020-09-30T03:17:59Z</dc:date>
    </item>
    <item>
      <title>Re: Number of fields occurrence  in json data</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Number-of-fields-occurrence-in-json-data/m-p/503006#M139963</link>
      <description>&lt;P&gt;Hi , &lt;/P&gt;

&lt;P&gt;try this&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;base query| spath | stats count(**documentType) as DocType,  values(**reference) as Reference , values(**name) as Name  by **msg| rex field=**msg "Filtered\sstatements\sfor\saccount\s(?P&amp;lt;AccountNo&amp;gt;[^\:]+)" | search DocType &amp;gt; 1 | table AccountNo , Name, Reference, DocType&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;Here when we use spath , fields are automatically extracted . Choose the right field name that is under interesting fileds and put in above query and try . &lt;/P&gt;

&lt;P&gt;Thanks &lt;BR /&gt;
Anantha.&lt;/P&gt;</description>
      <pubDate>Tue, 10 Dec 2019 17:44:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Number-of-fields-occurrence-in-json-data/m-p/503006#M139963</guid>
      <dc:creator>Anantha123</dc:creator>
      <dc:date>2019-12-10T17:44:38Z</dc:date>
    </item>
    <item>
      <title>Re: Number of fields occurrence  in json data</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Number-of-fields-occurrence-in-json-data/m-p/503007#M139964</link>
      <description>&lt;P&gt;Hi Govind,&lt;/P&gt;

&lt;P&gt;You need to parse the JSON logs to achieve this.&lt;BR /&gt;
To parse the logs - you need to trim down the events to make it as exact JSON Splunk expects.&lt;BR /&gt;
Use regex or replace functionality for that.&lt;/P&gt;

&lt;P&gt;You could use the below query after that.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|your_query
|search documentType="ANNUAL_STATEMENT"
|stats list (reference),list(name),list(mimeType),list(documentType),list(creationDate)
|where mvcount(documentType)&amp;gt;1
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 10 Dec 2019 19:04:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Number-of-fields-occurrence-in-json-data/m-p/503007#M139964</guid>
      <dc:creator>dindu</dc:creator>
      <dc:date>2019-12-10T19:04:45Z</dc:date>
    </item>
  </channel>
</rss>

