<?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: Extract fields from multiple events based off of min( id ) and max(id) by a common field. in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Extract-fields-from-multiple-events-based-off-of-min-id-and-max/m-p/419838#M120715</link>
    <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|makeresults | eval _raw=" _time                     id                apiid             did           callerid     extension_number
2019-03-02 09:42:05    533481479    vejf7t2gehtq3cttuml4    18008112345    10118997050    11111103003
2019-03-02 09:42:05    533481480    vejf7t2gehtq3cttuml4    18008112345    10118997050    11111103003
2019-03-02 09:42:05    533481481    vejf7t2gehtq3cttuml4    18008112345    10118997050    11111102000
2019-03-02 09:59:34    533489343    a54pdykd7ytwjbmmo7yi    18008112345    10008556468    11111103003
2019-03-02 09:59:34    533489344    a54pdykd7ytwjbmmo7yi    18008112345    10008556468    11111102000
2019-03-02 09:59:34    533489345    a54pdykd7ytwjbmmo7yi    18008112345    10008556468    11111103003
2019-03-02 09:59:54    533489611    a54pdykd7ytwjbmmo7yi    18008112345    10008556468    11111103003
2019-03-02 09:59:54    533489612    a54pdykd7ytwjbmmo7yi    18008112345    10008556468    11111103003
2019-03-02 09:59:54    533489613    a54pdykd7ytwjbmmo7yi    18008112345    10008556468    11111100063
2019-03-02 09:59:55    533489614    a54pdykd7ytwjbmmo7yi    18008112345    10008556468    11111100063
2019-03-02 10:00:23    533489836    4tvdwnrwenhw73k4ivbu    18008112345    18086965170    11111103003
2019-03-02 10:00:23    533489837    4tvdwnrwenhw73k4ivbu    18008112345    18086965170    11111102000
2019-03-02 10:00:23    533489838    4tvdwnrwenhw73k4ivbu    18008112345    18086965170    11111103003
2019-03-02 10:00:43    533489949    4tvdwnrwenhw73k4ivbu    18008112345    18086965170    11111103003
2019-03-02 10:00:43    533489950    4tvdwnrwenhw73k4ivbu    18008112345    18086965170    11111103003
2019-03-02 10:00:43    533489951    4tvdwnrwenhw73k4ivbu    18008112345    18086965170    11111100063
2019-03-02 10:00:43    533489952    4tvdwnrwenhw73k4ivbu    18008112345    18086965170    11111100063"
| multikv forceheader=1 copyattrs=f
| eval _time = strptime(time, "%Y-%m-%d %H:%M:%S")

| rename COMMENT AS "Everything above generates sample event data; everything below is your solution"

| eventstats min(id) AS min_id max(id) AS max_id
| multireport
[where id == min_id
| table time, did, and callerid]
[where id == max_id 
| table extension_number ]
| stats values(*) AS *
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 12 Nov 2019 02:17:19 GMT</pubDate>
    <dc:creator>woodcock</dc:creator>
    <dc:date>2019-11-12T02:17:19Z</dc:date>
    <item>
      <title>Extract fields from multiple events based off of min( id ) and max(id) by a common field.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-fields-from-multiple-events-based-off-of-min-id-and-max/m-p/419834#M120711</link>
      <description>&lt;P&gt;I would like to extract the &lt;CODE&gt;time, did, and callerid&lt;/CODE&gt; from the event with the min(id) by apiid&lt;BR /&gt;
Additionally, extract &lt;CODE&gt;extension_number&lt;/CODE&gt; from max(id) by apiid&lt;BR /&gt;
sample data:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;_time                    id             apiid            did           callerid  extension_number
2019-03-02 09:42:05 533481479   vejf7t2gehtq3cttuml4    18008112345 10118997050 11111103003
2019-03-02 09:42:05 533481480   vejf7t2gehtq3cttuml4    18008112345 10118997050 11111103003
2019-03-02 09:42:05 533481481   vejf7t2gehtq3cttuml4    18008112345 10118997050 11111102000
2019-03-02 09:59:34 533489343   a54pdykd7ytwjbmmo7yi    18008112345 10008556468 11111103003
2019-03-02 09:59:34 533489344   a54pdykd7ytwjbmmo7yi    18008112345 10008556468 11111102000
2019-03-02 09:59:34 533489345   a54pdykd7ytwjbmmo7yi    18008112345 10008556468 11111103003
2019-03-02 09:59:54 533489611   a54pdykd7ytwjbmmo7yi    18008112345 10008556468 11111103003
2019-03-02 09:59:54 533489612   a54pdykd7ytwjbmmo7yi    18008112345 10008556468 11111103003
2019-03-02 09:59:54 533489613   a54pdykd7ytwjbmmo7yi    18008112345 10008556468 11111100063
2019-03-02 09:59:55 533489614   a54pdykd7ytwjbmmo7yi    18008112345 10008556468 11111100063
2019-03-02 10:00:23 533489836   4tvdwnrwenhw73k4ivbu    18008112345 18086965170 11111103003
2019-03-02 10:00:23 533489837   4tvdwnrwenhw73k4ivbu    18008112345 18086965170 11111102000
2019-03-02 10:00:23 533489838   4tvdwnrwenhw73k4ivbu    18008112345 18086965170 11111103003
2019-03-02 10:00:43 533489949   4tvdwnrwenhw73k4ivbu    18008112345 18086965170 11111103003
2019-03-02 10:00:43 533489950   4tvdwnrwenhw73k4ivbu    18008112345 18086965170 11111103003
2019-03-02 10:00:43 533489951   4tvdwnrwenhw73k4ivbu    18008112345 18086965170 11111100063
2019-03-02 10:00:43 533489952   4tvdwnrwenhw73k4ivbu    18008112345 18086965170 11111100063
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I have been able to extract min and max by apiid with&lt;BR /&gt;
base search |  stats max(id) as maxid min(id) as minid by apiid&lt;/P&gt;

&lt;P&gt;and also tried this so those values would not dispaly&lt;BR /&gt;
base search |  eventstats max(id) as maxid min(id) as minid by apiid&lt;/P&gt;

&lt;P&gt;I have been able to get the min(id) values but not sure how to combine those with max(id) fields I am looking for&lt;/P&gt;

&lt;P&gt;base search| eventstats max(id) as maxid min(id) as minid by apiid&lt;BR /&gt;
| where id=minid | table _time,did, callerid&lt;/P&gt;</description>
      <pubDate>Sat, 02 Mar 2019 16:53:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-fields-from-multiple-events-based-off-of-min-id-and-max/m-p/419834#M120711</guid>
      <dc:creator>fmatera</dc:creator>
      <dc:date>2019-03-02T16:53:18Z</dc:date>
    </item>
    <item>
      <title>Re: Extract fields from multiple events based off of min( id ) and max(id) by a common field.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-fields-from-multiple-events-based-off-of-min-id-and-max/m-p/419835#M120712</link>
      <description>&lt;P&gt;Hi @fmatera,&lt;/P&gt;

&lt;P&gt;Try the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;base search...
| eventstats max(id) as maxid min(id) as minid by apiid 
| stats values(eval(if(id==minid, _time, NULL))) as _time, 
    values(did) as did,
    values(callerid) as callerid,
    values(eval(if(id==maxid, extension_number, NULL))) as extension_number
    by minid
| rename minid as id
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This search uses stats to get all the values from the event that has id=minid, and the extension number from the event that has id=maxid.&lt;/P&gt;</description>
      <pubDate>Sun, 03 Mar 2019 00:59:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-fields-from-multiple-events-based-off-of-min-id-and-max/m-p/419835#M120712</guid>
      <dc:creator>spavin</dc:creator>
      <dc:date>2019-03-03T00:59:14Z</dc:date>
    </item>
    <item>
      <title>Re: Extract fields from multiple events based off of min( id ) and max(id) by a common field.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-fields-from-multiple-events-based-off-of-min-id-and-max/m-p/419836#M120713</link>
      <description>&lt;P&gt;Thanks, @spavin, that worked well. Is there any way to exclude minid from the results table?&lt;/P&gt;</description>
      <pubDate>Mon, 04 Mar 2019 12:17:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-fields-from-multiple-events-based-off-of-min-id-and-max/m-p/419836#M120713</guid>
      <dc:creator>fmatera</dc:creator>
      <dc:date>2019-03-04T12:17:00Z</dc:date>
    </item>
    <item>
      <title>Re: Extract fields from multiple events based off of min( id ) and max(id) by a common field.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-fields-from-multiple-events-based-off-of-min-id-and-max/m-p/419837#M120714</link>
      <description>&lt;P&gt;Sure - update the last line to change it &lt;/P&gt;

&lt;P&gt;from: | rename minid as id &lt;/P&gt;

&lt;P&gt;to: &lt;/P&gt;

&lt;P&gt;| table _time, did, callerid, extension_number&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 23:29:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-fields-from-multiple-events-based-off-of-min-id-and-max/m-p/419837#M120714</guid>
      <dc:creator>spavin</dc:creator>
      <dc:date>2020-09-29T23:29:24Z</dc:date>
    </item>
    <item>
      <title>Re: Extract fields from multiple events based off of min( id ) and max(id) by a common field.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-fields-from-multiple-events-based-off-of-min-id-and-max/m-p/419838#M120715</link>
      <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|makeresults | eval _raw=" _time                     id                apiid             did           callerid     extension_number
2019-03-02 09:42:05    533481479    vejf7t2gehtq3cttuml4    18008112345    10118997050    11111103003
2019-03-02 09:42:05    533481480    vejf7t2gehtq3cttuml4    18008112345    10118997050    11111103003
2019-03-02 09:42:05    533481481    vejf7t2gehtq3cttuml4    18008112345    10118997050    11111102000
2019-03-02 09:59:34    533489343    a54pdykd7ytwjbmmo7yi    18008112345    10008556468    11111103003
2019-03-02 09:59:34    533489344    a54pdykd7ytwjbmmo7yi    18008112345    10008556468    11111102000
2019-03-02 09:59:34    533489345    a54pdykd7ytwjbmmo7yi    18008112345    10008556468    11111103003
2019-03-02 09:59:54    533489611    a54pdykd7ytwjbmmo7yi    18008112345    10008556468    11111103003
2019-03-02 09:59:54    533489612    a54pdykd7ytwjbmmo7yi    18008112345    10008556468    11111103003
2019-03-02 09:59:54    533489613    a54pdykd7ytwjbmmo7yi    18008112345    10008556468    11111100063
2019-03-02 09:59:55    533489614    a54pdykd7ytwjbmmo7yi    18008112345    10008556468    11111100063
2019-03-02 10:00:23    533489836    4tvdwnrwenhw73k4ivbu    18008112345    18086965170    11111103003
2019-03-02 10:00:23    533489837    4tvdwnrwenhw73k4ivbu    18008112345    18086965170    11111102000
2019-03-02 10:00:23    533489838    4tvdwnrwenhw73k4ivbu    18008112345    18086965170    11111103003
2019-03-02 10:00:43    533489949    4tvdwnrwenhw73k4ivbu    18008112345    18086965170    11111103003
2019-03-02 10:00:43    533489950    4tvdwnrwenhw73k4ivbu    18008112345    18086965170    11111103003
2019-03-02 10:00:43    533489951    4tvdwnrwenhw73k4ivbu    18008112345    18086965170    11111100063
2019-03-02 10:00:43    533489952    4tvdwnrwenhw73k4ivbu    18008112345    18086965170    11111100063"
| multikv forceheader=1 copyattrs=f
| eval _time = strptime(time, "%Y-%m-%d %H:%M:%S")

| rename COMMENT AS "Everything above generates sample event data; everything below is your solution"

| eventstats min(id) AS min_id max(id) AS max_id
| multireport
[where id == min_id
| table time, did, and callerid]
[where id == max_id 
| table extension_number ]
| stats values(*) AS *
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 12 Nov 2019 02:17:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-fields-from-multiple-events-based-off-of-min-id-and-max/m-p/419838#M120715</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-11-12T02:17:19Z</dc:date>
    </item>
  </channel>
</rss>

