<?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: stats query on JSON data in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/stats-query-on-JSON-data/m-p/177621#M35587</link>
    <description>&lt;P&gt;It seems to me as if &lt;CODE&gt;spath&lt;/CODE&gt; is confused by single quotes in the JSON. Take a look at this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats count | fields - count | eval _raw = "07/03/2014 11:55:05 Debug [b9d94320-2915-4bbc-a96f-98fa125c4e27] [IC3QOE11OAB5318640POGM14VSURV5] Wallet3DSecureSetResult started with Result[{'paressyntaxok':'true','paresverified':'false','version':'2.0','merchantid':'455665864697','xid':'MDAwMDAwMDBPREhMMDUzNDc3NzE=','mdstatus':'1','mderrormsg':'Authenticated','txstatus':'Y','ireqcode':'','ireqdetail':'','vendorcode':'','eci':'02','cavv':'jOm+n8MEwOyKAREABwMDh/QP5n4=','cavvalgorithm':'3','md':'123,123','digest':'U2eto4Un1nUa3jdOlRuzQk59ERY=','sid':'2','veresenrolledstatus':'Y','parestxstatus':'Y','status':'ok','requestpage':'api_deposit.aspx'}] MPIKey[borgun]" | rex "Result\[(?&amp;lt;result&amp;gt;.*?)\]" | eval result=replace(result, "'", "\"") | spath input=result | fields merchantid mdstatus | fields - _raw
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This gives me your two interesting fields perfectly, but only after replacing the single quotes with double quotes.&lt;/P&gt;

&lt;P&gt;According to &lt;A href="http://www.json.org/"&gt;http://www.json.org/&lt;/A&gt; double quotes are the only valid way of enclosing strings in JSON. Consider fixing your source to output valid JSON.&lt;/P&gt;

&lt;P&gt;&lt;IMG src="http://www.json.org/string.gif" alt="alt text" /&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 07 Mar 2014 14:36:51 GMT</pubDate>
    <dc:creator>martin_mueller</dc:creator>
    <dc:date>2014-03-07T14:36:51Z</dc:date>
    <item>
      <title>stats query on JSON data</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/stats-query-on-JSON-data/m-p/177620#M35586</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I've been struggling with spath attempts for this for a day or two, so reaching out for help! I have the following detail within an event:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;07/03/2014 11:55:05 Debug [b9d94320-2915-4bbc-a96f-98fa125c4e27] [IC3QOE11OAB5318640POGM14VSURV5] Wallet3DSecureSetResult started with Result[{'paressyntaxok':'true','paresverified':'false','version':'2.0','merchantid':'455665864697','xid':'MDAwMDAwMDBPREhMMDUzNDc3NzE=','mdstatus':'1','mderrormsg':'Authenticated','txstatus':'Y','ireqcode':'','ireqdetail':'','vendorcode':'','eci':'02','cavv':'jOm+n8MEwOyKAREABwMDh/QP5n4=','cavvalgorithm':'3','md':'123,123','digest':'U2eto4Un1nUa3jdOlRuzQk59ERY=','sid':'2','veresenrolledstatus':'Y','parestxstatus':'Y','status':'ok','requestpage':'api_deposit.aspx'}] MPIKey[borgun] 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The detail I'm interested in is 'merchantid' and 'mdstatus'. &lt;/P&gt;

&lt;P&gt;mdstatus can be a value between 0 and 8 - I want to be able to analyse per merchantid the count of each mdstatus.&lt;/P&gt;

&lt;P&gt;Any help appreciated!&lt;/P&gt;

&lt;P&gt;Cheers,&lt;BR /&gt;
Luke&lt;/P&gt;</description>
      <pubDate>Fri, 07 Mar 2014 12:06:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/stats-query-on-JSON-data/m-p/177620#M35586</guid>
      <dc:creator>luke_vamasoft</dc:creator>
      <dc:date>2014-03-07T12:06:30Z</dc:date>
    </item>
    <item>
      <title>Re: stats query on JSON data</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/stats-query-on-JSON-data/m-p/177621#M35587</link>
      <description>&lt;P&gt;It seems to me as if &lt;CODE&gt;spath&lt;/CODE&gt; is confused by single quotes in the JSON. Take a look at this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats count | fields - count | eval _raw = "07/03/2014 11:55:05 Debug [b9d94320-2915-4bbc-a96f-98fa125c4e27] [IC3QOE11OAB5318640POGM14VSURV5] Wallet3DSecureSetResult started with Result[{'paressyntaxok':'true','paresverified':'false','version':'2.0','merchantid':'455665864697','xid':'MDAwMDAwMDBPREhMMDUzNDc3NzE=','mdstatus':'1','mderrormsg':'Authenticated','txstatus':'Y','ireqcode':'','ireqdetail':'','vendorcode':'','eci':'02','cavv':'jOm+n8MEwOyKAREABwMDh/QP5n4=','cavvalgorithm':'3','md':'123,123','digest':'U2eto4Un1nUa3jdOlRuzQk59ERY=','sid':'2','veresenrolledstatus':'Y','parestxstatus':'Y','status':'ok','requestpage':'api_deposit.aspx'}] MPIKey[borgun]" | rex "Result\[(?&amp;lt;result&amp;gt;.*?)\]" | eval result=replace(result, "'", "\"") | spath input=result | fields merchantid mdstatus | fields - _raw
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This gives me your two interesting fields perfectly, but only after replacing the single quotes with double quotes.&lt;/P&gt;

&lt;P&gt;According to &lt;A href="http://www.json.org/"&gt;http://www.json.org/&lt;/A&gt; double quotes are the only valid way of enclosing strings in JSON. Consider fixing your source to output valid JSON.&lt;/P&gt;

&lt;P&gt;&lt;IMG src="http://www.json.org/string.gif" alt="alt text" /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Mar 2014 14:36:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/stats-query-on-JSON-data/m-p/177621#M35587</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2014-03-07T14:36:51Z</dc:date>
    </item>
    <item>
      <title>Re: stats query on JSON data</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/stats-query-on-JSON-data/m-p/177622#M35588</link>
      <description>&lt;P&gt;Thank you Martin - I can enjoy my weekend now!!!&lt;/P&gt;</description>
      <pubDate>Fri, 07 Mar 2014 14:55:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/stats-query-on-JSON-data/m-p/177622#M35588</guid>
      <dc:creator>luke_vamasoft</dc:creator>
      <dc:date>2014-03-07T14:55:43Z</dc:date>
    </item>
  </channel>
</rss>

