<?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: How can we speed up JSON array lookup? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-can-we-speed-up-JSON-array-lookup/m-p/96012#M19991</link>
    <description>&lt;P&gt;@Iguinn: It doesn't give a noticeable speedup :'(&lt;/P&gt;</description>
    <pubDate>Wed, 23 Jan 2013 23:14:49 GMT</pubDate>
    <dc:creator>vinodkd</dc:creator>
    <dc:date>2013-01-23T23:14:49Z</dc:date>
    <item>
      <title>How can we speed up JSON array lookup?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-can-we-speed-up-JSON-array-lookup/m-p/96010#M19989</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;My JSON event is in this form:&lt;/P&gt;

&lt;P&gt;{&lt;BR /&gt;
  TotalMemUsage : 887992,&lt;BR /&gt;
  ProcMemUsage : [&lt;BR /&gt;
    {&lt;BR /&gt;
      Name : "firefox",&lt;BR /&gt;
      PID : 758,&lt;BR /&gt;
      Usg : 228972,&lt;BR /&gt;
    },&lt;BR /&gt;
    {&lt;BR /&gt;
      Name : "eclipse",&lt;BR /&gt;
      PID : 569,&lt;BR /&gt;
      Usg : 19756,&lt;BR /&gt;
    }&lt;BR /&gt;
  ]&lt;BR /&gt;
}&lt;/P&gt;

&lt;P&gt;I've to take average of each process's memory usage and draw a chart.&lt;BR /&gt;
For the time being, I use following query.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;my_search 
| rename ProcMemUsage{}.Name as PNAME | rename ProcMemUsage{}.Usg as PUSAGE
| eval x=mvzip(PNAME,PUSAGE) 
| mvexpand x|eval x=split(x,",")
| eval P_NAME=mvindex(x,0)
| eval P_USAGE = mvindex(x,1)
| stats avg(P_USAGE) as MU by P_NAME 
| sort -MU | fields MU,P_NAME
|chart avg(MU) as AvgMU by P_NAME 
| sort -AvgMU
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But it takes lot of time to complete the operation. (Approx 5 minutes with only 30K records.). &lt;BR /&gt;
Is there any way to optimize it? Can we use jsonutils somehow?&lt;/P&gt;</description>
      <pubDate>Tue, 22 Jan 2013 23:03:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-can-we-speed-up-JSON-array-lookup/m-p/96010#M19989</guid>
      <dc:creator>vinodkd</dc:creator>
      <dc:date>2013-01-22T23:03:58Z</dc:date>
    </item>
    <item>
      <title>Re: How can we speed up JSON array lookup?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-can-we-speed-up-JSON-array-lookup/m-p/96011#M19990</link>
      <description>&lt;P&gt;I don't really think this will make things faster, but it might help a little:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;my_search 
| rename ProcMemUsage{}.Name as PNAME | rename ProcMemUsage{}.Usg as PUSAGE
| fields PNAME PUSAGE
| eval x=mvzip(PNAME,PUSAGE) 
| mvexpand x
| eval x=split(x,",")
| eval P_NAME=mvindex(x,0)
| eval P_USAGE = mvindex(x,1)
| chart avg(P_USAGE) as AvgMU by P_NAME 
| sort -AvgMU
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;It's also a bit cleaner. Post back with your results.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Jan 2013 23:53:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-can-we-speed-up-JSON-array-lookup/m-p/96011#M19990</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2013-01-22T23:53:07Z</dc:date>
    </item>
    <item>
      <title>Re: How can we speed up JSON array lookup?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-can-we-speed-up-JSON-array-lookup/m-p/96012#M19991</link>
      <description>&lt;P&gt;@Iguinn: It doesn't give a noticeable speedup :'(&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jan 2013 23:14:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-can-we-speed-up-JSON-array-lookup/m-p/96012#M19991</guid>
      <dc:creator>vinodkd</dc:creator>
      <dc:date>2013-01-23T23:14:49Z</dc:date>
    </item>
  </channel>
</rss>

