<?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: mvfilter before using mvexpand to reduce memory usage in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/mvfilter-before-using-mvexpand-to-reduce-memory-usage/m-p/516154#M145022</link>
    <description />
    <pubDate>Wed, 26 Aug 2020 12:07:32 GMT</pubDate>
    <dc:creator>to4kawa</dc:creator>
    <dc:date>2020-08-26T12:07:32Z</dc:date>
    <item>
      <title>mvfilter before using mvexpand to reduce memory usage</title>
      <link>https://community.splunk.com/t5/Splunk-Search/mvfilter-before-using-mvexpand-to-reduce-memory-usage/m-p/516151#M145020</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;I have some documents that looks like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;{
  "document_id": "some-id",
  "status": "some-status",
  "fields": "some values",
  "stages": [
    {
      "duration": 0.031,
      "name": "my_name",
      "more_fields": "more_values",
      "array_field": [...],
    },
    ...
  ]
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The length of the stages field can be quite large. I would like to calculate the avg or median duration for each type of stage but not for all stage types. Here is what I have initially:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;data_source
    | fields status, stages{}.name as sname, stages{}.duration
    | eval stage_fields=mvzip('stages{}.name', 'stages{}.duration')
    | where job_result in ("some-status")
    | mvexpand stage_fields
    | fields stage_fields
    | rex field=stage_fields "(?&amp;lt;stage_name&amp;gt;.+),(?&amp;lt;stage_duration&amp;gt;.+)"
    | where stage_name in ("my_name", "other_name")
    | timechart span=1h median(stage_duration) as "Median Stage Duration" by stage_name
    | rename stage_name as "Stage Name"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;This obviously starts truncating results because mvexpand starts expanding into a huge number of fields and complains about memory limits. I tried to put an mvfilter before it so that it only expands those stages that I am interested in but obviously I didn't know how to use it so that ended up as a no op.&lt;BR /&gt;&lt;BR /&gt;So the question is how can I make this query more efficient?&lt;BR /&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 25 Aug 2020 21:31:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/mvfilter-before-using-mvexpand-to-reduce-memory-usage/m-p/516151#M145020</guid>
      <dc:creator>unbelievable_ma</dc:creator>
      <dc:date>2020-08-25T21:31:19Z</dc:date>
    </item>
    <item>
      <title>Re: mvfilter before using mvexpand to reduce memory usage</title>
      <link>https://community.splunk.com/t5/Splunk-Search/mvfilter-before-using-mvexpand-to-reduce-memory-usage/m-p/516154#M145022</link>
      <description />
      <pubDate>Wed, 26 Aug 2020 12:07:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/mvfilter-before-using-mvexpand-to-reduce-memory-usage/m-p/516154#M145022</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-08-26T12:07:32Z</dc:date>
    </item>
    <item>
      <title>Re: mvfilter before using mvexpand to reduce memory usage</title>
      <link>https://community.splunk.com/t5/Splunk-Search/mvfilter-before-using-mvexpand-to-reduce-memory-usage/m-p/516192#M145034</link>
      <description>&lt;P&gt;Sorry I don't get it. Could you expand on this a bit?&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 26 Aug 2020 06:52:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/mvfilter-before-using-mvexpand-to-reduce-memory-usage/m-p/516192#M145034</guid>
      <dc:creator>unbelievable_ma</dc:creator>
      <dc:date>2020-08-26T06:52:58Z</dc:date>
    </item>
    <item>
      <title>Re: mvfilter before using mvexpand to reduce memory usage</title>
      <link>https://community.splunk.com/t5/Splunk-Search/mvfilter-before-using-mvexpand-to-reduce-memory-usage/m-p/516215#M145040</link>
      <description />
      <pubDate>Wed, 26 Aug 2020 12:07:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/mvfilter-before-using-mvexpand-to-reduce-memory-usage/m-p/516215#M145040</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-08-26T12:07:47Z</dc:date>
    </item>
    <item>
      <title>Re: mvfilter before using mvexpand to reduce memory usage</title>
      <link>https://community.splunk.com/t5/Splunk-Search/mvfilter-before-using-mvexpand-to-reduce-memory-usage/m-p/516246#M145051</link>
      <description>&lt;P&gt;Well it doesn't really do what I stated in the problem.&lt;BR /&gt;&lt;BR /&gt;Perhaps you could say explains this part?&lt;BR /&gt;&amp;gt;&amp;nbsp;stats values(_time) as _time by stages&lt;/P&gt;</description>
      <pubDate>Wed, 26 Aug 2020 11:44:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/mvfilter-before-using-mvexpand-to-reduce-memory-usage/m-p/516246#M145051</guid>
      <dc:creator>unbelievable_ma</dc:creator>
      <dc:date>2020-08-26T11:44:10Z</dc:date>
    </item>
    <item>
      <title>Re: mvfilter before using mvexpand to reduce memory usage</title>
      <link>https://community.splunk.com/t5/Splunk-Search/mvfilter-before-using-mvexpand-to-reduce-memory-usage/m-p/516249#M145053</link>
      <description />
      <pubDate>Wed, 26 Aug 2020 12:08:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/mvfilter-before-using-mvexpand-to-reduce-memory-usage/m-p/516249#M145053</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-08-26T12:08:01Z</dc:date>
    </item>
    <item>
      <title>Re: mvfilter before using mvexpand to reduce memory usage</title>
      <link>https://community.splunk.com/t5/Splunk-Search/mvfilter-before-using-mvexpand-to-reduce-memory-usage/m-p/516316#M145081</link>
      <description>&lt;P&gt;No _time is not unique because multiple values exist within the same event (hence mvexpand) hence the results are not correct.&lt;BR /&gt;I can try to give another example. Lets say I can get this table&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="50%" height="25px"&gt;id&lt;/TD&gt;&lt;TD width="50%" height="25px"&gt;mv_field&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="50%" height="114px"&gt;1&lt;/TD&gt;&lt;TD width="50%" height="114px"&gt;&lt;P&gt;key1,100&lt;/P&gt;&lt;P&gt;key2,200&lt;/P&gt;&lt;P&gt;key3,300&amp;nbsp;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="50%" height="25px"&gt;2&lt;/TD&gt;&lt;TD width="50%" height="25px"&gt;&lt;P&gt;key1,100&lt;/P&gt;&lt;P&gt;key2,200&lt;/P&gt;&lt;P&gt;key3,300&amp;nbsp;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="50%" height="25px"&gt;3&lt;/TD&gt;&lt;TD width="50%" height="25px"&gt;&amp;nbsp;&lt;P&gt;key1,100&lt;/P&gt;&lt;P&gt;key2,200&lt;/P&gt;&lt;P&gt;key3,300&amp;nbsp;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Given this I want the result:&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="50%"&gt;key&lt;/TD&gt;&lt;TD width="50%"&gt;sum&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="50%"&gt;key1&lt;/TD&gt;&lt;TD width="50%"&gt;300&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="50%"&gt;key2&lt;/TD&gt;&lt;TD width="50%"&gt;600&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="50%"&gt;key3&lt;/TD&gt;&lt;TD width="50%"&gt;900&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The important part here is that the second column is an mv field. mvexpand breaks the memory usage there so I need some other way to accumulate the results. Maybe I will post this as a separate question cause this is perhaps simpler to explain.&lt;BR /&gt;&lt;BR /&gt;Update: mvfilter didn't help with the memory. I found a solution to this that I added here:&lt;BR /&gt;&lt;A href="https://community.splunk.com/t5/Splunk-Search/Accumulate-values-for-a-multi-value-field-by-key/m-p/516577#M145195" target="_blank" rel="noopener"&gt;https://community.splunk.com/t5/Splunk-Search/Accumulate-values-for-a-multi-value-field-by-key/m-p/516577#M145195&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Aug 2020 20:45:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/mvfilter-before-using-mvexpand-to-reduce-memory-usage/m-p/516316#M145081</guid>
      <dc:creator>unbelievable_ma</dc:creator>
      <dc:date>2020-08-27T20:45:48Z</dc:date>
    </item>
  </channel>
</rss>

