<?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: Iterate the extraction of json objects using Splunk query language in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Iterate-the-extraction-of-json-objects-using-Splunk-query/m-p/135482#M27880</link>
    <description>&lt;P&gt;Thanks.&lt;BR /&gt;
I should have thought about this solution.&lt;/P&gt;</description>
    <pubDate>Wed, 19 Feb 2014 13:05:42 GMT</pubDate>
    <dc:creator>lpolo</dc:creator>
    <dc:date>2014-02-19T13:05:42Z</dc:date>
    <item>
      <title>Iterate the extraction of json objects using Splunk query language</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Iterate-the-extraction-of-json-objects-using-Splunk-query/m-p/135480#M27878</link>
      <description>&lt;P&gt;Is there an example that shows how to iterate the extraction of json objects using Splunk query language?&lt;/P&gt;

&lt;P&gt;The spath command documentation shows an example but it is only for 2 key names&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/6.0.1/SearchReference/Spath" target="test_blank"&gt;http://docs.splunk.com/Documentation/Splunk/6.0.1/SearchReference/Spath&lt;/A&gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I need to create a splunk query construct that iterates the json objects found in the following log event and then aggregate as follow:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Splunk main construct |stats sum(total) as total sum(Fails) as Fails sum(TimeOuts) as TimeOuts by client
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Is there a way to do it in Splunk query language?&lt;/P&gt;

&lt;P&gt;Json event:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[
{
"_time": "2014-02-17T18:15:00.000+00:00",
"Total": "194118",
"Bad": "7373",
"mean": "65.28",
"Fails": "10",
"client": "hello.com",
"TimeOuts": "0",
"Good": "194108",
"Service": "4u"
},
{
"_time": "2014-02-17T18:15:00.000+00:00",
"Total": "194118",
"Bad": "7373",
"mean": "65.28",
"Fails": "10",
"client": "HYO.com",
"TimeOuts": "0",
"Good": "194108",
"Service": "4u"
},
]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks ,&lt;BR /&gt;
Lp&lt;/P&gt;</description>
      <pubDate>Mon, 03 Feb 2014 17:30:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Iterate-the-extraction-of-json-objects-using-Splunk-query/m-p/135480#M27878</guid>
      <dc:creator>lpolo</dc:creator>
      <dc:date>2014-02-03T17:30:52Z</dc:date>
    </item>
    <item>
      <title>Re: Iterate the extraction of json objects using Splunk query language</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Iterate-the-extraction-of-json-objects-using-Splunk-query/m-p/135481#M27879</link>
      <description>&lt;P&gt;As another approach, because you have nice json events with a timestamp, and no sub level json.&lt;BR /&gt;
Why not defining a sourcetype that will break your json in events each time you reach a new line with "{"&lt;BR /&gt;
then you will have all your events separated, and can use spath to get your fields extracted.&lt;/P&gt;

&lt;P&gt;example : &lt;A href="http://answers.splunk.com/answers/80741/event-break-json"&gt;http://answers.splunk.com/answers/80741/event-break-json&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Feb 2014 20:00:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Iterate-the-extraction-of-json-objects-using-Splunk-query/m-p/135481#M27879</guid>
      <dc:creator>yannK</dc:creator>
      <dc:date>2014-02-18T20:00:34Z</dc:date>
    </item>
    <item>
      <title>Re: Iterate the extraction of json objects using Splunk query language</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Iterate-the-extraction-of-json-objects-using-Splunk-query/m-p/135482#M27880</link>
      <description>&lt;P&gt;Thanks.&lt;BR /&gt;
I should have thought about this solution.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Feb 2014 13:05:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Iterate-the-extraction-of-json-objects-using-Splunk-query/m-p/135482#M27880</guid>
      <dc:creator>lpolo</dc:creator>
      <dc:date>2014-02-19T13:05:42Z</dc:date>
    </item>
    <item>
      <title>Re: Iterate the extraction of json objects using Splunk query language</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Iterate-the-extraction-of-json-objects-using-Splunk-query/m-p/135483#M27881</link>
      <description>&lt;P&gt;yannK,&lt;/P&gt;

&lt;P&gt;Now, I am able to extract all the json key values as expected. However, I cannot aggregate using the stats function example presented in the question. The results are incorrect. Any idea?&lt;/P&gt;</description>
      <pubDate>Wed, 19 Feb 2014 14:39:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Iterate-the-extraction-of-json-objects-using-Splunk-query/m-p/135483#M27881</guid>
      <dc:creator>lpolo</dc:creator>
      <dc:date>2014-02-19T14:39:13Z</dc:date>
    </item>
    <item>
      <title>Re: Iterate the extraction of json objects using Splunk query language</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Iterate-the-extraction-of-json-objects-using-Splunk-query/m-p/135484#M27882</link>
      <description>&lt;P&gt;yannK,&lt;/P&gt;

&lt;P&gt;I think that the problem is that the json objects are not split into events. Therefore, any aggregation function will not work as expected.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Feb 2014 15:16:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Iterate-the-extraction-of-json-objects-using-Splunk-query/m-p/135484#M27882</guid>
      <dc:creator>lpolo</dc:creator>
      <dc:date>2014-02-19T15:16:30Z</dc:date>
    </item>
    <item>
      <title>Re: Iterate the extraction of json objects using Splunk query language</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Iterate-the-extraction-of-json-objects-using-Splunk-query/m-p/135485#M27883</link>
      <description>&lt;P&gt;I can assure you that my regex is correct.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Feb 2014 13:51:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Iterate-the-extraction-of-json-objects-using-Splunk-query/m-p/135485#M27883</guid>
      <dc:creator>lpolo</dc:creator>
      <dc:date>2014-02-26T13:51:06Z</dc:date>
    </item>
  </channel>
</rss>

