<?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: Doing stats on multivalued JSON fields (mxexpand is too slow) in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Doing-stats-on-multivalued-JSON-fields-mxexpand-is-too-slow/m-p/364607#M66428</link>
    <description>&lt;P&gt;No worries I already thought that and tired it and it works! I have to test it to verify the effective performance impact. Thanks a lot!&lt;/P&gt;</description>
    <pubDate>Wed, 04 Oct 2017 11:14:27 GMT</pubDate>
    <dc:creator>claudio_manig</dc:creator>
    <dc:date>2017-10-04T11:14:27Z</dc:date>
    <item>
      <title>Doing stats on multivalued JSON fields (mxexpand is too slow)</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Doing-stats-on-multivalued-JSON-fields-mxexpand-is-too-slow/m-p/364601#M66422</link>
      <description>&lt;P&gt;Hi Ninjas&lt;/P&gt;

&lt;P&gt;I'm dealing with some deeply nested JSON events like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;"sendTime":"2017-09-21T17:02:06.583+02:00","runningProcess":[{"Name":"_Total","PercentProcessorTime":"100","WorkingSetPrivate":"1557368"},{"Name":"Bananaservice","PercentProcessorTime":"0","WorkingSetPrivate":"593"},{"Name":"Cherryservice","PercentProcessorTime":"0","WorkingSetPrivate":"7671"},{"Name":"Pineappleservice","PercentProcessorTime":"0","WorkingSetPrivate":"466"},{"Name":"Kiwiservice","PercentProcessorTime":"0","WorkingSetPrivate":"442"},{"Name":"Appleservice","PercentProcessorTime":"0","WorkingSetPrivate":"630"},{"Name":"Peachservice","PercentProcessorTime":"0","WorkingSetPrivate":"1470"}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So all i want to do is getting out the avg values over time by each process,  something like &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats avg(runningProcess{}.PercentProcessorTime) as CPU by runningProcess{}.Name, _time
| stats list(*) as * by _time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But without mvexpand and so on, I'm not getting the right data as just takes the value of the first entry of the mv field by each event.&lt;BR /&gt;
As said, I'm aware of doing it with mvexpand etc. but it slows down the search dramatically and i was wondering whether there is a more elegant solution to get the right data here.&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 03 Oct 2017 12:07:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Doing-stats-on-multivalued-JSON-fields-mxexpand-is-too-slow/m-p/364601#M66422</guid>
      <dc:creator>claudio_manig</dc:creator>
      <dc:date>2017-10-03T12:07:52Z</dc:date>
    </item>
    <item>
      <title>Re: Doing stats on multivalued JSON fields (mxexpand is too slow)</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Doing-stats-on-multivalued-JSON-fields-mxexpand-is-too-slow/m-p/364602#M66423</link>
      <description>&lt;P&gt;@claudio.manig - Please post the rest of the SPL for the searches that you've tried.  It's possible that we can optimize the extraction itself, or reduce the impact of the &lt;CODE&gt;mvexpand&lt;/CODE&gt; with some subtle magic.&lt;/P&gt;</description>
      <pubDate>Tue, 03 Oct 2017 20:48:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Doing-stats-on-multivalued-JSON-fields-mxexpand-is-too-slow/m-p/364602#M66423</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-10-03T20:48:46Z</dc:date>
    </item>
    <item>
      <title>Re: Doing stats on multivalued JSON fields (mxexpand is too slow)</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Doing-stats-on-multivalued-JSON-fields-mxexpand-is-too-slow/m-p/364603#M66424</link>
      <description>&lt;P&gt;Well mvexpand itself already slows it down by its logic - creating an event out of each field value. So in reality i have json events with around 200+ processes running, resulting in tons of events out of one.&lt;/P&gt;

&lt;P&gt;But sure, have a go, the query looks something like that:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| index=skynet sourcetype=t800
| spath output=prcNames path=runningProcess{}
| mvexpand prcNames
| rex field=prcNames "\{\"Name\":\"(?&amp;lt;ProcessName&amp;gt;.*)\",\"PercentProcessorTime\":\"(?&amp;lt;ProcessCPU&amp;gt;.*)\",\"WorkingSetPrivate\":\"(?&amp;lt;ProcessMemoryKB&amp;gt;.*)\"\}" 
| where ProcessCPU &amp;gt; 20 and ProcessName!="_Total" and ProcessName!="Idle" 
| stats count avg(ProcessCPU) AS AvgProcessCPU avg(ProcessMemoryKB) AS AvgMem by ProcessName 
| sort -AvgProcessCPU -count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The spath is needed so we can group the subcategories of each processname like cpu and mem together.&lt;/P&gt;</description>
      <pubDate>Wed, 04 Oct 2017 06:36:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Doing-stats-on-multivalued-JSON-fields-mxexpand-is-too-slow/m-p/364603#M66424</guid>
      <dc:creator>claudio_manig</dc:creator>
      <dc:date>2017-10-04T06:36:55Z</dc:date>
    </item>
    <item>
      <title>Re: Doing stats on multivalued JSON fields (mxexpand is too slow)</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Doing-stats-on-multivalued-JSON-fields-mxexpand-is-too-slow/m-p/364604#M66425</link>
      <description>&lt;P&gt;Hi claudio.manig,&lt;/P&gt;

&lt;P&gt;I have tried to remove mvexpand from your search. Can you please try below search??&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| index=skynet sourcetype=t800
| rename runningProcess{}.Name as ProcessName, runningProcess{}.PercentProcessorTime as ProcessCPU, runningProcess{}.WorkingSetPrivate as ProcessMemoryKB
| eval tempField=mvzip(mvzip(ProcessName,ProcessCPU),ProcessMemoryKB) 
| stats count by _time,messageId,tempField 
| eval ProcessName=mvindex(split(tempField,","),0), ProcessCPU=mvindex(split(tempField,","),1), ProcessMemoryKB=mvindex(split(tempField,","),2) 
| where ProcessCPU &amp;gt; 20 and ProcessName!="_Total" and ProcessName!="Idle" 
| stats count avg(ProcessCPU) AS AvgProcessCPU avg(ProcessMemoryKB) AS AvgMem by ProcessName 
| sort -AvgProcessCPU -count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I'm not sure about "runningProcess{}.Name" field name I'm assuming from your search. So you can replace it with the original field name. &lt;/P&gt;

&lt;P&gt;I hope It will help you.&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 04 Oct 2017 10:14:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Doing-stats-on-multivalued-JSON-fields-mxexpand-is-too-slow/m-p/364604#M66425</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2017-10-04T10:14:35Z</dc:date>
    </item>
    <item>
      <title>Re: Doing stats on multivalued JSON fields (mxexpand is too slow)</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Doing-stats-on-multivalued-JSON-fields-mxexpand-is-too-slow/m-p/364605#M66426</link>
      <description>&lt;P&gt;Hey kamlesh - looking really good so far! But i was not sure why you used the "messageId" field to group your first stats as this field does not exist.&lt;/P&gt;</description>
      <pubDate>Wed, 04 Oct 2017 10:47:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Doing-stats-on-multivalued-JSON-fields-mxexpand-is-too-slow/m-p/364605#M66426</guid>
      <dc:creator>claudio_manig</dc:creator>
      <dc:date>2017-10-04T10:47:56Z</dc:date>
    </item>
    <item>
      <title>Re: Doing stats on multivalued JSON fields (mxexpand is too slow)</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Doing-stats-on-multivalued-JSON-fields-mxexpand-is-too-slow/m-p/364606#M66427</link>
      <description>&lt;P&gt;ooh.. that's just my temporary variable... I forgot to remove it.&lt;/P&gt;

&lt;P&gt;Can you please remove it and execute search?&lt;/P&gt;

&lt;P&gt;| index=skynet sourcetype=t800&lt;BR /&gt;
 | rename runningProcess{}.Name as ProcessName, runningProcess{}.PercentProcessorTime as ProcessCPU, runningProcess{}.WorkingSetPrivate as ProcessMemoryKB&lt;BR /&gt;
 | eval tempField=mvzip(mvzip(ProcessName,ProcessCPU),ProcessMemoryKB) &lt;BR /&gt;
 | stats count by _time,tempField &lt;BR /&gt;
 | eval ProcessName=mvindex(split(tempField,","),0), ProcessCPU=mvindex(split(tempField,","),1), ProcessMemoryKB=mvindex(split(tempField,","),2) &lt;BR /&gt;
 | where ProcessCPU &amp;gt; 20 and ProcessName!="_Total" and ProcessName!="Idle" &lt;BR /&gt;
 | stats count avg(ProcessCPU) AS AvgProcessCPU avg(ProcessMemoryKB) AS AvgMem by ProcessName &lt;BR /&gt;
 | sort -AvgProcessCPU -count&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 16:05:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Doing-stats-on-multivalued-JSON-fields-mxexpand-is-too-slow/m-p/364606#M66427</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2020-09-29T16:05:36Z</dc:date>
    </item>
    <item>
      <title>Re: Doing stats on multivalued JSON fields (mxexpand is too slow)</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Doing-stats-on-multivalued-JSON-fields-mxexpand-is-too-slow/m-p/364607#M66428</link>
      <description>&lt;P&gt;No worries I already thought that and tired it and it works! I have to test it to verify the effective performance impact. Thanks a lot!&lt;/P&gt;</description>
      <pubDate>Wed, 04 Oct 2017 11:14:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Doing-stats-on-multivalued-JSON-fields-mxexpand-is-too-slow/m-p/364607#M66428</guid>
      <dc:creator>claudio_manig</dc:creator>
      <dc:date>2017-10-04T11:14:27Z</dc:date>
    </item>
    <item>
      <title>Re: Doing stats on multivalued JSON fields (mxexpand is too slow)</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Doing-stats-on-multivalued-JSON-fields-mxexpand-is-too-slow/m-p/364608#M66429</link>
      <description>&lt;P&gt;great.. If it is working then be sure to click Accept to close this question.&lt;/P&gt;</description>
      <pubDate>Wed, 04 Oct 2017 11:18:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Doing-stats-on-multivalued-JSON-fields-mxexpand-is-too-slow/m-p/364608#M66429</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2017-10-04T11:18:39Z</dc:date>
    </item>
  </channel>
</rss>

