<?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: Join consecutive events in same index in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Join-consecutive-events-in-same-index/m-p/415821#M119680</link>
    <description>&lt;P&gt;Try this!&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="file-times"
|stats max(FILETIME) as Filetime_End,min(FILETIME) as Filetime_Start by Service
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You can also use the transaction command.&lt;/P&gt;</description>
    <pubDate>Sun, 28 Jul 2019 03:16:44 GMT</pubDate>
    <dc:creator>HiroshiSatoh</dc:creator>
    <dc:date>2019-07-28T03:16:44Z</dc:date>
    <item>
      <title>Join consecutive events in same index</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-consecutive-events-in-same-index/m-p/415820#M119679</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;
I thought this would be easy but no!&lt;BR /&gt;
I'm doing the query below on the Sample data below but the FileTime_END value I'm getting is 15:29:00 for every line (don't have enough points to attach images or post links sorry).&lt;BR /&gt;
What am I doing wrong? Also is there a better way to do this without a JOIN?&lt;/P&gt;

&lt;P&gt;Cheers guys.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="file-times" State=Start | table Service FileTime State | rename Service as Service_Start FileTime as Filetime_Start, State as State_Start
| join Service type=outer [search index="file-times" State=END | table FileTime State | rename FileTime as Filetime_End, State as State_End]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Sample Log/Index Data:&lt;BR /&gt;
23/07/2019 09:34:00, Service=RR, FileTime=9:33:45, State=START&lt;BR /&gt;
23/07/2019 10:31:00, Service=RR, FileTime=10:30:45, State=END&lt;BR /&gt;
23/07/2019 11:01:00, Service=HHR, FileTime=11:00:32, State=START&lt;BR /&gt;
23/07/2019 11:31:00, Service=HHR, FileTime=11:30:32, State=END&lt;BR /&gt;
23/07/2019 12:01:00, Service=LPE, FileTime=12:00:32, State=START&lt;BR /&gt;
23/07/2019 12:55:00, Service=LPE, FileTime=12:54:32, State=END&lt;BR /&gt;
23/07/2019 12:01:00, Service=SMURF, FileTime=12:00:32, State=START&lt;BR /&gt;
23/07/2019 13:01:00, Service=SMURF, FileTime=13:00:00, State=END&lt;BR /&gt;
23/07/2019 14:00:00, Service=TEST, FileTime=14:05:00, State=START&lt;BR /&gt;
23/07/2019 14:30:00, Service=TEST, FileTime=14:29:00, State=END&lt;BR /&gt;
23/07/2019 15:00:00, Service=TEST1, FileTime=15:05:00, State=START&lt;BR /&gt;
23/07/2019 15:30:00, Service=TEST1, FileTime=15:29:00, State=END&lt;/P&gt;</description>
      <pubDate>Sat, 27 Jul 2019 19:03:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-consecutive-events-in-same-index/m-p/415820#M119679</guid>
      <dc:creator>intelli2019</dc:creator>
      <dc:date>2019-07-27T19:03:55Z</dc:date>
    </item>
    <item>
      <title>Re: Join consecutive events in same index</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-consecutive-events-in-same-index/m-p/415821#M119680</link>
      <description>&lt;P&gt;Try this!&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="file-times"
|stats max(FILETIME) as Filetime_End,min(FILETIME) as Filetime_Start by Service
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You can also use the transaction command.&lt;/P&gt;</description>
      <pubDate>Sun, 28 Jul 2019 03:16:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-consecutive-events-in-same-index/m-p/415821#M119680</guid>
      <dc:creator>HiroshiSatoh</dc:creator>
      <dc:date>2019-07-28T03:16:44Z</dc:date>
    </item>
    <item>
      <title>Re: Join consecutive events in same index</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-consecutive-events-in-same-index/m-p/415822#M119681</link>
      <description>&lt;P&gt;Thanks! I will try this. The production index will have multiple days data in it. To get min and max filetime by service for each day I just add a date field to the end of the query? I.e “by Service, Date” instead of just “by Service” ?&lt;/P&gt;</description>
      <pubDate>Sun, 28 Jul 2019 05:24:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-consecutive-events-in-same-index/m-p/415822#M119681</guid>
      <dc:creator>intelli2019</dc:creator>
      <dc:date>2019-07-28T05:24:23Z</dc:date>
    </item>
    <item>
      <title>Re: Join consecutive events in same index</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-consecutive-events-in-same-index/m-p/415823#M119682</link>
      <description>&lt;P&gt;Thanks! I will try this. The production index will have multiple days data in it. To get min and max filetime by service for each day I just add a date field to the end of the query? I.e “by Service, Date” instead of just “by Service” ?&lt;/P&gt;</description>
      <pubDate>Sun, 28 Jul 2019 05:25:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-consecutive-events-in-same-index/m-p/415823#M119682</guid>
      <dc:creator>intelli2019</dc:creator>
      <dc:date>2019-07-28T05:25:26Z</dc:date>
    </item>
    <item>
      <title>Re: Join consecutive events in same index</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-consecutive-events-in-same-index/m-p/415824#M119683</link>
      <description>&lt;P&gt;index="file-times"&lt;BR /&gt;
|eval date=substr(FILETIME,1,10)&lt;BR /&gt;
|stats max(FILETIME) as Filetime_End,min(FILETIME) as Filetime_Start by Service,date&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 01:28:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-consecutive-events-in-same-index/m-p/415824#M119683</guid>
      <dc:creator>HiroshiSatoh</dc:creator>
      <dc:date>2020-09-30T01:28:06Z</dc:date>
    </item>
    <item>
      <title>Re: Join consecutive events in same index</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-consecutive-events-in-same-index/m-p/415825#M119684</link>
      <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval raw="time=23/07/2019T09:34:00,Service=RR,FileTime=9:33:45,State=START time=23/07/2019T10:31:00,Service=RR,FileTime=10:30:45,State=END time=23/07/2019T11:01:00,Service=HHR,FileTime=11:00:32,State=START time=23/07/2019T11:31:00,Service=HHR,FileTime=11:30:32,State=END time=23/07/2019T12:01:00,Service=LPE,FileTime=12:00:32,State=START time=23/07/2019T12:55:00,Service=LPE,FileTime=12:54:32,State=END time=23/07/2019T12:01:00,Service=SMURF,FileTime=12:00:32,State=START time=23/07/2019T13:01:00,Service=SMURF,FileTime=13:00:00,State=END time=23/07/2019T14:00:00,Service=TEST,FileTime=14:05:00,State=START time=23/07/2019T14:30:00,Service=TEST,FileTime=14:29:00,State=END time=23/07/2019T15:00:00,Service=TEST1,FileTime=15:05:00,State=START time=23/07/2019T15:30:00,Service=TEST1,FileTime=15:29:00,State=END"
| makemv raw
| mvexpand raw
| rename raw AS _raw
| kv
| eval _time = strptime(time, "%d/%m/%YT%H:%M:%S")
| sort 0 - _time

| rename COMMENT AS "Everything above generates sample event data; everything below is your solution"

| reverse
| stats list(*) AS * BY Service
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 30 Jul 2019 05:08:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-consecutive-events-in-same-index/m-p/415825#M119684</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-07-30T05:08:41Z</dc:date>
    </item>
    <item>
      <title>Re: Join consecutive events in same index</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-consecutive-events-in-same-index/m-p/415826#M119685</link>
      <description>&lt;P&gt;Hi woodcock,&lt;BR /&gt;
Sorry mate I'm pretty new at this. Could you explain what your query does a little please?&lt;BR /&gt;
It looks like you're creating some raw data to query but this would be coming from a daily log file in my case.&lt;BR /&gt;
Cheers&lt;BR /&gt;
Nathan&lt;/P&gt;</description>
      <pubDate>Mon, 05 Aug 2019 23:57:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-consecutive-events-in-same-index/m-p/415826#M119685</guid>
      <dc:creator>nathc100</dc:creator>
      <dc:date>2019-08-05T23:57:18Z</dc:date>
    </item>
    <item>
      <title>Re: Join consecutive events in same index</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-consecutive-events-in-same-index/m-p/415827#M119686</link>
      <description>&lt;P&gt;See line 10?  It explains it.  You replace everything through line 10 with your main search and then use lines 12-13 to do what you were asking.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Aug 2019 00:00:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-consecutive-events-in-same-index/m-p/415827#M119686</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-08-06T00:00:39Z</dc:date>
    </item>
  </channel>
</rss>

