<?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 Summing values inside mvfield in Splunk ITSI</title>
    <link>https://community.splunk.com/t5/Splunk-ITSI/Summing-values-inside-mvfield/m-p/504996#M2072</link>
    <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;I am trying to substract values (timestamps) of an mv field, but they are of differing lengths;&lt;/P&gt;&lt;P&gt;## example data:&lt;BR /&gt;sysmodtime,idnumber,epoch time&lt;BR /&gt;05/03/20 12:40 PM,1,1588502400&lt;BR /&gt;05/01/20 12:01 AM,1,1588284060&lt;BR /&gt;05/01/20 12:02 AM,1,1588284120&lt;BR /&gt;05/01/20 12:02 AM,1,1588284120&lt;/P&gt;&lt;P&gt;05/02/20 12:00 PM,2,1588413600&lt;BR /&gt;04/02/20 12:00 AM,2,1585778400&lt;BR /&gt;04/02/20 01:00 AM,2,1585782000&lt;/P&gt;&lt;P&gt;04/02/20 02:00 AM,3,1585785600&lt;/P&gt;&lt;P&gt;##desired outcome: = new field time-diff at the end:&lt;BR /&gt;sysmodtime,idnumber,epoch time,time_diff&lt;BR /&gt;05/03/20 12:40 PM,1,1588502400,218340&lt;BR /&gt;05/01/20 12:01 AM,1,1588284060,-60&lt;BR /&gt;05/01/20 12:02 AM,1,1588284120,0&lt;BR /&gt;05/01/20 12:02 AM,1,1588284120,empty&lt;/P&gt;&lt;P&gt;05/02/20 12:00 PM,2,1588413600,2635200&lt;BR /&gt;04/02/20 12:00 AM,2,1585778400,-3600&lt;BR /&gt;04/02/20 01:00 AM,2,1585782000,empty&lt;/P&gt;&lt;P&gt;04/02/20 02:00 AM,3,1585785600,empty&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;-------------------------------&lt;BR /&gt;The original data is about 200.000 rows long, so we are looking for a structural solution.&lt;/P&gt;&lt;P&gt;Is there a simple way to loop through the timestamp value inside the mvfield and substract it and place it in a new field&lt;BR /&gt;Any suggestions would be very welcome,&lt;/P&gt;&lt;P&gt;Cheers,&lt;BR /&gt;Roelof&lt;/P&gt;</description>
    <pubDate>Thu, 18 Jun 2020 14:44:56 GMT</pubDate>
    <dc:creator>rvsroe</dc:creator>
    <dc:date>2020-06-18T14:44:56Z</dc:date>
    <item>
      <title>Summing values inside mvfield</title>
      <link>https://community.splunk.com/t5/Splunk-ITSI/Summing-values-inside-mvfield/m-p/504996#M2072</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;I am trying to substract values (timestamps) of an mv field, but they are of differing lengths;&lt;/P&gt;&lt;P&gt;## example data:&lt;BR /&gt;sysmodtime,idnumber,epoch time&lt;BR /&gt;05/03/20 12:40 PM,1,1588502400&lt;BR /&gt;05/01/20 12:01 AM,1,1588284060&lt;BR /&gt;05/01/20 12:02 AM,1,1588284120&lt;BR /&gt;05/01/20 12:02 AM,1,1588284120&lt;/P&gt;&lt;P&gt;05/02/20 12:00 PM,2,1588413600&lt;BR /&gt;04/02/20 12:00 AM,2,1585778400&lt;BR /&gt;04/02/20 01:00 AM,2,1585782000&lt;/P&gt;&lt;P&gt;04/02/20 02:00 AM,3,1585785600&lt;/P&gt;&lt;P&gt;##desired outcome: = new field time-diff at the end:&lt;BR /&gt;sysmodtime,idnumber,epoch time,time_diff&lt;BR /&gt;05/03/20 12:40 PM,1,1588502400,218340&lt;BR /&gt;05/01/20 12:01 AM,1,1588284060,-60&lt;BR /&gt;05/01/20 12:02 AM,1,1588284120,0&lt;BR /&gt;05/01/20 12:02 AM,1,1588284120,empty&lt;/P&gt;&lt;P&gt;05/02/20 12:00 PM,2,1588413600,2635200&lt;BR /&gt;04/02/20 12:00 AM,2,1585778400,-3600&lt;BR /&gt;04/02/20 01:00 AM,2,1585782000,empty&lt;/P&gt;&lt;P&gt;04/02/20 02:00 AM,3,1585785600,empty&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;-------------------------------&lt;BR /&gt;The original data is about 200.000 rows long, so we are looking for a structural solution.&lt;/P&gt;&lt;P&gt;Is there a simple way to loop through the timestamp value inside the mvfield and substract it and place it in a new field&lt;BR /&gt;Any suggestions would be very welcome,&lt;/P&gt;&lt;P&gt;Cheers,&lt;BR /&gt;Roelof&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jun 2020 14:44:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-ITSI/Summing-values-inside-mvfield/m-p/504996#M2072</guid>
      <dc:creator>rvsroe</dc:creator>
      <dc:date>2020-06-18T14:44:56Z</dc:date>
    </item>
    <item>
      <title>Re: Summing values inside mvfield</title>
      <link>https://community.splunk.com/t5/Splunk-ITSI/Summing-values-inside-mvfield/m-p/505016#M2073</link>
      <description>&lt;P&gt;If I understand your data correctly, you may be able to use streamstats.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;... | streamstats window=2 range('epoch timestamp') as time_diff&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 18 Jun 2020 15:46:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-ITSI/Summing-values-inside-mvfield/m-p/505016#M2073</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2020-06-18T15:46:02Z</dc:date>
    </item>
    <item>
      <title>Re: Summing values inside mvfield</title>
      <link>https://community.splunk.com/t5/Splunk-ITSI/Summing-values-inside-mvfield/m-p/505135#M2074</link>
      <description>&lt;P&gt;I believe you will have to mvexpand out the fields first to get the mv field into separate rows and then run streamstats. Take this for example&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| eval _raw="sysmodtime,idnumber,epoch time
05/03/20 12:40 PM,1,1588502400
05/01/20 12:01 AM,1,1588284060
05/01/20 12:02 AM,1,1588284120
05/01/20 12:02 AM,1,1588284120
05/02/20 12:00 PM,2,1588413600
04/02/20 12:00 AM,2,1585778400
04/02/20 01:00 AM,2,1585782000
04/02/20 02:00 AM,3,1585785600"
| multikv
| stats list(*) as * by idnumber
| eval x="So, up to here is your original data"
| eval base=mvzip(sysmodtime,epoch_time)
| fields - _raw linecount sysmodtime epoch_time
| mvexpand base
| rex field=base "(?&amp;lt;sysmodtime&amp;gt;[^,]*),(?&amp;lt;epoch_time&amp;gt;.*)"
| fields - base
| streamstats window=2 range(epoch_time) as time_diff by idnumber
| stats list(*) as * by idnumber
| eval time_diff=mvindex(time_diff,1,-1)&lt;/LI-CODE&gt;&lt;P&gt;That gives you what you want, but will be expensive to do the mvexpand and re-aggregations, but you can measure that.&lt;/P&gt;&lt;P&gt;As to calculating values inside MV fields, if you have Splunk 8 I think, then mvmap may be able to get you to where you want, I couldn't get it to work though - I've not used it before.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jun 2020 07:03:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-ITSI/Summing-values-inside-mvfield/m-p/505135#M2074</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2020-06-19T07:03:12Z</dc:date>
    </item>
    <item>
      <title>Re: Summing values inside mvfield</title>
      <link>https://community.splunk.com/t5/Splunk-ITSI/Summing-values-inside-mvfield/m-p/505162#M2075</link>
      <description>&lt;P&gt;This worked perfectly, thank you very much, I've only added a strftime to convert epoch into hours and minutes:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;| eval time_diff=strftime(mvindex(time_diff,1,-1),"%H:%M:%S") &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="forum1.PNG" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/9248iF319F80223D2E474/image-size/medium?v=v2&amp;amp;px=400" role="button" title="forum1.PNG" alt="forum1.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jun 2020 11:35:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-ITSI/Summing-values-inside-mvfield/m-p/505162#M2075</guid>
      <dc:creator>rvsroe</dc:creator>
      <dc:date>2020-06-19T11:35:09Z</dc:date>
    </item>
    <item>
      <title>Re: Summing values inside mvfield</title>
      <link>https://community.splunk.com/t5/Splunk-ITSI/Summing-values-inside-mvfield/m-p/505163#M2076</link>
      <description>&lt;P&gt;Thanks for the reply, streamstats was indeed helpful, I've accepted the other reply as answer though for its completeness&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jun 2020 11:36:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-ITSI/Summing-values-inside-mvfield/m-p/505163#M2076</guid>
      <dc:creator>rvsroe</dc:creator>
      <dc:date>2020-06-19T11:36:28Z</dc:date>
    </item>
  </channel>
</rss>

