<?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 How can I find the differance between 2 dates on multiple events, grouped by a field, based off of the min and max of another field in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/How-can-I-find-the-differance-between-2-dates-on-multiple-events/m-p/422704#M7442</link>
    <description>&lt;P&gt;Here is some data&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;id          apiid                 answer                     cr_date
493442120   fbnagf42wxpfmmrgrf5b    2019-01-23 19:15:41 2019-01-23 19:15:51
493442118   fbnagf42wxpfmmrgrf5b    2019-01-23 19:15:41 2019-01-23 19:15:51
493441485   fbnagf42wxpfmmrgrf5b    2019-01-23 19:15:18 2019-01-23 19:15:38
493441472   fbnagf42wxpfmmrgrf5b    2019-01-23 19:15:17 2019-01-23 19:15:38
493441471   fbnagf42wxpfmmrgrf5b    2019-01-23 19:15:17 2019-01-23 19:15:38
493440588   fbnagf42wxpfmmrgrf5b    2019-01-23 19:15:17 2019-01-23 19:15:17

493440012   5o3q2siu6lirzfbmprdp    2019-01-23 19:14:49 2019-01-23 19:15:08
493440010   5o3q2siu6lirzfbmprdp    2019-01-23 19:14:49 2019-01-23 19:15:08
493438858   5o3q2siu6lirzfbmprdp    2019-01-23 19:14:42 2019-01-23 19:14:43

493439140   kgjtl44jzdn5wtifg3pi    2019-01-23 19:14:41 2019-01-23 19:14:49
493439137   kgjtl44jzdn5wtifg3pi    2019-01-23 19:14:41 2019-01-23 19:14:49
493439114   kgjtl44jzdn5wtifg3pi    2019-01-23 19:14:41 2019-01-23 19:14:49
493439109   kgjtl44jzdn5wtifg3pi    2019-01-23 19:14:41 2019-01-23 19:14:49
493438775   kgjtl44jzdn5wtifg3pi    2019-01-23 19:14:41 2019-01-23 19:14:41
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;What I am trying to do is: get the answer time from min(id), the cr_date from max(id) by apiid . Get the difference between each of those by apiid, and display the avg time of all apiid's.&lt;/P&gt;

&lt;P&gt;I hope the question makes sense. I have tried a bunch of things, with no success.&lt;BR /&gt;
Any help would be greatly appreciated. Tks.&lt;/P&gt;</description>
    <pubDate>Wed, 23 Jan 2019 20:18:14 GMT</pubDate>
    <dc:creator>fmatera</dc:creator>
    <dc:date>2019-01-23T20:18:14Z</dc:date>
    <item>
      <title>How can I find the differance between 2 dates on multiple events, grouped by a field, based off of the min and max of another field</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-can-I-find-the-differance-between-2-dates-on-multiple-events/m-p/422704#M7442</link>
      <description>&lt;P&gt;Here is some data&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;id          apiid                 answer                     cr_date
493442120   fbnagf42wxpfmmrgrf5b    2019-01-23 19:15:41 2019-01-23 19:15:51
493442118   fbnagf42wxpfmmrgrf5b    2019-01-23 19:15:41 2019-01-23 19:15:51
493441485   fbnagf42wxpfmmrgrf5b    2019-01-23 19:15:18 2019-01-23 19:15:38
493441472   fbnagf42wxpfmmrgrf5b    2019-01-23 19:15:17 2019-01-23 19:15:38
493441471   fbnagf42wxpfmmrgrf5b    2019-01-23 19:15:17 2019-01-23 19:15:38
493440588   fbnagf42wxpfmmrgrf5b    2019-01-23 19:15:17 2019-01-23 19:15:17

493440012   5o3q2siu6lirzfbmprdp    2019-01-23 19:14:49 2019-01-23 19:15:08
493440010   5o3q2siu6lirzfbmprdp    2019-01-23 19:14:49 2019-01-23 19:15:08
493438858   5o3q2siu6lirzfbmprdp    2019-01-23 19:14:42 2019-01-23 19:14:43

493439140   kgjtl44jzdn5wtifg3pi    2019-01-23 19:14:41 2019-01-23 19:14:49
493439137   kgjtl44jzdn5wtifg3pi    2019-01-23 19:14:41 2019-01-23 19:14:49
493439114   kgjtl44jzdn5wtifg3pi    2019-01-23 19:14:41 2019-01-23 19:14:49
493439109   kgjtl44jzdn5wtifg3pi    2019-01-23 19:14:41 2019-01-23 19:14:49
493438775   kgjtl44jzdn5wtifg3pi    2019-01-23 19:14:41 2019-01-23 19:14:41
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;What I am trying to do is: get the answer time from min(id), the cr_date from max(id) by apiid . Get the difference between each of those by apiid, and display the avg time of all apiid's.&lt;/P&gt;

&lt;P&gt;I hope the question makes sense. I have tried a bunch of things, with no success.&lt;BR /&gt;
Any help would be greatly appreciated. Tks.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jan 2019 20:18:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-can-I-find-the-differance-between-2-dates-on-multiple-events/m-p/422704#M7442</guid>
      <dc:creator>fmatera</dc:creator>
      <dc:date>2019-01-23T20:18:14Z</dc:date>
    </item>
    <item>
      <title>Re: How can I find the differance between 2 dates on multiple events, grouped by a field, based off of the min and max of another field</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-can-I-find-the-differance-between-2-dates-on-multiple-events/m-p/422705#M7443</link>
      <description>&lt;P&gt;Give this a try&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base searching giving fields id apiid answer cr_date
| eventstats max(id) as maxid min(id) as minid by apiid
| eval mintime=if(id=minid,answer,null())
| eval maxtime=if(id=maxid,cr_date,null())
| stats values(mintime) as mintime values(maxtime) as maxtime by apiid
| convert mktime(*time) timeformat="%Y-%m-%d %H:%M:%S"
| eval diff=abs(mintime-maxtime)
| stats avg(diff) as AvgTimeInSecs
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 23 Jan 2019 21:34:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-can-I-find-the-differance-between-2-dates-on-multiple-events/m-p/422705#M7443</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2019-01-23T21:34:58Z</dc:date>
    </item>
  </channel>
</rss>

